remove global var screen, compute it

This commit is contained in:
Julien Danjou 2007-09-07 17:25:10 +02:00
parent 8db67dca7c
commit 80c119a873
3 changed files with 8 additions and 12 deletions

View File

@ -133,8 +133,6 @@ name_func_lookup(const char *funcname, const NameFuncLink * list)
return NULL;
}
/** \todo remove screen */
extern int screen;
/** \todo remove dc */
extern DC dc;
@ -153,7 +151,7 @@ uicb_reload(Display *disp, jdwm_config *jdwmconf, const char *arg __attribute__
p_delete(&jdwmconf->selected_tags);
p_delete(&jdwmconf->layouts);
p_delete(&jdwmconf->tag_layouts);
parse_config(disp, screen, &dc, jdwmconf);
parse_config(disp, DefaultScreen(disp), &dc, jdwmconf);
}
/** Set default configuration

View File

@ -13,7 +13,6 @@
#include "layouts/floating.h"
/* extern */
extern int screen; /* screen geometry */
extern int wax, way, wah, waw; /* windowarea geometry */
extern Window barwin;
extern DC dc; /* global draw context */
@ -239,7 +238,7 @@ handle_event_configurenotify(XEvent * e, jdwm_config *jdwmconf)
DisplayWidth(e->xany.display, DefaultScreen(e->xany.display)) = ev->width;
DisplayHeight(e->xany.display, DefaultScreen(e->xany.display)) = ev->height;
XFreePixmap(e->xany.display, dc.drawable);
dc.drawable = XCreatePixmap(e->xany.display, DefaultRootWindow(e->xany.display), DisplayWidth(e->xany.display, DefaultScreen(e->xany.display)), jdwmconf->statusbar.height, DefaultDepth(e->xany.display, screen));
dc.drawable = XCreatePixmap(e->xany.display, DefaultRootWindow(e->xany.display), DisplayWidth(e->xany.display, DefaultScreen(e->xany.display)), jdwmconf->statusbar.height, DefaultDepth(e->xany.display, DefaultScreen(e->xany.display)));
XResizeWindow(e->xany.display, barwin, DisplayWidth(e->xany.display, DefaultScreen(e->xany.display)), jdwmconf->statusbar.height);
updatebarpos(e->xany.display, jdwmconf->statusbar);
arrange(e->xany.display, jdwmconf);

13
jdwm.c
View File

@ -18,7 +18,7 @@
#include "layout.h"
#include "tag.h"
int screen, sx, sy, wax, way, waw, wah;
int sx, sy, wax, way, waw, wah;
Atom wmatom[WMLast], netatom[NetLast];
Client *clients = NULL;
Client *sel = NULL;
@ -176,14 +176,14 @@ setup(Display *disp, jdwm_config *jdwmconf)
wa.background_pixmap = ParentRelative;
wa.event_mask = ButtonPressMask | ExposureMask;
barwin = XCreateWindow(disp, DefaultRootWindow(disp), sx, sy, DisplayWidth(disp, DefaultScreen(disp)), jdwmconf->statusbar.height, 0,
DefaultDepth(disp, screen), CopyFromParent,
DefaultVisual(disp, screen),
DefaultDepth(disp, DefaultScreen(disp)), CopyFromParent,
DefaultVisual(disp, DefaultScreen(disp)),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
XDefineCursor(disp, barwin, cursor[CurNormal]);
updatebarpos(disp, jdwmconf->statusbar);
XMapRaised(disp, barwin);
/* pixmap for everything */
dc.drawable = XCreatePixmap(disp, DefaultRootWindow(disp), DisplayWidth(disp, DefaultScreen(disp)), jdwmconf->statusbar.height, DefaultDepth(disp, screen));
dc.drawable = XCreatePixmap(disp, DefaultRootWindow(disp), DisplayWidth(disp, DefaultScreen(disp)), jdwmconf->statusbar.height, DefaultDepth(disp, DefaultScreen(disp)));
dc.gc = XCreateGC(disp, DefaultRootWindow(disp), 0, 0);
XSetLineAttributes(disp, dc.gc, 1, LineSolid, CapButt, JoinMiter);
if(!dc.font.set)
@ -285,8 +285,7 @@ main(int argc, char *argv[])
if(!(dpy = XOpenDisplay(NULL)))
eprint("jdwm: cannot open display\n");
xfd = ConnectionNumber(dpy);
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
root = RootWindow(dpy, DefaultScreen(dpy));
XSetErrorHandler(xerrorstart);
/* this causes an error if some other window manager is running */
@ -300,7 +299,7 @@ main(int argc, char *argv[])
XSetErrorHandler(NULL);
xerrorxlib = XSetErrorHandler(xerror);
XSync(dpy, False);
parse_config(dpy, screen, &dc, &jdwmconf);
parse_config(dpy, DefaultScreen(dpy), &dc, &jdwmconf);
setup(dpy, &jdwmconf);
drawstatus(dpy, &jdwmconf);
scan(dpy, &jdwmconf);