mouse clicks on root window are now configurable

This commit is contained in:
Julien Danjou 2007-11-12 10:53:48 +01:00
parent 939d9eb149
commit 05e102a49a
7 changed files with 71 additions and 33 deletions

View File

@ -148,6 +148,22 @@ mouse
button = "5"
command = "view_tag_previous"
}
root
{
button = "3"
command = "spawn"
arg = "exec urxvt"
}
root
{
button = "4"
command = "view_tag_next"
}
root
{
button = "5"
command = "view_tag_previous"
}
}
keys

View File

@ -189,7 +189,8 @@ focus(Client *c, Bool selscreen, awesome_config *awesomeconf)
window_grabbuttons(awesomeconf->tags[i].client_sel->display,
awesomeconf->tags[i].client_sel->phys_screen,
awesomeconf->tags[i].client_sel->win,
False, True, awesomeconf->modkey, awesomeconf->numlockmask);
False, True, awesomeconf->buttons.root, awesomeconf->buttons.nroot,
awesomeconf->modkey, awesomeconf->numlockmask);
XSetWindowBorder(awesomeconf->tags[i].client_sel->display,
awesomeconf->tags[i].client_sel->win,
awesomeconf->colors_normal[ColBorder].pixel);
@ -200,7 +201,8 @@ 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->modkey, awesomeconf->numlockmask);
True, True, awesomeconf->buttons.root, awesomeconf->buttons.nroot,
awesomeconf->modkey, awesomeconf->numlockmask);
}
if(!selscreen)
return;
@ -324,7 +326,8 @@ client_manage(Window w, XWindowAttributes *wa, awesome_config *awesomeconf)
/* grab buttons */
window_grabbuttons(c->display, c->phys_screen, c->win,
False, True, awesomeconf->modkey, awesomeconf->numlockmask);
False, True, awesomeconf->buttons.root, awesomeconf->buttons.nroot,
awesomeconf->modkey, awesomeconf->numlockmask);
/* update window title */
updatetitle(c);

View File

@ -115,7 +115,7 @@ static const KeyMod KeyModList[] =
{"Mod3", Mod3Mask},
{"Mod4", Mod4Mask},
{"Mod5", Mod5Mask},
{NULL, 0}
{NULL, NoSymbol}
};
/** List of button name and corresponding X11 mask codes */
@ -152,7 +152,7 @@ key_mask_lookup(const char *keyname)
if(!a_strcmp(keyname, KeyModList[i].name))
return KeyModList[i].keysym;
return 0;
return NoSymbol;
}
/** Lookup for a mouse button from its name
@ -281,6 +281,7 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
CFG_SEC((char *) "tag", mouse_tag_opts, CFGF_MULTI),
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_END()
};
static cfg_opt_t opts[] =
@ -485,6 +486,19 @@ parse_config(const char *confpatharg, awesome_config *awesomeconf)
awesomeconf->buttons.title[i].arg = a_strdup(cfg_getstr(cfgsectmp, "arg"));
}
/* Mouse: root window click bindings */
awesomeconf->buttons.nroot = cfg_size(cfg_mouse, "root");
awesomeconf->buttons.root = p_new(Button, awesomeconf->buttons.nroot);
for(i = 0; i < awesomeconf->buttons.nroot; i++)
{
cfgsectmp = cfg_getnsec(cfg_mouse, "root", i);
for(j = 0; j < cfg_size(cfgsectmp, "modkey"); j++)
awesomeconf->buttons.root[i].mod |= key_mask_lookup(cfg_getnstr(cfgsectmp, "modkey", j));
awesomeconf->buttons.root[i].button = mouse_button_lookup(cfg_getstr(cfgsectmp, "button"));
awesomeconf->buttons.root[i].func = name_func_lookup(cfg_getstr(cfgsectmp, "command"), UicbList);
awesomeconf->buttons.root[i].arg = a_strdup(cfg_getstr(cfgsectmp, "arg"));
}
/* Keys */
awesomeconf->numlockmask = get_numlockmask(awesomeconf->display);
awesomeconf->nkeys = cfg_size(cfg_keys, "key");

View File

