remove Display from Client struct

This commit is contained in:
Julien Danjou 2007-12-27 23:10:43 +01:00
parent 48d9ea047f
commit f93a441da7
6 changed files with 65 additions and 65 deletions

View File

@ -58,7 +58,7 @@ client_loadprops(Client * c, int screen)
prop = p_new(char, ntags + 2); 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) for(i = 0, tag = globalconf.screens[screen].tags; tag && i < ntags && prop[i]; i++, tag = tag->next)
if(prop[i] == '1') if(prop[i] == '1')
@ -163,8 +163,8 @@ get_client_byname(Client *list, char *name)
void void
client_updatetitle(Client *c) client_updatetitle(Client *c)
{ {
if(!xgettextprop(c->display, c->win, XInternAtom(c->display, "_NET_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(c->display, c->win, XInternAtom(c->display, "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 /** Ban client and unmap it
@ -173,8 +173,8 @@ client_updatetitle(Client *c)
void void
client_ban(Client * c) client_ban(Client * c)
{ {
XUnmapWindow(c->display, c->win); XUnmapWindow(globalconf.display, c->win);
window_setstate(c->display, c->win, IconicState); window_setstate(globalconf.display, c->win, IconicState);
} }
/** Attach client to the beginning of the clients stack /** Attach client to the beginning of the clients stack
@ -215,11 +215,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.focus->client->display, globalconf.focus->client->phys_screen, window_grabbuttons(globalconf.display, globalconf.focus->client->phys_screen,
globalconf.focus->client->win, False, True); 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); 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); globalconf.screens[screen].opacity_unfocused);
} }
@ -230,7 +230,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(c->display, c->phys_screen, c->win, window_grabbuttons(globalconf.display, c->phys_screen, c->win,
True, True); True, True);
} }
@ -244,7 +244,7 @@ focus(Client *c, Bool selscreen, int screen)
if(globalconf.focus->client) if(globalconf.focus->client)
{ {
XSetInputFocus(globalconf.focus->client->display, XSetInputFocus(globalconf.display,
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)
@ -283,7 +283,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
c->h = c->rh = wa->height; c->h = c->rh = wa->height;
c->oldborder = wa->border_width; c->oldborder = wa->border_width;
c->display = globalconf.display; globalconf.display = globalconf.display;
c->screen = get_screen_bycoord(c->x, c->y); c->screen = get_screen_bycoord(c->x, c->y);
c->phys_screen = get_phys_screen(c->screen); c->phys_screen = get_phys_screen(c->screen);
@ -325,29 +325,29 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
/* set borders */ /* set borders */
wc.border_width = c->border; wc.border_width = c->border;
XConfigureWindow(c->display, w, CWBorderWidth, &wc); XConfigureWindow(globalconf.display, w, CWBorderWidth, &wc);
XSetWindowBorder(c->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(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 */ /* update sizehint */
client_updatesizehints(c); client_updatesizehints(c);
XSelectInput(c->display, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask); XSelectInput(globalconf.display, w, StructureNotifyMask | PropertyChangeMask | EnterWindowMask);
/* handle xshape */ /* handle xshape */
if(globalconf.have_shape) if(globalconf.have_shape)
{ {
XShapeSelectInput(c->display, w, ShapeNotifyMask); XShapeSelectInput(globalconf.display, w, ShapeNotifyMask);
window_setshape(c->display, c->phys_screen, c->win); window_setshape(globalconf.display, c->phys_screen, c->win);
} }
/* grab buttons */ /* 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 */ /* 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))) && (t = get_client_bywin(globalconf.clients, trans)))
for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next) for(tag = globalconf.screens[c->screen].tags; tag; tag = tag->next)
if(is_client_tagged(t, tag)) if(is_client_tagged(t, tag))
@ -364,7 +364,7 @@ client_manage(Window w, XWindowAttributes *wa, int screen)
client_attach(c); client_attach(c);
/* some windows require this */ /* 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); focus(c, True, screen);
@ -456,10 +456,10 @@ 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(c->display, c->win, CWX | CWY | CWWidth | CWHeight | CWBorderWidth, &wc); XConfigureWindow(globalconf.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); window_configure(globalconf.display, c->win, c->x, c->y, c->w, c->h, c->border);
XSync(c->display, False); XSync(globalconf.display, False);
if((c->x >= 0 || c->y >= 0) && XineramaIsActive(c->display)) if((c->x >= 0 || c->y >= 0) && XineramaIsActive(globalconf.display))
{ {
int new_screen = get_screen_bycoord(c->x, c->y); int new_screen = get_screen_bycoord(c->x, c->y);
if(c->screen != new_screen) if(c->screen != new_screen)
@ -488,7 +488,7 @@ client_saveprops(Client * c, int screen)
prop[++i] = '\0'; 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); PropModeReplace, (unsigned char *) prop, i);
p_delete(&prop); p_delete(&prop);
@ -497,8 +497,8 @@ client_saveprops(Client * c, int screen)
void void
client_unban(Client *c) client_unban(Client *c)
{ {
XMapWindow(c->display, c->win); XMapWindow(globalconf.display, c->win);
window_setstate(c->display, c->win, NormalState); window_setstate(globalconf.display, c->win, NormalState);
} }
void void
@ -509,19 +509,19 @@ client_unmanage(Client *c, long state)
wc.border_width = c->oldborder; wc.border_width = c->oldborder;
/* The server grab construct avoids race conditions. */ /* The server grab construct avoids race conditions. */
XGrabServer(c->display); XGrabServer(globalconf.display);
XConfigureWindow(c->display, c->win, CWBorderWidth, &wc); /* restore border */ XConfigureWindow(globalconf.display, c->win, CWBorderWidth, &wc); /* restore border */
client_detach(c); client_detach(c);
if(globalconf.focus->client == c) if(globalconf.focus->client == c)
focus(NULL, True, c->screen); focus(NULL, True, c->screen);
focus_delete_client(c); focus_delete_client(c);
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(c->display, AnyButton, AnyModifier, c->win); XUngrabButton(globalconf.display, AnyButton, AnyModifier, c->win);
window_setstate(c->display, c->win, state); window_setstate(globalconf.display, c->win, state);
XSync(c->display, False); XSync(globalconf.display, False);
XSetErrorHandler(xerror); XSetErrorHandler(xerror);
XUngrabServer(c->display); XUngrabServer(globalconf.display);
if(state != NormalState) if(state != NormalState)
arrange(c->screen); arrange(c->screen);
p_delete(&c); p_delete(&c);
@ -545,7 +545,7 @@ client_updatesizehints(Client *c)
long msize; long msize;
XSizeHints size; 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; size.flags = PSize;
c->flags = size.flags; c->flags = size.flags;
if(c->flags & PBaseSize) if(c->flags & PBaseSize)
@ -642,7 +642,7 @@ uicb_client_settrans(int screen __attribute__ ((unused)), char *arg)
return; return;
XGetWindowProperty(globalconf.display, sel->win, 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, 0L, 1L, False, XA_CARDINAL, &actual, &format, &n, &left,
(unsigned char **) &data); (unsigned char **) &data);
if(data) if(data)
@ -665,9 +665,9 @@ uicb_client_settrans(int screen __attribute__ ((unused)), char *arg)
} }
if(delta == 100.0 && !set_prop) if(delta == 100.0 && !set_prop)
window_settrans(sel->display, sel->win, -1); window_settrans(globalconf.display, sel->win, -1);
else 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; XEvent ev;
if(isprotodel(c->display, c->win)) if(isprotodel(globalconf.display, c->win))
{ {
ev.type = ClientMessage; ev.type = ClientMessage;
ev.xclient.window = c->win; ev.xclient.window = c->win;

View File

@ -131,8 +131,6 @@ struct Client
Client *prev; Client *prev;
/** Window of the client */ /** Window of the client */
Window win; Window win;
/** Client display */
Display *display;
/** Client logical screen */ /** Client logical screen */
int screen; int screen;
/** Client physical screen */ /** Client physical screen */

16
event.c
View File

@ -106,8 +106,8 @@ handle_event_buttonpress(XEvent *e)
&& ev->button == Button1) && ev->button == Button1)
{ {
restack(c->screen); restack(c->screen);
XAllowEvents(c->display, ReplayPointer, CurrentTime); XAllowEvents(globalconf.display, ReplayPointer, CurrentTime);
window_grabbuttons(c->display, c->phys_screen, c->win, True, True); window_grabbuttons(globalconf.display, 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);
@ -154,7 +154,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(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 */ /* 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);
@ -169,7 +169,7 @@ handle_event_configurerequest(XEvent * e)
arrange(c->screen); arrange(c->screen);
} }
else 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); p_delete(&curtags);
} }
else else
@ -240,7 +240,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(c->display, c->phys_screen, c->win, True, False); window_grabbuttons(globalconf.display, c->phys_screen, c->win, True, False);
p_delete(&curtags); p_delete(&curtags);
} }
else else
@ -367,7 +367,7 @@ handle_event_propertynotify(XEvent * e)
statusbar_draw(c->screen); statusbar_draw(c->screen);
break; 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); client_updatetitle(c);
if(c == globalconf.focus->client) if(c == globalconf.focus->client)
@ -384,7 +384,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(c->display, c->win) == NormalState) && ev->send_event && window_getstate(globalconf.display, c->win) == NormalState)
client_unmanage(c, WithdrawnState); client_unmanage(c, WithdrawnState);
} }
@ -395,7 +395,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(c->display, c->phys_screen, c->win); window_setshape(globalconf.display, c->phys_screen, c->win);
} }
void void

View File

@ -165,14 +165,14 @@ restack(int screen)
curtags = get_current_tags(screen); curtags = get_current_tags(screen);
if(sel->isfloating || if(sel->isfloating ||
curtags[0]->layout->arrange == layout_floating) curtags[0]->layout->arrange == layout_floating)
XRaiseWindow(sel->display, sel->win); XRaiseWindow(globalconf.display, sel->win);
if(!(curtags[0]->layout->arrange == layout_floating)) if(!(curtags[0]->layout->arrange == layout_floating))
{ {
wc.stack_mode = Below; wc.stack_mode = Below;
wc.sibling = globalconf.screens[screen].statusbar->window; wc.sibling = globalconf.screens[screen].statusbar->window;
if(!sel->isfloating) if(!sel->isfloating)
{ {
XConfigureWindow(sel->display, sel->win, CWSibling | CWStackMode, &wc); XConfigureWindow(globalconf.display, sel->win, CWSibling | CWStackMode, &wc);
wc.sibling = sel->win; wc.sibling = sel->win;
} }
for(c = globalconf.clients; c; c = c->next) for(c = globalconf.clients; c; c = c->next)

28
mouse.c
View File

@ -63,21 +63,21 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused)))
ocx = nx = c->x; ocx = nx = c->x;
ocy = ny = c->y; ocy = ny = c->y;
if(XGrabPointer(c->display, if(XGrabPointer(globalconf.display,
RootWindow(c->display, c->phys_screen), RootWindow(globalconf.display, c->phys_screen),
False, MOUSEMASK, GrabModeAsync, GrabModeAsync, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, globalconf.cursor[CurMove], CurrentTime) != GrabSuccess) None, globalconf.cursor[CurMove], CurrentTime) != GrabSuccess)
return; return;
XQueryPointer(c->display, XQueryPointer(globalconf.display,
RootWindow(c->display, c->phys_screen), RootWindow(globalconf.display, c->phys_screen),
&dummy, &dummy, &x1, &y1, &di, &di, &dui); &dummy, &dummy, &x1, &y1, &di, &di, &dui);
for(;;) for(;;)
{ {
XMaskEvent(c->display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev); XMaskEvent(globalconf.display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
switch (ev.type) switch (ev.type)
{ {
case ButtonRelease: case ButtonRelease:
XUngrabPointer(c->display, CurrentTime); XUngrabPointer(globalconf.display, CurrentTime);
return; return;
case ConfigureRequest: case ConfigureRequest:
handle_event_configurerequest(&ev); handle_event_configurerequest(&ev);
@ -89,7 +89,7 @@ uicb_client_movemouse(int screen, char *arg __attribute__ ((unused)))
handle_event_maprequest(&ev); handle_event_maprequest(&ev);
break; break;
case MotionNotify: case MotionNotify:
XSync(c->display, False); XSync(globalconf.display, False);
nx = ocx + (ev.xmotion.x - x1); nx = ocx + (ev.xmotion.x - x1);
ny = ocy + (ev.xmotion.y - y1); ny = ocy + (ev.xmotion.y - y1);
if(abs(nx) < globalconf.screens[screen].snap + area.x && nx > area.x) 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; ocx = c->x;
ocy = c->y; 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, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
None, globalconf.cursor[CurResize], CurrentTime) != GrabSuccess) None, globalconf.cursor[CurResize], CurrentTime) != GrabSuccess)
return; return;
c->ismax = False; 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(;;) for(;;)
{ {
XMaskEvent(c->display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev); XMaskEvent(globalconf.display, MOUSEMASK | ExposureMask | SubstructureRedirectMask, &ev);
switch (ev.type) switch (ev.type)
{ {
case ButtonRelease: case ButtonRelease:
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);
XUngrabPointer(c->display, CurrentTime); XUngrabPointer(globalconf.display, CurrentTime);
while(XCheckMaskEvent(c->display, EnterWindowMask, &ev)); while(XCheckMaskEvent(globalconf.display, EnterWindowMask, &ev));
return; return;
case ConfigureRequest: case ConfigureRequest:
handle_event_configurerequest(&ev); handle_event_configurerequest(&ev);
@ -158,7 +158,7 @@ uicb_client_resizemouse(int screen, char *arg __attribute__ ((unused)))
handle_event_maprequest(&ev); handle_event_maprequest(&ev);
break; break;
case MotionNotify: case MotionNotify:
XSync(c->display, False); XSync(globalconf.display, False);
if((nw = ev.xmotion.x - ocx - 2 * c->border + 1) <= 0) if((nw = ev.xmotion.x - ocx - 2 * c->border + 1) <= 0)
nw = 1; nw = 1;
if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0) if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0)

View File

@ -22,6 +22,8 @@
#include "util.h" #include "util.h"
#include "rules.h" #include "rules.h"
extern AwesomeConf globalconf;
void void
compileregs(Rule *rules) compileregs(Rule *rules)
{ {
@ -57,7 +59,7 @@ client_match_rule(Client *c, Rule *r)
XClassHint ch = { 0, 0 }; XClassHint ch = { 0, 0 };
Bool ret; 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); len = a_strlen(ch.res_class) + a_strlen(ch.res_name) + a_strlen(c->name);
prop = p_new(char, len + 3); prop = p_new(char, len + 3);