fixed several issues

This commit is contained in:
garbeam 2005-12-11 16:47:23 +02:00
parent 304d22ed62
commit 55b6611a50
16 changed files with 66 additions and 54 deletions

View File

@ -47,8 +47,10 @@ void destroy_area(Area *a)
{
Client *c;
a->layout->deinit(a);
while ((c = cext_stack_get_top_item(&a->clients)))
while ((c = cext_stack_get_top_item(&a->clients))) {
cext_detach_item(&a->clients, c);
cext_attach_item(&detached, c);
}
ixp_remove_file(ixps, a->file[A_PREFIX]);
cext_detach_item(&areas, a);
free(a);

View File

@ -47,8 +47,7 @@ void set_client_state(Client * c, int state)
data[0] = (long) state;
data[1] = (long) None;
XChangeProperty(dpy, c->win, wm_state, wm_state, 32,
PropModeReplace, (unsigned char *) data, 2);
XChangeProperty(dpy, c->win, wm_state, wm_state, 32, PropModeReplace, (unsigned char *) data, 2);
}
void show_client(Client * c)
@ -83,12 +82,10 @@ void grab_client(Client * c, unsigned long mod, unsigned int button)
XGrabButton(dpy, button, mod, c->win, False,
ButtonPressMask, GrabModeAsync, GrabModeAsync, None, None);
if ((mod != AnyModifier) && num_lock_mask) {
XGrabButton(dpy, button, mod | num_lock_mask, c->win,
False, ButtonPressMask, GrabModeAsync, GrabModeAsync,
None, None);
XGrabButton(dpy, button, mod | num_lock_mask | LockMask,
c->win, False, ButtonPressMask, GrabModeAsync,
GrabModeAsync, None, None);
XGrabButton(dpy, button, mod | num_lock_mask, c->win, False, ButtonPressMask,
GrabModeAsync, GrabModeAsync, None, None);
XGrabButton(dpy, button, mod | num_lock_mask | LockMask, c->win, False, ButtonPressMask,
GrabModeAsync, GrabModeAsync, None, None);
}
XSelectInput(dpy, c->win, CLIENT_MASK);
XSync(dpy, False);
@ -198,6 +195,7 @@ void handle_client_property(Client * c, XPropertyEvent * e)
void destroy_client(Client * c)
{
cext_detach_item(&detached, c);
cext_detach_item(&clients, c);
ixp_remove_file(ixps, c->file[C_PREFIX]);
free(c);
@ -341,8 +339,10 @@ void detach_client(Client *c) {
}
if (c->destroyed)
destroy_client(c);
if ((p = get_sel_page()))
if ((p = get_sel_page())) {
sel_page(p);
draw_page(p);
}
}
Client *get_sel_client()

View File

