diff options
Diffstat (limited to 'x-placement-manager.c')
| -rw-r--r-- | x-placement-manager.c | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/x-placement-manager.c b/x-placement-manager.c index f997709..fdc1269 100644 --- a/x-placement-manager.c +++ b/x-placement-manager.c @@ -18,58 +18,58 @@ If not, see http://creativecommons.org/publicdomain/zero/1.0/ */ void place_center(Display *d, XEvent *e); static void (*handler[LASTEvent]) (Display *d, XEvent *) = { - [MapRequest] = place_center, - [ConfigureNotify] = place_center + [MapRequest] = place_center, + [ConfigureNotify] = place_center }; /// fun on down void place_center(Display *d, XEvent *e) { - static XWindowAttributes r_wa; - static XWindowAttributes c_wa; - Window r = DefaultRootWindow(d); - Window trans = None; - XMapRequestEvent *ev = &e->xmaprequest; - int x, y; + static XWindowAttributes r_wa; + static XWindowAttributes c_wa; + Window r = DefaultRootWindow(d); + Window trans = None; + XMapRequestEvent *ev = &e->xmaprequest; + int x, y; - if (!XGetWindowAttributes(d, r, &r_wa)) - return; - if (!XGetWindowAttributes(d, ev->window, &c_wa)) - return; - if (c_wa.override_redirect) - return; - if(XGetTransientForHint(d, ev->window, &trans)) - return; - x = r_wa.width/2 - c_wa.width/2; - y = r_wa.height/2 - c_wa.height/2; - if (x < 0) - x = 0; - if (y < 0) - y = 0; - XMoveResizeWindow(d, ev->window, x, y, - c_wa.width > r_wa.width ? r_wa.width : c_wa.width, - c_wa.height > r_wa.height ? r_wa.height : c_wa.height - ); + if (!XGetWindowAttributes(d, r, &r_wa)) + return; + if (!XGetWindowAttributes(d, ev->window, &c_wa)) + return; + if (c_wa.override_redirect) + return; + if(XGetTransientForHint(d, ev->window, &trans)) + return; + x = r_wa.width/2 - c_wa.width/2; + y = r_wa.height/2 - c_wa.height/2; + if (x < 0) + x = 0; + if (y < 0) + y = 0; + XMoveResizeWindow(d, ev->window, x, y, + c_wa.width > r_wa.width ? r_wa.width : c_wa.width, + c_wa.height > r_wa.height ? r_wa.height : c_wa.height + ); } int main(int argc, char **argv) { - Display *dpy; - XEvent e; - XSetWindowAttributes wa; + Display *dpy; + XEvent e; + XSetWindowAttributes wa; - if(!(dpy = XOpenDisplay(NULL))) - return 1; + if(!(dpy = XOpenDisplay(NULL))) + return 1; - wa.cursor = XCreateFontCursor(dpy, XC_left_ptr); - wa.event_mask = SubstructureNotifyMask|StructureNotifyMask; - XChangeWindowAttributes(dpy, DefaultRootWindow(dpy) , CWEventMask|CWCursor, &wa); + wa.cursor = XCreateFontCursor(dpy, XC_left_ptr); + wa.event_mask = SubstructureNotifyMask|StructureNotifyMask; + XChangeWindowAttributes(dpy, DefaultRootWindow(dpy) , CWEventMask|CWCursor, &wa); - for(;;) { - XNextEvent(dpy, &e); - if(handler[e.type]) - handler[e.type](dpy, &e); - } + for(;;) { + XNextEvent(dpy, &e); + if(handler[e.type]) + handler[e.type](dpy, &e); + } } |
