]> git.lizzy.rs Git - bspwm.git/commitdiff
*click_to_focus* is now a button name
authorBastien Dejean <nihilhill@gmail.com>
Wed, 12 Jul 2017 08:33:51 +0000 (10:33 +0200)
committerBastien Dejean <nihilhill@gmail.com>
Wed, 12 Jul 2017 08:33:51 +0000 (10:33 +0200)
Booleans are deprecated but still accepted.

doc/bspwm.1
doc/bspwm.1.asciidoc
src/events.c
src/events.h
src/messages.c
src/parse.c
src/parse.h
src/pointer.c
src/query.c
src/query.h
src/settings.h

index b909ecc9be0b21b4cfbcd84f783d36a2a4802671..0258032960db555e752f2e911f8f6e47d72d901d 100644 (file)
@@ -2,12 +2,12 @@
 .\"     Title: bspwm
 .\"    Author: [see the "Author" section]
 .\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
-.\"      Date: 06/04/2017
+.\"      Date: 07/12/2017
 .\"    Manual: Bspwm Manual
-.\"    Source: Bspwm 0.9.2-48-gfab441b
+.\"    Source: Bspwm 0.9.2-57-g61d5ca4
 .\"  Language: English
 .\"
-.TH "BSPWM" "1" "06/04/2017" "Bspwm 0\&.9\&.2\-48\-gfab441b" "Bspwm Manual"
+.TH "BSPWM" "1" "07/12/2017" "Bspwm 0\&.9\&.2\-57\-g61d5ca4" "Bspwm Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -1123,14 +1123,20 @@ Action performed when pressing
 .PP
 \fIclick_to_focus\fR
 .RS 4
-Focus a window (or a monitor) by clicking it\&.
+Button used for focusing a window (or a monitor)\&. The possible values are:
+\fBbutton1\fR,
+\fBbutton2\fR,
+\fBbutton3\fR,
+\fBany\fR,
+\fBnone\fR\&.
 .RE
 .PP
 \fIswallow_first_click\fR
 .RS 4
