Xinqi Bao's Git
projects
/
dwm.git
/ blobdiff
summary
|
log
|
commit
|
diff
|
tree
raw
|
inline
| side by side
added dwm favicon
[dwm.git]
/
draw.c
diff --git
a/draw.c
b/draw.c
index
b5d8bd2
..
869c2f2
100644
(file)
--- a/
draw.c
+++ b/
draw.c
@@
-3,7
+3,6
@@
* See LICENSE file for license details.
*/
#include "dwm.h"
* See LICENSE file for license details.
*/
#include "dwm.h"
-
#include <stdio.h>
#include <string.h>
#include <X11/Xlocale.h>
#include <stdio.h>
#include <string.h>
#include <X11/Xlocale.h>
@@
-31,7
+30,7
@@
drawborder(void)
}
static unsigned int
}
static unsigned int
-textnw(char *text, unsigned int len)
+textnw(c
onst c
har *text, unsigned int len)
{
XRectangle r;
{
XRectangle r;
@@
-43,7
+42,7
@@
textnw(char *text, unsigned int len)
}
static void
}
static void
-drawtext(const char *text, Bool invert
, Bool border
)
+drawtext(const char *text, Bool invert)
{
int x, y, w, h;
static char buf[256];
{
int x, y, w, h;
static char buf[256];
@@
-53,14
+52,12
@@
drawtext(const char *text, Bool invert, Bool border)
XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg);
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg);
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
-
- w = 0;
- if(border)
- drawborder();
+ drawborder();
if(!text)
return;
if(!text)
return;
+ w = 0;
len = strlen(text);
if(len >= sizeof(buf))
len = sizeof(buf) - 1;
len = strlen(text);
if(len >= sizeof(buf))
len = sizeof(buf) - 1;
@@
-99,7
+96,7
@@
drawall()
{
Client *c;
{
Client *c;
- for(c = clients; c; c = getnext(c->next
, tsel
))
+ for(c = clients; c; c = getnext(c->next))
drawtitle(c);
drawstatus();
}
drawtitle(c);
drawstatus();
}
@@
-107,31
+104,30
@@
drawall()
void
drawstatus()
{
void
drawstatus()
{
- int i;
+ int i
, x
;
Bool istile = arrange == dotile;
dc.x = dc.y = 0;
dc.w = bw;
Bool istile = arrange == dotile;
dc.x = dc.y = 0;
dc.w = bw;
- drawtext(NULL, !istile
, False
);
+ drawtext(NULL, !istile);
dc.w = 0;
dc.w = 0;
- for(i = 0; i <
TLast
; i++) {
+ for(i = 0; i <
ntags
; i++) {
dc.x += dc.w;
dc.w = textw(tags[i]);
if(istile)
dc.x += dc.w;
dc.w = textw(tags[i]);
if(istile)
- drawtext(tags[i], (i == tsel)
, True
);
+ drawtext(tags[i], (i == tsel));
else
else
- drawtext(tags[i], (i != tsel), True);
- }
- if(sel) {
- dc.x += dc.w;
- dc.w = textw(sel->name);
- drawtext(sel->name, istile, True);
+ drawtext(tags[i], (i != tsel));
}
}
+ x = dc.x + dc.w;
dc.w = textw(stext);
dc.x = bx + bw - dc.w;
dc.w = textw(stext);
dc.x = bx + bw - dc.w;
- drawtext(stext, !istile, False);
-
+ drawtext(stext, !istile);
+ if(sel && ((dc.w = dc.x - x) >= bh)) {
+ dc.x = x;
+ drawtext(sel->name, istile);
+ }
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
XSync(dpy, False);
}
XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0);
XSync(dpy, False);
}
@@
-142,7
+138,7
@@
drawtitle(Client *c)
int i;
Bool istile = arrange == dotile;
int i;
Bool istile = arrange == dotile;
- if(c == sel) {
+ if(c == sel
&& issel
) {
drawstatus();
XUnmapWindow(dpy, c->title);
XSetWindowBorder(dpy, c->win, dc.fg);
drawstatus();
XUnmapWindow(dpy, c->title);
XSetWindowBorder(dpy, c->win, dc.fg);
@@
-155,16
+151,16
@@
drawtitle(Client *c)
dc.x = dc.y = 0;
dc.w = 0;
dc.x = dc.y = 0;
dc.w = 0;
- for(i = 0; i <
TLast
; i++) {
+ for(i = 0; i <
ntags
; i++) {
if(c->tags[i]) {
dc.x += dc.w;
if(c->tags[i]) {
dc.x += dc.w;
- dc.w = textw(
c->
tags[i]);
- drawtext(
c->tags[i], !istile, Tru
e);
+ dc.w = textw(tags[i]);
+ drawtext(
tags[i], !istil
e);
}
}
dc.x += dc.w;
dc.w = textw(c->name);
}
}
dc.x += dc.w;
dc.w = textw(c->name);
- drawtext(c->name, !istile
, True
);
+ drawtext(c->name, !istile);
XCopyArea(dpy, dc.drawable, c->title, dc.gc, 0, 0, c->tw, c->th, 0, 0);
XSync(dpy, False);
}
XCopyArea(dpy, dc.drawable, c->title, dc.gc, 0, 0, c->tw, c->th, 0, 0);
XSync(dpy, False);
}
@@
-231,7
+227,7
@@
setfont(const char *fontstr)
}
unsigned int
}
unsigned int
-textw(char *text)
+textw(c
onst c
har *text)
{
return textnw(text, strlen(text)) + dc.font.height;
}
{
return textnw(text, strlen(text)) + dc.font.height;
}