X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=openbox%2Ffocus.c;h=0f399be73e02a21e2817df2ec8fe4ea570a21b17;hb=7cf4c970ae89f06aa77345900f96a310400c8595;hp=0f9f2f1bba29ed47a1f0a35b9eb770700ba3a84f;hpb=9cb80fc994c09ee62f99f46244b840ce25fd40f4;p=chaz%2Fopenbox diff --git a/openbox/focus.c b/openbox/focus.c index 0f9f2f1b..0f399be7 100644 --- a/openbox/focus.c +++ b/openbox/focus.c @@ -94,7 +94,8 @@ void focus_set_client(ObClient *client) } } -static ObClient* focus_fallback_target(gboolean allow_refocus, ObClient *old) +static ObClient* focus_fallback_target(gboolean allow_refocus, ObClient *old, + gboolean send_focus) { GList *it; ObClient *c; @@ -103,10 +104,14 @@ static ObClient* focus_fallback_target(gboolean allow_refocus, ObClient *old) if (config_focus_follow && !config_focus_last) if ((c = client_under_pointer()) && (allow_refocus || c != old) && - (client_normal(c) && - client_focus(c))) + client_normal(c) && + /* if we're sending focus then try to */ + ((send_focus && client_focus(c)) || + /* if not just see if we could try, or it's already focused */ + (!send_focus && (c == old || client_can_focus(c))))) { - ob_debug_type(OB_DEBUG_FOCUS, "found in pointer stuff\n"); + ob_debug_type(OB_DEBUG_FOCUS, "found in pointer stuff (%d)\n", + send_focus); return c; } @@ -114,9 +119,11 @@ static ObClient* focus_fallback_target(gboolean allow_refocus, ObClient *old) if (allow_refocus && old && old->desktop == DESKTOP_ALL && client_normal(old) && - client_focus(old)) + /* this one is only for when not sending focus, to keep it there */ + !send_focus) { - ob_debug_type(OB_DEBUG_FOCUS, "found in omnipresentness\n"); + ob_debug_type(OB_DEBUG_FOCUS, "found in omnipresentness (%d)\n", + send_focus); return old; } @@ -134,9 +141,14 @@ static ObClient* focus_fallback_target(gboolean allow_refocus, ObClient *old) if (c->desktop == screen_desktop && client_normal(c) && (allow_refocus || c != old) && - client_focus(c)) + /* if we're sending focus then try to */ + ((send_focus && client_focus(c)) || + /* if not just see if we could try, or it's already focused */ + (!send_focus && (c == old || client_can_focus(c))))) { - ob_debug_type(OB_DEBUG_FOCUS, "found in focus order\n"); + ob_debug_type(OB_DEBUG_FOCUS, "found in focus order (%d) 0x%x " + "from 0x%x\n", + send_focus, c, old); return c; } } @@ -153,9 +165,13 @@ static ObClient* focus_fallback_target(gboolean allow_refocus, ObClient *old) */ if (c->type == OB_CLIENT_TYPE_DESKTOP && (allow_refocus || c != old) && - client_focus(c)) + /* if we're sending focus then try to */ + ((send_focus && client_focus(c)) || + /* if not just see if we could try, or it's already focused */ + (!send_focus && (c == old || client_can_focus(c))))) { - ob_debug_type(OB_DEBUG_FOCUS, "found a desktop window\n"); + ob_debug_type(OB_DEBUG_FOCUS, "found a desktop window (%d)\n", + send_focus); return c; } } @@ -168,12 +184,15 @@ ObClient* focus_fallback(gboolean allow_refocus) ObClient *new; ObClient *old = focus_client; + new = focus_fallback_target(allow_refocus, old, FALSE); + if (new == old) return; + /* unfocus any focused clients.. they can be focused by Pointer events and such, and then when we try focus them, we won't get a FocusIn event at all for them. */ focus_nothing(); - new = focus_fallback_target(allow_refocus, old); + new = focus_fallback_target(allow_refocus, old, TRUE); return new; }