-Don\(cqt replay the click that makes a window focused when
+Don\(cqt replay the click that makes a window focused if
 \fIclick_to_focus\fR
-is set\&.
+isn\(cqt
+\fBnone\fR\&.
 .RE
 .PP
 \fIfocus_follows_pointer\fR
@@ -1198,11 +1204,10 @@ Window border width\&.
 .RE
 .SH "POINTER BINDINGS"
 .PP
-\fIbutton1\fR
-.RS 4
-Focus the window under the pointer if
 \fIclick_to_focus\fR
-is set\&.
+.RS 4
+Focus the window (or the monitor) under the pointer if the value isn\(cqt
+\fBnone\fR\&.
 .RE
 .PP
 \fIpointer_modifier\fR + \fIbutton1\fR
index 9513967809fa93b4a9a3f072c8d27b8d0facca8b..ff8031e476b29d4d78f4705cb69c4336e76bddb6 100644 (file)
@@ -651,10 +651,10 @@ Global Settings
        Action performed when pressing 'pointer_modifier' + 'button<n>'. Accept the following values: *move*, *resize_side*, *resize_corner*, *focus*, *none*.
 
 'click_to_focus'::
-       Focus a window (or a monitor) by clicking it.
+       Button used for focusing a window (or a monitor). The possible values are: *button1*, *button2*, *button3*, *any*, *none*.
 
 'swallow_first_click'::
-       Don't replay the click that makes a window focused when 'click_to_focus' is set.
+       Don't replay the click that makes a window focused if 'click_to_focus' isn't *none*.
 
 'focus_follows_pointer'::
        Focus the window under the pointer.
@@ -707,8 +707,8 @@ Node Settings
 Pointer Bindings
 ----------------
 
-'button1'::
-       Focus the window under the pointer if 'click_to_focus' is set.
+'click_to_focus'::
+       Focus the window (or the monitor) under the pointer if the value isn't *none*.
 
 'pointer_modifier' + 'button1'::
        Move the window under the pointer.
index 02b84533ebfdfb7fe43ec2a762b0db0c64947337..3d7022caa576328b482aca788ff89d23179895a5 100644 (file)
@@ -340,12 +340,12 @@ void button_press(xcb_generic_event_t *evt)
 {
        xcb_button_press_event_t *e = (xcb_button_press_event_t *) evt;
        bool replay = false;
-       uint8_t buttons[] = {XCB_BUTTON_INDEX_1, XCB_BUTTON_INDEX_2, XCB_BUTTON_INDEX_3};
-       for (unsigned int i = 0; i < LENGTH(buttons); i++) {
-               if (e->detail != buttons[i]) {
+       for (unsigned int i = 0; i < LENGTH(BUTTONS); i++) {
+               if (e->detail != BUTTONS[i]) {
                        continue;
                }
-               if (click_to_focus && cleaned_mask(e->state) == XCB_NONE) {
+               if ((click_to_focus == XCB_BUTTON_INDEX_ANY || click_to_focus == BUTTONS[i]) &&
+                       cleaned_mask(e->state) == XCB_NONE) {
                        bool pff = pointer_follows_focus;
                        bool pfm = pointer_follows_monitor;
                        pointer_follows_focus = false;
index a65f4ea2d4a711e111664e8f539e51d0ed5d8cab..d0e37383ddb6a355a55fb0d3e6f2c47c2a303eee 100644 (file)
@@ -29,6 +29,7 @@
 #include <xcb/xcb_event.h>
 
 uint8_t randr_base;
+static const xcb_button_index_t BUTTONS[] = {XCB_BUTTON_INDEX_1, XCB_BUTTON_INDEX_2, XCB_BUTTON_INDEX_3};
 
 void handle_event(xcb_generic_event_t *evt);
 void map_request(xcb_generic_event_t *evt);
index 3bf5a7a517d5225adaf22085f859f4a1b3ed927c..7706bd073112d40a686bc50a497d27ef35966b96 100644 (file)
@@ -1487,7 +1487,7 @@ void set_setting(coordinates_t loc, char *name, char *value, FILE *rsp)
                        return;
                }
        } else if (streq("click_to_focus", name)) {
-               if (parse_bool(value, &click_to_focus)) {
+               if (parse_button_index(value, &click_to_focus)) {
                        ungrab_buttons();
                        grab_buttons();
                } else {
@@ -1621,6 +1621,8 @@ void get_setting(coordinates_t loc, char *name, FILE* rsp)
                fprintf(rsp, "%s", TIGHTNESS_STR(directional_focus_tightness));
        } else if (streq("pointer_modifier", name)) {
                print_modifier_mask(pointer_modifier, rsp);
+       } else if (streq("click_to_focus", name)) {
+               print_button_index(click_to_focus, rsp);
        } else if (streq("pointer_motion_interval", name)) {
                fprintf(rsp, "%u", pointer_motion_interval);
        } else if (streq("pointer_action1", name) ||
@@ -1643,7 +1645,6 @@ void get_setting(coordinates_t loc, char *name, FILE* rsp)
        GET_BOOL(gapless_monocle)
        GET_BOOL(paddingless_monocle)
        GET_BOOL(single_monocle)
-       GET_BOOL(click_to_focus)
        GET_BOOL(swallow_first_click)
        GET_BOOL(focus_follows_pointer)
        GET_BOOL(pointer_follows_focus)
index 97c2ab9a7fa0737296661654abb32fc816d6e721..225f0cf74df4a266d7321cb5bb27ed187653ab6d 100644 (file)
@@ -213,6 +213,35 @@ bool parse_modifier_mask(char *s, uint16_t *m)
        return false;
 }
 
+bool parse_button_index(char *s, int8_t *b)
+{
+       bool v;
+       if (strcmp(s, "any") == 0) {
+               *b = XCB_BUTTON_INDEX_ANY;
+               return true;
+       } else if (strcmp(s, "button1") == 0) {
+               *b = XCB_BUTTON_INDEX_1;
+               return true;
+       } else if (strcmp(s, "button2") == 0) {
+               *b = XCB_BUTTON_INDEX_2;
+               return true;
+       } else if (strcmp(s, "button3") == 0) {
+               *b = XCB_BUTTON_INDEX_3;
+               return true;
+       } else if (strcmp(s, "none") == 0) {
+               *b = -1;
+               return true;
+       } else if (parse_bool(s, &v)) {
+               if (v) {
+                       *b = XCB_BUTTON_INDEX_1;
+               } else {
+                       *b = -1;
+               }
+               return true;
+       }
+       return false;
+}
+
 bool parse_pointer_action(char *s, pointer_action_t *a)
 {
        if (streq("move", s)) {
index bf16c2f780be03484543919746900bfd7b9a884a..bc505ffbad87a6e6ce4114156397093f39e33993 100644 (file)
@@ -22,6 +22,7 @@ bool parse_history_direction(char *s, history_dir_t *d);
 bool parse_flip(char *s, flip_t *f);
 bool parse_resize_handle(char *s, resize_handle_t *h);
 bool parse_modifier_mask(char *s, uint16_t *m);
+bool parse_button_index(char *s, int8_t *b);
 bool parse_pointer_action(char *s, pointer_action_t *a);
 bool parse_child_polarity(char *s, child_polarity_t *p);
 bool parse_tightness(char *s, tightness_t *t);
index f2890da0e5a535dc93ca56cd81224d4463b0ff1d..1bdb6c673b58e6383290b01a6914a3df6f06cac7 100644 (file)
@@ -50,13 +50,12 @@ void pointer_init(void)
 
 void window_grab_buttons(xcb_window_t win)
 {
-       uint8_t buttons[] = {XCB_BUTTON_INDEX_1, XCB_BUTTON_INDEX_2, XCB_BUTTON_INDEX_3};
-       for (unsigned int i = 0; i < LENGTH(buttons); i++) {
-               if (click_to_focus) {
-                       window_grab_button(win, buttons[i], XCB_NONE);
+       for (unsigned int i = 0; i < LENGTH(BUTTONS); i++) {
+               if (click_to_focus == XCB_BUTTON_INDEX_ANY || click_to_focus == BUTTONS[i]) {
+                       window_grab_button(win, BUTTONS[i], XCB_NONE);
                }
                if (pointer_actions[i] != ACTION_NONE) {
-                       window_grab_button(win, buttons[i], pointer_modifier);
+                       window_grab_button(win, BUTTONS[i], pointer_modifier);
                }
        }
 }
index a30847cdfe38cef44493da693f013a8bdc88473c..b6d1a2b29d32d8d856c5d02a307520ce5003368a 100644 (file)
@@ -340,6 +340,27 @@ void print_modifier_mask(uint16_t m, FILE *rsp)
        }
 }
 
+void print_button_index(int8_t b, FILE *rsp)
+{
+       switch (b) {
+               case XCB_BUTTON_INDEX_ANY:
+                       fprintf(rsp, "any");
+                       break;
+               case XCB_BUTTON_INDEX_1:
+                       fprintf(rsp, "button1");
+                       break;
+               case XCB_BUTTON_INDEX_2:
+                       fprintf(rsp, "button2");
+                       break;
+               case XCB_BUTTON_INDEX_3:
+                       fprintf(rsp, "button3");
+                       break;
+               case -1:
+                       fprintf(rsp, "none");
+                       break;
+       }
+}
+
 void print_pointer_action(pointer_action_t a, FILE *rsp)
 {
        switch (a) {
index c38d47a8e6e856ecaf728f903f0afa731d810254..38da7c6bf2597549d7e773e4b386dbf9c80abd96 100644 (file)
@@ -65,6 +65,7 @@ void fprint_monitor_name(monitor_t *m, FILE *rsp);
 void fprint_desktop_id(desktop_t *d, FILE *rsp);
 void fprint_desktop_name(desktop_t *d, FILE *rsp);
 void print_modifier_mask(uint16_t m, FILE *rsp);
+void print_button_index(int8_t b, FILE *rsp);
 void print_pointer_action(pointer_action_t a, FILE *rsp);
 node_select_t make_node_select(void);
 desktop_select_t make_desktop_select(void);
index 5845f05400abfbf4fcfb42306c0fee630bc2fb61..ba188a57fc8b25c38713fa0ae0995d40e405f05d 100644 (file)
@@ -54,7 +54,7 @@
 #define POINTER_FOLLOWS_MONITOR     false
 #define IGNORE_EWMH_FOCUS           false
 #define CENTER_PSEUDO_TILED         true
-#define CLICK_TO_FOCUS              false
+#define CLICK_TO_FOCUS              -1
 #define SWALLOW_FIRST_CLICK         false
 #define HONOR_SIZE_HINTS            false
 #define REMOVE_DISABLED_MONITORS    false
@@ -89,7 +89,7 @@ bool pointer_follows_focus;
 bool pointer_follows_monitor;
 bool ignore_ewmh_focus;
 bool center_pseudo_tiled;
-bool click_to_focus;
+int8_t click_to_focus;
 bool swallow_first_click;
 bool honor_size_hints;
 bool remove_disabled_monitors;