diff --git a/awesome.c b/awesome.c index cee7f94b5..55420a81f 100644 --- a/awesome.c +++ b/awesome.c @@ -166,7 +166,7 @@ scan() || wa.override_redirect || XGetTransientForHint(globalconf.display, wins[i], &d1)) continue; - if(wa.map_state == IsViewable || window_getstate(globalconf.display, wins[i]) == IconicState) + if(wa.map_state == IsViewable || window_getstate(wins[i]) == IconicState) { if(screen == 0) real_screen = get_screen_bycoord(wa.x, wa.y); @@ -179,7 +179,7 @@ scan() if(!XGetWindowAttributes(globalconf.display, wins[i], &wa)) continue; if(XGetTransientForHint(globalconf.display, wins[i], &d1) - && (wa.map_state == IsViewable || window_getstate(globalconf.display, wins[i]) == IconicState)) + && (wa.map_state == IsViewable || window_getstate(wins[i]) == IconicState)) { if(screen == 0) real_screen = get_screen_bycoord(wa.x, wa.y); diff --git a/client.c b/client.c index a856d1b4d..d6ba462ea 100644 --- a/client.c +++ b/client.c @@ -183,7 +183,7 @@ void client_ban(Client * c) { XUnmapWindow(globalconf.display, c->win); - window_setstate(globalconf.display, c->win, IconicState); + window_setstate(c->win, IconicState); } /** Attach client to the beginning of the clients stack @@ -224,11 +224,11 @@ focus(Client *c, Bool selscreen, int screen) /* unfocus current selected client */ if(globalconf.focus->client) { - window_grabbuttons(globalconf.display, globalconf.focus->client->phys_screen, + window_grabbuttons(globalconf.focus->client->phys_screen, globalconf.focus->client->win, False, True); XSetWindowBorder(globalconf.display, globalconf.focus->client->win, globalconf.screens[screen].colors_normal[ColBorder].pixel); - window_settrans(globalconf.display, globalconf.focus->client->win, + window_settrans(globalconf.focus->client->win, globalconf.screens[screen].opacity_unfocused); } @@ -245,8 +245,7 @@ focus(Client *c, Bool selscreen, int screen) if(c) { XSetWindowBorder(globalconf.display, c->win, globalconf.screens[screen].colors_selected[ColBorder].pixel); - window_grabbuttons(globalconf.display, c->phys_screen, c->win, - True, True); + window_grabbuttons(c->phys_screen, c->win, True, True); } if(!selscreen) @@ -263,9 +262,9 @@ focus(Client *c, Bool selscreen, int screen) globalconf.focus->client->win, RevertToPointerRoot, CurrentTime); for(c = globalconf.clients; c; c = c->next) if(c != globalconf.focus->client) - window_settrans(globalconf.display, globalconf.focus->client->win, + window_settrans(globalconf.focus->client->win, globalconf.screens[screen].opacity_unfocused); - window_settrans(globalconf.display, globalconf.focus->client->win, -1); + window_settrans(globalconf.focus->client->win, -1); } else XSetInputFocus(globalconf.display, @@ -348,7 +347,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen) XSetWindowBorder(globalconf.display, w, globalconf.screens[screen].colors_normal[ColBorder].pixel); /* propagates border_width, if size doesn't change */ - window_configure(globalconf.display, c->win, c->x, c->y, c->w, c->h, c->border); + window_configure(c->win, c->x, c->y, c->w, c->h, c->border); /* update hints */ client_updatesizehints(c); @@ -360,11 +359,11 @@ client_manage(Window w, XWindowAttributes *wa, int screen) if(globalconf.have_shape) { XShapeSelectInput(globalconf.display, w, ShapeNotifyMask); - window_setshape(globalconf.display, c->phys_screen, c->win); + window_setshape(c->phys_screen, c->win); } /* grab buttons */ - window_grabbuttons(globalconf.display, c->phys_screen, c->win, False, True); + window_grabbuttons(c->phys_screen, c->win, False, True); /* check for transient and set tags like its parent */ if((rettrans = XGetTransientForHint(globalconf.display, w, &trans) == Success) @@ -485,7 +484,7 @@ client_resize(Client *c, int x, int y, int w, int h, p_delete(&curtags); wc.border_width = c->border; 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); + window_configure(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)) { @@ -529,7 +528,7 @@ void client_unban(Client *c) { XMapWindow(globalconf.display, c->win); - window_setstate(globalconf.display, c->win, NormalState); + window_setstate(c->win, NormalState); } void @@ -549,7 +548,7 @@ client_unmanage(Client *c, long state) for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next) untag_client(c, tag); XUngrabButton(globalconf.display, AnyButton, AnyModifier, c->win); - window_setstate(globalconf.display, c->win, state); + window_setstate(c->win, state); XSync(globalconf.display, False); XSetErrorHandler(xerror); XUngrabServer(globalconf.display); @@ -699,9 +698,9 @@ uicb_client_settrans(int screen __attribute__ ((unused)), char *arg) } if(delta == 100.0 && !set_prop) - window_settrans(globalconf.display, sel->win, -1); + window_settrans(sel->win, -1); else - window_settrans(globalconf.display, sel->win, delta); + window_settrans(sel->win, delta); } diff --git a/event.c b/event.c index 2defe2757..685cf3371 100644 --- a/event.c +++ b/event.c @@ -107,7 +107,7 @@ handle_event_buttonpress(XEvent *e) { restack(c->screen); XAllowEvents(globalconf.display, ReplayPointer, CurrentTime); - window_grabbuttons(globalconf.display, c->phys_screen, c->win, True, True); + window_grabbuttons(c->phys_screen, c->win, True, True); } else handle_mouse_button_press(c->screen, ev->button, ev->state, globalconf.buttons.client, NULL); @@ -148,7 +148,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(globalconf.display, c->win, c->x, c->y, c->w, c->h, c->border); + window_configure(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); @@ -163,7 +163,7 @@ handle_event_configurerequest(XEvent * e) arrange(c->screen); } else - window_configure(globalconf.display, c->win, c->x, c->y, c->w, c->h, c->border); + window_configure(c->win, c->x, c->y, c->w, c->h, c->border); } else { @@ -233,7 +233,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(globalconf.display, c->phys_screen, c->win, True, False); + window_grabbuttons(c->phys_screen, c->win, True, False); p_delete(&curtags); } else @@ -377,7 +377,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(globalconf.display, c->win) == NormalState) + && ev->send_event && window_getstate(c->win) == NormalState) client_unmanage(c, WithdrawnState); } @@ -388,7 +388,7 @@ handle_event_shape(XEvent * e) Client *c = get_client_bywin(globalconf.clients, ev->window); if(c) - window_setshape(globalconf.display, c->phys_screen, c->win); + window_setshape(c->phys_screen, c->win); } void diff --git a/window.c b/window.c index ca82e4e29..523ed37dc 100644 --- a/window.c +++ b/window.c @@ -28,35 +28,33 @@ extern AwesomeConf globalconf; /** Set client WM_STATE property - * \param disp Display ref * \param win Window * \param state state */ int -window_setstate(Display *disp, Window win, long state) +window_setstate(Window win, long state) { long data[] = { state, None }; - return XChangeProperty(disp, win, XInternAtom(disp, "WM_STATE", False), - XInternAtom(disp, "WM_STATE", False), 32, + return XChangeProperty(globalconf.display, win, XInternAtom(globalconf.display, "WM_STATE", False), + XInternAtom(globalconf.display, "WM_STATE", False), 32, PropModeReplace, (unsigned char *) data, 2); } /** Get a window state (WM_STATE) - * \param disp Display ref * \param w Client window * \return state */ long -window_getstate(Display *disp, Window w) +window_getstate(Window w) { int format; long result = -1; unsigned char *p = NULL; unsigned long n, extra; Atom real; - if(XGetWindowProperty(disp, w, XInternAtom(disp, "WM_STATE", False), - 0L, 2L, False, XInternAtom(disp, "WM_STATE", False), + if(XGetWindowProperty(globalconf.display, w, XInternAtom(globalconf.display, "WM_STATE", False), + 0L, 2L, False, XInternAtom(globalconf.display, "WM_STATE", False), &real, &format, &n, &extra, (unsigned char **) &p) != Success) return -1; if(n != 0) @@ -66,12 +64,12 @@ window_getstate(Display *disp, Window w) } Status -window_configure(Display *disp, Window win, int x, int y, int w, int h, int border) +window_configure(Window win, int x, int y, int w, int h, int border) { XConfigureEvent ce; ce.type = ConfigureNotify; - ce.display = disp; + ce.display = globalconf.display; ce.event = win; ce.window = win; ce.x = x; @@ -81,98 +79,96 @@ window_configure(Display *disp, Window win, int x, int y, int w, int h, int bord ce.border_width = border; ce.above = None; ce.override_redirect = False; - return XSendEvent(disp, win, False, StructureNotifyMask, (XEvent *) & ce); + return XSendEvent(globalconf.display, win, False, StructureNotifyMask, (XEvent *) & ce); } /** Grab or ungrab buttons on a window - * \param disp Display ref * \param screen The screen * \param win The window * \param focused True if client is focused * \param raised True if the client is above other clients */ void -window_grabbuttons(Display *disp, - int screen, +window_grabbuttons(int screen, Window win, Bool focused, Bool raised) { Button *b; - XUngrabButton(disp, AnyButton, AnyModifier, win); + XUngrabButton(globalconf.display, AnyButton, AnyModifier, win); if(focused) { if(!raised) - XGrabButton(disp, Button1, NoSymbol, win, False, + XGrabButton(globalconf.display, Button1, NoSymbol, win, False, BUTTONMASK, GrabModeSync, GrabModeAsync, None, None); for(b = globalconf.buttons.client; b; b = b->next) { - XGrabButton(disp, b->button, b->mod, win, False, BUTTONMASK, + XGrabButton(globalconf.display, b->button, b->mod, win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, b->button, b->mod | LockMask, win, False, + XGrabButton(globalconf.display, b->button, b->mod | LockMask, win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, b->button, b->mod | globalconf.numlockmask, win, False, + XGrabButton(globalconf.display, b->button, b->mod | globalconf.numlockmask, win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, b->button, b->mod | globalconf.numlockmask | LockMask, + XGrabButton(globalconf.display, b->button, b->mod | globalconf.numlockmask | LockMask, win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); } - XUngrabButton(disp, AnyButton, AnyModifier, RootWindow(disp, screen)); + XUngrabButton(globalconf.display, AnyButton, AnyModifier, RootWindow(globalconf.display, screen)); } else { - XGrabButton(disp, AnyButton, AnyModifier, win, False, BUTTONMASK, + XGrabButton(globalconf.display, AnyButton, AnyModifier, win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); for(b = globalconf.buttons.root; b; b = b->next) { - XGrabButton(disp, b->button, b->mod, - RootWindow(disp, screen), False, BUTTONMASK, + XGrabButton(globalconf.display, b->button, b->mod, + RootWindow(globalconf.display, screen), False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, b->button, b->mod | LockMask, - RootWindow(disp, screen), False, BUTTONMASK, + XGrabButton(globalconf.display, b->button, b->mod | LockMask, + RootWindow(globalconf.display, screen), False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, b->button, b->mod | globalconf.numlockmask, - RootWindow(disp, screen), False, BUTTONMASK, + XGrabButton(globalconf.display, b->button, b->mod | globalconf.numlockmask, + RootWindow(globalconf.display, screen), False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); - XGrabButton(disp, b->button, b->mod | globalconf.numlockmask | LockMask, - RootWindow(disp, screen), False, BUTTONMASK, + XGrabButton(globalconf.display, b->button, b->mod | globalconf.numlockmask | LockMask, + RootWindow(globalconf.display, screen), False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); } } } void -window_setshape(Display *disp, int screen, Window win) +window_setshape(int screen, Window win) { int bounding_shaped; int i, b; unsigned int u; /* dummies */ /* Logic to decide if we have a shaped window cribbed from fvwm-2.5.10. */ - if(XShapeQueryExtents(disp, win, &bounding_shaped, &i, &i, + if(XShapeQueryExtents(globalconf.display, win, &bounding_shaped, &i, &i, &u, &u, &b, &i, &i, &u, &u) && bounding_shaped) - XShapeCombineShape(disp, RootWindow(disp, screen), ShapeBounding, 0, 0, win, ShapeBounding, ShapeSet); + XShapeCombineShape(globalconf.display, RootWindow(globalconf.display, screen), ShapeBounding, 0, 0, win, ShapeBounding, ShapeSet); } void -window_settrans(Display *disp, Window win, double opacity) +window_settrans(Window win, double opacity) { unsigned int real_opacity = 0xffffffff; if(opacity >= 0 && opacity <= 100) { real_opacity = ((opacity / 100.0) * 0xffffffff); - XChangeProperty(disp, win, XInternAtom(disp, "_NET_WM_WINDOW_OPACITY", False), + XChangeProperty(globalconf.display, win, XInternAtom(globalconf.display, "_NET_WM_WINDOW_OPACITY", False), XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &real_opacity, 1L); } else - XDeleteProperty(disp, win, XInternAtom(disp, "_NET_WM_WINDOW_OPACITY", False)); + XDeleteProperty(globalconf.display, win, XInternAtom(globalconf.display, "_NET_WM_WINDOW_OPACITY", False)); - XSync(disp, False); + XSync(globalconf.display, False); } // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/window.h b/window.h index 44529856d..b76195055 100644 --- a/window.h +++ b/window.h @@ -27,12 +27,12 @@ /** Mask shorthands, used in event.c and window.c */ #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask) -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); -void window_setshape(Display *, int, Window); -void window_settrans(Display *, Window, double); +int window_setstate(Window, long); +long window_getstate(Window); +Status window_configure(Window, int, int, int, int, int); +void window_grabbuttons(int, Window, Bool, Bool); +void window_setshape(int, Window); +void window_settrans(Window, double); #endif // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80