diff --git a/client.c b/client.c index 3cb918988..fcb46ea05 100644 --- a/client.c +++ b/client.c @@ -58,7 +58,7 @@ client_loadprops(Client * c, int screen) prop = p_new(char, ntags + 2); - if(xgettextprop(c->display, c->win, AWESOMEPROPS_ATOM(c->display), prop, ntags + 2)) + if(xgettextprop(globalconf.display, c->win, AWESOMEPROPS_ATOM(globalconf.display), prop, ntags + 2)) { for(i = 0, tag = globalconf.screens[screen].tags; tag && i < ntags && prop[i]; i++, tag = tag->next) if(prop[i] == '1') @@ -163,8 +163,8 @@ get_client_byname(Client *list, char *name) void client_updatetitle(Client *c) { - if(!xgettextprop(c->display, c->win, XInternAtom(c->display, "_NET_WM_NAME", False), c->name, sizeof(c->name))) - xgettextprop(c->display, c->win, XInternAtom(c->display, "WM_NAME", False), c->name, sizeof(c->name)); + if(!xgettextprop(globalconf.display, c->win, XInternAtom(globalconf.display, "_NET_WM_NAME", False), c->name, sizeof(c->name))) + xgettextprop(globalconf.display, c->win, XInternAtom(globalconf.display, "WM_NAME", False), c->name, sizeof(c->name)); } /** Ban client and unmap it @@ -173,8 +173,8 @@ client_updatetitle(Client *c) void client_ban(Client * c) { - XUnmapWindow(c->display, c->win); - window_setstate(c->display, c->win, IconicState); + XUnmapWindow(globalconf.display, c->win); + window_setstate(globalconf.display, c->win, IconicState); } /** Attach client to the beginning of the clients stack @@ -215,11 +215,11 @@ focus(Client *c, Bool selscreen, int screen) /* unfocus current selected client */ if(globalconf.focus->client) { - window_grabbuttons(globalconf.focus->client->display, globalconf.focus->client->phys_screen, + window_grabbuttons(globalconf.display, globalconf.focus->client->phys_screen, globalconf.focus->client->win, False, True); - XSetWindowBorder(globalconf.focus->client->display, globalconf.focus->client->win, + XSetWindowBorder(globalconf.display, globalconf.focus->client->win, globalconf.screens[screen].colors_normal[ColBorder].pixel); - window_settrans(globalconf.focus->client->display, globalconf.focus->client->win, + window_settrans(globalconf.display, globalconf.focus->client->win, globalconf.screens[screen].opacity_unfocused); } @@ -230,7 +230,7 @@ focus(Client *c, Bool selscreen, int screen) if(c) { XSetWindowBorder(globalconf.display, c->win, globalconf.screens[screen].colors_selected[ColBorder].pixel); - window_grabbuttons(c->display, c->phys_screen, c->win, + window_grabbuttons(globalconf.display, c->phys_screen, c->win, True, True); } @@ -244,7 +244,7 @@ focus(Client *c, Bool selscreen, int screen) if(globalconf.focus->client) { - XSetInputFocus(globalconf.focus->client->display, + XSetInputFocus(globalconf.display, globalconf.focus->client->win, RevertToPointerRoot, CurrentTime); for(c = globalconf.clients; c; c = c->next) if(c != globalconf.focus->client) @@ -283,7 +283,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen) c->h = c->rh = wa->height; c->oldborder = wa->border_width; - c->display = globalconf.display; + globalconf.display = globalconf.display; c->screen = get_screen_bycoord(c->x, c->y); c->phys_screen = get_phys_screen(c->screen); @@ -325,29 +325,29 @@ client_manage(Window w, XWindowAttributes *wa, int screen) /* set borders */ wc.border_width = c->border; - XConfigureWindow(c->display, w, CWBorderWidth, &wc); - XSetWindowBorder(c->display, w, globalconf.screens[screen].colors_normal[ColBorder].pixel); + XConfigureWindow(globalconf.display, w, CWBorderWidth, &wc); + XSetWindowBorder(globalconf.display, w, globalconf.screens[screen].colors_normal[ColBorder].pixel); /* propagates border_width, if size doesn't change */ - window_configure(c->display, c->win, c->x, c->y, c->w, c->h, c->border); + window_configure(globalconf.display, c->win, c->x, c->y, c->w, c->h, c->border); /* update sizehint */ client_updatesizehints(c); - XSelectInput(c->display, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask); + XSelectInput(globalconf.display, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask); /* handle xshape */ if(globalconf.have_shape) { - XShapeSelectInput(c->display, w, ShapeNotifyMask); - window_setshape(c->display, c->phys_screen, c->win); + XShapeSelectInput(globalconf.display, w, ShapeNotifyMask); + window_setshape(globalconf.display, c->phys_screen, c->win); } /* grab buttons */ - window_grabbuttons(c->display, c->phys_screen, c->win, False, True); + window_grabbuttons(globalconf.display, c->phys_screen, c->win, False, True); /* check for transient and set tags like its parent */ - if((rettrans = XGetTransientForHint(c->display, w, &trans) == Success) + if((rettrans = XGetTransientForHint(globalconf.display, w, &trans) == Success) && (t = get_client_bywin(globalconf.clients, trans))) for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next) if(is_client_tagged(t, tag)) @@ -364,7 +364,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen) client_attach(c); /* some windows require this */ - XMoveResizeWindow(c->display, c->win, c->x, c->y, c->w, c->h); + XMoveResizeWindow(globalconf.display, c->win, c->x, c->y, c->w, c->h); focus(c, True, screen); @@ -456,10 +456,10 @@ client_resize(Client *c, int x, int y, int w, int h, } p_delete(&curtags); wc.border_width = c->border; - XConfigureWindow(c->display, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); - window_configure(c->display, c->win, c->x, c->y, c->w, c->h, c->border); - XSync(c->display, False); - if((c->x >= 0 || c->y >= 0) && XineramaIsActive(c->display)) + XConfigureWindow(globalconf.display, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); + window_configure(globalconf.display, c->win, c->x, c->y, c->w, c->h, c->border); + XSync(globalconf.display, False); + if((c->x >= 0 || c->y >= 0) && XineramaIsActive(globalconf.display)) { int new_screen = get_screen_bycoord(c->x, c->y); if(c->screen != new_screen) @@ -488,7 +488,7 @@ client_saveprops(Client * c, int screen) prop[++i] = '\0'; - XChangeProperty(c->display, c->win, AWESOMEPROPS_ATOM(c->display), XA_STRING, 8, + XChangeProperty(globalconf.display, c->win, AWESOMEPROPS_ATOM(globalconf.display), XA_STRING, 8, PropModeReplace, (unsigned char *) prop, i); p_delete(&prop); @@ -497,8 +497,8 @@ client_saveprops(Client * c, int screen) void client_unban(Client *c) { - XMapWindow(c->display, c->win); - window_setstate(c->display, c->win, NormalState); + XMapWindow(globalconf.display, c->win); + window_setstate(globalconf.display, c->win, NormalState); } void @@ -509,19 +509,19 @@ client_unmanage(Client *c, long state) wc.border_width = c->oldborder; /* The server grab construct avoids race conditions. */ - XGrabServer(c->display); - XConfigureWindow(c->display, c->win, CWBorderWidth, &wc); /* restore border */ + XGrabServer(globalconf.display); + XConfigureWindow(globalconf.display, c->win, CWBorderWidth, &wc); /* restore border */ client_detach(c); if(globalconf.focus->client == c) focus(NULL, True, c->screen); focus_delete_client(c); for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next) untag_client(c, tag); - XUngrabButton(c->display, AnyButton, AnyModifier, c->win); - window_setstate(c->display, c->win, state); - XSync(c->display, False); + XUngrabButton(globalconf.display, AnyButton, AnyModifier, c->win); + window_setstate(globalconf.display, c->win, state); + XSync(globalconf.display, False); XSetErrorHandler(xerror); - XUngrabServer(c->display); + XUngrabServer(globalconf.display); if(state != NormalState) arrange(c->screen); p_delete(&c); @@ -545,7 +545,7 @@ client_updatesizehints(Client *c) long msize; XSizeHints size; - if(!XGetWMNormalHints(c->display, c->win, &size, &msize) || !size.flags) + if(!XGetWMNormalHints(globalconf.display, c->win, &size, &msize) || !size.flags) size.flags = PSize; c->flags = size.flags; if(c->flags & PBaseSize) @@ -642,7 +642,7 @@ uicb_client_settrans(int screen __attribute__ ((unused)), char *arg) return; XGetWindowProperty(globalconf.display, sel->win, - XInternAtom(sel->display, "_NET_WM_WINDOW_OPACITY", False), + XInternAtom(globalconf.display, "_NET_WM_WINDOW_OPACITY", False), 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left, (unsigned char **) &data); if(data) @@ -665,9 +665,9 @@ uicb_client_settrans(int screen __attribute__ ((unused)), char *arg) } if(delta == 100.0 && !set_prop) - window_settrans(sel->display, sel->win, -1); + window_settrans(globalconf.display, sel->win, -1); else - window_settrans(sel->display, sel->win, delta); + window_settrans(globalconf.display, sel->win, delta); } @@ -788,7 +788,7 @@ client_kill(Client *c) { XEvent ev; - if(isprotodel(c->display, c->win)) + if(isprotodel(globalconf.display, c->win)) { ev.type = ClientMessage; ev.xclient.window = c->win; diff --git a/config.h b/config.h index 2065f42dd..d6caa3a2f 100644 --- a/config.h +++ b/config.h @@ -131,8 +131,6 @@ struct Client Client *prev; /** Window of the client */ Window win; - /** Client display */ - Display *display; /** Client logical screen */ int screen; /** Client physical screen */ diff --git a/event.c b/event.c index 046a09908..f8a99ccbf 100644 --- a/event.c +++ b/event.c @@ -106,8 +106,8 @@ handle_event_buttonpress(XEvent *e) && ev->button == Button1) { restack(c->screen); - XAllowEvents(c->display, ReplayPointer, CurrentTime); - window_grabbuttons(c->display, c->phys_screen, c->win, True, True); + XAllowEvents(globalconf.display, ReplayPointer, CurrentTime); + window_grabbuttons(globalconf.display, c->phys_screen, c->win, True, True); } else handle_mouse_button_press(c->screen, ev->button, ev->state, globalconf.buttons.client, NULL); @@ -154,7 +154,7 @@ handle_event_configurerequest(XEvent * e) if(ev->value_mask & CWHeight) c->rh = c->h = ev->height; if((ev->value_mask & (CWX | CWY)) && !(ev->value_mask & (CWWidth | CWHeight))) - window_configure(c->display, c->win, c->x, c->y, c->w, c->h, c->border); + window_configure(globalconf.display, c->win, c->x, c->y, c->w, c->h, c->border); /* recompute screen */ old_screen = c->screen; c->screen = get_screen_bycoord(c->x, c->y); @@ -169,7 +169,7 @@ handle_event_configurerequest(XEvent * e) arrange(c->screen); } else - window_configure(c->display, c->win, c->x, c->y, c->w, c->h, c->border); + window_configure(globalconf.display, c->win, c->x, c->y, c->w, c->h, c->border); p_delete(&curtags); } else @@ -240,7 +240,7 @@ handle_event_enternotify(XEvent * e) curtags = get_current_tags(c->screen); focus(c, ev->same_screen, c->screen); if (c->isfloating || curtags[0]->layout->arrange == layout_floating) - window_grabbuttons(c->display, c->phys_screen, c->win, True, False); + window_grabbuttons(globalconf.display, c->phys_screen, c->win, True, False); p_delete(&curtags); } else @@ -367,7 +367,7 @@ handle_event_propertynotify(XEvent * e) statusbar_draw(c->screen); break; } - if(ev->atom == XA_WM_NAME || ev->atom == XInternAtom(c->display, "_NET_WM_NAME", False)) + if(ev->atom == XA_WM_NAME || ev->atom == XInternAtom(globalconf.display, "_NET_WM_NAME", False)) { client_updatetitle(c); if(c == globalconf.focus->client) @@ -384,7 +384,7 @@ handle_event_unmapnotify(XEvent * e) if((c = get_client_bywin(globalconf.clients, ev->window)) && ev->event == RootWindow(e->xany.display, c->phys_screen) - && ev->send_event && window_getstate(c->display, c->win) == NormalState) + && ev->send_event && window_getstate(globalconf.display, c->win) == NormalState) client_unmanage(c, WithdrawnState); } @@ -395,7 +395,7 @@ handle_event_shape(XEvent * e) Client *c = get_client_bywin(globalconf.clients, ev->window); if(c) - window_setshape(c->display, c->phys_screen, c->win); + window_setshape(globalconf.display, c->phys_screen, c->win); } void diff --git a/layout.c b/layout.c index 7d3cb839f..4fe989d04 100644 --- a/layout.c +++ b/layout.c @@ -165,14 +165,14 @@ restack(int screen) curtags = get_current_tags(screen); if(sel->isfloating || curtags[0]->layout->arrange == layout_floating) - XRaiseWindow(sel->display, sel->win); + XRaiseWindow(globalconf.display, sel->win); if(!(curtags[0]->layout->arrange == layout_floating)) { wc.stack_mode = Below; wc.sibling = globalconf.screens[screen].statusbar->window; if(!sel->isfloating) { - XConfigureWindow(sel->display, sel->win, CWSibling | CWStackMode, &wc); + XConfigureWindow(globalconf.display, sel->win, CWSibling | CWStackMode, &wc); wc.sibling = sel->win; } for(c = globalconf.clients; c; c = c->next) diff --git a/mouse.c b/mouse.c index 3a3e8e89f..9827aeb3e 100644 --- a/mouse.c +++ b/mouse.c @@ -63,21 +63,21 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused))) ocx = nx = c->x; ocy = ny = c->y; - if(XGrabPointer(c->display, - RootWindow(c->display, c->phys_screen), + if(XGrabPointer(globalconf.display, + RootWindow(globalconf.display, c->phys_screen), False, MOUSEMASK, GrabModeAsync, GrabModeAsync, None, globalconf.cursor[CurMove], CurrentTime) != GrabSuccess) return; - XQueryPointer(c->display, - RootWindow(c->display, c->phys_screen), + XQueryPointer(globalconf.display, + RootWindow(globalconf.display, c->phys_screen), &dummy, &dummy, &x1, &y1, &di, &di, &dui); for(;;) { - XMaskEvent(c->display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev); + XMaskEvent(globalconf.display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev); switch (ev.type) { case ButtonRelease: - XUngrabPointer(c->display, CurrentTime); + XUngrabPointer(globalconf.display, CurrentTime); return; case ConfigureRequest: handle_event_configurerequest(&ev); @@ -89,7 +89,7 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused))) handle_event_maprequest(&ev); break; case MotionNotify: - XSync(c->display, False); + XSync(globalconf.display, False); nx = ocx + (ev.xmotion.x - x1); ny = ocy + (ev.xmotion.y - y1); if(abs(nx) < globalconf.screens[screen].snap + area.x && nx > area.x) @@ -132,21 +132,21 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused))) ocx = c->x; ocy = c->y; - if(XGrabPointer(c->display, RootWindow(c->display, c->phys_screen), + if(XGrabPointer(globalconf.display, RootWindow(globalconf.display, c->phys_screen), False, MOUSEMASK, GrabModeAsync, GrabModeAsync, None, globalconf.cursor[CurResize], CurrentTime) != GrabSuccess) return; c->ismax = False; - XWarpPointer(c->display, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1); + XWarpPointer(globalconf.display, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1); for(;;) { - XMaskEvent(c->display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev); + XMaskEvent(globalconf.display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev); switch (ev.type) { case ButtonRelease: - XWarpPointer(c->display, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1); - XUngrabPointer(c->display, CurrentTime); - while(XCheckMaskEvent(c->display, EnterWindowMask, &ev)); + XWarpPointer(globalconf.display, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1); + XUngrabPointer(globalconf.display, CurrentTime); + while(XCheckMaskEvent(globalconf.display, EnterWindowMask, &ev)); return; case ConfigureRequest: handle_event_configurerequest(&ev); @@ -158,7 +158,7 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused))) handle_event_maprequest(&ev); break; case MotionNotify: - XSync(c->display, False); + XSync(globalconf.display, False); if((nw = ev.xmotion.x - ocx - 2 * c->border + 1) <= 0) nw = 1; if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0) diff --git a/rules.c b/rules.c index 3c4121bcb..4b6e880f8 100644 --- a/rules.c +++ b/rules.c @@ -22,6 +22,8 @@ #include "util.h" #include "rules.h" +extern AwesomeConf globalconf; + void compileregs(Rule *rules) { @@ -57,7 +59,7 @@ client_match_rule(Client *c, Rule *r) XClassHint ch = { 0, 0 }; Bool ret; - XGetClassHint(c->display, c->win, &ch); + XGetClassHint(globalconf.display, c->win, &ch); len = a_strlen(ch.res_class) + a_strlen(ch.res_name) + a_strlen(c->name); prop = p_new(char, len + 3);