remove Display as arg from window_*() fcts

This commit is contained in:
Julien Danjou 2007-12-30 15:24:51 +01:00
parent 84c59a5704
commit 6f4dec78ff
5 changed files with 61 additions and 66 deletions

View File

@ -166,7 +166,7 @@ scan()
|| wa.override_redirect || wa.override_redirect
|| XGetTransientForHint(globalconf.display, wins[i], &d1)) || XGetTransientForHint(globalconf.display, wins[i], &d1))
continue; 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) if(screen == 0)
real_screen = get_screen_bycoord(wa.x, wa.y); real_screen = get_screen_bycoord(wa.x, wa.y);
@ -179,7 +179,7 @@ scan()
if(!XGetWindowAttributes(globalconf.display, wins[i], &wa)) if(!XGetWindowAttributes(globalconf.display, wins[i], &wa))
continue; continue;
if(XGetTransientForHint(globalconf.display, wins[i], &d1) 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) if(screen == 0)
real_screen = get_screen_bycoord(wa.x, wa.y); real_screen = get_screen_bycoord(wa.x, wa.y);

View File

@ -183,7 +183,7 @@ void
client_ban(Client * c) client_ban(Client * c)
{ {
XUnmapWindow(globalconf.display, c->win); 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 /** Attach client to the beginning of the clients stack
@ -224,11 +224,11 @@ focus(Client *c, Bool selscreen, int screen)
/* unfocus current selected client */ /* unfocus current selected client */
if(globalconf.focus->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); globalconf.focus->client->win, False, True);
XSetWindowBorder(globalconf.display, globalconf.focus->client->win, XSetWindowBorder(globalconf.display, globalconf.focus->client->win,
globalconf.screens[screen].colors_normal[ColBorder].pixel); 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); globalconf.screens[screen].opacity_unfocused);
} }
@ -245,8 +245,7 @@ focus(Client *c, Bool selscreen, int screen)
if(c) if(c)
{ {
XSetWindowBorder(globalconf.display, c->win, globalconf.screens[screen].colors_selected[ColBorder].pixel); XSetWindowBorder(globalconf.display, c->win, globalconf.screens[screen].colors_selected[ColBorder].pixel);
window_grabbuttons(globalconf.display, c->phys_screen, c->win, window_grabbuttons(c->phys_screen, c->win, True, True);
True, True);
} }
if(!selscreen) if(!selscreen)
@ -263,9 +262,9 @@ focus(Client *c, Bool selscreen, int screen)
globalconf.focus->client->win, RevertToPointerRoot, CurrentTime); globalconf.focus->client->win, RevertToPointerRoot, CurrentTime);
for(c = globalconf.clients; c; c = c->next) for(c = globalconf.clients; c; c = c->next)
if(c != globalconf.focus->client) if(c != globalconf.focus->client)
window_settrans(globalconf.display, globalconf.focus->client->win, window_settrans(globalconf.focus->client->win,
globalconf.screens[screen].opacity_unfocused); globalconf.screens[screen].opacity_unfocused);
window_settrans(globalconf.display, globalconf.focus->client->win, -1); window_settrans(globalconf.focus->client->win, -1);
} }
else else
XSetInputFocus(globalconf.display, 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); XSetWindowBorder(globalconf.display, w, globalconf.screens[screen].colors_normal[ColBorder].pixel);
/* propagates border_width, if size doesn't change */ /* 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 */ /* update hints */
client_updatesizehints(c); client_updatesizehints(c);
@ -360,11 +359,11 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
if(globalconf.have_shape) if(globalconf.have_shape)
{ {
XShapeSelectInput(globalconf.display, w, ShapeNotifyMask); XShapeSelectInput(globalconf.display, w, ShapeNotifyMask);
window_setshape(globalconf.display, c->phys_screen, c->win); window_setshape(c->phys_screen, c->win);
} }
/* grab buttons */ /* 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 */ /* check for transient and set tags like its parent */
if((rettrans = XGetTransientForHint(globalconf.display, w, &trans) == Success) 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); p_delete(&curtags);
wc.border_width = c->border; wc.border_width = c->border;
XConfigureWindow(globalconf.display, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); 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); XSync(globalconf.display, False);
if((c->x >= 0 || c->y >= 0) && XineramaIsActive(globalconf.display)) if((c->x >= 0 || c->y >= 0) && XineramaIsActive(globalconf.display))
{ {
@ -529,7 +528,7 @@ void
client_unban(Client *c) client_unban(Client *c)
{ {
XMapWindow(globalconf.display, c->win); XMapWindow(globalconf.display, c->win);
window_setstate(globalconf.display, c->win, NormalState); window_setstate(c->win, NormalState);
} }
void void
@ -549,7 +548,7 @@ client_unmanage(Client *c, long state)
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
untag_client(c, tag); untag_client(c, tag);
XUngrabButton(globalconf.display, AnyButton, AnyModifier, c->win); XUngrabButton(globalconf.display, AnyButton, AnyModifier, c->win);
window_setstate(globalconf.display, c->win, state); window_setstate(c->win, state);
XSync(globalconf.display, False); XSync(globalconf.display, False);
XSetErrorHandler(xerror); XSetErrorHandler(xerror);
XUngrabServer(globalconf.display); XUngrabServer(globalconf.display);
@ -699,9 +698,9 @@ uicb_client_settrans(int screen __attribute__ ((unused)), char *arg)
} }
if(delta == 100.0 && !set_prop) if(delta == 100.0 && !set_prop)
window_settrans(globalconf.display, sel->win, -1); window_settrans(sel->win, -1);
else else
window_settrans(globalconf.display, sel->win, delta); window_settrans(sel->win, delta);
} }

