bar.c
author Anselm R. Garbe <garbeam@gmail.com>
Sat, 15 Sep 2007 13:16:54 +0200
changeset 988 aea51354bbe6
parent 987 draw.c@ea0cef59c3a3
child 989 5f7018237edb
permissions -rw-r--r--
moved bar-related stuff to bar.c (merged draw.c into that)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
910
c13cb8c6b7a5 referred to LICENSE file
Anselm R. Garbe <arg@suckless.org>
parents: 909
diff changeset
     1
/* See LICENSE file for copyright and license details. */
793
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
     2
#include "dwm.h"
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
     3
#include <string.h>
988
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
     4
#include <stdio.h>
793
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
     5
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
     6
/* static */
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
     7
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
     8
static void
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
     9
drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]) {
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    10
	int x;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    11
	XGCValues gcv;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    12
	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    13
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    14
	gcv.foreground = col[ColFG];
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    15
	XChangeGC(dpy, dc.gc, GCForeground, &gcv);
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    16
	x = (dc.font.ascent + dc.font.descent + 2) / 4;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    17
	r.x = dc.x + 1;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    18
	r.y = dc.y + 1;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    19
	if(filled) {
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    20
		r.width = r.height = x + 1;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    21
		XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    22
	}
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    23
	else if(empty) {
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    24
		r.width = r.height = x;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    25
		XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1);
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    26
	}
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    27
}
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    28
988
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    29
static unsigned long
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    30
initcolor(const char *colstr) {
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    31
	Colormap cmap = DefaultColormap(dpy, screen);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    32
	XColor color;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    33
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    34
	if(!XAllocNamedColor(dpy, cmap, colstr, &color, &color))
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    35
		eprint("error, cannot allocate color '%s'\n", colstr);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    36
	return color.pixel;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    37
}
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    38
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    39
static void
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    40
initfont(const char *fontstr) {
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    41
	char *def, **missing;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    42
	int i, n;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    43
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    44
	missing = NULL;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    45
	if(dc.font.set)
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    46
		XFreeFontSet(dpy, dc.font.set);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    47
	dc.font.set = XCreateFontSet(dpy, fontstr, &missing, &n, &def);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    48
	if(missing) {
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    49
		while(n--)
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    50
			fprintf(stderr, "dwm: missing fontset: %s\n", missing[n]);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    51
		XFreeStringList(missing);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    52
	}
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    53
	if(dc.font.set) {
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    54
		XFontSetExtents *font_extents;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    55
		XFontStruct **xfonts;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    56
		char **font_names;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    57
		dc.font.ascent = dc.font.descent = 0;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    58
		font_extents = XExtentsOfFontSet(dc.font.set);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    59
		n = XFontsOfFontSet(dc.font.set, &xfonts, &font_names);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    60
		for(i = 0, dc.font.ascent = 0, dc.font.descent = 0; i < n; i++) {
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    61
			if(dc.font.ascent < (*xfonts)->ascent)
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    62
				dc.font.ascent = (*xfonts)->ascent;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    63
			if(dc.font.descent < (*xfonts)->descent)
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    64
				dc.font.descent = (*xfonts)->descent;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    65
			xfonts++;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    66
		}
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    67
	}
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    68
	else {
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    69
		if(dc.font.xfont)
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    70
			XFreeFont(dpy, dc.font.xfont);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    71
		dc.font.xfont = NULL;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    72
		if(!(dc.font.xfont = XLoadQueryFont(dpy, fontstr)))
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    73
			eprint("error, cannot load font: '%s'\n", fontstr);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    74
		dc.font.ascent = dc.font.xfont->ascent;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    75
		dc.font.descent = dc.font.xfont->descent;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    76
	}
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    77
	dc.font.height = dc.font.ascent + dc.font.descent;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    78
}
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
    79
793
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    80
static Bool
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    81
isoccupied(unsigned int t) {
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    82
	Client *c;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    83
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    84
	for(c = clients; c; c = c->next)
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    85
		if(c->tags[t])
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    86
			return True;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    87
	return False;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    88
}
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
    89
794
6fa07beba3a7 fixed order
Anselm R. Garbe <arg@suckless.org>
parents: 793
diff changeset
    90
static unsigned int
6fa07beba3a7 fixed order
Anselm R. Garbe <arg@suckless.org>
parents: 793
diff changeset
    91
