Xinqi Bao's Git
projects
/
dwm.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
introduced monitor symbols
[dwm.git]
/
dwm.c
diff --git
a/dwm.c
b/dwm.c
index
f20861e
..
5c714db
100644
(file)
--- a/
dwm.c
+++ b/
dwm.c
@@
-124,7
+124,7
@@
struct Monitor {
int screen_number;
float mfact;
int by, btx; /* bar geometry */
int screen_number;
float mfact;
int by, btx; /* bar geometry */
- int mx, my, mw, mh;
/* screen size */
+ int mx, my, mw, mh; /* screen size */
int wx, wy, ww, wh; /* window area */
unsigned int seltags;
unsigned int sellt;
int wx, wy, ww, wh; /* window area */
unsigned int seltags;
unsigned int sellt;
@@
-172,6
+172,7
@@
static void enternotify(XEvent *e);
static void expose(XEvent *e);
static void focus(Client *c);
static void focusin(XEvent *e);
static void expose(XEvent *e);
static void focus(Client *c);
static void focusin(XEvent *e);
+static void focusmon(const Arg *arg);
static void focusstack(const Arg *arg);
static unsigned long getcolor(const char *colstr);
static Bool getrootpointer(int *x, int *y);
static void focusstack(const Arg *arg);
static unsigned long getcolor(const char *colstr);
static Bool getrootpointer(int *x, int *y);
@@
-207,6
+208,7
@@
static void showhide(Client *c);
static void sigchld(int signal);
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void sigchld(int signal);
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
+static void tagmon(const Arg *arg);
static int textnw(const char *text, unsigned int len);
static void tile(Monitor *);
static void togglebar(const Arg *arg);
static int textnw(const char *text, unsigned int len);
static void tile(Monitor *);
static void togglebar(const Arg *arg);
@@
-231,15
+233,11
@@
static int xerror(Display *dpy, XErrorEvent *ee);
static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
static int xerrordummy(Display *dpy, XErrorEvent *ee);
static int xerrorstart(Display *dpy, XErrorEvent *ee);
static void zoom(const Arg *arg);
-#ifdef XINERAMA
-static void focusmon(const Arg *arg);
-static void tagmon(const Arg *arg);
-#endif /* XINERAMA */
/* variables */
static char stext[256];
static int screen;
/* variables */
static char stext[256];
static int screen;
-static int s
x, sy, s
w, sh; /* X display screen geometry x, y, width, height */
+static int sw, sh; /* X display screen geometry x, y, width, height */
static int bh, blw = 0; /* bar geometry */
static int (*xerrorxlib)(Display *, XErrorEvent *);
static unsigned int numlockmask = 0;
static int bh, blw = 0; /* bar geometry */
static int (*xerrorxlib)(Display *, XErrorEvent *);
static unsigned int numlockmask = 0;
@@
-302,19
+300,20
@@
applyrules(Client *c) {
Bool
applysizehints(Client *c, int *x, int *y, int *w, int *h) {
Bool baseismin;
Bool
applysizehints(Client *c, int *x, int *y, int *w, int *h) {
Bool baseismin;
+ Monitor *m = c->mon;
/* set minimum possible */
*w = MAX(1, *w);
*h = MAX(1, *h);
/* set minimum possible */
*w = MAX(1, *w);
*h = MAX(1, *h);
- if(*x >
sx + s
w)
- *x =
s
w - WIDTH(c);
- if(*y >
sy + s
h)
- *y =
s
h - HEIGHT(c);
- if(*x + *w + 2 * c->bw <
s
x)
- *x =
s
x;
- if(*y + *h + 2 * c->bw <
s
y)
- *y =
s
y;
+ if(*x >
m->mx + m->m
w)
+ *x =
m->mx + m->m
w - WIDTH(c);
+ if(*y >
m->my + m->m
h)
+ *y =
m->my + m->m
h - HEIGHT(c);
+ if(*x + *w + 2 * c->bw <
m->m
x)
+ *x =
m->m
x;
+ if(*y + *h + 2 * c->bw <
m->m
y)
+ *y =
m->m
y;
if(*h < bh)
*h = bh;
if(*w < bh)
if(*h < bh)
*h = bh;
if(*w < bh)
@@
-635,16
+634,11
@@
drawbar(Monitor *m) {
}
dc.x = 0;
}
dc.x = 0;
-#ifdef XINERAMA
if(mons->next) { /* more than a single monitor */
if(mons->next) { /* more than a single monitor */
- char buf[2];
- buf[0] = m->screen_number + '0';
- buf[1] = '\0';
- dc.w = TEXTW(buf);
- drawtext(buf, selmon == m ? dc.sel : dc.norm, True);
+ dc.w = TEXTW(monsyms[m->screen_number]);
+ drawtext(monsyms[m->screen_number], selmon == m ? dc.sel : dc.norm, True);
dc.x += dc.w;
}
dc.x += dc.w;
}
-#endif /* XINERAMA */
m->btx = dc.x;
for(i = 0; i < LENGTH(tags); i++) {
dc.w = TEXTW(tags[i]);
m->btx = dc.x;
for(i = 0; i < LENGTH(tags); i++) {
dc.w = TEXTW(tags[i]);
@@
-802,7
+796,6
@@
focusin(XEvent *e) { /* there are some broken focus acquiring clients */
XSetInputFocus(dpy, selmon->sel->win, RevertToPointerRoot, CurrentTime);
}
XSetInputFocus(dpy, selmon->sel->win, RevertToPointerRoot, CurrentTime);
}
-#ifdef XINERAMA
void
focusmon(const Arg *arg) {
Monitor *m;
void
focusmon(const Arg *arg) {
Monitor *m;
@@
-813,7
+806,6
@@
focusmon(const Arg *arg) {
selmon = m;
focus(NULL);
}
selmon = m;
focus(NULL);
}
-#endif /* XINERAMA */
void
focusstack(const Arg *arg) {
void
focusstack(const Arg *arg) {
@@
-1200,7
+1192,7
@@
pointertomon(int x, int y) {
for(m = mons; m; m = m->next)
if(INRECT(x, y, m->wx, m->wy, m->ww, m->wh))
return m;
for(m = mons; m; m = m->next)
if(INRECT(x, y, m->wx, m->wy, m->ww, m->wh))
return m;
- return
mons
;
+ return
selmon
;
}
void
}
void
@@
-1375,6
+1367,7
@@
void
sendmon(Client *c, Monitor *m) {
if(c->mon == m)
return;
sendmon(Client *c, Monitor *m) {
if(c->mon == m)
return;
+ unfocus(c);
detach(c);
detachstack(c);
c->mon = m;
detach(c);
detachstack(c);
c->mon = m;
@@
-1429,8
+1422,6
@@
setup(void) {
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
initfont(font);
screen = DefaultScreen(dpy);
root = RootWindow(dpy, screen);
initfont(font);
- sx = 0;
- sy = 0;
sw = DisplayWidth(dpy, screen);
sh = DisplayHeight(dpy, screen);
bh = dc.h = dc.font.height + 2;
sw = DisplayWidth(dpy, screen);
sh = DisplayHeight(dpy, screen);
bh = dc.h = dc.font.height + 2;
@@
-1530,7
+1521,6
@@
tag(const Arg *arg) {
}
}
}
}
-#ifdef XINERAMA
void
tagmon(const Arg *arg) {
Monitor *m;
void
tagmon(const Arg *arg) {
Monitor *m;
@@
-1539,7
+1529,6
@@
tagmon(const Arg *arg) {
return;
sendmon(selmon->sel, m);
}
return;
sendmon(selmon->sel, m);
}
-#endif /* XINERAMA */
int
textnw(const char *text, unsigned int len) {
int
textnw(const char *text, unsigned int len) {
@@
-1735,9
+1724,9
@@
updategeom(void) {
/* default monitor setup */
{
m->screen_number = 0;
/* default monitor setup */
{
m->screen_number = 0;
- m->
wx = sx
;
- m->my = m->wy =
sy
;
- m->ww = sw;
+ m->
mx = m->wx = 0
;
+ m->my = m->wy =
0
;
+ m->
mw = m->
ww = sw;
m->mh = m->wh = sh;
}
m->mh = m->wh = sh;
}
@@
-1766,7
+1755,7
@@
updategeom(void) {
/* select focused monitor */
cleanupmons();
/* select focused monitor */
cleanupmons();
- mons = newmons;
+
selmon =
mons = newmons;
selmon = wintomon(root);
}
selmon = wintomon(root);
}
@@
-1899,7
+1888,7
@@
wintomon(Window w) {
return m;
if((c = wintoclient(w)))
return c->mon;
return m;
if((c = wintoclient(w)))
return c->mon;
- return
mons
;
+ return
selmon
;
}
/* There's no way to check accesses to destroyed windows, thus those cases are
}
/* There's no way to check accesses to destroyed windows, thus those cases are