diff options
Diffstat (limited to 'src/cursor.c')
-rw-r--r-- | src/cursor.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/cursor.c b/src/cursor.c index 9212b55..737c33b 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -80,6 +80,11 @@ int gsr_cursor_init(gsr_cursor *self, gsr_egl *egl, Display *display) { } self->egl->glGenTextures(1, &self->texture_id); + + XFixesSelectCursorInput(self->display, DefaultRootWindow(self->display), XFixesDisplayCursorNotifyMask); + gsr_cursor_set_from_x11_cursor_image(self, XFixesGetCursorImage(self->display)); + self->cursor_image_set = true; + return 0; } @@ -92,44 +97,31 @@ void gsr_cursor_deinit(gsr_cursor *self) { self->texture_id = 0; } - if(self->window) { - XFixesSelectCursorInput(self->display, self->window, 0); - self->window = None; - } + XFixesSelectCursorInput(self->display, DefaultRootWindow(self->display), 0); self->display = NULL; self->egl = NULL; } -int gsr_cursor_change_window_target(gsr_cursor *self, Window window) { - if(self->window) - XFixesSelectCursorInput(self->display, self->window, 0); - - XFixesSelectCursorInput(self->display, window, XFixesDisplayCursorNotifyMask); - self->window = window; - self->cursor_image_set = false; - return 0; -} - void gsr_cursor_update(gsr_cursor *self, XEvent *xev) { if(xev->type == self->x_fixes_event_base + XFixesCursorNotify) { XFixesCursorNotifyEvent *cursor_notify_event = (XFixesCursorNotifyEvent*)xev; - if(cursor_notify_event->subtype == XFixesDisplayCursorNotify && cursor_notify_event->window == self->window) { + if(cursor_notify_event->subtype == XFixesDisplayCursorNotify && cursor_notify_event->window == DefaultRootWindow(self->display)) { self->cursor_image_set = true; gsr_cursor_set_from_x11_cursor_image(self, XFixesGetCursorImage(self->display)); } } - if(!self->cursor_image_set && self->window) { + if(!self->cursor_image_set) { self->cursor_image_set = true; gsr_cursor_set_from_x11_cursor_image(self, XFixesGetCursorImage(self->display)); } } -void gsr_cursor_tick(gsr_cursor *self) { +void gsr_cursor_tick(gsr_cursor *self, Window relative_to) { /* TODO: Use XInput2 instead. However that doesn't work when the pointer is grabbed. Maybe check for focused window change and XSelectInput PointerMask */ Window dummy_window; int dummy_i; unsigned int dummy_u; - XQueryPointer(self->display, DefaultRootWindow(self->display), &dummy_window, &dummy_window, &dummy_i, &dummy_i, &self->position.x, &self->position.y, &dummy_u); + XQueryPointer(self->display, relative_to, &dummy_window, &dummy_window, &dummy_i, &dummy_i, &self->position.x, &self->position.y, &dummy_u); } |