remove sw/sh, calculate each time
This commit is contained in:
parent
c3d2e56ef1
commit
8db67dca7c
13
client.c
13
client.c
|
@ -13,7 +13,7 @@
|
|||
#include "layouts/floating.h"
|
||||
|
||||
/* extern */
|
||||
extern int sx, sy, sw, sh; /* screen geometry */
|
||||
extern int sx, sy; /* screen geometry */
|
||||
extern int wax, way, wah, waw; /* windowarea geometry */
|
||||
extern Client *clients, *sel, *stack; /* global client list and stack */
|
||||
extern Atom wmatom[WMLast], netatom[NetLast];
|
||||
|
@ -346,7 +346,8 @@ manage(Display * disp, DC *drawcontext, Window w, XWindowAttributes * wa, jdwm_c
|
|||
c->h = c->rh = wa->height;
|
||||
c->oldborder = wa->border_width;
|
||||
c->display = disp;
|
||||
if(c->w == sw && c->h == sh)
|
||||
if(c->w == DisplayWidth(disp, DefaultScreen(disp))
|
||||
&& c->h == DisplayHeight(disp, DefaultScreen(disp)))
|
||||
{
|
||||
c->x = sx;
|
||||
c->y = sy;
|
||||
|
@ -438,10 +439,10 @@ resize(Client * c, int x, int y, int w, int h, Bool sizehints)
|
|||
if(w <= 0 || h <= 0)
|
||||
return;
|
||||
/* offscreen appearance fixes */
|
||||
if(x > sw)
|
||||
x = sw - w - 2 * c->border;
|
||||
if(y > sh)
|
||||
y = sh - h - 2 * c->border;
|
||||
if(x > DisplayWidth(c->display, DefaultScreen(c->display)))
|
||||
x = DisplayWidth(c->display, DefaultScreen(c->display)) - w - 2 * c->border;
|
||||
if(y > DisplayHeight(c->display, DefaultScreen(c->display)))
|
||||
y = DisplayHeight(c->display, DefaultScreen(c->display)) - h - 2 * c->border;
|
||||
if(x + w + 2 * c->border < sx)
|
||||
x = sx;
|
||||
if(y + h + 2 * c->border < sy)
|
||||
|
|
7
draw.c
7
draw.c
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "layout.h"
|
||||
|
||||
extern int sw; /* screen geometry */
|
||||
extern Window barwin;
|
||||
extern DC dc; /* global draw context */
|
||||
extern Client *clients, *sel, *stack; /* global client list and stack */
|
||||
|
@ -130,11 +129,11 @@ drawstatus(Display *disp, jdwm_config * jdwmconf)
|
|||
drawtext(disp, jdwmconf->current_layout->symbol, dc.norm);
|
||||
x = dc.x + dc.w;
|
||||
dc.w = textw(jdwmconf->statustext);
|
||||
dc.x = sw - dc.w;
|
||||
dc.x = DisplayWidth(disp, DefaultScreen(disp)) - dc.w;
|
||||
if(dc.x < x)
|
||||
{
|
||||
dc.x = x;
|
||||
dc.w = sw - x;
|
||||
dc.w = DisplayWidth(disp, DefaultScreen(disp)) - x;
|
||||
}
|
||||
drawtext(disp, jdwmconf->statustext, dc.norm);
|
||||
if((dc.w = dc.x - x) > jdwmconf->statusbar.height)
|
||||
|
@ -148,6 +147,6 @@ drawstatus(Display *disp, jdwm_config * jdwmconf)
|
|||
else
|
||||
drawtext(disp, NULL, dc.norm);
|
||||
}
|
||||
XCopyArea(disp, dc.drawable, barwin, dc.gc, 0, 0, sw, jdwmconf->statusbar.height, 0, 0);
|
||||
XCopyArea(disp, dc.drawable, barwin, dc.gc, 0, 0, DisplayWidth(disp, DefaultScreen(disp)), jdwmconf->statusbar.height, 0, 0);
|
||||
XSync(disp, False);
|
||||
}
|
||||
|
|
20
event.c
20
event.c
|
@ -13,7 +13,7 @@
|
|||
#include "layouts/floating.h"
|
||||
|
||||
/* extern */
|
||||
extern int screen, sw, sh; /* screen geometry */
|
||||
extern int screen; /* screen geometry */
|
||||
extern int wax, way, wah, waw; /* windowarea geometry */
|
||||
extern Window barwin;
|
||||
extern DC dc; /* global draw context */
|
||||
|
@ -203,10 +203,10 @@ handle_event_configurerequest(XEvent * e, jdwm_config *jdwmconf __attribute__ ((
|
|||
c->w = ev->width;
|
||||
if(ev->value_mask & CWHeight)
|
||||
c->h = ev->height;
|
||||
if((c->x + c->w) > sw && c->isfloating)
|
||||
c->x = sw / 2 - c->w / 2; /* center in x direction */
|
||||
if((c->y + c->h) > sh && c->isfloating)
|
||||
c->y = sh / 2 - c->h / 2; /* center in y direction */
|
||||
if((c->x + c->w) > DisplayWidth(c->display, DefaultScreen(c->display)) && c->isfloating)
|
||||
c->x = DisplayWidth(c->display, DefaultScreen(c->display)) / 2 - c->w / 2; /* center in x direction */
|
||||
if((c->y + c->h) > DisplayHeight(c->display, DefaultScreen(c->display)) && c->isfloating)
|
||||
c->y = DisplayHeight(c->display, DefaultScreen(c->display)) / 2 - c->h / 2; /* center in y direction */
|
||||
if((ev->value_mask & (CWX | CWY)) && !(ev->value_mask & (CWWidth | CWHeight)))
|
||||
configure(c);
|
||||
if(isvisible(c, jdwmconf->selected_tags, jdwmconf->ntags))
|
||||
|
@ -234,13 +234,13 @@ handle_event_configurenotify(XEvent * e, jdwm_config *jdwmconf)
|
|||
{
|
||||
XConfigureEvent *ev = &e->xconfigure;
|
||||
|
||||
if(ev->window == DefaultRootWindow(e->xany.display) && (ev->width != sw || ev->height != sh))
|
||||
if(ev->window == DefaultRootWindow(e->xany.display) && (ev->width != DisplayWidth(e->xany.display, DefaultScreen(e->xany.display)) || ev->height != DisplayHeight(e->xany.display, DefaultScreen(e->xany.display))))
|
||||
{
|
||||
sw = ev->width;
|
||||
sh = ev->height;
|
||||
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), sw, jdwmconf->statusbar.height, DefaultDepth(e->xany.display, screen));
|
||||
XResizeWindow(e->xany.display, barwin, sw, jdwmconf->statusbar.height);
|
||||
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));
|
||||
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);
|
||||
}
|
||||
|
|
12
jdwm.c
12
jdwm.c
|
@ -18,7 +18,7 @@
|
|||
#include "layout.h"
|
||||
#include "tag.h"
|
||||
|
||||
int screen, sx, sy, sw, sh, wax, way, waw, wah;
|
||||
int screen, sx, sy, wax, way, waw, wah;
|
||||
Atom wmatom[WMLast], netatom[NetLast];
|
||||
Client *clients = NULL;
|
||||
Client *sel = NULL;
|
||||
|
@ -170,14 +170,12 @@ setup(Display *disp, jdwm_config *jdwmconf)
|
|||
compileregs(jdwmconf);
|
||||
/* geometry */
|
||||
sx = sy = 0;
|
||||
sw = DisplayWidth(disp, screen);
|
||||
sh = DisplayHeight(disp, screen);
|
||||
/* bar */
|
||||
dc.h = jdwmconf->statusbar.height = dc.font.height + 2;
|
||||
wa.override_redirect = 1;
|
||||
wa.background_pixmap = ParentRelative;
|
||||
wa.event_mask = ButtonPressMask | ExposureMask;
|
||||
barwin = XCreateWindow(disp, DefaultRootWindow(disp), sx, sy, sw, jdwmconf->statusbar.height, 0,
|
||||
barwin = XCreateWindow(disp, DefaultRootWindow(disp), sx, sy, DisplayWidth(disp, DefaultScreen(disp)), jdwmconf->statusbar.height, 0,
|
||||
DefaultDepth(disp, screen), CopyFromParent,
|
||||
DefaultVisual(disp, screen),
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
||||
|
@ -185,7 +183,7 @@ setup(Display *disp, jdwm_config *jdwmconf)
|
|||
updatebarpos(disp, jdwmconf->statusbar);
|
||||
XMapRaised(disp, barwin);
|
||||
/* pixmap for everything */
|
||||
dc.drawable = XCreatePixmap(disp, DefaultRootWindow(disp), sw, jdwmconf->statusbar.height, DefaultDepth(disp, screen));
|
||||
dc.drawable = XCreatePixmap(disp, DefaultRootWindow(disp), DisplayWidth(disp, DefaultScreen(disp)), jdwmconf->statusbar.height, DefaultDepth(disp, screen));
|
||||
dc.gc = XCreateGC(disp, DefaultRootWindow(disp), 0, 0);
|
||||
XSetLineAttributes(disp, dc.gc, 1, LineSolid, CapButt, JoinMiter);
|
||||
if(!dc.font.set)
|
||||
|
@ -221,8 +219,8 @@ updatebarpos(Display *disp, Statusbar statusbar)
|
|||
|
||||
wax = sx;
|
||||
way = sy;
|
||||
wah = sh;
|
||||
waw = sw;
|
||||
wah = DisplayHeight(disp, DefaultScreen(disp));
|
||||
waw = DisplayWidth(disp, DefaultScreen(disp));
|
||||
switch (statusbar.position)
|
||||
{
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue