From 7a919a76fbb9df15d0bd322f8c5828b5e263a76a Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 14 Nov 2007 17:18:16 +0100 Subject: [PATCH] mouse button clicks on windows are now configurable --- awesomerc | 18 ++++++++++++++++++ client.c | 6 +++--- config.c | 4 ++++ config.h | 1 + event.c | 36 ++++++++++------------------------- window.c | 57 ++++++++++++------------------------------------------- window.h | 2 +- 7 files changed, 49 insertions(+), 75 deletions(-) diff --git a/awesomerc b/awesomerc index 0ec820ff..d4cd49e2 100644 --- a/awesomerc +++ b/awesomerc @@ -165,6 +165,24 @@ mouse button = "5" command = "view_tag_previous" } + client + { + modkey = {"Mod4"} + button = "1" + command = "movemouse" + } + client + { + modkey = {"Mod4"} + button = "2" + command = "zoom" + } + client + { + modkey = {"Mod4"} + button = "3" + command = "resizemouse" + } } keys diff --git a/client.c b/client.c index 1518b2cb..947a2c04 100644 --- a/client.c +++ b/client.c @@ -191,7 +191,7 @@ focus(Client *c, Bool selscreen, awesome_config *awesomeconf) awesomeconf->tags[i].client_sel->phys_screen, awesomeconf->tags[i].client_sel->win, False, True, awesomeconf->buttons.root, - awesomeconf->modkey, awesomeconf->numlockmask); + awesomeconf->buttons.client, awesomeconf->numlockmask); XSetWindowBorder(awesomeconf->tags[i].client_sel->display, awesomeconf->tags[i].client_sel->win, awesomeconf->colors_normal[ColBorder].pixel); @@ -203,7 +203,7 @@ focus(Client *c, Bool selscreen, awesome_config *awesomeconf) XSetWindowBorder(awesomeconf->display, c->win, awesomeconf->colors_selected[ColBorder].pixel); window_grabbuttons(c->display, c->phys_screen, c->win, True, True, awesomeconf->buttons.root, - awesomeconf->modkey, awesomeconf->numlockmask); + awesomeconf->buttons.client, awesomeconf->numlockmask); } if(!selscreen) return; @@ -374,7 +374,7 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf) /* grab buttons */ window_grabbuttons(c->display, c->phys_screen, c->win, False, True, current_acf->buttons.root, - current_acf->modkey, current_acf->numlockmask); + current_acf->buttons.client, current_acf->numlockmask); move_client_to_screen(c, current_acf, True); diff --git a/config.c b/config.c index 0301c246..6571770a 100644 --- a/config.c +++ b/config.c @@ -324,6 +324,7 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf) CFG_SEC((char *) "layout", mouse_generic_opts, CFGF_MULTI), CFG_SEC((char *) "title", mouse_generic_opts, CFGF_MULTI), CFG_SEC((char *) "root", mouse_generic_opts, CFGF_MULTI), + CFG_SEC((char *) "client", mouse_generic_opts, CFGF_MULTI), CFG_END() }; static cfg_opt_t opts[] = @@ -518,6 +519,9 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf) /* Mouse: root window click bindings */ awesomeconf->buttons.root = parse_mouse_bindings(cfg_mouse, "root", True); + /* Mouse: client windows click bindings */ + awesomeconf->buttons.client = parse_mouse_bindings(cfg_mouse, "client", True); + /* Keys */ awesomeconf->numlockmask = get_numlockmask(awesomeconf->display); diff --git a/config.h b/config.h index 2aa55fb3..70c6d584 100644 --- a/config.h +++ b/config.h @@ -180,6 +180,7 @@ struct awesome_config Button *title; Button *layout; Button *root; + Button *client; } buttons; /** Default modkey */ KeySym modkey; diff --git a/event.c b/event.c index 58660863..7f3ce309 100644 --- a/event.c +++ b/event.c @@ -103,33 +103,17 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf) { XAllowEvents(c->display, ReplayPointer, CurrentTime); focus(c, ev->same_screen, &awesomeconf[c->screen]); - if(CLEANMASK(ev->state, awesomeconf[c->screen]) != awesomeconf[c->screen].modkey) + if(CLEANMASK(ev->state, awesomeconf[c->screen]) == NoSymbol + && ev->button == Button1) { - if (ev->button == Button1) - { - restack(&awesomeconf[c->screen]); - window_grabbuttons(c->display, c->phys_screen, c->win, - True, True, awesomeconf->buttons.root, - awesomeconf->modkey, awesomeconf->numlockmask); - } + restack(&awesomeconf[c->screen]); + window_grabbuttons(c->display, c->phys_screen, c->win, + True, True, awesomeconf->buttons.root, + awesomeconf->buttons.client, awesomeconf->numlockmask); } - else if(ev->button == Button1) - uicb_movemouse(&awesomeconf[c->screen], NULL); - else if(ev->button == Button2) - { - if((get_current_layout(awesomeconf[c->screen].tags, - awesomeconf[c->screen].ntags)->arrange != layout_floating) - && !c->isfixed && c->isfloating) - uicb_togglefloating(&awesomeconf[c->screen], NULL); - else - uicb_zoom(&awesomeconf[c->screen], NULL); - } - else if(ev->button == Button3) - uicb_resizemouse(&awesomeconf[c->screen], NULL); - else if(ev->button == Button4) - uicb_settrans(&awesomeconf[c->screen], "+5"); - else if(ev->button == Button5) - uicb_settrans(&awesomeconf[c->screen], "-5"); + else + handle_mouse_button_press(&awesomeconf[c->screen], ev->button, ev->state, + awesomeconf[c->screen].buttons.client, NULL); } else for(screen = 0; screen < ScreenCount(e->xany.display); screen++) @@ -250,7 +234,7 @@ handle_event_enternotify(XEvent * e, awesome_config *awesomeconf) awesomeconf[c->screen].ntags)->arrange == layout_floating) window_grabbuttons(c->display, c->phys_screen, c->win, True, False, awesomeconf->buttons.root, - awesomeconf->modkey, awesomeconf->numlockmask); + awesomeconf->buttons.client, awesomeconf->numlockmask); } else for(screen = 0; screen < ScreenCount(e->xany.display); screen++) diff --git a/window.c b/window.c index 4436b615..0ad52d8e 100644 --- a/window.c +++ b/window.c @@ -93,7 +93,7 @@ window_configure(Display *disp, Window win, int x, int y, int w, int h, int bord */ void window_grabbuttons(Display *disp, int screen, Window win, Bool focused, Bool raised, - Button *buttons_root, KeySym modkey, unsigned int numlockmask) + Button *buttons_root, Button *buttons_client, unsigned int numlockmask) { Button *b; @@ -105,50 +105,17 @@ window_grabbuttons(Display *disp, int screen, Window win, Bool focused, Bool rai XGrabButton(disp, Button1, NoSymbol, win, False, BUTTONMASK, GrabModeSync, GrabModeAsync, None, None); - XGrabButton(disp, Button1, modkey, win, False, BUTTONMASK, - GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, Button1, modkey | LockMask, win, False, - BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, Button1, modkey | numlockmask, win, False, - BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, Button1, modkey | numlockmask | LockMask, - win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - - XGrabButton(disp, Button2, modkey, win, False, BUTTONMASK, - GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, Button2, modkey | LockMask, win, False, - BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, Button2, modkey | numlockmask, win, False, - BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, Button2, modkey | numlockmask | LockMask, - win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - - XGrabButton(disp, Button3, modkey, win, False, BUTTONMASK, - GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, Button3, modkey | LockMask, win, False, - BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, Button3, modkey | numlockmask, win, False, - BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, Button3, modkey | numlockmask | LockMask, - win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - - XGrabButton(disp, Button4, modkey, win, False, BUTTONMASK, - GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, Button4, modkey | LockMask, win, False, - BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, Button4, modkey | numlockmask, win, False, - BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, Button4, modkey | numlockmask | LockMask, - win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - - XGrabButton(disp, Button5, modkey, win, False, BUTTONMASK, - GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, Button5, modkey | LockMask, win, False, - BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, Button5, modkey | numlockmask, win, False, - BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, Button5, modkey | numlockmask | LockMask, - win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); + for(b = buttons_client; b; b = b->next) + { + XGrabButton(disp, b->button, b->mod, win, False, BUTTONMASK, + GrabModeAsync, GrabModeSync, None, None); + XGrabButton(disp, b->button, b->mod | LockMask, win, False, + BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); + XGrabButton(disp, b->button, b->mod | numlockmask, win, False, + BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); + XGrabButton(disp, b->button, b->mod | numlockmask | LockMask, + win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); + } XUngrabButton(disp, AnyButton, AnyModifier, RootWindow(disp, screen)); } diff --git a/window.h b/window.h index 6b93b18b..0747bbde 100644 --- a/window.h +++ b/window.h @@ -31,7 +31,7 @@ int window_setstate(Display *, Window, long); long window_getstate(Display *, Window); Status window_configure(Display *, Window, int, int, int, int, int); -void window_grabbuttons(Display *, int, Window, Bool, Bool, Button *, KeySym, unsigned int); +void window_grabbuttons(Display *, int, Window, Bool, Bool, Button *, Button *, unsigned int); void window_setshape(Display *, int, Window); void window_settrans(Display *, Window, double);