From a132c4b6081f4bc80108cc1650dc29247185386a Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Thu, 11 Oct 2012 17:19:45 +0200 Subject: xcbviewfs: always hide cursor There used to be a corner case (the topleft corner) where the pointer was still visible which is now fixed. Optimise by using one pixmap for the same thing. --- xcbviewfs.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/xcbviewfs.c b/xcbviewfs.c index f0b4652..98d2622 100644 --- a/xcbviewfs.c +++ b/xcbviewfs.c @@ -84,12 +84,25 @@ int main(int argc, char **argv) { screen->root_visual, mask, valwin); + if (hide_cursor) { + xcb_pixmap_t cp = xcb_create_pixmap_from_bitmap_data(c, win, + empty_cursor_data, 16, 16, 1, 0, 0, 0); + + cursor = xcb_generate_id(c); + xcb_create_cursor(c, cursor, cp, cp, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8); + xcb_free_pixmap(c, cp); + /* pointer is already changed by xcb_grab_pointer */ + if (!grab_pointer) { + xcb_change_window_attributes(c, win, XCB_CW_CURSOR, &cursor); + xcb_flush(c); + } + } if (grab_pointer) { xcb_grab_pointer_cookie_t cookie; xcb_grab_pointer_reply_t *reply; cookie = xcb_grab_pointer(c, 1, screen->root, XCB_NONE, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, - XCB_NONE, XCB_NONE, + XCB_NONE, hide_cursor ? cursor : XCB_NONE, XCB_CURRENT_TIME); if (!(reply = xcb_grab_pointer_reply(c, cookie, NULL))) { bail(disconnect, "No pointer grab reply\n"); @@ -99,21 +112,7 @@ int main(int argc, char **argv) { } free(reply); } - if (hide_cursor) { - xcb_pixmap_t cp = xcb_create_pixmap_from_bitmap_data(c, win, - empty_cursor_data, 16, 16, 1, 0, 0, 0); - xcb_pixmap_t mp = xcb_create_pixmap_from_bitmap_data(c, win, - empty_cursor_data, 16, 16, 1, 0, 0, 0); - - cursor = xcb_generate_id(c); - xcb_create_cursor(c, cursor, cp, mp, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8); - xcb_free_pixmap(c, cp); - xcb_free_pixmap(c, mp); - - xcb_change_window_attributes(c, win, XCB_CW_CURSOR, &cursor); - xcb_free_cursor(c, cursor); - xcb_flush(c); - } + if (hide_cursor) xcb_free_cursor(c, cursor); if (grab_kbd) { xcb_grab_keyboard_cookie_t cookie; xcb_grab_keyboard_reply_t *reply; -- cgit v1.2.1