mouse button clicks on windows are now configurable

This commit is contained in:
Julien Danjou 2007-11-14 17:18:16 +01:00
parent 88b6f17410
commit 7a919a76fb
7 changed files with 49 additions and 75 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -180,6 +180,7 @@ struct awesome_config
Button *title;
Button *layout;
Button *root;
Button *client;
} buttons;
/** Default modkey */
KeySym modkey;

36
event.c
View File

@ -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++)

View File

@ -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));
}

View File

@ -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);