From: Scott Moreau Date: Sat, 18 Feb 2012 12:05:28 +0000 (-0700) Subject: server: Implement wl_keyboard_grab_interface. X-Git-Tag: 0.94.90~204 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ab3b5cd71ce6dd1a532d9c1fecabb1a6e9d1a055;p=platform%2Fupstream%2Fwayland.git server: Implement wl_keyboard_grab_interface. --- diff --git a/src/wayland-server.c b/src/wayland-server.c index b7d92ad..9e90ae5 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -484,6 +484,24 @@ static const struct wl_pointer_grab_interface default_grab_button }; +static void +default_grab_key(struct wl_keyboard_grab *grab, + uint32_t time, uint32_t key, int32_t state) +{ + struct wl_input_device *device = grab->input_device; + struct wl_resource *resource; + + resource = device->keyboard_focus_resource; + if (resource) + wl_resource_post_event(resource, WL_INPUT_DEVICE_KEY, + time, key, state); +} + +static const struct wl_keyboard_grab_interface + default_keyboard_grab_interface = { + default_grab_key +}; + WL_EXPORT void wl_input_device_init(struct wl_input_device *device) { @@ -497,6 +515,10 @@ wl_input_device_init(struct wl_input_device *device) device->default_pointer_grab.input_device = device; device->pointer_grab = &device->default_pointer_grab; + device->default_keyboard_grab.interface = &default_keyboard_grab_interface; + device->default_keyboard_grab.input_device = device; + device->keyboard_grab = &device->default_keyboard_grab; + wl_list_init(&device->drag_resource_list); device->selection_data_source = NULL; wl_list_init(&device->selection_listener_list); @@ -604,6 +626,21 @@ wl_input_device_set_keyboard_focus(struct wl_input_device *device, } WL_EXPORT void +wl_input_device_start_keyboard_grab(struct wl_input_device *device, + struct wl_keyboard_grab *grab, uint32_t time) +{ + device->keyboard_grab = grab; + grab->input_device = device; + +} + +WL_EXPORT void +wl_input_device_end_keyboard_grab(struct wl_input_device *device, uint32_t time) +{ + device->keyboard_grab = &device->default_keyboard_grab; +} + +WL_EXPORT void wl_input_device_start_pointer_grab(struct wl_input_device *device, struct wl_pointer_grab *grab, uint32_t time) { diff --git a/src/wayland-server.h b/src/wayland-server.h index e3f107f..edd8147 100644 --- a/src/wayland-server.h +++ b/src/wayland-server.h @@ -164,6 +164,19 @@ struct wl_pointer_grab { int32_t x, y; }; +struct wl_keyboard_grab; +struct wl_keyboard_grab_interface { + void (*key)(struct wl_keyboard_grab *grab, + uint32_t time, uint32_t key, int32_t state); +}; + +struct wl_keyboard_grab { + const struct wl_keyboard_grab_interface *interface; + struct wl_input_device *input_device; + struct wl_surface *focus; + uint32_t key; +}; + struct wl_data_offer { struct wl_resource resource; struct wl_data_source *source; @@ -202,10 +215,13 @@ struct wl_input_device { struct wl_pointer_grab *pointer_grab; struct wl_pointer_grab default_pointer_grab; + struct wl_keyboard_grab *keyboard_grab; + struct wl_keyboard_grab default_keyboard_grab; uint32_t button_count; uint32_t grab_time; int32_t grab_x, grab_y; uint32_t grab_button; + uint32_t grab_key; struct wl_listener grab_listener; struct wl_list drag_resource_list; @@ -283,6 +299,12 @@ int wl_data_device_manager_init(struct wl_display *display); void +wl_input_device_start_keyboard_grab(struct wl_input_device *device, + struct wl_keyboard_grab *grab, uint32_t time); +void +wl_input_device_end_keyboard_grab(struct wl_input_device *device, uint32_t time); + +void wl_input_device_start_pointer_grab(struct wl_input_device *device, struct wl_pointer_grab *grab, uint32_t time); void