From: Marco Peereboom Date: Wed, 30 Jun 2010 00:09:19 +0000 (+0000) Subject: Add insane follow-mouse-sometimes feature for bob beck X-Git-Url: https://jasonwoof.com/gitweb/?a=commitdiff_plain;h=a2474fde688e23b80ecea4e9011d254575030e24;hp=22a67dc7cd91a22dc226c775dbcd1b7ffbbb1c43;p=spectrwm.git Add insane follow-mouse-sometimes feature for bob beck --- diff --git a/scrotwm.1 b/scrotwm.1 index 8b5277c..e539732 100644 --- a/scrotwm.1 +++ b/scrotwm.1 @@ -142,6 +142,9 @@ Enable by setting to 1 .It Cm modkey Change mod key. Mod1 is generally the ALT key and Mod4 is the windows key on a PC. +.It Cm focus_mode +Using a value of follow_cursor will make the window manager focus the window +under the mouse when switching workspaces and creating windows. .It Cm program Ns Bq Ar p Define new action to spawn a program .Ar p . diff --git a/scrotwm.c b/scrotwm.c index 5c8441d..7430de3 100644 --- a/scrotwm.c +++ b/scrotwm.c @@ -52,7 +52,7 @@ static const char *cvstag = "$scrotwm$"; -#define SWM_VERSION "0.9.23" +#define SWM_VERSION "0.9.24" #include #include @@ -154,6 +154,10 @@ u_int32_t swm_debug = 0 #define SWM_MAX_FONT_STEPS (3) #define WINID(w) (w ? w->id : 0) +#define SWM_FOCUS_DEFAULT (0) +#define SWM_FOCUS_SYNERGY (1) +#define SWM_FOCUS_FOLLOW (2) + #ifndef SWM_LIB #define SWM_LIB "/usr/local/lib/libswmhack.so" #endif @@ -201,6 +205,7 @@ int clock_enabled = 1; char *clock_format = NULL; int title_name_enabled = 0; int title_class_enabled = 0; +int focus_mode = SWM_FOCUS_DEFAULT; pid_t bar_pid; GC bar_gc; XGCValues bar_gcv; @@ -3353,8 +3358,9 @@ setup_quirks(void) enum { SWM_S_BAR_DELAY, SWM_S_BAR_ENABLED, SWM_S_STACK_ENABLED, SWM_S_CLOCK_ENABLED, SWM_S_CLOCK_FORMAT, SWM_S_CYCLE_EMPTY, SWM_S_CYCLE_VISIBLE, SWM_S_SS_ENABLED, SWM_S_TERM_WIDTH, - SWM_S_TITLE_CLASS_ENABLED, SWM_S_TITLE_NAME_ENABLED, SWM_S_BAR_FONT, - SWM_S_BAR_ACTION, SWM_S_SPAWN_TERM, SWM_S_SS_APP, SWM_S_DIALOG_RATIO + SWM_S_TITLE_CLASS_ENABLED, SWM_S_TITLE_NAME_ENABLED, + SWM_S_FOCUS_MODE, SWM_S_BAR_FONT, SWM_S_BAR_ACTION, SWM_S_SPAWN_TERM, + SWM_S_SS_APP, SWM_S_DIALOG_RATIO }; int @@ -3398,6 +3404,16 @@ setconfvalue(char *selector, char *value, int flags) case SWM_S_TITLE_NAME_ENABLED: title_name_enabled = atoi(value); break; + case SWM_S_FOCUS_MODE: + if (!strcmp(value, "default")) + focus_mode = SWM_FOCUS_DEFAULT; + else if (!strcmp(value, "follow_cursor")) + focus_mode = SWM_FOCUS_FOLLOW; + else if (!strcmp(value, "synergy")) + focus_mode = SWM_FOCUS_SYNERGY; + else + err(1, "focus_mode"); + break; case SWM_S_BAR_FONT: free(bar_fonts[0]); if ((bar_fonts[0] = strdup(value)) == NULL) @@ -3488,7 +3504,8 @@ struct config_option configopt[] = { { "screenshot_app", setconfvalue, SWM_S_SS_APP }, { "term_width", setconfvalue, SWM_S_TERM_WIDTH }, { "title_class_enabled", setconfvalue, SWM_S_TITLE_CLASS_ENABLED }, - { "title_name_enabled", setconfvalue, SWM_S_TITLE_NAME_ENABLED } + { "title_name_enabled", setconfvalue, SWM_S_TITLE_NAME_ENABLED }, + { "focus_mode", setconfvalue, SWM_S_FOCUS_MODE }, }; @@ -4011,7 +4028,17 @@ enternotify(XEvent *e) ev->window, ev->mode, ev->detail, ev->root, ev->subwindow, ev->same_screen, ev->focus, ev->state); - goto focusme; + switch (focus_mode) { + case SWM_FOCUS_DEFAULT: + if (QLength(display)) { + DNPRINTF(SWM_D_EVENT, "ignore enternotify %d\n", + QLength(display)); + return; + } + break; + case SWM_FOCUS_FOLLOW: + break; + case SWM_FOCUS_SYNERGY: #if 0 /* * all these checks need to be in this order because the @@ -4080,11 +4107,7 @@ enternotify(XEvent *e) } } #endif -focusme: - if (QLength(display)) { - DNPRINTF(SWM_D_EVENT, "ignore enternotify %d\n", - QLength(display)); - return; + break; } if ((win = find_window(ev->window)) == NULL) { diff --git a/scrotwm.conf b/scrotwm.conf index 2ab8b1a..3eb5baf 100644 --- a/scrotwm.conf +++ b/scrotwm.conf @@ -17,6 +17,7 @@ clock_enabled = 1 #clock_format = %a %b %d %R %Z %Y title_name_enabled = 0 title_class_enabled = 0 +#focus_mode = default # spawn app # program[term] = xterm