From 712cf1caa511dc568c2a009401ab37782dea67d2 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Tue, 4 Mar 2008 21:32:24 -0500 Subject: [PATCH] handle configure notify events --- dcompmgr.c | 25 +++++++++++++++++++++++-- screen.c | 11 ++++++++++- screen.h | 4 ++++ window.c | 16 ++++++++++++++++ window.h | 3 +++ 5 files changed, 56 insertions(+), 3 deletions(-) diff --git a/dcompmgr.c b/dcompmgr.c index 26363c4..f9d1ebb 100644 --- a/dcompmgr.c +++ b/dcompmgr.c @@ -54,15 +54,16 @@ event(d_display_t *dpy) xcb_destroy_notify_event_t *dev; d_screen_t *sc; d_window_t *w; + gboolean vis; dev = (xcb_destroy_notify_event_t*)ev; sc = display_screen_from_root(dpy, dev->event); if (!sc) break; w = screen_find_window(sc, dev->window); + vis = window_is_mapped(w); sc->window_hide(w); screen_remove_window(sc, w); - printf("** refresh needed **\n"); - screen_refresh(sc); + if (vis) screen_refresh(sc); break; } case XCB_REPARENT_NOTIFY: @@ -81,6 +82,7 @@ event(d_display_t *dpy) sc->window_hide(w); screen_remove_window(sc, w); } + screen_refresh(w->sc); break; } case XCB_MAP_NOTIFY: @@ -94,6 +96,7 @@ event(d_display_t *dpy) if (!sc) break; w = screen_find_window(sc, mev->window); sc->window_show(w); + screen_refresh(w->sc); break; } case XCB_UNMAP_NOTIFY: @@ -107,6 +110,24 @@ event(d_display_t *dpy) if (!sc) break; w = screen_find_window(sc, mev->window); sc->window_hide(w); + screen_refresh(w->sc); + break; + } + case XCB_CONFIGURE_NOTIFY: + { + xcb_configure_notify_event_t *cev; + d_screen_t *sc; + d_window_t *w, *above; + + cev = (xcb_configure_notify_event_t*)ev; + sc = display_screen_from_root(dpy, cev->event); + if (!sc) break; + w = screen_find_window(sc, cev->window); + sc->window_configure(w, cev->x, cev->y, + cev->width, cev->height, cev->border_width); + above = screen_find_window(sc, cev->above_sibling); + screen_stacking_move_above(sc, w, above); + screen_refresh(w->sc); break; } default: diff --git a/screen.c b/screen.c index 5a588d3..ada1b4f 100644 --- a/screen.c +++ b/screen.c @@ -279,6 +279,15 @@ screen_stacking_remove(d_screen_t *sc, struct d_window *w) list_remove(sc->stacking, w); } +void +screen_stacking_move_above(d_screen_t *sc, struct d_window *w, + struct d_window *above) +{ + d_list_it_t *wit = list_find(sc->stacking, w); + d_list_it_t *ait = list_find(sc->stacking, above); + list_move_before(sc->stacking, wit, ait); +} + static void screen_set_next_repaint(d_screen_t *sc) { @@ -295,7 +304,7 @@ screen_setup_default_functions(d_screen_t *sc) sc->window_show = window_show; sc->window_hide = window_hide; sc->window_become_zombie = window_become_zombie; - + sc->window_configure = window_configure; } void diff --git a/screen.h b/screen.h index 4c6d5c8..5d46555 100644 --- a/screen.h +++ b/screen.h @@ -33,6 +33,8 @@ typedef struct d_screen { void (*window_show)(struct d_window *w); void (*window_hide)(struct d_window *w); void (*window_become_zombie)(struct d_window *w); + void (*window_configure)(struct d_window *w, int x, int y, + int width, int height, int border_width); } d_screen_t; d_screen_t* screen_new(struct d_display *dpy, int num, xcb_screen_t *xcb); @@ -52,6 +54,8 @@ struct d_window* screen_find_window(d_screen_t *sc, xcb_window_t id); void screen_stacking_add(d_screen_t *sc, struct d_window *w); void screen_stacking_remove(d_screen_t *sc, struct d_window *w); +void screen_stacking_move_above(d_screen_t *sc, struct d_window *w, + struct d_window *above); void screen_setup_default_functions(d_screen_t *sc); diff --git a/window.c b/window.c index 658d10f..9c7847e 100644 --- a/window.c +++ b/window.c @@ -225,6 +225,7 @@ xcb_pixmap_t window_get_pixmap(d_window_t *pubw) { d_window_priv_t *w = (d_window_priv_t*)pubw; + if (w->ck_get_pixmap.sequence) { xcb_generic_error_t *err; //printf("** checking get pixmap 0x%x\n", w->id); @@ -238,3 +239,18 @@ window_get_pixmap(d_window_t *pubw) //printf("returning pixmap 0x%x for window 0x%x\n", w->pixmap, w->id); return w->pixmap; } + +void +window_configure(d_window_t *pubw, int x, int y, int width, int height, + int border_width) +{ + d_window_priv_t *w = (d_window_priv_t*)pubw; + + /* this overrides any reply from our get_geometry call */ + if (w->ck_get_geom.sequence) + w->ck_get_geom.sequence = 0; + w->x = x; + w->y = y; + w->w = width + border_width * 2; + w->h = height + border_width * 2; +} diff --git a/window.h b/window.h index c0484cb..b86f587 100644 --- a/window.h +++ b/window.h @@ -24,6 +24,9 @@ void window_hide(d_window_t *w); void window_become_zombie(d_window_t *w); +void window_configure(d_window_t *w, int x, int y, int width, int height, + int border_width); + gboolean window_is_zombie(d_window_t *w); gboolean window_is_input_only(d_window_t *w); gboolean window_is_mapped(d_window_t *w); -- 2.34.1