]> git.lizzy.rs Git - bspwm.git/commitdiff
New setting: `pointer_follows_monitor`
authorBastien Dejean <nihilhill@gmail.com>
Wed, 5 Jun 2013 19:21:12 +0000 (21:21 +0200)
committerBastien Dejean <nihilhill@gmail.com>
Wed, 5 Jun 2013 19:21:12 +0000 (21:21 +0200)
README.md
bash_completion
bspwm.1
messages.c
settings.c
settings.h
tree.c
window.c
window.h

index 96a9b124f434ddf1b1e29d22d6726fe7053a7e7f..cc49d655079532727a1b364207de9bfdbc3c82bd 100644 (file)
--- a/README.md
+++ b/README.md
@@ -201,6 +201,8 @@ The following messages are handled:
 
 Colors are either [X color names](http://en.wikipedia.org/wiki/X11_color_names) or *#RRGGBB*, booleans are *true* or *false*.
 
+All the boolean settings are *false* by default.
+
 - `focused_border_color` — Color of the border of a focused window of a focused monitor.
 
 - `active_border_color` — Color of the border of a focused window of an unfocused monitor.
@@ -227,19 +229,21 @@ Colors are either [X color names](http://en.wikipedia.org/wiki/X11_color_names)
 
 - `wm_name` — The value that shall be used for the `_NET_WM_NAME` property of the root window.
 
-- `borderless_monocle` — Whether to remove borders for tiled windows in monocle mode.
+- `borderless_monocle` — Remove borders for tiled windows in monocle mode.
+
+- `gapless_monocle` — Remove gaps for tiled windows in monocle mode.
 
-- `gapless_monocle` — Whether to remove gaps for tiled windows in monocle mode.
+- `focus_follows_pointer` — Focus the window under the pointer.
 
-- `focus_follows_pointer` — Whether to focus the window under the pointer.
+- `pointer_follows_monitor` — When focusing a monitor, put the pointer at its center.
 
 - `adaptative_raise` — Prevent floating windows from being raised when they might cover other floating windows.
 
 - `apply_shadow_property` — Enable shadows for floating windows via the `_COMPTON_SHADOW` property.
 
-- `auto_alternate` — Whether to interpret two consecutive identical `use` messages as an `alternate` message.
+- `auto_alternate` — Interpret two consecutive identical `use` messages as an `alternate` message.
 
-- `focus_by_distance` — Whether to use window or leaf distance for focus movement.
+- `focus_by_distance` — Use window or leaf distance for focus movement.
 
 ## Environment Variables
 
index eaf2ea556c50944e7a09daf83ba907f451f4d6c3..3fa02cdb9a16617147ecd5b6f6508e00a2c86348 100644 (file)
@@ -2,7 +2,7 @@ _bspc()
 {
     local messages='get set list list_desktops list_monitors list_windows list_rules list_history presel cancel ratio pad focus shift swap push pull cycle nearest biggest circulate grab_pointer track_pointer ungrab_pointer toggle_fullscreen toggle_floating toggle_locked toggle_visibility close kill send_to drop_to send_to_monitor drop_to_monitor use use_monitor alternate alternate_desktop alternate_monitor add add_in rename_monitor rename remove_desktop send_desktop_to cycle_monitor cycle_desktop layout cycle_layout rotate flip balance rule remove_rule put_status adopt_orphans restore_layout restore_history quit'
 
-    local settings='focused_border_color active_border_color normal_border_color presel_border_color focused_locked_border_color active_locked_border_color normal_locked_border_color urgent_border_color border_width window_gap split_ratio top_padding right_padding bottom_padding left_padding wm_name borderless_monocle gapless_monocle focus_follows_pointer adaptative_raise apply_shadow_property auto_alternate focus_by_distance'
+    local settings='focused_border_color active_border_color normal_border_color presel_border_color focused_locked_border_color active_locked_border_color normal_locked_border_color urgent_border_color border_width window_gap split_ratio top_padding right_padding bottom_padding left_padding wm_name borderless_monocle gapless_monocle focus_follows_pointer pointer_follows_monitor adaptative_raise apply_shadow_property auto_alternate focus_by_distance'
 
     COMPREPLY=()
 
diff --git a/bspwm.1 b/bspwm.1
index a99894a63d5020d6a453d624cfe16b85f8f415fd..05a2306cf459e21ad9fe448cc266d7d22accde93 100644 (file)
--- a/bspwm.1
+++ b/bspwm.1
@@ -275,6 +275,7 @@ Restore the history of each desktop from the content of FILE_PATH.
 .BI quit " [EXIT_STATUS]"
 Quit.
 .SH SETTINGS
+.P
 Colors are either
 .B X
 color names (cf.
@@ -285,6 +286,10 @@ or
 .I #RRGGBB
 , booleans are
 .IR "true " "or " false .
+.P
+All the boolean settings are
+.I false
+by default.
 .TP
 .I focused_border_color
 Color of the border of a focused window of a focused monitor.
@@ -336,13 +341,16 @@ The value that shall be used for the
 property of the root window.
 .TP
 .I borderless_monocle
-Whether to remove borders for tiled windows in monocle mode.
+Remove borders for tiled windows in monocle mode.
 .TP
 .I gapless_monocle
-Whether to remove gaps for tiled windows in monocle mode.
+Remove gaps for tiled windows in monocle mode.
 .TP
 .I focus_follows_pointer
-Whether to focus the window under the pointer.
+Focus the window under the pointer.
+.TP
+.I pointer_follows_monitor
+When focusing a monitor, put the pointer at its center.
 .TP
 .I adaptative_raise
 Prevent floating windows from being raised when they might cover other floating windows.
@@ -353,14 +361,14 @@ Enable shadows for floating windows via the
 property.
 .TP
 .I auto_alernate
-Whether to interpret two consecutive identical
+Interpret two consecutive identical
 .B use
 messages as an
 .B alternate
 message.
 .TP
 .I focus_by_distance
-Whether to use window or leaf distance for focus movement.
+Use window or leaf distance for focus movement.
 .SH ENVIRONMENT VARIABLES
 .TP
 .I BSPWM_SOCKET
index dbb997e574235d9999fafc5e3e71a258b365e01b..9aa02850b9fdb89814f39e0ecd0f467ed8f9f031 100644 (file)
@@ -571,6 +571,11 @@ void set_setting(char *name, char *value, char *rsp)
             focus_follows_pointer = b;
         }
         return;
+    } else if (strcmp(name, "pointer_follows_monitor") == 0) {
+        bool b;
+        if (parse_bool(value, &b))
+            pointer_follows_monitor = b;
+        return;
     } else if (strcmp(name, "adaptative_raise") == 0) {
         bool b;
         if (parse_bool(value, &b))
@@ -644,6 +649,8 @@ void get_setting(char *name, char* rsp)
         snprintf(rsp, BUFSIZ, "%s", BOOLSTR(gapless_monocle));
     else if (strcmp(name, "focus_follows_pointer") == 0)
         snprintf(rsp, BUFSIZ, "%s", BOOLSTR(focus_follows_pointer));
+    else if (strcmp(name, "pointer_follows_monitor") == 0)
+        snprintf(rsp, BUFSIZ, "%s", BOOLSTR(pointer_follows_monitor));
     else if (strcmp(name, "adaptative_raise") == 0)
         snprintf(rsp, BUFSIZ, "%s", BOOLSTR(adaptative_raise));
     else if (strcmp(name, "apply_shadow_property") == 0)
index 7162f8b9d4e0511f31a33be915566772b923d6c3..8852740226cb7dc009e09afb13daefb681849279 100644 (file)
@@ -63,6 +63,7 @@ void load_settings(void)
     borderless_monocle = BORDERLESS_MONOCLE;
     gapless_monocle = GAPLESS_MONOCLE;
     focus_follows_pointer = FOCUS_FOLLOWS_POINTER;
+    pointer_follows_monitor = POINTER_FOLLOWS_MONITOR;
     adaptative_raise = ADAPTATIVE_RAISE;
     apply_shadow_property = APPLY_SHADOW_PROPERTY;
     auto_alternate = AUTO_ALTERNATE;
index e53b9a60ac6dd968c578b46f839a4b2165c4d8de..f38924e91355e0a2b2e3172f356b6227c3b826ef 100644 (file)
 #define WINDOW_GAP     6
 #define SPLIT_RATIO    0.5
 
-#define BORDERLESS_MONOCLE     false
-#define GAPLESS_MONOCLE        false
-#define FOCUS_FOLLOWS_POINTER  false
-#define ADAPTATIVE_RAISE       false
-#define APPLY_SHADOW_PROPERTY  false
-#define AUTO_ALTERNATE         false
-#define FOCUS_BY_DISTANCE      false
+#define BORDERLESS_MONOCLE       false
+#define GAPLESS_MONOCLE          false
+#define FOCUS_FOLLOWS_POINTER    false
+#define POINTER_FOLLOWS_MONITOR  false
+#define ADAPTATIVE_RAISE         false
+#define APPLY_SHADOW_PROPERTY    false
+#define AUTO_ALTERNATE           false
+#define FOCUS_BY_DISTANCE        false
 
 char focused_border_color[MAXLEN];
 char active_border_color[MAXLEN];
@@ -53,6 +54,7 @@ double split_ratio;
 bool borderless_monocle;
 bool gapless_monocle;
 bool focus_follows_pointer;
+bool pointer_follows_monitor;
 bool adaptative_raise;
 bool apply_shadow_property;
 bool auto_alternate;
diff --git a/tree.c b/tree.c
index 61c067a848fc1ed6701489016d01c0524bb71fc8..1ed0074d45cf5348907828422aeb6ad38132295e 100644 (file)
--- a/tree.c
+++ b/tree.c
@@ -766,6 +766,9 @@ void select_monitor(monitor_t *m)
     last_mon = mon;
     mon = m;
 
+    if (pointer_follows_monitor)
+        center_pointer(m);
+
     ewmh_update_current_desktop();
 }
 
index a904a317179646e60275a982329de8902b98aa1d..fe9297d00d86d74da26e1378d99cea4c9148e236 100644 (file)
--- a/window.c
+++ b/window.c
@@ -614,3 +614,10 @@ void clear_input_focus(void)
 {
     xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT, root, XCB_CURRENT_TIME);
 }
+
+void center_pointer(monitor_t *m)
+{
+    int16_t cx = m->rectangle.x + m->rectangle.width / 2;
+    int16_t cy = m->rectangle.y + m->rectangle.height / 2;
+    xcb_warp_pointer(dpy, XCB_NONE, root, 0, 0, 0, 0, cx, cy);
+}
index f51c6b722d484cb2f9eba84538b1485bb4537068..90f97acacd5aa11b31a2a6ce17e203dc2c984995 100644 (file)
--- a/window.h
+++ b/window.h
@@ -50,5 +50,6 @@ void enable_motion_recorder(void);
 void disable_motion_recorder(void);
 void update_motion_recorder(void);
 void clear_input_focus(void);
+void center_pointer(monitor_t *);
 
 #endif