]> code.delx.au - spectrwm/commitdiff
Add new option: warp_focus
authorReginald Kennedy <rk@rejii.com>
Wed, 15 Oct 2014 11:38:45 +0000 (19:38 +0800)
committerReginald Kennedy <rk@rejii.com>
Fri, 27 Feb 2015 20:05:37 +0000 (04:05 +0800)
Focus on the target window/workspace/region when clamped.
For example, when attempting to switch to a workspace that is mapped on
another region and workspace_clamp is enabled, focus on the region with
the target workspace.  Enable by setting to 1.

Rename visible_noswap to workspace_clamp and update man page:
Prevents workspaces from being swapped when attempting to switch to a
workspace that is mapped to another region.  Use warp_focus if you want
to focus on the region containing the workspace and warp_pointer if you
want to also send the pointer.  Enable by setting to 1.

closes #80.

spectrwm.1
spectrwm.c
spectrwm.conf

index 00fae3f9970df811c00a0fa87be02d36db1b2eb4..1b978054eb977a851012b5821ef9537632e8eb55 100644 (file)
@@ -1,6 +1,6 @@
 .\" Copyright (c) 2009-2012 Marco Peereboom <marco@peereboom.us>
 .\" Copyright (c) 2009 Darrin Chandler <dwchandler@stilyagin.com>
-.\" Copyright (c) 2011-2014 Reginald Kennedy <rk@rejii.com>
+.\" Copyright (c) 2011-2015 Reginald Kennedy <rk@rejii.com>
 .\" Copyright (c) 2011-2012 Lawrence Teo <lteo@lteo.net>
 .\" Copyright (c) 2011-2012 Tiago Cunha <tcunha@gmx.com>
 .\" Copyright (c) 2012 David Hill <dhill@mindcry.org>
@@ -470,11 +470,14 @@ See
 and
 .Ar stack_dec
 for more information.
-.It Ic visible_noswap
-Do not swap on already visible workspace, useful on multi screen setup.
+.It Ic workspace_clamp
+Prevents workspaces from being swapped when attempting to switch to a workspace
+that is mapped to another region.
 Use
+.Ar warp_focus
+if you want to focus on the region containing the workspace and
 .Ar warp_pointer
-if you want to send pointer in that region.
+if you want to also send the pointer.
 Enable by setting to 1.
 .It Ic window_class_enabled
 Enable or disable displaying the window class name (from WM_CLASS) in the
@@ -494,6 +497,13 @@ the bar, it's limited to 64 characters, by default.
 See the
 .Ic bar_format
 option for more details.
+.It Ic warp_focus
+Focus on the target window/workspace/region when clamped.
+For example, when attempting to switch to a workspace that is mapped on another
+region and
+.Ar workspace_clamp
+is enabled, focus on the region with the target workspace.
+Enable by setting to 1.
 .It Ic warp_pointer
 Centers the mouse pointer on the focused window when using key bindings to
 change focus, switch workspaces, change regions, etc.
index 4fbbe0ba4622951ff345bbeb562178ed0267ab02..ca7fe742615ad72932606e8f5de3955ed093bc96 100644 (file)
@@ -333,8 +333,9 @@ bool                        cycle_visible = false;
 int                    term_width = 0;
 int                    font_adjusted = 0;
 unsigned int           mod_key = MODKEY;
+bool                   warp_focus = false;
 bool                   warp_pointer = false;
-bool                   visible_noswap = false;
+bool                   workspace_clamp = false;
 
 /* dmenu search */
 struct swm_region      *search_r;
@@ -3884,6 +3885,20 @@ switchws(struct swm_region *r, union arg *args)
        if (new_ws == old_ws)
                return;
 
+       other_r = new_ws->r;
+       if (other_r && workspace_clamp) {
+               DNPRINTF(SWM_D_WS, "switchws: ws clamped.\n");
+
+               if (warp_focus) {
+                       DNPRINTF(SWM_D_WS, "switchws: warping focus to region "
+                           "with ws %d.\n", wsid);
+                       focus_region(other_r);
+                       center_pointer(other_r);
+                       focus_flush();
+               }
+               return;
+       }
+
        if ((win = old_ws->focus) != NULL) {
                update_window_color(win);
 
@@ -3892,22 +3907,17 @@ switchws(struct swm_region *r, union arg *args)
                    &none);
        }
 
