From 11808514b4ebd79f94dc628c91405ccf4515d6cf Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Sat, 22 Nov 2008 00:39:06 +0100 Subject: [PATCH] event: Add configureevent function (to replace configurerequest) --- src/client.c | 2 -- src/event.c | 75 +++++++++++++++++++++++++++++----------------------- src/frame.c | 10 +++---- src/wmfs.h | 2 +- 4 files changed, 48 insertions(+), 41 deletions(-) diff --git a/src/client.c b/src/client.c index 2af5b7c..007f944 100644 --- a/src/client.c +++ b/src/client.c @@ -72,8 +72,6 @@ client_configure(Client *c) { XConfigureEvent ev; - client_moveresize(c, c->geo, True); - ev.type = ConfigureNotify; ev.event = c->win; ev.window = c->win; diff --git a/src/event.c b/src/event.c index b4f76b7..8df7339 100644 --- a/src/event.c +++ b/src/event.c @@ -98,49 +98,58 @@ buttonpress(XButtonEvent *ev) return; } -/** ConfigureRequest handle event - * \param ev XConfigureRequestEvent pointer +/** ConfigureRequest & ConfigureNotify handle event + * \param ev XEvent pointer */ void -configurerequest(XConfigureRequestEvent *ev) +configureevent(XEvent *ev) { - Client *c; XWindowChanges wc; + XWindowAttributes win_at, ev_at; + XRectangle geo = { 0 }; + Client *c; - if((c = client_gb_win(ev->window))) + /* Check part */ + if((c = client_gb_win(ev->xconfigurerequest.window)) + || (c = client_gb_win(ev->xconfigure.window))) { CHECK(!c->tile); CHECK(!c->lmax); - - c->geo.x = ev->x + BORDH; - c->geo.y = ev->y + TBARH; - c->geo.width = ev->width; - c->geo.height = ev->height; - - wc.x = BORDH; - wc.y = TBARH + BORDH; - wc.width = c->geo.width; - wc.height = c->geo.height; - wc.border_width = ev->border_width; - wc.sibling = ev->above; - wc.stack_mode = ev->detail; - - XConfigureWindow(dpy, c->win, ev->value_mask, &wc); - - client_configure(c); } - else + + /* Configure Request Part {{{ */ + wc.x = ev->xconfigurerequest.x; + wc.y = ev->xconfigurerequest.y; + wc.width = ev->xconfigurerequest.width; + wc.height = ev->xconfigurerequest.height; + wc.border_width = ev->xconfigurerequest.border_width; + wc.sibling = ev->xconfigurerequest.above; + wc.stack_mode = ev->xconfigurerequest.detail; + XConfigureWindow(dpy, ev->xconfigurerequest.window, + ev->xconfigurerequest.value_mask, &wc); + /* }}} */ + + /* Configure Notify Part {{{*/ + if((c = client_gb_win(ev->xconfigure.window))) { - wc.x = ev->x; - wc.y = ev->y; - wc.width = ev->width; - wc.height = ev->height; - wc.border_width = ev->border_width; - wc.sibling = ev->above; - wc.stack_mode = ev->detail; - XConfigureWindow(dpy, ev->window, ev->value_mask, &wc); + XGetWindowAttributes(dpy, ev->xconfigure.window, &win_at); + XGetWindowAttributes(dpy, ev->xconfigure.event, &ev_at); + + /* Frame config */ + if(win_at.width != ev_at.width + || win_at.height != ev_at.height) + { + c->geo.width = geo.width = ev->xconfigure.width; + c->geo.height = geo.height = ev->xconfigure.height; + frame_moveresize(c, geo); + } + + /* Win config (re-adjust it with the frame) */ + if(ev->xconfigure.x != BORDH + || ev->xconfigure.y != BORDH + TBARH) + XMoveWindow(dpy, ev->xconfigure.window, BORDH, BORDH + TBARH); } - XSync(dpy, False); + /* }}} */ return; } @@ -358,7 +367,7 @@ getevent(XEvent ev) switch (ev.type) { case ButtonPress: buttonpress(&ev.xbutton); break; - case ConfigureRequest: configurerequest(&ev.xconfigurerequest); break; + case ConfigureRequest: configureevent(&ev); break; case DestroyNotify: destroynotify(&ev.xdestroywindow); break; case EnterNotify: enternotify(&ev.xcrossing); break; case Expose: expose(&ev.xexpose); break; diff --git a/src/frame.c b/src/frame.c index 6f1a5ae..85700d4 100644 --- a/src/frame.c +++ b/src/frame.c @@ -45,7 +45,7 @@ frame_create(Client *c) at.background_pixmap = ParentRelative; at.override_redirect = True; at.bit_gravity = StaticGravity; - at.event_mask = SubstructureRedirectMask|SubstructureNotifyMask + at.event_mask = SubstructureRedirectMask|SubstructureNotifyMask |ExposureMask|VisibilityChangeMask |EnterWindowMask|LeaveWindowMask|FocusChangeMask |KeyMask|ButtonMask|MouseMask; @@ -125,10 +125,10 @@ frame_delete(Client *c) void frame_moveresize(Client *c, XRectangle geo) { - c->frame_geo.x = geo.x - BORDH; - c->frame_geo.y = geo.y - TBARH; - c->frame_geo.width = FRAMEW(geo.width); - c->frame_geo.height = FRAMEH(geo.height); + c->frame_geo.x = (geo.x) ? geo.x - BORDH : c->frame_geo.x; + c->frame_geo.y = (geo.y) ? geo.y - TBARH : c->frame_geo.y; + c->frame_geo.width = (geo.width) ? FRAMEW(geo.width) : c->frame_geo.width; + c->frame_geo.height = (geo.height) ? FRAMEH(geo.height) : c->frame_geo.height; /* Frame */ XMoveResizeWindow(dpy, c->frame, diff --git a/src/wmfs.h b/src/wmfs.h index 7634f97..ddf2e57 100644 --- a/src/wmfs.h +++ b/src/wmfs.h @@ -145,7 +145,7 @@ void init_conf(void); /* event.c */ void buttonpress(XButtonEvent *ev); -void configurerequest(XConfigureRequestEvent *ev); +void configureevent(XEvent *ev); void destroynotify(XDestroyWindowEvent *ev); void enternotify(XCrossingEvent *ev); void expose(XExposeEvent *ev);