From c1569eedf417e32ea98f979de987ad2b9d180a15 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 23 Jan 2008 16:05:52 +0100 Subject: [PATCH] store simple window geometry --- config.c | 2 +- event.c | 18 ++++++++---------- structs.h | 1 + window.c | 6 ++++++ 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/config.c b/config.c index bcf03fb7..6890e879 100644 --- a/config.c +++ b/config.c @@ -355,8 +355,8 @@ config_parse_screen(cfg_t *cfg, int screen) statusbar->width = cfg_getint(cfgsectmp, "width"); statusbar->name = a_strdup(cfg_title(cfgsectmp)); statusbar->screen = screen; - create_widgets(cfgsectmp, statusbar); statusbar_preinit(statusbar); + create_widgets(cfgsectmp, statusbar); statusbar_list_push(&virtscreen->statusbar, statusbar); } diff --git a/event.c b/event.c index 9a56aed7..01e7a3f4 100644 --- a/event.c +++ b/event.c @@ -88,8 +88,9 @@ handle_event_buttonpress(XEvent *e) case Right: for(widget = statusbar->widgets; widget; widget = widget->next) if(ev->y >= widget->area.x && ev->y < widget->area.x + widget->area.width - && statusbar->height - ev->x >= widget->area.y - && statusbar->height - ev->x < widget->area.y + widget->area.height) + && statusbar->sw->geometry.height - ev->x >= widget->area.y + && statusbar->sw->geometry.height - ev->x + < widget->area.y + widget->area.height) { widget->button_press(widget, ev); return; @@ -97,8 +98,9 @@ handle_event_buttonpress(XEvent *e) break; default: for(widget = statusbar->widgets; widget; widget = widget->next) - if(statusbar->width - ev->y >= widget->area.x - && statusbar->width - ev->y < widget->area.x + widget->area.width + if(statusbar->sw->geometry.width - ev->y >= widget->area.x + && statusbar->sw->geometry.width - ev->y + < widget->area.x + widget->area.width && ev->x >= widget->area.y && ev->x < widget->area.y + widget->area.height) { widget->button_press(widget, ev); @@ -191,6 +193,7 @@ handle_event_configurenotify(XEvent * e) int screen; Area area; + /* XXX this is all crap -- need to rewrite everything */ for(screen = 0; screen < ScreenCount(e->xany.display); screen++) if(ev->window == RootWindow(e->xany.display, screen) && (ev->width != DisplayWidth(e->xany.display, screen) @@ -201,12 +204,7 @@ handle_event_configurenotify(XEvent * e) /* update statusbar */ area = get_screen_area(screen, NULL, &globalconf.screens[screen].padding); - globalconf.screens[screen].statusbar->width = area.width; - - XResizeWindow(e->xany.display, - globalconf.screens[screen].statusbar->sw->window, - globalconf.screens[screen].statusbar->width, - globalconf.screens[screen].statusbar->height); + globalconf.screens[screen].statusbar->sw->geometry.width = area.width; widget_invalidate_cache(screen, WIDGET_CACHE_ALL); globalconf.screens[screen].need_arrange = True; diff --git a/structs.h b/structs.h index 5be8c590..93195e97 100644 --- a/structs.h +++ b/structs.h @@ -132,6 +132,7 @@ typedef struct SimpleWindow { Window window; Drawable drawable; + Area geometry; } SimpleWindow; /** Status bar */ diff --git a/window.c b/window.c index a88dc331..6750db88 100644 --- a/window.c +++ b/window.c @@ -185,6 +185,12 @@ simplewindow_new(int phys_screen, int x, int y, unsigned int w, unsigned int h, SimpleWindow *sw; sw = p_new(SimpleWindow, 1); + + sw->geometry.x = x; + sw->geometry.y = y; + sw->geometry.width = w; + sw->geometry.height = h; + wa.event_mask = SubstructureRedirectMask | SubstructureNotifyMask | EnterWindowMask | LeaveWindowMask | StructureNotifyMask; wa.cursor = globalconf.cursor[CurNormal];