Booleans are deprecated but still accepted.
.\" 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
.\" -----------------------------------------------------------------
.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
.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
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.
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.
{
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;
#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);
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 {
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) ||
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)
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)) {
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);
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);
}
}
}
}
}
+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) {
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);
#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
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;