X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=openbox%2Ffocus_cycle.c;h=1fef375480d41d7f06f85b2d68334b1700173994;hb=a76ac8205cbfe484a5fee7749daa20ed2b7e8a2b;hp=440a9834dc1ec6f01281f1710fa9feef3d77f2f1;hpb=83eb9220122d98ac72d1b6aa636d1da52d3832e2;p=chaz%2Fopenbox diff --git a/openbox/focus_cycle.c b/openbox/focus_cycle.c index 440a9834..1fef3754 100644 --- a/openbox/focus_cycle.c +++ b/openbox/focus_cycle.c @@ -35,6 +35,7 @@ ObClient *focus_cycle_target = NULL; static void focus_cycle_destroy_notify (ObClient *client, gpointer data); static gboolean focus_target_has_siblings (ObClient *ft, + gboolean iconic_windows, gboolean all_desktops); static ObClient *focus_find_directional (ObClient *c, ObDirection dir, @@ -76,7 +77,9 @@ static void focus_cycle_destroy_notify(ObClient *client, gpointer data) /*! Returns if a focus target has valid group siblings that can be cycled to in its place */ -static gboolean focus_target_has_siblings(ObClient *ft, gboolean all_desktops) +static gboolean focus_target_has_siblings(ObClient *ft, + gboolean iconic_windows, + gboolean all_desktops) { GSList *it; @@ -87,7 +90,8 @@ static gboolean focus_target_has_siblings(ObClient *ft, gboolean all_desktops) ObClient *c = it->data; /* check that it's not a helper window to avoid infinite recursion */ if (c != ft && !client_helper(c) && - focus_cycle_target_valid(c, all_desktops, FALSE, FALSE)) + focus_cycle_target_valid(c, iconic_windows, all_desktops, FALSE, + FALSE)) { return TRUE; } @@ -96,6 +100,7 @@ static gboolean focus_target_has_siblings(ObClient *ft, gboolean all_desktops) } gboolean focus_cycle_target_valid(ObClient *ft, + gboolean iconic_windows, gboolean all_desktops, gboolean dock_windows, gboolean desktop_windows) @@ -112,11 +117,16 @@ gboolean focus_cycle_target_valid(ObClient *ft, /* the window can receive focus somehow */ ok = ok && (ft->can_focus || ft->focus_notify); + /* the window is not iconic, or we're allowed to go to iconic ones */ + ok = ok && (iconic_windows || !ft->iconic); + /* it's the right type of window */ if (dock_windows || desktop_windows) ok = ok && ((dock_windows && ft->type == OB_CLIENT_TYPE_DOCK) || (desktop_windows && ft->type == OB_CLIENT_TYPE_DESKTOP)); - else + /* modal windows are important and can always get focus if they are + visible and stuff, so don't change 'ok' based on their type */ + else if (!ft->modal) /* normal non-helper windows are valid targets */ ok = ok && ((client_normal(ft) && !client_helper(ft)) @@ -127,15 +137,16 @@ gboolean focus_cycle_target_valid(ObClient *ft, ((focus_client && ft->group == focus_client->group) || /* ... or if there are no other windows in its group that can be cycled to instead */ - !focus_target_has_siblings(ft, all_desktops)))); + !focus_target_has_siblings(ft, iconic_windows, all_desktops)))); /* it's not set to skip the taskbar (unless it is a type that would be - expected to set this hint */ + expected to set this hint, or modal) */ ok = ok && ((ft->type == OB_CLIENT_TYPE_DOCK || ft->type == OB_CLIENT_TYPE_DESKTOP || ft->type == OB_CLIENT_TYPE_TOOLBAR || ft->type == OB_CLIENT_TYPE_MENU || ft->type == OB_CLIENT_TYPE_UTILITY) || + ft->modal || !ft->skip_taskbar); /* it's not going to just send fous off somewhere else (modal window) */ @@ -190,7 +201,8 @@ void focus_cycle(gboolean forward, gboolean all_desktops, if (it == NULL) it = g_list_last(list); } ft = it->data; - if (focus_cycle_target_valid(ft, all_desktops, dock_windows, + if (focus_cycle_target_valid(ft, TRUE, + all_desktops, dock_windows, desktop_windows)) { if (interactive) { @@ -200,7 +212,8 @@ void focus_cycle(gboolean forward, gboolean all_desktops, } if (dialog) /* same arguments as focus_target_valid */ - focus_cycle_popup_show(ft, all_desktops, dock_windows, + focus_cycle_popup_show(ft, TRUE, + all_desktops, dock_windows, desktop_windows); return; } else if (ft != focus_cycle_target) { @@ -257,23 +270,8 @@ static ObClient *focus_find_directional(ObClient *c, ObDirection dir, /* the currently selected window isn't interesting */ if(cur == c) continue; - if (cur->type == OB_CLIENT_TYPE_DOCK && !dock_windows) - continue; - if (cur->type == OB_CLIENT_TYPE_DESKTOP && !desktop_windows) - continue; - if (!client_normal(cur) && - cur->type != OB_CLIENT_TYPE_DOCK && - cur->type != OB_CLIENT_TYPE_DESKTOP) - continue; - /* using c->desktop instead of screen_desktop doesn't work if the - * current window was omnipresent, hope this doesn't have any other - * side effects */ - if(screen_desktop != cur->desktop && cur->desktop != DESKTOP_ALL) - continue; - if(cur->iconic) - continue; - if(!(client_focus_target(cur) == cur && - client_can_focus(cur))) + if (!focus_cycle_target_valid(it->data, FALSE, FALSE, dock_windows, + desktop_windows)) continue; /* find the centre coords of this window, from the @@ -367,7 +365,7 @@ void focus_directional_cycle(ObDirection dir, gboolean dock_windows, GList *it; for (it = focus_order; it; it = g_list_next(it)) - if (focus_cycle_target_valid(it->data, FALSE, dock_windows, + if (focus_cycle_target_valid(it->data, FALSE, FALSE, dock_windows, desktop_windows)) ft = it->data; } @@ -380,8 +378,9 @@ void focus_directional_cycle(ObDirection dir, gboolean dock_windows, } if (focus_cycle_target && dialog) { /* same arguments as focus_target_valid */ - focus_cycle_popup_show(focus_cycle_target, FALSE, dock_windows, - desktop_windows); + focus_cycle_popup_single_show(focus_cycle_target, + FALSE, FALSE, dock_windows, + desktop_windows); return; } @@ -393,23 +392,7 @@ done_cycle: focus_cycle_target = NULL; focus_cycle_draw_indicator(NULL); - focus_cycle_popup_hide(); + focus_cycle_popup_single_hide(); return; } - -void focus_order_add_new(ObClient *c) -{ - if (c->iconic) - focus_order_to_top(c); - else { - g_assert(!g_list_find(focus_order, c)); - /* if there are any iconic windows, put this above them in the order, - but if there are not, then put it under the currently focused one */ - if (focus_order && ((ObClient*)focus_order->data)->iconic) - focus_order = g_list_insert(focus_order, c, 0); - else - focus_order = g_list_insert(focus_order, c, 1); - } -} -