textnw(const char *text, unsigned int len) {
6fa07beba3a7 fixed order
Anselm R. Garbe <arg@suckless.org>
parents: 793
diff changeset
    92
	XRectangle r;
6fa07beba3a7 fixed order
Anselm R. Garbe <arg@suckless.org>
parents: 793
diff changeset
    93
6fa07beba3a7 fixed order
Anselm R. Garbe <arg@suckless.org>
parents: 793
diff changeset
    94
	if(dc.font.set) {
6fa07beba3a7 fixed order
Anselm R. Garbe <arg@suckless.org>
parents: 793
diff changeset
    95
		XmbTextExtents(dc.font.set, text, len, NULL, &r);
6fa07beba3a7 fixed order
Anselm R. Garbe <arg@suckless.org>
parents: 793
diff changeset
    96
		return r.width;
6fa07beba3a7 fixed order
Anselm R. Garbe <arg@suckless.org>
parents: 793
diff changeset
    97
	}
6fa07beba3a7 fixed order
Anselm R. Garbe <arg@suckless.org>
parents: 793
diff changeset
    98
	return XTextWidth(dc.font.xfont, text, len);
6fa07beba3a7 fixed order
Anselm R. Garbe <arg@suckless.org>
parents: 793
diff changeset
    99
}
6fa07beba3a7 fixed order
Anselm R. Garbe <arg@suckless.org>
parents: 793
diff changeset
   100
988
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   101
static void
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   102
drawtext(const char *text, unsigned long col[ColLast]) {
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   103
	int x, y, w, h;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   104
	static char buf[256];
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   105
	unsigned int len, olen;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   106
	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   107
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   108
	XSetForeground(dpy, dc.gc, col[ColBG]);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   109
	XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   110
	if(!text)
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   111
		return;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   112
	w = 0;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   113
	olen = len = strlen(text);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   114
	if(len >= sizeof buf)
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   115
		len = sizeof buf - 1;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   116
	memcpy(buf, text, len);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   117
	buf[len] = 0;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   118
	h = dc.font.ascent + dc.font.descent;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   119
	y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   120
	x = dc.x + (h / 2);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   121
	/* shorten text if necessary */
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   122
	while(len && (w = textnw(buf, len)) > dc.w - h)
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   123
		buf[--len] = 0;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   124
	if(len < olen) {
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   125
		if(len > 1)
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   126
			buf[len - 1] = '.';
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   127
		if(len > 2)
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   128
			buf[len - 2] = '.';
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   129
		if(len > 3)
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   130
			buf[len - 3] = '.';
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   131
	}
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   132
	if(w > dc.w)
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   133
		return; /* too long */
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   134
	XSetForeground(dpy, dc.gc, col[ColFG]);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   135
	if(dc.font.set)
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   136
		XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   137
	else
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   138
		XDrawString(dpy, dc.drawable, dc.gc, x, y, buf, len);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   139
}
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   140
793
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   141
/* extern */
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   142
988
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   143
unsigned int bh;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   144
unsigned int bpos = BARPOS;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   145
DC dc = {0};
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   146
Window barwin;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   147
793
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   148
void
987
ea0cef59c3a3 renamed drawstatus into drawbar
Anselm R. Garbe <garbeam@gmail.com>
parents: 960
diff changeset
   149