@ -179,6 +179,8 @@ struct awesome_config
int ntitle;
Button *layout;
int nlayout;
Button *root;
int nroot;
} buttons;
/** Number of keys binding in *keys */
int nkeys;

15
event.c
View File

@ -212,7 +212,8 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
{
restack(&awesomeconf[c->screen]);
window_grabbuttons(c->display, c->phys_screen, c->win,
True, True, awesomeconf->modkey, awesomeconf->numlockmask);
True, True, awesomeconf->buttons.root, awesomeconf->buttons.nroot,
awesomeconf->modkey, awesomeconf->numlockmask);
}
}
else if(ev->button == Button1)
@ -255,11 +256,10 @@ handle_event_buttonpress(XEvent * e, awesome_config *awesomeconf)
&& XQueryPointer(e->xany.display, ev->window, &wdummy, &wdummy, &x, &y, &i, &i, &udummy))
{
screen = get_screen_bycoord(e->xany.display, x, y);
if(ev->button == Button4)
uicb_tag_viewnext(&awesomeconf[screen], NULL);
else if(ev->button == Button5)
uicb_tag_viewprev(&awesomeconf[screen], NULL);
break;
handle_mouse_button_press(&awesomeconf[screen],
ev->button, ev->state, awesomeconf->numlockmask,
awesomeconf->buttons.root, awesomeconf->buttons.nroot, NULL);
return;
}
}
@ -369,7 +369,8 @@ handle_event_enternotify(XEvent * e, awesome_config *awesomeconf)
|| get_current_layout(awesomeconf[c->screen].tags,
awesomeconf[c->screen].ntags)->arrange == layout_floating)
window_grabbuttons(c->display, c->phys_screen, c->win,
True, False, awesomeconf->modkey, awesomeconf->numlockmask);
True, False, awesomeconf->buttons.root, awesomeconf->buttons.nroot,
awesomeconf->modkey, awesomeconf->numlockmask);
}
else
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)

View File

@ -92,8 +92,12 @@ window_configure(Display *disp, Window win, int x, int y, int w, int h, int bord
* \param numlockmask Numlock mask
*/
void
window_grabbuttons(Display *disp, int screen, Window win, Bool focused, Bool raised, KeySym modkey, unsigned int numlockmask)
window_grabbuttons(Display *disp, int screen, Window win, Bool focused, Bool raised,
Button *buttons_root, int nbuttons_root,
KeySym modkey, unsigned int numlockmask)
{
int i;
XUngrabButton(disp, AnyButton, AnyModifier, win);
if(focused)
@ -154,24 +158,21 @@ window_grabbuttons(Display *disp, int screen, Window win, Bool focused, Bool rai
XGrabButton(disp, AnyButton, AnyModifier, win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, Button4, NoSymbol, RootWindow(disp, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, Button4, LockMask, RootWindow(disp, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, Button4, numlockmask, RootWindow(disp, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, Button4, numlockmask | LockMask, RootWindow(disp, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, Button5, NoSymbol, RootWindow(disp, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, Button5, LockMask, RootWindow(disp, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, Button5, numlockmask, RootWindow(disp, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, Button5, numlockmask | LockMask, RootWindow(disp, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
for(i = 0; i < nbuttons_root; i++)
{
XGrabButton(disp, buttons_root[i].button, buttons_root[i].mod,
RootWindow(disp, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, buttons_root[i].button, buttons_root[i].mod | LockMask,
RootWindow(disp, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, buttons_root[i].button, buttons_root[i].mod | numlockmask,
RootWindow(disp, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, buttons_root[i].button, buttons_root[i].mod | numlockmask | LockMask,
RootWindow(disp, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None);
}
}
}

View File

@ -23,6 +23,7 @@
#define AWESOME_WINDOW_H
#include <X11/Xlib.h>
#include "config.h"
/** Mask shorthands, used in event.c and window.c */
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
@ -30,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, KeySym, unsigned int);
void window_grabbuttons(Display *, int, Window, Bool, Bool, Button *, int, KeySym, unsigned int);
void window_setshape(Display *, int, Window);
void window_settrans(Display *, Window, double);