From 418095b48ea33dfce904a0250f1659a6a0feeb78 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Wed, 3 Sep 2003 08:12:07 +0000 Subject: [PATCH] add the focusDelay option --- data/rc.xml | 1 + openbox/config.c | 4 ++++ openbox/config.h | 5 +++-- openbox/event.c | 32 +++++++++++++++++++++++++++++++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/data/rc.xml b/data/rc.xml index 40c6b076..0ae56bdd 100644 --- a/data/rc.xml +++ b/data/rc.xml @@ -15,6 +15,7 @@ no yes yes + 150000 diff --git a/openbox/config.c b/openbox/config.c index 72ccd3b4..e2ca29f7 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -10,6 +10,7 @@ gboolean config_focus_new; gboolean config_focus_follow; gboolean config_focus_last; gboolean config_focus_last_on_desktop; +guint config_focus_delay; char *config_theme; @@ -205,6 +206,8 @@ static void parse_focus(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, config_focus_last = parse_bool(doc, n); if ((n = parse_find_node("focusLastOnDesktop", node))) config_focus_last_on_desktop = parse_bool(doc, n); + if ((n = parse_find_node("focusDelay", node))) + config_focus_delay = parse_int(doc, n); } static void parse_theme(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node, @@ -358,6 +361,7 @@ void config_startup(ObParseInst *i) config_focus_follow = FALSE; config_focus_last = TRUE; config_focus_last_on_desktop = TRUE; + config_focus_delay = 150000; parse_register(i, "focus", parse_focus, NULL); diff --git a/openbox/config.h b/openbox/config.h index 02ee2457..3312adb6 100644 --- a/openbox/config.h +++ b/openbox/config.h @@ -16,8 +16,9 @@ extern gboolean config_focus_follow; extern gboolean config_focus_last; /*! Focus the last focused window as a fallback when switching desktops */ extern gboolean config_focus_last_on_desktop; -/*! The number of slits to create - extern int config_slit_number;*/ +/*! Timeout for focusing windows on focus follows mouse, in microseconds */ +extern guint config_focus_delay; + /*! When true windows' contents are refreshed while they are resized; otherwise they are not updated until the resize is complete */ extern gboolean config_redraw_resize; diff --git a/openbox/event.c b/openbox/event.c index dda1d227..00036b48 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -46,6 +46,9 @@ static void event_handle_dock(ObDock *s, XEvent *e); static void event_handle_dockapp(ObDockApp *app, XEvent *e); static void event_handle_client(ObClient *c, XEvent *e); +static gboolean focus_delay_func(gpointer data); +static void focus_delay_client_dest(gpointer data); + #define INVALID_FOCUSIN(e) ((e)->xfocus.detail == NotifyInferior || \ (e)->xfocus.detail == NotifyAncestor || \ (e)->xfocus.detail > NotifyNonlinearVirtual) @@ -137,10 +140,13 @@ void event_startup() #ifdef USE_LIBSN ob_main_loop_x_add(ob_main_loop, sn_handler, ob_sn_display, NULL); #endif + + client_add_destructor(focus_delay_client_dest); } void event_shutdown() { + client_remove_destructor(focus_delay_client_dest); XFreeModifiermap(modmap); } @@ -648,6 +654,11 @@ static void event_handle_client(ObClient *client, XEvent *e) client->frame->close_hover = FALSE; frame_adjust_state(client->frame); break; + case OB_FRAME_CONTEXT_FRAME: + /* XXX if doing a 'reconfigure' make sure you kill this timer, + maybe all timers.. */ + if (config_focus_delay) + ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func); default: break; } @@ -690,7 +701,14 @@ static void event_handle_client(ObClient *client, XEvent *e) ob_debug("EnterNotify on %lx, focusing window\n", client->window); #endif - client_focus(client); + if (config_focus_delay) { + ob_main_loop_timeout_add(ob_main_loop, + config_focus_delay, + focus_delay_func, + client, + NULL); + } else + client_focus(client); } } break; @@ -1157,3 +1175,15 @@ static void event_handle_menu(XEvent *ev) break; } } + +static gboolean focus_delay_func(gpointer data) +{ + ObClient *c = data; + client_focus(c); + return FALSE; /* no repeat */ +} + +static void focus_delay_client_dest(gpointer data) +{ + ob_main_loop_timeout_remove(ob_main_loop, focus_delay_func); +} -- 2.45.2