drawbar(void) {
793
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   150
	int i, x;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   151
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   152
	dc.x = dc.y = 0;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   153
	for(i = 0; i < ntags; i++) {
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   154
		dc.w = textw(tags[i]);
960
b5f856fcef4c renamed seltag into seltags
Anselm R. Garbe <garbeam@gmail.com>
parents: 946
diff changeset
   155
		if(seltags[i]) {
793
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   156
			drawtext(tags[i], dc.sel);
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   157
			drawsquare(sel && sel->tags[i], isoccupied(i), dc.sel);
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   158
		}
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   159
		else {
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   160
			drawtext(tags[i], dc.norm);
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   161
			drawsquare(sel && sel->tags[i], isoccupied(i), dc.norm);
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   162
		}
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   163
		dc.x += dc.w;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   164
	}
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   165
	dc.w = blw;
946
b938876de936 made Layout a static struct in layout.c, added some convenience getters in layout.c, now lt->arrange accesses are not possible anymore, arrange() is the super-arrange function which sets up all layouts
Anselm R. Garbe <garbeam@gmail.com>
parents: 910
diff changeset
   166
	drawtext(getsymbol(), dc.norm);
793
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   167
	x = dc.x + dc.w;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   168
	dc.w = textw(stext);
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   169
	dc.x = sw - dc.w;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   170
	if(dc.x < x) {
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   171
		dc.x = x;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   172
		dc.w = sw - x;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   173
	}
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   174
	drawtext(stext, dc.norm);
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   175
	if((dc.w = dc.x - x) > bh) {
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   176
		dc.x = x;
817
90435b444620 dwm draws a small caret before the client title if it's a versatile client
Anselm R. Garbe <arg@suckless.org>
parents: 794
diff changeset
   177
		if(sel) {
90435b444620 dwm draws a small caret before the client title if it's a versatile client
Anselm R. Garbe <arg@suckless.org>
parents: 794
diff changeset
   178
			drawtext(sel->name, dc.sel);
837
123231b9eb87 renamed untiled into floating, keeping tiled instead of tiling (afaik tiled sounds more correct) - English speakers convinced me
Anselm R. Garbe <arg@suckless.org>
parents: 830
diff changeset
   179
			drawsquare(sel->ismax, sel->isfloating, dc.sel);
817
90435b444620 dwm draws a small caret before the client title if it's a versatile client
Anselm R. Garbe <arg@suckless.org>
parents: 794
diff changeset
   180
		}
90435b444620 dwm draws a small caret before the client title if it's a versatile client
Anselm R. Garbe <arg@suckless.org>
parents: 794
diff changeset
   181
		else
90435b444620 dwm draws a small caret before the client title if it's a versatile client
Anselm R. Garbe <arg@suckless.org>
parents: 794
diff changeset
   182
			drawtext(NULL, dc.norm);
793
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   183
	}
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   184
	XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, sw, bh, 0, 0);
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   185
	XSync(dpy, False);
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   186
}
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   187
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   188
void
988
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   189
initbar(void) {
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   190
	XSetWindowAttributes wa;
793
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   191
988
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   192
	dc.norm[ColBorder] = initcolor(NORMBORDERCOLOR);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   193
	dc.norm[ColBG] = initcolor(NORMBGCOLOR);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   194
	dc.norm[ColFG] = initcolor(NORMFGCOLOR);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   195
	dc.sel[ColBorder] = initcolor(SELBORDERCOLOR);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   196
	dc.sel[ColBG] = initcolor(SELBGCOLOR);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   197
	dc.sel[ColFG] = initcolor(SELFGCOLOR);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   198
	initfont(FONT);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   199
	dc.h = bh = dc.font.height + 2;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   200
	wa.override_redirect = 1;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   201
	wa.background_pixmap = ParentRelative;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   202
	wa.event_mask = ButtonPressMask | ExposureMask;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   203
	barwin = XCreateWindow(dpy, root, sx, sy, sw, bh, 0,
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   204
			DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen),
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   205
			CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   206
	XDefineCursor(dpy, barwin, cursor[CurNormal]);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   207
	updatebarpos();
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   208
	XMapRaised(dpy, barwin);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   209
	strcpy(stext, "dwm-"VERSION);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   210
	dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   211
	dc.gc = XCreateGC(dpy, root, 0, 0);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   212
	XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   213
	if(!dc.font.set)
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   214
		XSetFont(dpy, dc.gc, dc.font.xfont->fid);
793
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   215
}
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   216
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   217
unsigned int
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   218
textw(const char *text) {
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   219
	return textnw(text, strlen(text)) + dc.font.height;
79cb72e82b21 added draw.c again (except getcolor and setfont which are helpers in main.c)
Anselm R. Garbe <arg@suckless.org>
parents:
diff changeset
   220
}
988
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   221
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   222
void
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   223
togglebar(const char *arg) {
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   224
	if(bpos == BarOff)
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   225
		bpos = (BARPOS == BarOff) ? BarTop : BARPOS;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   226
	else
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   227
		bpos = BarOff;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   228
	updatebarpos();
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   229
	arrange();
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   230
}
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   231
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   232
void
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   233
updatebarpos(void) {
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   234
	XEvent ev;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   235
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   236
	wax = sx;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   237
	way = sy;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   238
	wah = sh;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   239
	waw = sw;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   240
	switch(bpos) {
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   241
	default:
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   242
		wah -= bh;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   243
		way += bh;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   244
		XMoveWindow(dpy, barwin, sx, sy);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   245
		break;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   246
	case BarBot:
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   247
		wah -= bh;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   248
		XMoveWindow(dpy, barwin, sx, sy + wah);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   249
		break;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   250
	case BarOff:
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   251
		XMoveWindow(dpy, barwin, sx, sy - bh);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   252
		break;
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   253
	}
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   254
	XSync(dpy, False);
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   255
	while(XCheckMaskEvent(dpy, EnterWindowMask, &ev));
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   256
}
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   257
aea51354bbe6 moved bar-related stuff to bar.c (merged draw.c into that)
Anselm R. Garbe <garbeam@gmail.com>
parents: 987
diff changeset
   258