changeset: 1404:2fd482e3405b
tag: tip
user: Anselm R Garbe <anselm_AT_garbe.us>
date: Mon Jun 22 20:29:59 2009 +0100
files: dwm.c
description:
some more refactoring, bar toggle fixes
diff -r 9bfeee8174c2 -r 2fd482e3405b dwm.c
--- a/dwm.c Mon Jun 22 18:13:05 2009 +0100
+++ b/dwm.c Mon Jun 22 20:29:59 2009 +0100
@@ -124,6 +124,7 @@
int screen_number;
float mfact;
int by, btx; /* bar geometry */
+ int my, mh; /* vertical screen size*/
int wx, wy, ww, wh; /* window area */
unsigned int seltags;
unsigned int sellt;
@@ -209,6 +210,7 @@
static void unmanage(Client *c);
static void unmapnotify(XEvent *e);
static void updategeom(void);
+static void updatebarpos(Monitor *m);
static void updatebars(void);
static void updatenumlockmask(void);
static void updatesizehints(Client *c);
@@ -389,7 +391,7 @@
XButtonPressedEvent *ev = &e->xbutton;
click = ClkRootWin;
- if(ev->window == selmon->barwin) {
+ if(ev->window == selmon->barwin && ev->x >= selmon->btx) {
i = 0;
x = selmon->btx;
do
@@ -597,6 +599,7 @@
void
drawbar(Monitor *m) {
+ char buf[2];
int x;
unsigned int i, occ = 0, urg = 0;
unsigned long *col;
@@ -613,11 +616,11 @@
dc.x = 0;
#ifdef XINERAMA
{
- /*
- dc.w = TEXTW(m->symbol);
- drawtext(NULL, selmon == m ? dc.sel : dc.norm, False);
+ buf[0] = m->screen_number + '0';
+ buf[1] = '\0';
+ dc.w = TEXTW(buf);
+ drawtext(buf, selmon == m ? dc.sel : dc.norm, True);
dc.x += dc.w;
- */
}
#endif /* XINERAMA */
m->btx = dc.x;
@@ -1525,7 +1528,7 @@
void
togglebar(const Arg *arg) {
selmon->showbar = !selmon->showbar;
- updategeom();
+ updatebarpos(selmon);
XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
arrange();
}
@@ -1615,6 +1618,19 @@
}
void
+updatebarpos(Monitor *m) {
+ m->wy = m->my;
+ m->wh = m->mh;
+ if(m->showbar) {
+ m->wh -= bh;
+ m->by = m->topbar ? m->wy : m->wy + m->wh;
+ m->wy = m->topbar ? m->wy + bh : m->wy;
+ }
+ else
+ m->by = -bh;
+}
+
+void
updategeom(void) {
int i, n;
Client *c;
@@ -1639,9 +1655,9 @@
for(i = 0, m = newmons; m; m = m->next, i++) {
m->screen_number = info[i].screen_number;
m->wx = info[i].x_org;
- m->wy = info[i].y_org;
+ m->my = m->wy = info[i].y_org;
m->ww = info[i].width;
- m->wh = info[i].height;
+ m->mh = m->wh = info[i].height;
}
XFree(info);
}
@@ -1651,9 +1667,9 @@
{
m->screen_number = 0;
m->wx = sx;
- m->wy = sy;
+ m->my = m->wy = sy;
m->ww = sw;
- m->wh = sh;
+ m->mh = m->wh = sh;
}
/* bar geometry setup */
@@ -1665,13 +1681,7 @@
m->mfact = mfact;
m->showbar = showbar;
m->topbar = topbar;
- if(m->showbar) {
- m->wh -= bh;
- m->by = m->topbar ? m->wy : m->wy + m->wh;
- m->wy = m->topbar ? m->wy + bh : m->wy;
- }
- else
- m->by = -bh;
+ updatebarpos(m);
/* reassign all clients with same screen number */
for(c = clients; c; c = c->next)
if(c->m->screen_number == m->screen_number)
Received on Mon Jun 22 2009 - 19:30:03 UTC
This archive was generated by hypermail 2.2.0 : Mon Jun 22 2009 - 19:36:05 UTC