URI: 
       tForce window to be mapped within screen boundaries - glazier - window management experiments
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
   DIR README
   DIR LICENSE
       ---
   DIR commit 441d533e156dcc67e06d9aeeb059da89bebaee5c
   DIR parent 3efed6d6184ac45cc943ab490bd8ab33bd98fbbe
  HTML Author: Willy Goiffon <dev@z3bra.org>
       Date:   Thu,  5 Dec 2019 08:50:27 +0100
       
       Force window to be mapped within screen boundaries
       
       Diffstat:
         M glazier.c                           |      16 +++++++---------
       
       1 file changed, 7 insertions(+), 9 deletions(-)
       ---
   DIR diff --git a/glazier.c b/glazier.c
       t@@ -124,7 +124,7 @@ usage(char *name)
        int
        adopt(xcb_window_t wid)
        {
       -        int x, y, w, h, sw, sh;
       +        int x, y, w, h;
        
                if (wm_is_ignored(wid))
                        return -1;
       t@@ -141,14 +141,6 @@ adopt(xcb_window_t wid)
                                x = MAX(0, x - w/2);
                                y = MAX(0, y - h/2);
                        }
       -
       -                /* prevent windows to pop outside of the screen */
       -                sw = wm_get_attribute(scrn->root, ATTR_W);
       -                sh = wm_get_attribute(scrn->root, ATTR_H);
       -                if ((x + w) > sw) x = sw - w/2;
       -                if ((y + h) > sh) y = sh - h/2;
       -
       -                wm_teleport(wid, MAX(0, x), MAX(0, y), w, h);
                }
        
                return wm_reg_window_event(wid, XCB_EVENT_MASK_ENTER_WINDOW
       t@@ -303,6 +295,7 @@ cb_create(xcb_generic_event_t *ev)
        int
        cb_mapreq(xcb_generic_event_t *ev)
        {
       +        int x, y;
                xcb_map_request_event_t *e;
        
                e = (xcb_map_request_event_t *)ev;
       t@@ -314,6 +307,11 @@ cb_mapreq(xcb_generic_event_t *ev)
                wm_set_border(border, border_color, e->window);
                wm_set_focus(e->window);
        
       +        /* prevent window to pop outside the screen */
       +        x = wm_get_attribute(e->window, ATTR_X);
       +        y = wm_get_attribute(e->window, ATTR_Y);
       +        wm_move(e->window, ABSOLUTE, x, y);
       +
                return 0;
        }