tslw.c: change cursor to select window - wmutils - X windows manipulation utilities
 (HTM) git clone git://z3bra.org/wmutils
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 354acb7922e8d630bb56240934a1071e21031ab8
 (DIR) parent f946be83a69bda18f335cec80e5d244b3b884b2a
 (HTM) Author: Willy Goiffon <dev@z3bra.org>
       Date:   Mon, 14 Oct 2019 12:31:31 +0200
       
       slw.c: change cursor to select window
       
       Diffstat:
         M slw.c                               |      16 ++++++++++++++--
       
       1 file changed, 14 insertions(+), 2 deletions(-)
       ---
 (DIR) diff --git a/slw.c b/slw.c
       t@@ -9,6 +9,9 @@
        
        #include "util.h"
        
       +/* use "heart" to show us your love! */
       +#define XHAIR "tcross"
       +
        static xcb_connection_t *conn;
        static xcb_screen_t *scr;
        
       t@@ -17,13 +20,21 @@ select_window(void)
        {
                uint32_t val[] = { XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE  };
                xcb_window_t w = 0;
       +        xcb_cursor_t p;
       +        xcb_cursor_context_t *ctx;
                xcb_grab_pointer_cookie_t c;
                xcb_grab_pointer_reply_t *r;
                xcb_generic_event_t *e;
        
       +        if (xcb_cursor_context_new(conn, scr, &ctx) < 0)
       +                errx(1, "cannot instantiate cursor");
       +
       +        p = xcb_cursor_load_cursor(ctx, XHAIR);
       +        xcb_flush(conn);
       +
                c = xcb_grab_pointer(conn, 0, scr->root,
                        XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE,
       -                XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE,
       +                XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, p,
                        XCB_CURRENT_TIME);
        
                r = xcb_grab_pointer_reply(conn, c, NULL);
       t@@ -40,8 +51,9 @@ select_window(void)
                                w = ((xcb_button_press_event_t*)e)->child;
                                break;
                        case XCB_BUTTON_RELEASE:
       +                        xcb_cursor_context_free(ctx);
                                return w;
       -                        break;
       +                        break; /* NOTREACHED */
                        }
                }
        }