Move grabkeys() out of event, and move it into window; clean and remove setup() function in awesome.c
This commit is contained in:
parent
d10036a366
commit
bd2f4a212e
66
awesome.c
66
awesome.c
|
@ -108,44 +108,6 @@ scan()
|
|||
}
|
||||
}
|
||||
|
||||
/** Setup everything before running
|
||||
* \param screen Screen number
|
||||
* \todo clean things...
|
||||
*/
|
||||
static void
|
||||
setup(int screen)
|
||||
{
|
||||
XSetWindowAttributes wa;
|
||||
Statusbar *statusbar;
|
||||
int phys_screen = get_phys_screen(screen);
|
||||
|
||||
/* init cursors */
|
||||
globalconf.cursor[CurNormal] = XCreateFontCursor(globalconf.display, XC_left_ptr);
|
||||
globalconf.cursor[CurResize] = XCreateFontCursor(globalconf.display, XC_sizing);
|
||||
globalconf.cursor[CurMove] = XCreateFontCursor(globalconf.display, XC_fleur);
|
||||
|
||||
/* select for events */
|
||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
||||
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask | PointerMotionMask;
|
||||
wa.cursor = globalconf.cursor[CurNormal];
|
||||
|
||||
XChangeWindowAttributes(globalconf.display,
|
||||
RootWindow(globalconf.display, phys_screen),
|
||||
CWEventMask | CWCursor, &wa);
|
||||
|
||||
XSelectInput(globalconf.display,
|
||||
RootWindow(globalconf.display, phys_screen),
|
||||
wa.event_mask);
|
||||
|
||||
grabkeys(phys_screen);
|
||||
|
||||
/* view at least one tag */
|
||||
tag_view(globalconf.screens[screen].tags, True);
|
||||
|
||||
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
|
||||
statusbar_init(statusbar);
|
||||
}
|
||||
|
||||
/** Startup Error handler to check if another window manager
|
||||
* is already running.
|
||||
* \param disp Display
|
||||
|
@ -223,12 +185,14 @@ main(int argc, char *argv[])
|
|||
const char *confpath = NULL;
|
||||
int r, xfd, e_dummy, csfd, shape_event, randr_event_base, i, screen, opt;
|
||||
ssize_t cmdlen = 1;
|
||||
Statusbar *statusbar;
|
||||
fd_set rd;
|
||||
XEvent ev;
|
||||
Display * dpy;
|
||||
event_handler **handler;
|
||||
struct sockaddr_un *addr;
|
||||
Client *c;
|
||||
XSetWindowAttributes wa;
|
||||
static struct option long_options[] =
|
||||
{
|
||||
{"help", 0, NULL, 'h'},
|
||||
|
@ -306,18 +270,42 @@ main(int argc, char *argv[])
|
|||
/* parse config */
|
||||
config_parse(confpath);
|
||||
|
||||
/* scan existing windows */
|
||||
scan();
|
||||
|
||||
/* init cursors */
|
||||
globalconf.cursor[CurNormal] = XCreateFontCursor(globalconf.display, XC_left_ptr);
|
||||
globalconf.cursor[CurResize] = XCreateFontCursor(globalconf.display, XC_sizing);
|
||||
globalconf.cursor[CurMove] = XCreateFontCursor(globalconf.display, XC_fleur);
|
||||
|
||||
/* for each virtual screen */
|
||||
for(screen = 0; screen < globalconf.nscreen; screen++)
|
||||
setup(screen);
|
||||
{
|
||||
/* view at least one tag */
|
||||
tag_view(globalconf.screens[screen].tags, True);
|
||||
|
||||
for(statusbar = globalconf.screens[screen].statusbar; statusbar; statusbar = statusbar->next)
|
||||
statusbar_init(statusbar);
|
||||
}
|
||||
|
||||
/* select for events */
|
||||
wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask
|
||||
| EnterWindowMask | LeaveWindowMask | StructureNotifyMask | PointerMotionMask;
|
||||
wa.cursor = globalconf.cursor[CurNormal];
|
||||
|
||||
/* do this only for real screen */
|
||||
for(screen = 0; screen < ScreenCount(dpy); screen++)
|
||||
{
|
||||
XChangeWindowAttributes(globalconf.display,
|
||||
RootWindow(globalconf.display, screen),
|
||||
CWEventMask | CWCursor, &wa);
|
||||
XSelectInput(globalconf.display,
|
||||
RootWindow(globalconf.display, screen),
|
||||
wa.event_mask);
|
||||
ewmh_set_supported_hints(screen);
|
||||
/* call this to at least grab root window clicks */
|
||||
window_root_grabbuttons(screen);
|
||||
window_root_grabkeys(screen);
|
||||
}
|
||||
|
||||
handler = p_new(event_handler *, LASTEvent);
|
||||
|
|
25
event.c
25
event.c
|
@ -360,7 +360,7 @@ event_handle_mappingnotify(XEvent *e)
|
|||
XRefreshKeyboardMapping(ev);
|
||||
if(ev->request == MappingKeyboard)
|
||||
for(screen = 0; screen < ScreenCount(e->xany.display); screen++)
|
||||
grabkeys(screen);
|
||||
window_root_grabkeys(screen);
|
||||
}
|
||||
|
||||
/** Handle XMapRequest events
|
||||
|
@ -473,27 +473,4 @@ event_handle_clientmessage(XEvent *e)
|
|||
ewmh_process_client_message(&e->xclient);
|
||||
}
|
||||
|
||||
/** Grab keys on root window
|
||||
* \param phys_screen physical screen id
|
||||
*/
|
||||
void
|
||||
grabkeys(int phys_screen)
|
||||
{
|
||||
Key *k;
|
||||
|
||||
XUngrabKey(globalconf.display, AnyKey, AnyModifier, RootWindow(globalconf.display, phys_screen));
|
||||
|
||||
for(k = globalconf.keys; k; k = k->next)
|
||||
if(k->keycode)
|
||||
{
|
||||
XGrabKey(globalconf.display, k->keycode, k->mod,
|
||||
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(globalconf.display, k->keycode, k->mod | LockMask,
|
||||
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(globalconf.display, k->keycode, k->mod | globalconf.numlockmask,
|
||||
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(globalconf.display, k->keycode, k->mod | globalconf.numlockmask | LockMask,
|
||||
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
||||
}
|
||||
}
|
||||
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|
||||
|
|
2
event.h
2
event.h
|
@ -26,8 +26,6 @@
|
|||
|
||||
#define CLEANMASK(mask) (mask & ~(globalconf.numlockmask | LockMask))
|
||||
|
||||
void grabkeys(int);
|
||||
|
||||
void event_handle_buttonpress(XEvent *);
|
||||
void event_handle_configurerequest(XEvent *);
|
||||
void event_handle_configurenotify(XEvent *);
|
||||
|
|
26
window.c
26
window.c
|
@ -125,7 +125,7 @@ window_grabbuttons(int phys_screen, Window win)
|
|||
XUngrabButton(globalconf.display, AnyButton, AnyModifier, RootWindow(globalconf.display, phys_screen));
|
||||
}
|
||||
|
||||
/** Grab button on root window
|
||||
/** Grab buttons on root window
|
||||
* \param phys_screen physical screen id
|
||||
*/
|
||||
void
|
||||
|
@ -150,6 +150,30 @@ window_root_grabbuttons(int phys_screen)
|
|||
}
|
||||
}
|
||||
|
||||
/** Grab keys on root window
|
||||
* \param phys_screen physical screen id
|
||||
*/
|
||||
void
|
||||
window_root_grabkeys(int phys_screen)
|
||||
{
|
||||
Key *k;
|
||||
|
||||
XUngrabKey(globalconf.display, AnyKey, AnyModifier, RootWindow(globalconf.display, phys_screen));
|
||||
|
||||
for(k = globalconf.keys; k; k = k->next)
|
||||
if(k->keycode)
|
||||
{
|
||||
XGrabKey(globalconf.display, k->keycode, k->mod,
|
||||
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(globalconf.display, k->keycode, k->mod | LockMask,
|
||||
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(globalconf.display, k->keycode, k->mod | globalconf.numlockmask,
|
||||
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
||||
XGrabKey(globalconf.display, k->keycode, k->mod | globalconf.numlockmask | LockMask,
|
||||
RootWindow(globalconf.display, phys_screen), True, GrabModeAsync, GrabModeAsync);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
window_setshape(int screen, Window win)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue