]> code.delx.au - spectrwm/commitdiff
Add insane follow-mouse-sometimes feature for bob beck
authorMarco Peereboom <marco@conformal.com>
Wed, 30 Jun 2010 00:09:19 +0000 (00:09 +0000)
committerMarco Peereboom <marco@conformal.com>
Wed, 30 Jun 2010 00:09:19 +0000 (00:09 +0000)
scrotwm.1
scrotwm.c
scrotwm.conf

index 8b5277cebb8a901edaa5b2b407c2f98d2b8b1dd6..e5397327d3cb6b20d704871e41e5aa04a6a4e097 100644 (file)
--- 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 .
index 5c8441d3238484848a095b67fbb652150de9d361..7430de3c8963c016c09953cbfb549fd86cc9e1d0 100644 (file)
--- 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 <stdio.h>
 #include <stdlib.h>
@@ -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) {
index 2ab8b1a8b18ec2b635fb7efcabb6a2fc72f1c637..3eb5baf850333b8d20ae8a92ac1464fb2d09e571 100644 (file)
@@ -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