a focus fix? konquerer would end up losign focus on close sometimes. this is the only thing i can think of tht would cause it. we will see..
This commit is contained in:
parent
2c507a7207
commit
f289adf653
1 changed files with 50 additions and 11 deletions
|
@ -275,14 +275,13 @@ static void event_hack_mods(XEvent *e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean wanted_focusevent(XEvent *e)
|
static gboolean wanted_focusevent(XEvent *e, gboolean in_client_only)
|
||||||
{
|
{
|
||||||
gint mode = e->xfocus.mode;
|
gint mode = e->xfocus.mode;
|
||||||
gint detail = e->xfocus.detail;
|
gint detail = e->xfocus.detail;
|
||||||
Window win = e->xany.window;
|
Window win = e->xany.window;
|
||||||
|
|
||||||
if (e->type == FocusIn) {
|
if (e->type == FocusIn) {
|
||||||
|
|
||||||
/* These are ones we never want.. */
|
/* These are ones we never want.. */
|
||||||
|
|
||||||
/* This means focus was given by a keyboard/mouse grab. */
|
/* This means focus was given by a keyboard/mouse grab. */
|
||||||
|
@ -294,7 +293,7 @@ static gboolean wanted_focusevent(XEvent *e)
|
||||||
|
|
||||||
/* These are the ones we want.. */
|
/* These are the ones we want.. */
|
||||||
|
|
||||||
if (win == RootWindow(ob_display, ob_screen)) {
|
if (win == RootWindow(ob_display, ob_screen) && !in_client_only) {
|
||||||
/* This means focus reverted off of a client */
|
/* This means focus reverted off of a client */
|
||||||
if (detail == NotifyPointerRoot || detail == NotifyDetailNone ||
|
if (detail == NotifyPointerRoot || detail == NotifyDetailNone ||
|
||||||
detail == NotifyInferior)
|
detail == NotifyInferior)
|
||||||
|
@ -310,7 +309,7 @@ static gboolean wanted_focusevent(XEvent *e)
|
||||||
if (detail == NotifyNonlinearVirtual)
|
if (detail == NotifyNonlinearVirtual)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
/* This means focus moved to the frame window */
|
/* This means focus moved to the frame window */
|
||||||
if (detail == NotifyInferior)
|
if (detail == NotifyInferior && !in_client_only)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* Otherwise.. */
|
/* Otherwise.. */
|
||||||
|
@ -318,7 +317,6 @@ static gboolean wanted_focusevent(XEvent *e)
|
||||||
} else {
|
} else {
|
||||||
g_assert(e->type == FocusOut);
|
g_assert(e->type == FocusOut);
|
||||||
|
|
||||||
|
|
||||||
/* These are ones we never want.. */
|
/* These are ones we never want.. */
|
||||||
|
|
||||||
/* This means focus was taken by a keyboard/mouse grab. */
|
/* This means focus was taken by a keyboard/mouse grab. */
|
||||||
|
@ -348,18 +346,58 @@ static gboolean wanted_focusevent(XEvent *e)
|
||||||
|
|
||||||
static Bool look_for_focusin(Display *d, XEvent *e, XPointer arg)
|
static Bool look_for_focusin(Display *d, XEvent *e, XPointer arg)
|
||||||
{
|
{
|
||||||
return e->type == FocusIn && wanted_focusevent(e);
|
return e->type == FocusIn && wanted_focusevent(e, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Bool look_for_focusin_client(Display *d, XEvent *e, XPointer arg)
|
||||||
|
{
|
||||||
|
return e->type == FocusIn && wanted_focusevent(e, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void print_focusevent(XEvent *e)
|
||||||
|
{
|
||||||
|
gint mode = e->xfocus.mode;
|
||||||
|
gint detail = e->xfocus.detail;
|
||||||
|
Window win = e->xany.window;
|
||||||
|
const gchar *modestr, *detailstr;
|
||||||
|
|
||||||
|
switch (mode) {
|
||||||
|
case NotifyNormal: modestr="NotifyNormal"; break;
|
||||||
|
case NotifyGrab: modestr="NotifyGrab"; break;
|
||||||
|
case NotifyUngrab: modestr="NotifyUngrab"; break;
|
||||||
|
case NotifyWhileGrabbed: modestr="NotifyWhileGrabbed"; break;
|
||||||
|
}
|
||||||
|
switch (detail) {
|
||||||
|
case NotifyAncestor: detailstr="NotifyAncestor"; break;
|
||||||
|
case NotifyVirtual: detailstr="NotifyVirtual"; break;
|
||||||
|
case NotifyInferior: detailstr="NotifyInferior"; break;
|
||||||
|
case NotifyNonlinear: detailstr="NotifyNonlinear"; break;
|
||||||
|
case NotifyNonlinearVirtual: detailstr="NotifyNonlinearVirtual"; break;
|
||||||
|
case NotifyPointer: detailstr="NotifyPointer"; break;
|
||||||
|
case NotifyPointerRoot: detailstr="NotifyPointerRoot"; break;
|
||||||
|
case NotifyDetailNone: detailstr="NotifyDetailNone"; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_assert(modestr);
|
||||||
|
g_assert(detailstr);
|
||||||
|
ob_debug_type(OB_DEBUG_FOCUS, "Focus%s 0x%x mode=%s detail=%s\n",
|
||||||
|
(e->xfocus.type == FocusIn ? "In" : "Out"),
|
||||||
|
win,
|
||||||
|
modestr, detailstr);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean event_ignore(XEvent *e, ObClient *client)
|
static gboolean event_ignore(XEvent *e, ObClient *client)
|
||||||
{
|
{
|
||||||
switch(e->type) {
|
switch(e->type) {
|
||||||
case FocusIn:
|
case FocusIn:
|
||||||
if (!wanted_focusevent(e))
|
print_focusevent(e);
|
||||||
|
if (!wanted_focusevent(e, FALSE))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
break;
|
break;
|
||||||
case FocusOut:
|
case FocusOut:
|
||||||
if (!wanted_focusevent(e))
|
print_focusevent(e);
|
||||||
|
if (!wanted_focusevent(e, FALSE))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -438,8 +476,11 @@ static void event_process(const XEvent *ec, gpointer data)
|
||||||
hasn't received focus yet, so something else) -> send focusin
|
hasn't received focus yet, so something else) -> send focusin
|
||||||
which means the "something else" is the last thing to get a
|
which means the "something else" is the last thing to get a
|
||||||
focusin sent to it, so the new window doesn't end up with focus.
|
focusin sent to it, so the new window doesn't end up with focus.
|
||||||
|
|
||||||
|
But if the other focus in is something like PointerRoot then we
|
||||||
|
still want to fall back.
|
||||||
*/
|
*/
|
||||||
if (XCheckIfEvent(ob_display, &ce, look_for_focusin, NULL)) {
|
if (XCheckIfEvent(ob_display, &ce, look_for_focusin_client, NULL)){
|
||||||
XPutBackEvent(ob_display, &ce);
|
XPutBackEvent(ob_display, &ce);
|
||||||
ob_debug_type(OB_DEBUG_FOCUS,
|
ob_debug_type(OB_DEBUG_FOCUS,
|
||||||
" but another FocusIn is coming\n");
|
" but another FocusIn is coming\n");
|
||||||
|
@ -468,8 +509,6 @@ static void event_process(const XEvent *ec, gpointer data)
|
||||||
gboolean nomove = FALSE;
|
gboolean nomove = FALSE;
|
||||||
XEvent ce;
|
XEvent ce;
|
||||||
|
|
||||||
ob_debug_type(OB_DEBUG_FOCUS, "FocusOut Event\n");
|
|
||||||
|
|
||||||
/* Look for the followup FocusIn */
|
/* Look for the followup FocusIn */
|
||||||
if (!XCheckIfEvent(ob_display, &ce, look_for_focusin, NULL)) {
|
if (!XCheckIfEvent(ob_display, &ce, look_for_focusin, NULL)) {
|
||||||
/* There is no FocusIn, this means focus went to a window that
|
/* There is no FocusIn, this means focus went to a window that
|
||||||
|
|
Loading…
Reference in a new issue