New setting: 'button_modifier'

This commit is contained in:
Bastien Dejean 2012-10-23 12:42:40 +02:00
parent f0ab3e390e
commit d810e72c35
7 changed files with 45 additions and 9 deletions

View file

@ -256,6 +256,9 @@ 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.
button_modifier
The modifier mask used for mouse bindings (possible values: 'mod1' ... 'mod5').
borderless_monocle
Whether to remove borders for tiled windows in monocle mode.
@ -264,17 +267,15 @@ Colors are either [X color names](http://en.wikipedia.org/wiki/X11_color_names)
## Mouse Bindings
M4 + Left Button
button_modifier + left mouse button
Move the window under the pointer.
M4 + Middle Button
button_modifier + middle mouse button
Focus the window under the pointer.
M4 + Middle Button
button_modifier + right mouse button
Resize the window under the pointer (by moving one of its four corners).
Where *M4* is the fourth modifier mask (generally bound to *Super*).
## Panel
`dzen2` fed with the output of `ewmhstatus`. Example: [launchpanel](https://github.com/baskerville/bin/blob/master/launchpanel).

11
bspwm.c
View file

@ -38,9 +38,13 @@ void register_events(void)
err("another WM is already running\n");
}
xcb_grab_button(dpy, false, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_1, BUTTON_MODIFIER);
xcb_grab_button(dpy, false, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_2, BUTTON_MODIFIER);
xcb_grab_button(dpy, false, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_3, BUTTON_MODIFIER);
}
void grab_buttons(void)
{
xcb_grab_button(dpy, false, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_1, button_modifier);
xcb_grab_button(dpy, false, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_2, button_modifier);
xcb_grab_button(dpy, false, screen->root, XCB_EVENT_MASK_BUTTON_PRESS, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE, XCB_BUTTON_INDEX_3, button_modifier);
}
void setup(void)
@ -157,6 +161,7 @@ int main(void)
load_settings();
run_autostart();
ewmh_update_wm_name();
grab_buttons();
while (running) {

View file

@ -5,7 +5,6 @@
#define ROOT_EVENT_MASK (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY)
#define CLIENT_EVENT_MASK (XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_ENTER_WINDOW)
#define BUTTON_MODIFIER XCB_MOD_MASK_4
xcb_connection_t *dpy;
int default_screen, screen_width, screen_height;
@ -29,6 +28,7 @@ pointer_state_t *frozen_pointer;
bool running;
void register_events(void);
void grab_buttons(void);
void handle_zombie(int);
void setup(void);
void quit(void);

View file

@ -356,6 +356,11 @@ void set_setting(char *name, char *value, char *rsp)
strncpy(wm_name, value, sizeof(wm_name));
ewmh_update_wm_name();
return;
} else if (strcmp(name, "button_modifier") == 0) {
unsigned int m;
if (parse_modifier_mask(value, &m))
button_modifier = m;
return;
} else {
snprintf(rsp, BUFSIZ, "unknown setting: %s", name);
return;
@ -560,3 +565,24 @@ bool parse_fence_move(char *s, fence_move_t *m)
}
return false;
}
bool parse_modifier_mask(char *s, unsigned int *m)
{
if (strcmp(s, "mod1") == 0) {
*m = XCB_MOD_MASK_1;
return true;
} else if (strcmp(s, "mod2") == 0) {
*m = XCB_MOD_MASK_2;
return true;
} else if (strcmp(s, "mod3") == 0) {
*m = XCB_MOD_MASK_3;
return true;
} else if (strcmp(s, "mod4") == 0) {
*m = XCB_MOD_MASK_4;
return true;
} else if (strcmp(s, "mod5") == 0) {
*m = XCB_MOD_MASK_5;
return true;
}
return false;
}

View file

@ -16,5 +16,6 @@ bool parse_skip_client(char *, skip_client_t *);
bool parse_corner(char *, corner_t *);
bool parse_rotate(char *, rotate_t *);
bool parse_fence_move(char *, fence_move_t *);
bool parse_modifier_mask(char *, unsigned int *);
#endif

View file

@ -53,6 +53,7 @@ void load_settings(void)
urgent_border_color_pxl = get_color(urgent_border_color);
strncpy(wm_name, WM_NAME, sizeof(wm_name));
button_modifier = BUTTON_MODIFIER;
inner_border_width = INNER_BORDER_WIDTH;
main_border_width = MAIN_BORDER_WIDTH;

View file

@ -5,6 +5,7 @@
#define WM_NAME "bspwm"
#define AUTOSTART_FILE "autostart"
#define BUTTON_MODIFIER XCB_MOD_MASK_4
#define FOCUSED_BORDER_COLOR "#7D7F8A"
#define ACTIVE_BORDER_COLOR "#7D7F8A"
@ -68,6 +69,7 @@ bool borderless_monocle;
bool focus_follows_mouse;
char wm_name[MAXLEN];
unsigned int button_modifier;
void load_settings(void);
void run_autostart(void);