summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <lekensteyn@gmail.com>2012-10-11 17:19:45 +0200
committerPeter Wu <lekensteyn@gmail.com>2012-10-11 17:19:45 +0200
commita132c4b6081f4bc80108cc1650dc29247185386a (patch)
tree468006e13484f514020ca421c2c57a2da60d7747
parent442de021096e3f7ae95a0548dd3d08d75d1a5bd2 (diff)
downloadc-files-a132c4b6081f4bc80108cc1650dc29247185386a.tar.gz
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.
-rw-r--r--xcbviewfs.c31
1 files 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;