fixed annoying bug in wmikeys after introduction of container

This commit is contained in:
garbeam 2005-12-08 19:14:20 +02:00
parent 38f1663df9
commit 5b66795946
4 changed files with 11 additions and 17 deletions

View File

@ -45,7 +45,6 @@ static int displayed = 0;
static char *sockfile = 0;
static File *file[B_LAST];
static Container items = {0};
static unsigned int id = 0;
static Pixmap pmap;
static XFontStruct *font;
@ -125,12 +124,12 @@ static void _destroy(void *obj, char *arg)
static void reset(void *obj, char *arg)
{
int i;
size_t size = cext_sizeof(&items);
char buf[512];
for (i = 0; i < id; i++) {
for (i = 0; i < size; i++) {
snprintf(buf, sizeof(buf), "/%d", i + 1);
ixps->remove(ixps, buf);
}
id = 0;
draw_bar(0, 0);
}
@ -201,7 +200,7 @@ static void draw()
if (!size)
return;
expandable = _strtonum(file[B_EXPANDABLE]->content, 0, id);
expandable = _strtonum(file[B_EXPANDABLE]->content, 0, size);
snprintf(buf, sizeof(buf), "/%d", expandable);
if (!ixp_walk(ixps, buf))
expandable = 0;
@ -417,14 +416,13 @@ static void handle_before_read(IXPServer * s, File * f)
{
char buf[64];
if (f == file[B_GEOMETRY]) {
snprintf(buf, sizeof(buf), "%d,%d,%d,%d", brect.x, brect.y,
brect.width, brect.height);
snprintf(buf, sizeof(buf), "%d,%d,%d,%d", brect.x, brect.y, brect.width, brect.height);
if (f->content)
free(f->content);
f->content = strdup(buf);
f->size = strlen(buf);
} else if (f == file[B_NEW]) {
snprintf(buf, sizeof(buf), "%d", ++id);
snprintf(buf, sizeof(buf), "%d", cext_sizeof(&items));
if (f->content)
free(f->content);
f->content = strdup(buf);

View File

@ -187,17 +187,14 @@ static void emulate_key_press(unsigned long mod, KeyCode key)
XSync(dpy, False);
}
static void
handle_shortcut_chain(Window w, Shortcut * processed, char *prefix,
int grab)
static void handle_shortcut_chain(Window w, Shortcut * processed, char *prefix, int grab)
{
unsigned long mod;
KeyCode key;
Shortcut *s = processed->next;
if (grab) {
XGrabKeyboard(dpy, w, True, GrabModeAsync,
GrabModeAsync, CurrentTime);
XGrabKeyboard(dpy, w, True, GrabModeAsync, GrabModeAsync, CurrentTime);
XMapRaised(dpy, win);
}
draw_shortcut_box(prefix);
@ -237,7 +234,7 @@ static void handle_shortcut_gkb(Window w, unsigned long mod, KeyCode key)
comp.mod = mod;
comp.key = key;
s = cext_find_item(&shortcuts, &s, comp_shortcut);
s = cext_find_item(&shortcuts, &comp, comp_shortcut);
if (s && s->cmdfile && s->cmdfile->content) {
spawn(dpy, s->cmdfile->content);
return;
@ -254,7 +251,7 @@ static void handle_shortcut(Window w, unsigned long mod, KeyCode key)
comp.mod = mod;
comp.key = key;
s = cext_find_item(&shortcuts, &s, comp_shortcut);
s = cext_find_item(&shortcuts, &comp, comp_shortcut);
if (s && s->cmdfile && s->cmdfile->content) {
spawn(dpy, s->cmdfile->content);
return;

View File

@ -182,8 +182,7 @@ static void update_offsets()
w = cmdw + 2 * seek;
for (i = offset[OFF_CURR] - 1; i >= 0; i--) {
item = cext_list_get_item(&items, i);
for (i = offset[OFF_CURR] - 1; (i >= 0) && (item = cext_list_get_item(&items, i)); i--) {
w += XTextWidth(font, item->content, strlen(item->content)) + mrect.height;
if (w > mrect.width)
break;

View File

@ -90,7 +90,7 @@ wmir write /bar/$clab/bgcolor $SEL_BG_COLOR
wmir write /bar/$clab/bordercolor $SEL_BG_COLOR
barsucks $clab
wmir write /bar/expandable 2
wmir write /bar/expandable 1
wmir write /bar/geometry 0,south,east,$BAR_HEIGHT
wmir write /bar/ctl 'display 1'