12
event.c
View File

@ -107,7 +107,7 @@ handle_event_buttonpress(XEvent *e)
{ {
restack(c->screen); restack(c->screen);
XAllowEvents(globalconf.display, ReplayPointer, CurrentTime); 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 else
handle_mouse_button_press(c->screen, ev->button, ev->state, globalconf.buttons.client, NULL); 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) if(ev->value_mask & CWHeight)
c->rh = c->h = ev->height; c->rh = c->h = ev->height;
if((ev->value_mask & (CWX | CWY)) && !(ev->value_mask & (CWWidth | CWHeight))) 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 */ /* recompute screen */
old_screen = c->screen; old_screen = c->screen;
c->screen = get_screen_bycoord(c->x, c->y); c->screen = get_screen_bycoord(c->x, c->y);
@ -163,7 +163,7 @@ handle_event_configurerequest(XEvent * e)
arrange(c->screen); arrange(c->screen);
} }
else 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 else
{ {
@ -233,7 +233,7 @@ handle_event_enternotify(XEvent * e)
curtags = get_current_tags(c->screen); curtags = get_current_tags(c->screen);
focus(c, ev->same_screen, c->screen); focus(c, ev->same_screen, c->screen);
if (c->isfloating || curtags[0]->layout->arrange == layout_floating) 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); p_delete(&curtags);
} }
else else
@ -377,7 +377,7 @@ handle_event_unmapnotify(XEvent * e)
if((c = get_client_bywin(globalconf.clients, ev->window)) if((c = get_client_bywin(globalconf.clients, ev->window))
&& ev->event == RootWindow(e->xany.display, c->phys_screen) && 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); client_unmanage(c, WithdrawnState);
} }
@ -388,7 +388,7 @@ handle_event_shape(XEvent * e)
Client *c = get_client_bywin(globalconf.clients, ev->window); Client *c = get_client_bywin(globalconf.clients, ev->window);
if(c) if(c)
window_setshape(globalconf.display, c->phys_screen, c->win); window_setshape(c->phys_screen, c->win);
} }
void void

View File