@ -63,6 +63,7 @@ static void handle_buttonpress(XEvent * e)
Client *c;
XButtonPressedEvent *ev = &e->xbutton;
Frame *f = win_to_frame(ev->window);
fprintf(stderr, "%s\n", "handle_buttonpress");
if (f) {
handle_frame_buttonpress(ev, f);
@ -104,7 +105,8 @@ static void handle_configurerequest(XEvent * e)
unsigned int bw = 0, tabh = 0;
Frame *f = 0;
/* fprintf(stderr, "%s", "configure request\n"); */
fprintf(stderr, "%s\n", "handle_configurerequest");
c = win_to_client(ev->window);
ev->value_mask &= ~CWSibling;
@ -167,7 +169,7 @@ static void handle_destroynotify(XEvent * e)
{
XDestroyWindowEvent *ev = &e->xdestroywindow;
Client *c = win_to_client(ev->window);
/* fprintf(stderr, "destroy: client 0x%x\n", (int)ev->window); */
fprintf(stderr, "%s\n", "handle_destroynotify");
if (c) {
c->destroyed = True;
detach_client(c);
@ -177,6 +179,7 @@ static void handle_destroynotify(XEvent * e)
static void handle_expose(XEvent * e)
{
static Frame *f;
fprintf(stderr, "%s\n", "handle_expose");
if (e->xexpose.count == 0) {
f = win_to_frame(e->xbutton.window);
if (f)
@ -190,7 +193,7 @@ static void handle_maprequest(XEvent * e)
static XWindowAttributes wa;
static Client *c;
/* fprintf(stderr, "map: window 0x%x\n", (int)ev->window); */
fprintf(stderr, "%s\n", "handle_maprequest");
if (!XGetWindowAttributes(dpy, ev->window, &wa))
return;
if (wa.override_redirect)
@ -209,6 +212,7 @@ static void handle_motionnotify(XEvent * e)
{
Frame *f = win_to_frame(e->xmotion.window);
Cursor cursor;
fprintf(stderr, "%s\n", "handle_motionnotify");
if (f) {
cursor = cursor_for_motion(f, e->xmotion.x, e->xmotion.y);
if (cursor != f->cursor) {
@ -223,6 +227,7 @@ static void handle_propertynotify(XEvent * e)
XPropertyEvent *ev = &e->xproperty;
Client *c = win_to_client(ev->window);
fprintf(stderr, "%s\n", "handle_propertynotify");
if (c)
handle_client_property(c, ev);
}
@ -231,6 +236,7 @@ static void handle_unmapnotify(XEvent * e)
{
XUnmapEvent *ev = &e->xunmap;
Client *c;
fprintf(stderr, "%s\n", "handle_unmapnotify");
handle_ignore_enternotify_crap(e);
if ((c = win_to_client(ev->window)))
detach_client(c);
@ -244,6 +250,7 @@ static void handle_enternotify(XEvent * e)
if ((ev->mode != NotifyNormal) || (ev->detail == NotifyInferior))
return;
fprintf(stderr, "%s\n", "handle_enternotify");
c = win_to_client(ev->window);
if (c && c->frame && (ev->serial != ignore_enternotify_crap)) {
Frame *old = get_sel_frame();
@ -257,6 +264,7 @@ static void handle_enternotify(XEvent * e)
static void handle_ignore_enternotify_crap(XEvent *e)
{
fprintf(stderr, "%s\n", "handle_ignore_enternotify_crap");
ignore_enternotify_crap = e->xany.serial;
XSync(dpy, False);
}

View File

@ -123,14 +123,14 @@ void destroy_frame(Frame * f)
unsigned int tab_height(Frame * f)
{
if (_strtonum(f->file[F_TAB]->content, 1, 1))
if (blitz_strtonum(f->file[F_TAB]->content, 0, 1))
return font->ascent + font->descent + 4;
return 0;
}
unsigned int border_width(Frame * f)
{
if (_strtonum(f->file[F_BORDER]->content, 0, 1))
if (blitz_strtonum(f->file[F_BORDER]->content, 0, 1))
return BORDER_WIDTH;
return 0;
}
@ -305,7 +305,9 @@ void attach_client_to_frame(Frame *f, Client *c)
f->file[F_SEL_CLIENT]->content = c->file[C_PREFIX]->content;
cext_attach_item(&f->clients, c);
c->frame = f;
reparent_client(c, f->win, border_width(f), tab_height(f));
c->rect.x = border_width(f);
c->rect.y = tab_height(f);
reparent_client(c, f->win, c->rect.x, c->rect.y);
resize_frame(f, &f->rect, 0);
show_client(c);
sel_client(c);
@ -320,10 +322,12 @@ void detach_client_from_frame(Client *c)
wmii_move_ixpfile(c->file[C_PREFIX], def[WM_DETACHED_CLIENT]);
cext_detach_item(&f->clients, c);
if (!c->destroyed) {
cext_attach_item(&detached, c);
hide_client(c);
c->rect.x += f->rect.x;
c->rect.y += f->rect.y;
c->rect.x = f->rect.x;
c->rect.y = f->rect.y;
reparent_client(c, root, c->rect.x, c->rect.y);
XSync(dpy, False);
}
if ((client = cext_stack_get_top_item(&f->clients))) {
sel_client(client);
@ -344,7 +348,7 @@ static void select_client(void *obj, char *arg)
else if (!strncmp(arg, "next", 5))
c = cext_list_get_next_item(&f->clients, c);
else
c = cext_list_get_item(&f->clients, _strtonum(arg, 0, cext_sizeof(&f->clients) - 1));
c = cext_list_get_item(&f->clients, blitz_strtonum(arg, 0, cext_sizeof(&f->clients) - 1));
sel_client(c);
draw_frame(f, nil);
}

View File

@ -285,6 +285,8 @@ static void select_col(Frame *f, Bool raise)
cext_stack_top_item(&col->frames, f);
cext_stack_top_item(&acme->frames, f);
a->file[A_SEL_FRAME]->content = f->file[F_PREFIX]->content;
if (raise)
center_pointer(f);
}
static Container *get_frames_col(Area *a)
@ -317,7 +319,7 @@ static void select_frame(void *obj, char *arg)
else if (!strncmp(arg, "east", 5))
f = cext_stack_get_top_item(&((Column *)cext_list_get_next_item(&acme->columns, col))->frames);
else
f = cext_list_get_item(&col->frames, _strtonum(arg, 0, cext_sizeof(&col->frames) - 1));
f = cext_list_get_item(&col->frames, blitz_strtonum(arg, 0, cext_sizeof(&col->frames) - 1));
if (old != f) {
select_col(f, True);
center_pointer(f);

View File

@ -66,7 +66,6 @@ static void deinit_float(Area *a)
static Bool attach_float(Area *a, Client *c)
{
Frame *f = get_sel_frame_of_area(a);
Bool center = False;
/* check for tabbing? */
if (f && (((char *) f->file[F_LOCKED]->content)[0] == '1'))
@ -75,13 +74,10 @@ static Bool attach_float(Area *a, Client *c)
f = alloc_frame(&c->rect);
attach_frame_to_area(a, f);
cext_attach_item((Container *)a->aux, f);
center = True;
}
attach_client_to_frame(f, c);
if (a->page == get_sel_page())
XMapWindow(dpy, f->win);
if (center)
center_pointer(f);
select_float(f, True);
draw_frame(f, nil);
return True;
@ -109,8 +105,10 @@ static void select_float(Frame *f, Bool raise)
sel_client(cext_stack_get_top_item(&f->clients));
cext_stack_top_item(a->aux, f);
a->file[A_SEL_FRAME]->content = f->file[F_PREFIX]->content;
if (raise)
if (raise) {
XRaiseWindow(dpy, f->win);
center_pointer(f);
}
}
static Container *get_frames_float(Area *a)
@ -132,7 +130,7 @@ static void select_frame(void *obj, char *arg)
else if (!strncmp(arg, "next", 5))
f = cext_list_get_next_item(c, f);
else
f = cext_list_get_item(c, _strtonum(arg, 0, cext_sizeof(c) - 1));
f = cext_list_get_item(c, blitz_strtonum(arg, 0, cext_sizeof(c) - 1));
if (old != f) {
select_float(f, True);
center_pointer(f);

View File

@ -295,8 +295,8 @@ void mouse_move(Frame * f)
Window dummy;
XEvent ev;
/* borders */
int snapw = rect.width * _strtonum(def[WM_SNAP_VALUE]->content, 0, 1000) / 1000;
int snaph = rect.height * _strtonum(def[WM_SNAP_VALUE]->content, 0, 1000) / 1000;
int snapw = rect.width * blitz_strtonum(def[WM_SNAP_VALUE]->content, 0, 1000) / 1000;
int snaph = rect.height * blitz_strtonum(def[WM_SNAP_VALUE]->content, 0, 1000) / 1000;
unsigned int num;
unsigned int dmask;
XRectangle *rects = rectangles(&num);
@ -538,8 +538,8 @@ void mouse_resize(Frame * f, Align align)
Window dummy;
XEvent ev;
/* borders */
int snapw = rect.width * _strtonum(def[WM_SNAP_VALUE]->content, 0, 1000) / 1000;
int snaph = rect.height * _strtonum(def[WM_SNAP_VALUE]->content, 0, 1000) / 1000;
int snapw = rect.width * blitz_strtonum(def[WM_SNAP_VALUE]->content, 0, 1000) / 1000;
int snaph = rect.height * blitz_strtonum(def[WM_SNAP_VALUE]->content, 0, 1000) / 1000;
unsigned int dmask;
unsigned int num;
XRectangle *rects = rectangles(&num);

View File

@ -395,7 +395,6 @@ static void _detach_client(void *obj, char *cmd)
return;
c = cext_stack_get_top_item(&f->clients);
f->area->layout->detach(f->area, c);
cext_attach_item(&detached, c);
}
static void _select_page(void *obj, char *cmd)
@ -408,7 +407,7 @@ static void _select_page(void *obj, char *cmd)
else if (!strncmp(cmd, "next", 5))
p = cext_list_get_next_item(&pages, p);
else
p = cext_list_get_item(&pages, _strtonum(cmd, 0, cext_sizeof(&pages) - 1));
p = cext_list_get_item(&pages, blitz_strtonum(cmd, 0, cext_sizeof(&pages) - 1));
sel_page(p);
}

View File

@ -144,7 +144,7 @@ static void display(void *obj, char *arg)
{
if (!arg)
return;
displayed = _strtonum(arg, 0, 1);
displayed = blitz_strtonum(arg, 0, 1);
if (displayed) {
XMapRaised(dpy, win);
draw_bar(0, 0);
@ -202,7 +202,7 @@ static void draw()
if (!size)
return;
expandable = _strtonum(file[B_EXPANDABLE]->content, 0, size);
expandable = blitz_strtonum(file[B_EXPANDABLE]->content, 0, size);
snprintf(buf, sizeof(buf), "/%d", expandable);
if (!ixp_walk(ixps, buf))
expandable = 0;

View File

@ -367,7 +367,7 @@ static void handle_after_write(IXPServer * s, File * f)
}
}
} else if (f == files[K_GRAB_KB]) {
grabkb = _strtonum(files[K_GRAB_KB]->content, 0, 1);
grabkb = blitz_strtonum(files[K_GRAB_KB]->content, 0, 1);
if (!grabkb) {
XUngrabKeyboard(dpy, CurrentTime);
XUnmapWindow(dpy, win);

View File

@ -146,7 +146,7 @@ static void display(void *obj, char *arg)
{
if (!arg)
return;
if (_strtonum(arg, 0, 1))
if (blitz_strtonum(arg, 0, 1))
show();
else
hide();

View File

@ -56,5 +56,4 @@ char *blitz_modtostr(unsigned long mod);
unsigned long blitz_strtomod(char *val);
/* util.c */
long long
_strtonum(const char *numstr, long long minval, long long maxval);
long long blitz_strtonum(const char *numstr, long long minval, long long maxval);

View File

@ -139,7 +139,7 @@ void blitz_drawmeter(Display * dpy, Draw * d)
if (!d->data || strncmp(d->data, "%m:", 3))
return;
val = _strtonum(&d->data[3], 0, 100);
val = blitz_strtonum(&d->data[3], 0, 100);
draw_bg(dpy, d);
_draw_border(dpy, d);

View File

@ -69,13 +69,13 @@ int blitz_strtorect(XRectangle * root, XRectangle * r, char *val)
}
}
if (x && (sx = (x[0] >= '0') && (x[0] <= '9')))
r->x = _strtonum(x, 0, 65535);
r->x = blitz_strtonum(x, 0, 65535);
if (y && (sy = (y[0] >= '0') && (y[0] <= '9')))
r->y = _strtonum(y, 0, 65535);
r->y = blitz_strtonum(y, 0, 65535);
if (w && (sw = (w[0] >= '0') && (w[0] <= '9')))
r->width = _strtonum(w, 0, 65535);
r->width = blitz_strtonum(w, 0, 65535);
if (h && (sh = (h[0] >= '0') && (h[0] <= '9')))
r->height = _strtonum(h, 0, 65535);
r->height = blitz_strtonum(h, 0, 65535);
if (!sx && !sw && x && w
&& x[0] != '-' && x[0] != '+' && w[0] != '-' && w[0] != '+') {
@ -151,34 +151,34 @@ int blitz_strtorect(XRectangle * root, XRectangle * r, char *val)
if (x) {
p = strchr(x, '-');
if (p)
r->x -= _strtonum(++p, 0, 65535);
r->x -= blitz_strtonum(++p, 0, 65535);
p = strchr(x, '+');
if (p)
r->x += _strtonum(++p, 0, 65535);
r->x += blitz_strtonum(++p, 0, 65535);
}
if (y) {
p = strchr(y, '-');
if (p)
r->y -= _strtonum(++p, 0, 65535);
r->y -= blitz_strtonum(++p, 0, 65535);
p = strchr(y, '+');
if (p)
r->y += _strtonum(++p, 0, 65535);
r->y += blitz_strtonum(++p, 0, 65535);
}
if (w) {
p = strchr(w, '-');
if (p)
r->width -= _strtonum(++p, 0, 65535);
r->width -= blitz_strtonum(++p, 0, 65535);
p = strchr(w, '+');
if (p)
r->width += _strtonum(++p, 0, 65535);
r->width += blitz_strtonum(++p, 0, 65535);
}
if (h) {
p = strchr(h, '-');
if (p)
r->height -= _strtonum(++p, 0, 65535);
r->height -= blitz_strtonum(++p, 0, 65535);
p = strchr(h, '+');
if (p)
r->height += _strtonum(++p, 0, 65535);
r->height += blitz_strtonum(++p, 0, 65535);
}
return TRUE;
}

View File

@ -22,6 +22,6 @@ unsigned int blitz_strtobutton(char *val)
{
unsigned int res = 0;
if (val && strlen(val) > 6 && !strncmp(val, "Button", 6))
res = _strtonum(&val[6], 1, 5) + Button1;
res = blitz_strtonum(&val[6], 1, 5) + Button1;
return res;
}

View File

@ -7,11 +7,11 @@
#include "blitz.h"
long long _strtonum(const char *numstr, long long minval, long long maxval)
long long blitz_strtonum(const char *numstr, long long minval, long long maxval)
{
const char *errstr;
long long ret = cext_strtonum(numstr, minval, maxval, &errstr);
if (errstr)
fprintf(stderr, "liblitz: cannot convert '%s' into integer: %s\n", numstr, errstr);
fprintf(stderr, "liblitz: cannot convert '%s' into integer: %s [%lld..%lld]\n", numstr, errstr, minval, maxval);
return ret;
}