From: Dana Jansens Date: Sat, 19 May 2007 20:31:08 +0000 (+0000) Subject: fix the popup for directional focusing, only show what is going to be a valid target... X-Git-Url: https://git.brokenzipper.com/gitweb?a=commitdiff_plain;h=2253b5e341e2a20dee5c0c17eae3f5a8baa1b6ac;p=chaz%2Fopenbox fix the popup for directional focusing, only show what is going to be a valid target. change directional focus to use the same criteria as normal cycling. --- diff --git a/openbox/focus_cycle.c b/openbox/focus_cycle.c index 440a9834..56a22838 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,6 +117,9 @@ 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) || @@ -127,7 +135,7 @@ 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 */ @@ -190,7 +198,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 +209,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 +267,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 +362,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,7 +375,7 @@ 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, + focus_cycle_popup_show(focus_cycle_target, FALSE, FALSE, dock_windows, desktop_windows); return; } diff --git a/openbox/focus_cycle.h b/openbox/focus_cycle.h index 4d1e265f..38c0e837 100644 --- a/openbox/focus_cycle.h +++ b/openbox/focus_cycle.h @@ -45,6 +45,7 @@ void focus_directional_cycle(ObDirection dir, gboolean dock_windows, void focus_cycle_stop(); gboolean focus_cycle_target_valid(struct _ObClient *ft, + gboolean iconic_windows, gboolean all_desktops, gboolean dock_windows, gboolean desktop_windows); diff --git a/openbox/focus_cycle_popup.c b/openbox/focus_cycle_popup.c index 4d6ccdca..b171e942 100644 --- a/openbox/focus_cycle_popup.c +++ b/openbox/focus_cycle_popup.c @@ -71,9 +71,13 @@ struct _ObFocusCyclePopup static ObFocusCyclePopup popup; static gchar *popup_get_name (ObClient *c); -static void popup_setup (ObFocusCyclePopup *p,gboolean all_desktops, - gboolean dock_windows, gboolean desktop_windows); -static void popup_render (ObFocusCyclePopup *p, const ObClient *c); +static void popup_setup (ObFocusCyclePopup *p, + gboolean iconic_windows, + gboolean all_desktops, + gboolean dock_windows, + gboolean desktop_windows); +static void popup_render (ObFocusCyclePopup *p, + const ObClient *c); static Window create_window(Window parent, guint bwidth, gulong mask, XSetWindowAttributes *attr) @@ -142,7 +146,8 @@ void focus_cycle_popup_shutdown(gboolean reconfig) RrAppearanceFree(popup.a_bg); } -static void popup_setup(ObFocusCyclePopup *p,gboolean all_desktops, +static void popup_setup(ObFocusCyclePopup *p, + gboolean iconic_windows, gboolean all_desktops, gboolean dock_windows, gboolean desktop_windows) { gint maxwidth, n; @@ -161,6 +166,7 @@ static void popup_setup(ObFocusCyclePopup *p,gboolean all_desktops, ObClient *ft = it->data; if (focus_cycle_target_valid(ft, + iconic_windows, all_desktops, dock_windows, desktop_windows)) @@ -410,7 +416,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c) p->last_target = newtarget; } -void focus_cycle_popup_show(ObClient *c, +void focus_cycle_popup_show(ObClient *c, gboolean iconic_windows, gboolean all_desktops, gboolean dock_windows, gboolean desktop_windows) { @@ -418,7 +424,8 @@ void focus_cycle_popup_show(ObClient *c, /* do this stuff only when the dialog is first showing */ if (!popup.mapped) - popup_setup(&popup, all_desktops, dock_windows, desktop_windows); + popup_setup(&popup, iconic_windows, all_desktops, + dock_windows, desktop_windows); g_assert(popup.targets != NULL); popup_render(&popup, c); diff --git a/openbox/focus_cycle_popup.h b/openbox/focus_cycle_popup.h index 695dfe53..8626a5d3 100644 --- a/openbox/focus_cycle_popup.h +++ b/openbox/focus_cycle_popup.h @@ -27,7 +27,7 @@ struct _ObClient; void focus_cycle_popup_startup(gboolean reconfig); void focus_cycle_popup_shutdown(gboolean reconfig); -void focus_cycle_popup_show(struct _ObClient *c, +void focus_cycle_popup_show(struct _ObClient *c, gboolean iconic_windows, gboolean all_desktops, gboolean dock_windows, gboolean desktop_windows); void focus_cycle_popup_hide();