From bdaf66a292ed77b3589ad5d4c4cf2bbf484df840 Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 2 Nov 2017 00:03:55 +0100 Subject: [PATCH] Set xwayland root cursor --- meson.build | 1 + xwayland/meson.build | 1 + xwayland/xwm.c | 36 +++++++++++++++++++++++++++++++----- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 74bb6dcd..e37250a7 100644 --- a/meson.build +++ b/meson.build @@ -52,6 +52,7 @@ pixman = dependency('pixman-1') xcb = dependency('xcb') xcb_composite = dependency('xcb-composite') xcb_xfixes = dependency('xcb-xfixes') +xcb_image = dependency('xcb-image') xcb_icccm = dependency('xcb-icccm', required: false) x11_xcb = dependency('x11-xcb') libcap = dependency('libcap', required: false) diff --git a/xwayland/meson.build b/xwayland/meson.build index a05ae584..669a0984 100644 --- a/xwayland/meson.build +++ b/xwayland/meson.build @@ -11,6 +11,7 @@ lib_wlr_xwayland = static_library( xcb, xcb_composite, xcb_xfixes, + xcb_image, xcb_icccm, pixman, ], diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 4930d45c..b6a49574 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "wlr/util/log.h" #include "wlr/types/wlr_surface.h" #include "wlr/xwayland.h" @@ -1220,15 +1221,40 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) { xwm_get_resources(xwm); xwm_get_visual_and_colormap(xwm); - uint32_t values[1]; - values[0] = + xcb_cursor_t cursor = xcb_generate_id(xwm->xcb_conn); + + { + // Create root cursor + + uint8_t data[] = { + 0x00, 0x00, 0xfe, 0x07, 0xfe, 0x03, 0xfe, 0x01, 0xfe, 0x01, 0xfe, 0x03, + 0xfe, 0x07, 0xfe, 0x0f, 0xfe, 0x1f, 0xe6, 0x0f, 0xc2, 0x07, 0x80, 0x03, + 0x00, 0x01, 0x00, 0x00 + }; + + uint8_t mask[] = { + 0xff, 0x3f, 0xff, 0x1f, 0xff, 0x07, 0xff, 0x03, 0xff, 0x03, 0xff, 0x07, + 0xff, 0x0f, 0xff, 0x1f, 0xff, 0x3f, 0xff, 0x1f, 0xe7, 0x0f, 0xc3, 0x07, + 0x83, 0x03, 0x01, 0x01 + }; + + xcb_pixmap_t cp = xcb_create_pixmap_from_bitmap_data(xwm->xcb_conn, xwm->screen->root, data, 14, 14, 1, 0, 0, 0); + xcb_pixmap_t mp = xcb_create_pixmap_from_bitmap_data(xwm->xcb_conn, xwm->screen->root, mask, 14, 14, 1, 0, 0, 0); + xcb_create_cursor(xwm->xcb_conn, cursor, cp, mp, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 0, 0); + xcb_free_pixmap(xwm->xcb_conn, cp); + xcb_free_pixmap(xwm->xcb_conn, mp); + } + + uint32_t values[] = { XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | - XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | - XCB_EVENT_MASK_PROPERTY_CHANGE; + XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | + XCB_EVENT_MASK_PROPERTY_CHANGE, + cursor, + }; xcb_change_window_attributes(xwm->xcb_conn, xwm->screen->root, - XCB_CW_EVENT_MASK /* | XCB_CW_CURSOR */, + XCB_CW_EVENT_MASK | XCB_CW_CURSOR, values); xcb_composite_redirect_subwindows(xwm->xcb_conn,