From ea371936cec5f1e7f0eaed698b2cff6fab42f210 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 11 Jan 2008 16:11:51 -0500 Subject: [PATCH] let you raise the focus target temporarily during focus cycling, with the option. also a new option lets you turn off the indicator bar --- openbox/actions/cyclewindows.c | 33 +++++++++++++++++++++------- openbox/actions/directionalwindows.c | 33 +++++++++++++++++++++------- openbox/focus_cycle.c | 13 ++++++----- openbox/focus_cycle.h | 4 +++- openbox/focus_cycle_indicator.c | 12 ++++++++-- 5 files changed, 70 insertions(+), 25 deletions(-) diff --git a/openbox/actions/cyclewindows.c b/openbox/actions/cyclewindows.c index 285df370..059db93f 100644 --- a/openbox/actions/cyclewindows.c +++ b/openbox/actions/cyclewindows.c @@ -1,4 +1,6 @@ #include "openbox/actions.h" +#include "openbox/stacking.h" +#include "openbox/window.h" #include "openbox/event.h" #include "openbox/focus_cycle.h" #include "openbox/openbox.h" @@ -11,6 +13,8 @@ typedef struct { gboolean desktop_windows; gboolean all_desktops; gboolean forward; + gboolean bar; + gboolean raise; GSList *actions; } Options; @@ -46,11 +50,16 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) o = g_new0(Options, 1); o->dialog = TRUE; + o->bar = TRUE; if ((n = parse_find_node("linear", node))) o->linear = parse_bool(doc, n); if ((n = parse_find_node("dialog", node))) o->dialog = parse_bool(doc, n); + if ((n = parse_find_node("bar", node))) + o->bar = parse_bool(doc, n); + if ((n = parse_find_node("raise", node))) + o->raise = parse_bool(doc, n); if ((n = parse_find_node("panels", node))) o->dock_windows = parse_bool(doc, n); if ((n = parse_find_node("desktop", node))) @@ -111,17 +120,22 @@ static void free_func(gpointer options) static gboolean run_func(ObActionsData *data, gpointer options) { Options *o = options; + struct _ObClient *ft; - focus_cycle(o->forward, - o->all_desktops, - o->dock_windows, - o->desktop_windows, - o->linear, - TRUE, - o->dialog, - FALSE, FALSE); + ft = focus_cycle(o->forward, + o->all_desktops, + o->dock_windows, + o->desktop_windows, + o->linear, + TRUE, + o->bar, + o->dialog, + FALSE, FALSE); cycling = TRUE; + stacking_restore(); + if (o->raise) stacking_temp_raise(CLIENT_AS_WINDOW(ft)); + return TRUE; } @@ -174,6 +188,7 @@ static void end_cycle(gboolean cancel, guint state, Options *o) o->desktop_windows, o->linear, TRUE, + o->bar, o->dialog, TRUE, cancel); cycling = FALSE; @@ -181,4 +196,6 @@ static void end_cycle(gboolean cancel, guint state, Options *o) if (ft) actions_run_acts(o->actions, OB_USER_ACTION_KEYBOARD_KEY, state, -1, -1, 0, OB_FRAME_CONTEXT_NONE, ft); + + stacking_restore(); } diff --git a/openbox/actions/directionalwindows.c b/openbox/actions/directionalwindows.c index 707659eb..c575d84e 100644 --- a/openbox/actions/directionalwindows.c +++ b/openbox/actions/directionalwindows.c @@ -1,5 +1,7 @@ #include "openbox/actions.h" #include "openbox/event.h" +#include "openbox/stacking.h" +#include "openbox/window.h" #include "openbox/focus_cycle.h" #include "openbox/openbox.h" #include "openbox/misc.h" @@ -11,6 +13,8 @@ typedef struct { gboolean dock_windows; gboolean desktop_windows; ObDirection direction; + gboolean bar; + gboolean raise; GSList *actions; } Options; @@ -46,9 +50,14 @@ static gpointer setup_func(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node) o = g_new0(Options, 1); o->dialog = TRUE; + o->bar = TRUE; if ((n = parse_find_node("dialog", node))) o->dialog = parse_bool(doc, n); + if ((n = parse_find_node("bar", node))) + o->bar = parse_bool(doc, n); + if ((n = parse_find_node("raise", node))) + o->raise = parse_bool(doc, n); if ((n = parse_find_node("panels", node))) o->dock_windows = parse_bool(doc, n); if ((n = parse_find_node("desktop", node))) @@ -135,13 +144,19 @@ static gboolean run_func(ObActionsData *data, gpointer options) if (!o->interactive) end_cycle(FALSE, data->state, o); else { - focus_directional_cycle(o->direction, - o->dock_windows, - o->desktop_windows, - TRUE, - o->dialog, - FALSE, FALSE); + struct _ObClient *ft; + + ft = focus_directional_cycle(o->direction, + o->dock_windows, + o->desktop_windows, + TRUE, + o->bar, + o->dialog, + FALSE, FALSE); cycling = TRUE; + + stacking_restore(); + if (o->raise) stacking_temp_raise(CLIENT_AS_WINDOW(ft)); } return o->interactive; @@ -194,12 +209,14 @@ static void end_cycle(gboolean cancel, guint state, Options *o) o->dock_windows, o->desktop_windows, o->interactive, + o->bar, o->dialog, TRUE, cancel); cycling = FALSE; - if (ft) { + if (ft) actions_run_acts(o->actions, OB_USER_ACTION_KEYBOARD_KEY, state, -1, -1, 0, OB_FRAME_CONTEXT_NONE, ft); - } + + stacking_restore(); } diff --git a/openbox/focus_cycle.c b/openbox/focus_cycle.c index 85cdf480..2348f8d0 100644 --- a/openbox/focus_cycle.c +++ b/openbox/focus_cycle.c @@ -62,15 +62,16 @@ void focus_cycle_stop(ObClient *ifclient) focus_cycle_dock_windows, focus_cycle_desktop_windows)) { - focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE); - focus_directional_cycle(0, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE); + focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,TRUE); + focus_directional_cycle(0, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE); } } ObClient* focus_cycle(gboolean forward, gboolean all_desktops, gboolean dock_windows, gboolean desktop_windows, gboolean linear, gboolean interactive, - gboolean dialog, gboolean done, gboolean cancel) + gboolean showbar, gboolean dialog, + gboolean done, gboolean cancel) { static ObClient *t = NULL; static GList *order = NULL; @@ -128,7 +129,7 @@ ObClient* focus_cycle(gboolean forward, gboolean all_desktops, if (interactive) { if (ft != focus_cycle_target) { /* prevents flicker */ focus_cycle_target = ft; - focus_cycle_draw_indicator(ft); + focus_cycle_draw_indicator(showbar ? ft : NULL); } if (dialog) /* same arguments as focus_target_valid */ @@ -261,7 +262,7 @@ static ObClient *focus_find_directional(ObClient *c, ObDirection dir, ObClient* focus_directional_cycle(ObDirection dir, gboolean dock_windows, gboolean desktop_windows, gboolean interactive, - gboolean dialog, + gboolean showbar, gboolean dialog, gboolean done, gboolean cancel) { static ObClient *first = NULL; @@ -307,7 +308,7 @@ ObClient* focus_directional_cycle(ObDirection dir, gboolean dock_windows, focus_cycle_target = ft; if (!interactive) goto done_cycle; - focus_cycle_draw_indicator(ft); + focus_cycle_draw_indicator(showbar ? ft : NULL); } if (focus_cycle_target && dialog) /* same arguments as focus_target_valid */ diff --git a/openbox/focus_cycle.h b/openbox/focus_cycle.h index 68b8d929..6e1c2c9d 100644 --- a/openbox/focus_cycle.h +++ b/openbox/focus_cycle.h @@ -37,11 +37,13 @@ void focus_cycle_shutdown(gboolean reconfig); struct _ObClient* focus_cycle(gboolean forward, gboolean all_desktops, gboolean dock_windows, gboolean desktop_windows, gboolean linear, gboolean interactive, - gboolean dialog, gboolean done, gboolean cancel); + gboolean showbar, gboolean dialog, + gboolean done, gboolean cancel); struct _ObClient* focus_directional_cycle(ObDirection dir, gboolean dock_windows, gboolean desktop_windows, gboolean interactive, + gboolean showbar, gboolean dialog, gboolean done, gboolean cancel); diff --git a/openbox/focus_cycle_indicator.c b/openbox/focus_cycle_indicator.c index 79071314..5a6a1029 100644 --- a/openbox/focus_cycle_indicator.c +++ b/openbox/focus_cycle_indicator.c @@ -39,6 +39,7 @@ struct static RrAppearance *a_focus_indicator; static RrColor *color_white; +static gboolean visible; static Window create_window(Window parent, gulong mask, XSetWindowAttributes *attrib) @@ -53,6 +54,8 @@ void focus_cycle_indicator_startup(gboolean reconfig) { XSetWindowAttributes attr; + visible = FALSE; + if (reconfig) return; focus_indicator.top.obwin.type = Window_Internal; @@ -118,7 +121,7 @@ void focus_cycle_indicator_shutdown(gboolean reconfig) void focus_cycle_draw_indicator(ObClient *c) { - if (!c) { + if (!c && visible) { gulong ignore_start; /* kill enter events cause by this unmapping */ @@ -130,7 +133,10 @@ void focus_cycle_draw_indicator(ObClient *c) XUnmapWindow(ob_display, focus_indicator.bottom.win); event_end_ignore_all_enters(ignore_start); - } else { + + visible = FALSE; + } + else if (c) { /* if (c) frame_adjust_focus(c->frame, FALSE); @@ -249,5 +255,7 @@ void focus_cycle_draw_indicator(ObClient *c) XMapWindow(ob_display, focus_indicator.left.win); XMapWindow(ob_display, focus_indicator.right.win); XMapWindow(ob_display, focus_indicator.bottom.win); + + visible = TRUE; } } -- 2.39.2