From: Dana Jansens Date: Sun, 22 Apr 2007 20:43:45 +0000 (+0000) Subject: merge r5799-5806 from trunk X-Git-Tag: openbox-3_3_991-RELEASE~238 X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=36a03a65c9d876249aa1da1caf163ba4d26fdd12;p=dana%2Fopenbox.git merge r5799-5806 from trunk --- diff --git a/openbox/event.c b/openbox/event.c index c8356be1..f9d5c38f 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -348,10 +348,6 @@ static gboolean wanted_focusevent(XEvent *e) if (detail == NotifyNonlinearVirtual) return TRUE; - /* This means focus reverted off of a client */ - if (detail == NotifyInferior) - return TRUE; - /* Otherwise.. */ return FALSE; } else { @@ -391,7 +387,12 @@ static gboolean event_ignore(XEvent *e, ObClient *client) { switch(e->type) { case FocusIn: + if (!wanted_focusevent(e)) + return TRUE; + break; case FocusOut: + if (client == NULL) + return TRUE; if (!wanted_focusevent(e)) return TRUE; break; @@ -453,26 +454,10 @@ static void event_process(const XEvent *ec, gpointer data) /* crossing events for menu */ event_handle_menu(e); } else if (e->type == FocusIn) { - if (e->xfocus.detail == NotifyPointerRoot || - e->xfocus.detail == NotifyDetailNone) { - ob_debug_type(OB_DEBUG_FOCUS, "Focus went to root\n"); - /* Focus has been reverted to the root window or nothing - FocusOut events come after UnmapNotify, so we don't need to - worry about focusing an invalid window - */ - focus_fallback(TRUE); - } else if (e->xfocus.detail == NotifyInferior) { - ob_debug_type(OB_DEBUG_FOCUS, "Focus went to parent\n"); - /* Focus has been reverted to parent, which is our frame window, - or the root window - FocusOut events come after UnmapNotify, so we don't need to - worry about focusing an invalid window - */ - focus_fallback(TRUE); - } else if (client && client != focus_client) { + if (client && client != focus_client) { frame_adjust_focus(client->frame, TRUE); - client_calc_layer(client); focus_set_client(client); + client_calc_layer(client); } } else if (e->type == FocusOut) { gboolean nomove = FALSE; @@ -488,8 +473,18 @@ static void event_process(const XEvent *ec, gpointer data) /* nothing is focused */ focus_set_client(NULL); } else if (ce.xany.window == e->xany.window) { + ob_debug_type(OB_DEBUG_FOCUS, "Focus didn't go anywhere\n"); /* If focus didn't actually move anywhere, there is nothing to do*/ nomove = TRUE; + } else if (ce.xfocus.detail == NotifyPointerRoot || + ce.xfocus.detail == NotifyDetailNone || + ce.xfocus.detail == NotifyInferior) { + ob_debug_type(OB_DEBUG_FOCUS, "Focus went to root\n"); + /* Focus has been reverted to the root window or nothing + FocusOut events come after UnmapNotify, so we don't need to + worry about focusing an invalid window + */ + focus_fallback(TRUE); } else { /* Focus did move, so process the FocusIn event */ ObEventData ed = { .ignored = FALSE }; @@ -506,6 +501,7 @@ static void event_process(const XEvent *ec, gpointer data) if (client && !nomove) { frame_adjust_focus(client->frame, FALSE); + /* focus_set_client has already been called for sure */ client_calc_layer(client); } } else if (group) diff --git a/openbox/focus.c b/openbox/focus.c index 7a686800..f794e466 100644 --- a/openbox/focus.c +++ b/openbox/focus.c @@ -259,10 +259,7 @@ ObClient* focus_fallback_target(gboolean allow_refocus, ObClient *old) void focus_fallback(gboolean allow_refocus) { ObClient *new; - ObClient *old; - - /* save this before moving focus away to nothing */ - old = focus_client; + ObClient *old = focus_client; /* unfocus any focused clients.. they can be focused by Pointer events and such, and then when I try focus them, I won't get a FocusIn event @@ -282,6 +279,8 @@ void focus_nothing() screen_install_colormap(NULL, TRUE); } + focus_client = NULL; + /* when nothing will be focused, send focus to the backup target */ XSetInputFocus(ob_display, screen_support_win, RevertToPointerRoot, event_curtime); diff --git a/openbox/popup.c b/openbox/popup.c index 031b1d49..88619e77 100644 --- a/openbox/popup.c +++ b/openbox/popup.c @@ -23,6 +23,7 @@ #include "frame.h" #include "client.h" #include "stacking.h" +#include "event.h" #include "screen.h" #include "render/render.h" #include "render/theme.h" diff --git a/openbox/screen.c b/openbox/screen.c index a54b2b56..c0569c29 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -460,10 +460,14 @@ void screen_set_desktop(guint num) } } - /* reduce flicker by hiliting now rather than waiting for the server - FocusIn event */ - if ((c = focus_fallback_target(TRUE, focus_client))) + /* have to try focus here because when you leave an empty desktop + there is no focus out to watch for */ + if ((c = focus_fallback_target(TRUE, focus_client))) { + /* reduce flicker by hiliting now rather than waiting for the server + FocusIn event */ frame_adjust_focus(c->frame, TRUE); + client_focus(c); + } event_ignore_queued_enters(); }