-       other_r = new_ws->r;
-       if (other_r == NULL) {
-               /* the other workspace is hidden, hide this one */
-               old_ws->r = NULL;
-               unmap_old = true;
-       } else {
-               if (visible_noswap) {
-                       center_pointer(other_r);
-                       return;
-               }
-
+       if (other_r) {
                /* the other ws is visible in another region, exchange them */
                other_r->ws_prior = new_ws;
                other_r->ws = old_ws;
                old_ws->r = other_r;
+       } else {
+               /* the other workspace is hidden, hide this one */
+               old_ws->r = NULL;
+               unmap_old = true;
        }
+
        this_r->ws_prior = old_ws;
        this_r->ws = new_ws;
        new_ws->r = this_r;
@@ -8049,11 +8059,12 @@ enum {
        SWM_S_URGENT_COLLAPSE,
        SWM_S_URGENT_ENABLED,
        SWM_S_VERBOSE_LAYOUT,
-       SWM_S_VISIBLE_NOSWAP,
+       SWM_S_WARP_FOCUS,
        SWM_S_WARP_POINTER,
        SWM_S_WINDOW_CLASS_ENABLED,
        SWM_S_WINDOW_INSTANCE_ENABLED,
        SWM_S_WINDOW_NAME_ENABLED,
+       SWM_S_WORKSPACE_CLAMP,
        SWM_S_WORKSPACE_LIMIT,
        SWM_S_WORKSPACE_NAME,
 };
@@ -8268,8 +8279,8 @@ setconfvalue(const char *selector, const char *value, int flags)
                                layouts[i].l_string = plain_stacker;
                }
                break;
-       case SWM_S_VISIBLE_NOSWAP:
-               visible_noswap = (atoi(value) != 0);
+       case SWM_S_WARP_FOCUS:
+               warp_focus = (atoi(value) != 0);
                break;
        case SWM_S_WARP_POINTER:
                warp_pointer = (atoi(value) != 0);
@@ -8283,6 +8294,9 @@ setconfvalue(const char *selector, const char *value, int flags)
        case SWM_S_WINDOW_NAME_ENABLED:
                window_name_enabled = (atoi(value) != 0);
                break;
+       case SWM_S_WORKSPACE_CLAMP:
+               workspace_clamp = (atoi(value) != 0);
+               break;
        case SWM_S_WORKSPACE_LIMIT:
                workspace_limit = atoi(value);
                if (workspace_limit > SWM_WS_MAX)
@@ -8611,11 +8625,12 @@ struct config_option configopt[] = {
        { "urgent_collapse",            setconfvalue,   SWM_S_URGENT_COLLAPSE },
        { "urgent_enabled",             setconfvalue,   SWM_S_URGENT_ENABLED },
        { "verbose_layout",             setconfvalue,   SWM_S_VERBOSE_LAYOUT },
-       { "visible_noswap",             setconfvalue,   SWM_S_VISIBLE_NOSWAP },
+       { "warp_focus",                 setconfvalue,   SWM_S_WARP_FOCUS },
        { "warp_pointer",               setconfvalue,   SWM_S_WARP_POINTER },
        { "window_class_enabled",       setconfvalue,   SWM_S_WINDOW_CLASS_ENABLED },
        { "window_instance_enabled",    setconfvalue,   SWM_S_WINDOW_INSTANCE_ENABLED },
        { "window_name_enabled",        setconfvalue,   SWM_S_WINDOW_NAME_ENABLED },
+       { "workspace_clamp",            setconfvalue,   SWM_S_WORKSPACE_CLAMP },
        { "workspace_limit",            setconfvalue,   SWM_S_WORKSPACE_LIMIT },
        { "name",                       setconfvalue,   SWM_S_WORKSPACE_NAME },
 };
index 0d8437c330632754413d91fd0f31faaec727dbe4..35948ef61c546aecffea2e859fcbcf78a3c5b5d7 100644 (file)
@@ -8,7 +8,8 @@
 # focus_close_wrap     = 1
 # focus_default                = last
 # spawn_position               = next
-# visible_noswap       = 1
+# workspace_clamp      = 1
+# warp_focus           = 1
 # warp_pointer         = 1
 
 # Window Decoration