add an option to next/previous window to only include hilited/flashing/urgent windows (feature req/bug #4341)

This commit is contained in:
Dana Jansens 2010-04-16 18:17:05 -04:00
parent fde5d8601a
commit 56fface3a4
10 changed files with 32 additions and 36 deletions

View file

@ -11,6 +11,7 @@ typedef struct {
gboolean linear; gboolean linear;
gboolean dock_windows; gboolean dock_windows;
gboolean desktop_windows; gboolean desktop_windows;
gboolean only_hilite_windows;
gboolean all_desktops; gboolean all_desktops;
gboolean forward; gboolean forward;
gboolean bar; gboolean bar;
@ -83,6 +84,8 @@ static gpointer setup_func(xmlNodePtr node,
o->raise = obt_xml_node_bool(n); o->raise = obt_xml_node_bool(n);
if ((n = obt_xml_find_node(node, "panels"))) if ((n = obt_xml_find_node(node, "panels")))
o->dock_windows = obt_xml_node_bool(n); o->dock_windows = obt_xml_node_bool(n);
if ((n = obt_xml_find_node(node, "hilite")))
o->only_hilite_windows = obt_xml_node_bool(n);
if ((n = obt_xml_find_node(node, "desktop"))) if ((n = obt_xml_find_node(node, "desktop")))
o->desktop_windows = obt_xml_node_bool(n); o->desktop_windows = obt_xml_node_bool(n);
if ((n = obt_xml_find_node(node, "allDesktops"))) if ((n = obt_xml_find_node(node, "allDesktops")))
@ -154,6 +157,7 @@ static gboolean run_func(ObActionsData *data, gpointer options)
ft = focus_cycle(o->forward, ft = focus_cycle(o->forward,
o->all_desktops, o->all_desktops,
!o->only_hilite_windows,
o->dock_windows, o->dock_windows,
o->desktop_windows, o->desktop_windows,
o->linear, o->linear,
@ -226,6 +230,7 @@ static void i_post_func(gpointer options)
ft = focus_cycle(o->forward, ft = focus_cycle(o->forward,
o->all_desktops, o->all_desktops,
!o->only_hilite_windows,
o->dock_windows, o->dock_windows,
o->desktop_windows, o->desktop_windows,
o->linear, o->linear,

View file

@ -295,7 +295,7 @@ void client_manage(Window window, ObPrompt *prompt)
/* this checks for focus=false for the window */ /* this checks for focus=false for the window */
(!settings || settings->focus != 0) && (!settings || settings->focus != 0) &&
focus_valid_target(self, self->desktop, focus_valid_target(self, self->desktop,
FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE,
settings->focus == 1)) settings->focus == 1))
{ {
activate = TRUE; activate = TRUE;

View file

@ -54,7 +54,8 @@ static gboolean self_update(ObMenuFrame *frame, gpointer data)
for (it = focus_order; it; it = g_list_next(it)) { for (it = focus_order; it; it = g_list_next(it)) {
ObClient *c = it->data; ObClient *c = it->data;
if (focus_valid_target(c, desktop, if (focus_valid_target(c, desktop,
TRUE, TRUE, FALSE, FALSE, FALSE, FALSE)) TRUE, TRUE,
FALSE, TRUE, FALSE, FALSE, FALSE))
{ {
empty = FALSE; empty = FALSE;

View file

@ -55,7 +55,7 @@ static gboolean desk_menu_update(ObMenuFrame *frame, gpointer data)
for (it = focus_order; it; it = g_list_next(it)) { for (it = focus_order; it; it = g_list_next(it)) {
ObClient *c = it->data; ObClient *c = it->data;
if (focus_valid_target(c, d->desktop, if (focus_valid_target(c, d->desktop,
TRUE, TRUE, FALSE, FALSE, FALSE, FALSE)) { TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE)) {
ObMenuEntry *e; ObMenuEntry *e;
empty = FALSE; empty = FALSE;

View file

@ -133,7 +133,8 @@ static ObClient* focus_fallback_target(gboolean allow_refocus,
*/ */
if ((allow_omnipresent || c->desktop == screen_desktop) && if ((allow_omnipresent || c->desktop == screen_desktop) &&
focus_valid_target(c, screen_desktop, focus_valid_target(c, screen_desktop,
TRUE, FALSE, FALSE, FALSE, FALSE, FALSE) && TRUE, FALSE, FALSE, TRUE, FALSE, FALSE,
FALSE) &&
!c->shaded && !c->shaded &&
(allow_refocus || client_focus_target(c) != old) && (allow_refocus || client_focus_target(c) != old) &&
client_focus(c)) client_focus(c))
@ -154,7 +155,7 @@ static ObClient* focus_fallback_target(gboolean allow_refocus,
backup fallback though) backup fallback though)
*/ */
if (focus_valid_target(c, screen_desktop, if (focus_valid_target(c, screen_desktop,
TRUE, FALSE, FALSE, FALSE, TRUE, FALSE) && TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE) &&
(allow_refocus || client_focus_target(c) != old) && (allow_refocus || client_focus_target(c) != old) &&
client_focus(c)) client_focus(c))
{ {
@ -288,7 +289,7 @@ static gboolean focus_target_has_siblings(ObClient *ft,
if (c != ft && c->type == OB_CLIENT_TYPE_NORMAL && if (c != ft && c->type == OB_CLIENT_TYPE_NORMAL &&
focus_valid_target(c, screen_desktop, focus_valid_target(c, screen_desktop,
TRUE, iconic_windows, all_desktops, TRUE, iconic_windows, all_desktops,
FALSE, FALSE, FALSE)) TRUE, FALSE, FALSE, FALSE))
{ {
return TRUE; return TRUE;
} }
@ -301,6 +302,7 @@ gboolean focus_valid_target(ObClient *ft,
gboolean helper_windows, gboolean helper_windows,
gboolean iconic_windows, gboolean iconic_windows,
gboolean all_desktops, gboolean all_desktops,
gboolean nonhilite_windows,
gboolean dock_windows, gboolean dock_windows,
gboolean desktop_windows, gboolean desktop_windows,
gboolean user_request) gboolean user_request)
@ -321,6 +323,9 @@ gboolean focus_valid_target(ObClient *ft,
ok = (all_desktops || ft->desktop == desktop || ok = (all_desktops || ft->desktop == desktop ||
ft->desktop == DESKTOP_ALL); ft->desktop == DESKTOP_ALL);
/* if we only include hilited windows, check if the window is */
ok = ok && (nonhilite_windows || ft->demands_attention);
/* the window can receive focus somehow */ /* the window can receive focus somehow */
ok = ok && (ft->can_focus || ft->focus_notify); ok = ok && (ft->can_focus || ft->focus_notify);
@ -370,6 +375,7 @@ gboolean focus_valid_target(ObClient *ft,
TRUE, TRUE,
iconic_windows, iconic_windows,
all_desktops, all_desktops,
nonhilite_windows,
dock_windows, dock_windows,
desktop_windows, desktop_windows,
FALSE)); FALSE));

View file

@ -73,6 +73,7 @@ gboolean focus_valid_target(struct _ObClient *ft,
gboolean helper_windows, gboolean helper_windows,
gboolean iconic_windows, gboolean iconic_windows,
gboolean all_desktops, gboolean all_desktops,
gboolean nonhilite_windows,
gboolean dock_windows, gboolean dock_windows,
gboolean desktop_windows, gboolean desktop_windows,
gboolean user_request); gboolean user_request);

View file

@ -39,6 +39,7 @@ ObClient *focus_cycle_target = NULL;
static ObCycleType focus_cycle_type = OB_CYCLE_NONE; static ObCycleType focus_cycle_type = OB_CYCLE_NONE;
static gboolean focus_cycle_iconic_windows; static gboolean focus_cycle_iconic_windows;
static gboolean focus_cycle_all_desktops; static gboolean focus_cycle_all_desktops;
static gboolean focus_cycle_nonhilite_windows;
static gboolean focus_cycle_dock_windows; static gboolean focus_cycle_dock_windows;
static gboolean focus_cycle_desktop_windows; static gboolean focus_cycle_desktop_windows;
@ -89,12 +90,13 @@ void focus_cycle_reorder()
TRUE); TRUE);
focus_cycle_update_indicator(focus_cycle_target); focus_cycle_update_indicator(focus_cycle_target);
if (!focus_cycle_target) if (!focus_cycle_target)
focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
TRUE, TRUE, TRUE, TRUE, TRUE); TRUE, TRUE, TRUE, TRUE, TRUE);
} }
} }
ObClient* focus_cycle(gboolean forward, gboolean all_desktops, ObClient* focus_cycle(gboolean forward, gboolean all_desktops,
gboolean nonhilite_windows,
gboolean dock_windows, gboolean desktop_windows, gboolean dock_windows, gboolean desktop_windows,
gboolean linear, gboolean interactive, gboolean linear, gboolean interactive,
gboolean showbar, ObFocusCyclePopupMode mode, gboolean showbar, ObFocusCyclePopupMode mode,
@ -126,6 +128,7 @@ ObClient* focus_cycle(gboolean forward, gboolean all_desktops,
if (focus_cycle_target == NULL) { if (focus_cycle_target == NULL) {
focus_cycle_iconic_windows = TRUE; focus_cycle_iconic_windows = TRUE;
focus_cycle_all_desktops = all_desktops; focus_cycle_all_desktops = all_desktops;
focus_cycle_nonhilite_windows = nonhilite_windows;
focus_cycle_dock_windows = dock_windows; focus_cycle_dock_windows = dock_windows;
focus_cycle_desktop_windows = desktop_windows; focus_cycle_desktop_windows = desktop_windows;
start = it = g_list_find(list, focus_client); start = it = g_list_find(list, focus_client);
@ -153,12 +156,7 @@ ObClient* focus_cycle(gboolean forward, gboolean all_desktops,
focus_cycle_draw_indicator(showbar ? ft : NULL); focus_cycle_draw_indicator(showbar ? ft : NULL);
} }
/* same arguments as focus_target_valid */ /* same arguments as focus_target_valid */
focus_cycle_popup_show(ft, focus_cycle_popup_show(ft, mode);
focus_cycle_iconic_windows,
focus_cycle_all_desktops,
focus_cycle_dock_windows,
focus_cycle_desktop_windows,
mode);
return focus_cycle_target; return focus_cycle_target;
} else if (ft != focus_cycle_target) { } else if (ft != focus_cycle_target) {
focus_cycle_target = ft; focus_cycle_target = ft;
@ -302,6 +300,7 @@ ObClient* focus_directional_cycle(ObDirection dir, gboolean dock_windows,
if (focus_cycle_target == NULL) { if (focus_cycle_target == NULL) {
focus_cycle_iconic_windows = FALSE; focus_cycle_iconic_windows = FALSE;
focus_cycle_all_desktops = FALSE; focus_cycle_all_desktops = FALSE;
focus_cycle_nonhilite_windows = TRUE;
focus_cycle_dock_windows = dock_windows; focus_cycle_dock_windows = dock_windows;
focus_cycle_desktop_windows = desktop_windows; focus_cycle_desktop_windows = desktop_windows;
} }
@ -332,11 +331,7 @@ ObClient* focus_directional_cycle(ObDirection dir, gboolean dock_windows,
} }
if (focus_cycle_target && dialog) if (focus_cycle_target && dialog)
/* same arguments as focus_target_valid */ /* same arguments as focus_target_valid */
focus_cycle_popup_single_show(focus_cycle_target, focus_cycle_popup_single_show(focus_cycle_target);
focus_cycle_iconic_windows,
focus_cycle_all_desktops,
focus_cycle_dock_windows,
focus_cycle_desktop_windows);
return focus_cycle_target; return focus_cycle_target;
done_cycle: done_cycle:
@ -357,6 +352,7 @@ gboolean focus_cycle_valid(struct _ObClient *client)
return focus_valid_target(client, screen_desktop, TRUE, return focus_valid_target(client, screen_desktop, TRUE,
focus_cycle_iconic_windows, focus_cycle_iconic_windows,
focus_cycle_all_desktops, focus_cycle_all_desktops,
focus_cycle_nonhilite_windows,
focus_cycle_dock_windows, focus_cycle_dock_windows,
focus_cycle_desktop_windows, focus_cycle_desktop_windows,
FALSE); FALSE);

View file

@ -36,6 +36,7 @@ void focus_cycle_shutdown(gboolean reconfig);
/*! Cycle focus amongst windows. */ /*! Cycle focus amongst windows. */
struct _ObClient* focus_cycle(gboolean forward, gboolean all_desktops, struct _ObClient* focus_cycle(gboolean forward, gboolean all_desktops,
gboolean nonhilite_windows,
gboolean dock_windows, gboolean desktop_windows, gboolean dock_windows, gboolean desktop_windows,
gboolean linear, gboolean interactive, gboolean linear, gboolean interactive,
gboolean showbar, ObFocusCyclePopupMode mode, gboolean showbar, ObFocusCyclePopupMode mode,

View file

@ -700,10 +700,7 @@ static void popup_render(ObFocusCyclePopup *p, const ObClient *c)
XFlush(obt_display); XFlush(obt_display);
} }
void focus_cycle_popup_show(ObClient *c, gboolean iconic_windows, void focus_cycle_popup_show(ObClient *c, ObFocusCyclePopupMode mode)
gboolean all_desktops, gboolean dock_windows,
gboolean desktop_windows,
ObFocusCyclePopupMode mode)
{ {
g_assert(c != NULL); g_assert(c != NULL);
@ -747,11 +744,7 @@ void focus_cycle_popup_hide(void)
popup_cleanup(); popup_cleanup();
} }
void focus_cycle_popup_single_show(struct _ObClient *c, void focus_cycle_popup_single_show(struct _ObClient *c)
gboolean iconic_windows,
gboolean all_desktops,
gboolean dock_windows,
gboolean desktop_windows)
{ {
gchar *text; gchar *text;

View file

@ -33,17 +33,10 @@ typedef enum {
void focus_cycle_popup_startup(gboolean reconfig); void focus_cycle_popup_startup(gboolean reconfig);
void focus_cycle_popup_shutdown(gboolean reconfig); void focus_cycle_popup_shutdown(gboolean reconfig);
void focus_cycle_popup_show(struct _ObClient *c, gboolean iconic_windows, void focus_cycle_popup_show(struct _ObClient *c, ObFocusCyclePopupMode mode);
gboolean all_desktops, gboolean dock_windows,
gboolean desktop_windows,
ObFocusCyclePopupMode mode);
void focus_cycle_popup_hide(void); void focus_cycle_popup_hide(void);
void focus_cycle_popup_single_show(struct _ObClient *c, void focus_cycle_popup_single_show(struct _ObClient *c);
gboolean iconic_windows,
gboolean all_desktops,
gboolean dock_windows,
gboolean desktop_windows);
void focus_cycle_popup_single_hide(void); void focus_cycle_popup_single_hide(void);
gboolean focus_cycle_popup_is_showing(struct _ObClient *c); gboolean focus_cycle_popup_is_showing(struct _ObClient *c);