@ -28,35 +28,33 @@
extern AwesomeConf globalconf; extern AwesomeConf globalconf;
/** Set client WM_STATE property /** Set client WM_STATE property
* \param disp Display ref
* \param win Window * \param win Window
* \param state state * \param state state
*/ */
int int
window_setstate(Display *disp, Window win, long state) window_setstate(Window win, long state)
{ {
long data[] = { state, None }; long data[] = { state, None };
return XChangeProperty(disp, win, XInternAtom(disp, "WM_STATE", False), return XChangeProperty(globalconf.display, win, XInternAtom(globalconf.display, "WM_STATE", False),
XInternAtom(disp, "WM_STATE", False), 32, XInternAtom(globalconf.display, "WM_STATE", False), 32,
PropModeReplace, (unsigned char *) data, 2); PropModeReplace, (unsigned char *) data, 2);
} }
/** Get a window state (WM_STATE) /** Get a window state (WM_STATE)
* \param disp Display ref
* \param w Client window * \param w Client window
* \return state * \return state
*/ */
long long
window_getstate(Display *disp, Window w) window_getstate(Window w)
{ {
int format; int format;
long result = -1; long result = -1;
unsigned char *p = NULL; unsigned char *p = NULL;
unsigned long n, extra; unsigned long n, extra;
Atom real; Atom real;
if(XGetWindowProperty(disp, w, XInternAtom(disp, "WM_STATE", False), if(XGetWindowProperty(globalconf.display, w, XInternAtom(globalconf.display, "WM_STATE", False),
0L, 2L, False, XInternAtom(disp, "WM_STATE", False), 0L, 2L, False, XInternAtom(globalconf.display, "WM_STATE", False),
&real, &format, &n, &extra, (unsigned char **) &p) != Success) &real, &format, &n, &extra, (unsigned char **) &p) != Success)
return -1; return -1;
if(n != 0) if(n != 0)
@ -66,12 +64,12 @@ window_getstate(Display *disp, Window w)
} }
Status 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; XConfigureEvent ce;
ce.type = ConfigureNotify; ce.type = ConfigureNotify;
ce.display = disp; ce.display = globalconf.display;
ce.event = win; ce.event = win;
ce.window = win; ce.window = win;
ce.x = x; 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.border_width = border;
ce.above = None; ce.above = None;
ce.override_redirect = False; 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 /** Grab or ungrab buttons on a window
* \param disp Display ref
* \param screen The screen * \param screen The screen
* \param win The window * \param win The window
* \param focused True if client is focused * \param focused True if client is focused
* \param raised True if the client is above other clients * \param raised True if the client is above other clients
*/ */
void void
window_grabbuttons(Display *disp, window_grabbuttons(int screen,
int screen,
Window win, Window win,
Bool focused, Bool focused,
Bool raised) Bool raised)
{ {
Button *b; Button *b;
XUngrabButton(disp, AnyButton, AnyModifier, win); XUngrabButton(globalconf.display, AnyButton, AnyModifier, win);
if(focused) if(focused)
{ {
if(!raised) if(!raised)
XGrabButton(disp, Button1, NoSymbol, win, False, XGrabButton(globalconf.display, Button1, NoSymbol, win, False,
BUTTONMASK, GrabModeSync, GrabModeAsync, None, None); BUTTONMASK, GrabModeSync, GrabModeAsync, None, None);
for(b = globalconf.buttons.client; b; b = b->next) 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); 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); 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); 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); win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
} }
XUngrabButton(disp, AnyButton, AnyModifier, RootWindow(disp, screen)); XUngrabButton(globalconf.display, AnyButton, AnyModifier, RootWindow(globalconf.display, screen));
} }
else else
{ {
XGrabButton(disp, AnyButton, AnyModifier, win, False, BUTTONMASK, XGrabButton(globalconf.display, AnyButton, AnyModifier, win, False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
for(b = globalconf.buttons.root; b; b = b->next) for(b = globalconf.buttons.root; b; b = b->next)
{ {
XGrabButton(disp, b->button, b->mod, XGrabButton(globalconf.display, b->button, b->mod,
RootWindow(disp, screen), False, BUTTONMASK, RootWindow(globalconf.display, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, b->button, b->mod | LockMask, XGrabButton(globalconf.display, b->button, b->mod | LockMask,
RootWindow(disp, screen), False, BUTTONMASK, RootWindow(globalconf.display, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, b->button, b->mod | globalconf.numlockmask, XGrabButton(globalconf.display, b->button, b->mod | globalconf.numlockmask,
RootWindow(disp, screen), False, BUTTONMASK, RootWindow(globalconf.display, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
XGrabButton(disp, b->button, b->mod | globalconf.numlockmask | LockMask, XGrabButton(globalconf.display, b->button, b->mod | globalconf.numlockmask | LockMask,
RootWindow(disp, screen), False, BUTTONMASK, RootWindow(globalconf.display, screen), False, BUTTONMASK,
GrabModeAsync, GrabModeSync, None, None); GrabModeAsync, GrabModeSync, None, None);
} }
} }
} }
void void
window_setshape(Display *disp, int screen, Window win) window_setshape(int screen, Window win)
{ {
int bounding_shaped; int bounding_shaped;
int i, b; unsigned int u; /* dummies */ int i, b; unsigned int u; /* dummies */
/* Logic to decide if we have a shaped window cribbed from fvwm-2.5.10. */ /* 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) &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 void
window_settrans(Display *disp, Window win, double opacity) window_settrans(Window win, double opacity)
{ {
unsigned int real_opacity = 0xffffffff; unsigned int real_opacity = 0xffffffff;
if(opacity >= 0 && opacity <= 100) if(opacity >= 0 && opacity <= 100)
{ {
real_opacity = ((opacity / 100.0) * 0xffffffff); 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); XA_CARDINAL, 32, PropModeReplace, (unsigned char *) &real_opacity, 1L);
} }
else 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 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -27,12 +27,12 @@
/** Mask shorthands, used in event.c and window.c */ /** Mask shorthands, used in event.c and window.c */
#define BUTTONMASK (ButtonPressMask | ButtonReleaseMask) #define BUTTONMASK (ButtonPressMask | ButtonReleaseMask)
int window_setstate(Display *, Window, long); int window_setstate(Window, long);
long window_getstate(Display *, Window); long window_getstate(Window);
Status window_configure(Display *, Window, int, int, int, int, int); Status window_configure(Window, int, int, int, int, int);
void window_grabbuttons(Display *, int, Window, Bool, Bool); void window_grabbuttons(int, Window, Bool, Bool);
void window_setshape(Display *, int, Window); void window_setshape(int, Window);
void window_settrans(Display *, Window, double); void window_settrans(Window, double);
#endif #endif
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80