]> code.delx.au - spectrwm/blobdiff - spectrwm.c
Add a new visible_noswap option that allow to not swap two visible workspace
[spectrwm] / spectrwm.c
index 2c839d9f86984fa78e1f17512bd4f373d2ab0ee3..4fbbe0ba4622951ff345bbeb562178ed0267ab02 100644 (file)
@@ -334,8 +334,7 @@ int                 term_width = 0;
 int                    font_adjusted = 0;
 unsigned int           mod_key = MODKEY;
 bool                   warp_pointer = false;
-unsigned int           mouse_button_move = XCB_BUTTON_INDEX_1;
-unsigned int           mouse_button_resize = XCB_BUTTON_INDEX_3;
+bool                   visible_noswap = false;
 
 /* dmenu search */
 struct swm_region      *search_r;
@@ -1130,8 +1129,6 @@ int        setautorun(const char *, const char *, int);
 int     setconfbinding(const char *, const char *, int);
 int     setconfcolor(const char *, const char *, int);
 int     setconfmodkey(const char *, const char *, int);
-int     setconfmousebuttonmove(const char *, const char *, int);
-int     setconfmousebuttonresize(const char *, const char *, int);
 int     setconfquirk(const char *, const char *, int);
 int     setconfregion(const char *, const char *, int);
 int     setconfspawn(const char *, const char *, int);
@@ -1179,7 +1176,6 @@ void       unmap_window(struct ws_win *);
 void    updatenumlockmask(void);
 void    update_floater(struct ws_win *);
 void    update_modkey(unsigned int);
-unsigned char  update_mousebutton(unsigned char, unsigned int);
 void    update_win_stacking(struct ws_win *);
 void    update_window(struct ws_win *);
 void    update_window_color(struct ws_win *);
@@ -3902,6 +3898,11 @@ switchws(struct swm_region *r, union arg *args)
                old_ws->r = NULL;
                unmap_old = true;
        } else {
+               if (visible_noswap) {
+                       center_pointer(other_r);
+                       return;
+               }
+
                /* the other ws is visible in another region, exchange them */
                other_r->ws_prior = new_ws;
                other_r->ws = old_ws;
@@ -6841,31 +6842,6 @@ update_modkey(unsigned int mod)
                        buttons[i].mask = mod;
 }
 
-unsigned char
-update_mousebutton(unsigned char type, unsigned int but)
-{
-       int                     i;
-
-       switch (type) {
-               case 0:
-                       mouse_button_move = but;
-                       break;
-               case 1:
-                       mouse_button_resize = but;
-                       break;
-       }
-
-       for (i = 0; i < LENGTH(buttons); i++) {
-               if (buttons[i].func == move)
-                       buttons[i].button = mouse_button_move;
-
-               if (buttons[i].func == resize)
-                       buttons[i].button = mouse_button_resize;
-       }
-
-       return(1);
-}
-
 int
 spawn_expand(struct swm_region *r, union arg *args, const char *spawn_name,
     char ***ret_args)
@@ -8073,6 +8049,7 @@ enum {
        SWM_S_URGENT_COLLAPSE,
        SWM_S_URGENT_ENABLED,
        SWM_S_VERBOSE_LAYOUT,
+       SWM_S_VISIBLE_NOSWAP,
        SWM_S_WARP_POINTER,
        SWM_S_WINDOW_CLASS_ENABLED,
        SWM_S_WINDOW_INSTANCE_ENABLED,
@@ -8291,6 +8268,9 @@ 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);
+               break;
        case SWM_S_WARP_POINTER:
                warp_pointer = (atoi(value) != 0);
                break;
@@ -8366,48 +8346,6 @@ setconfmodkey(const char *selector, const char *value, int flags)
        return (0);
 }
 
-int
-setconfmousebuttonmove(const char *selector, const char *value, int flags)
-{
-       /* suppress unused warnings since vars are needed */
-       (void)selector;
-       (void)flags;
-
-       if (strncasecmp(value, "But1", strlen("But1")) == 0) {
-               if (!update_mousebutton(0, XCB_BUTTON_INDEX_1))
-                       return (1);
-       } else if (strncasecmp(value, "But2", strlen("But2")) == 0) {
-               if (!update_mousebutton(0, XCB_BUTTON_INDEX_2))
-                       return (1);
-       } else if (strncasecmp(value, "But3", strlen("But3")) == 0) {
-               if (!update_mousebutton(0, XCB_BUTTON_INDEX_3))
-                       return (1);
-       } else
-               return (1);
-       return (0);
-}
-
-int
-setconfmousebuttonresize(const char *selector, const char *value, int flags)
-{
-       /* suppress unused warnings since vars are needed */
-       (void)selector;
-       (void)flags;
-
-       if (strncasecmp(value, "But1", strlen("But1")) == 0) {
-               if (!update_mousebutton(1, XCB_BUTTON_INDEX_1))
-                       return (1);
-       } else if (strncasecmp(value, "But2", strlen("But2")) == 0) {
-               if (!update_mousebutton(1, XCB_BUTTON_INDEX_2))
-                       return (1);
-       } else if (strncasecmp(value, "But3", strlen("But3")) == 0) {
-               if (!update_mousebutton(1, XCB_BUTTON_INDEX_3))
-                       return (1);
-       } else
-               return (1);
-       return (0);
-}
-
 int
 setconfcolor(const char *selector, const char *value, int flags)
 {
@@ -8657,8 +8595,6 @@ struct config_option configopt[] = {
        { "layout",                     setlayout,      0 },
        { "maximize_hide_bar",          setconfvalue,   SWM_S_MAXIMIZE_HIDE_BAR },
        { "modkey",                     setconfmodkey,  0 },
-       { "move_button",                setconfmousebuttonmove, 0 },
-       { "resize_button",              setconfmousebuttonresize, 0 },
        { "program",                    setconfspawn,   0 },
        { "quirk",                      setconfquirk,   0 },
        { "region",                     setconfregion,  0 },
@@ -8675,6 +8611,7 @@ 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_pointer",               setconfvalue,   SWM_S_WARP_POINTER },
        { "window_class_enabled",       setconfvalue,   SWM_S_WINDOW_CLASS_ENABLED },
        { "window_instance_enabled",    setconfvalue,   SWM_S_WINDOW_INSTANCE_ENABLED },
@@ -8824,12 +8761,6 @@ conf_load(const char *filename, int keymapping)
        if (line)
                free(line);
        fclose(config);
-
-       if (mouse_button_move == mouse_button_resize) {
-               add_startup_exception("%s: move and resize mouse buttons match",
-                   filename);
-       }
-
        DNPRINTF(SWM_D_CONF, "conf_load: end\n");
 
        return (0);