swc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/swc
Log | Files | Refs | README | LICENSE

commit 454b971658ba420bbbee33c154de914dffba5405
parent 0a5b78383629d22477fa4d598de8f00173a041db
Author: Michael Forney <mforney@mforney.org>
Date:   Mon,  6 Feb 2017 11:52:05 -0800

pointer: Set cursor to left_ptr when pointer has no focus

To do this, make input_focus call enter/leave even if resource or view
is NULL.

Diffstat:
Mlibswc/input.c | 9++-------
Mlibswc/keyboard.c | 4++++
Mlibswc/pointer.c | 6++++++
3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/libswc/input.c b/libswc/input.c @@ -37,15 +37,12 @@ focus(struct input_focus *input_focus, struct compositor_view *view) client = wl_resource_get_client(view->surface->resource); resource = wl_resource_find_for_client(&input_focus->resources, client); - wl_signal_add(&view->destroy_signal, &input_focus->view_destroy_listener); - - if (resource) - input_focus->handler->enter(input_focus->handler, resource, view); } input_focus->view = view; input_focus->resource = resource; + input_focus->handler->enter(input_focus->handler, resource, view); } static inline void @@ -53,9 +50,7 @@ unfocus(struct input_focus *input_focus) { if (input_focus->view) wl_list_remove(&input_focus->view_destroy_listener.link); - - if (input_focus->resource) - input_focus->handler->leave(input_focus->handler, input_focus->resource, input_focus->view); + input_focus->handler->leave(input_focus->handler, input_focus->resource, input_focus->view); } static void diff --git a/libswc/keyboard.c b/libswc/keyboard.c @@ -50,6 +50,8 @@ enter(struct input_focus_handler *handler, struct wl_resource *resource, struct struct keyboard_modifier_state *state = &keyboard->modifier_state; uint32_t serial; + if (!resource) + return; serial = wl_display_next_serial(swc.display); wl_keyboard_send_modifiers(resource, serial, state->depressed, state->locked, state->latched, state->group); wl_keyboard_send_enter(resource, serial, view->surface->resource, &keyboard->client_keys); @@ -60,6 +62,8 @@ leave(struct input_focus_handler *handler, struct wl_resource *resource, struct { uint32_t serial; + if (!resource) + return; serial = wl_display_next_serial(swc.display); wl_keyboard_send_leave(resource, serial, view->surface->resource); } diff --git a/libswc/pointer.c b/libswc/pointer.c @@ -41,6 +41,10 @@ enter(struct input_focus_handler *handler, struct wl_resource *resource, struct uint32_t serial; wl_fixed_t surface_x, surface_y; + if (!resource) { + pointer_set_cursor(pointer, cursor_left_ptr); + return; + } serial = wl_display_next_serial(swc.display); surface_x = pointer->x - wl_fixed_from_int(view->base.geometry.x); surface_y = pointer->y - wl_fixed_from_int(view->base.geometry.y); @@ -52,6 +56,8 @@ leave(struct input_focus_handler *handler, struct wl_resource *resource, struct { uint32_t serial; + if (!resource) + return; serial = wl_display_next_serial(swc.display); wl_pointer_send_leave(resource, serial, view->surface->resource); }