Split pointer_focus and keyboard_focus into enter and leave events

This commit is contained in:
Kristian Høgsberg 2012-02-18 01:25:44 -05:00
parent ab3b5cd71c
commit 3c6f42112d
2 changed files with 25 additions and 17 deletions

View file

@ -624,8 +624,8 @@
<arg name="state" type="uint"/> <arg name="state" type="uint"/>
</event> </event>
<event name="pointer_focus"> <event name="pointer_enter">
<description summary="pointer focus change event"> <description summary="pointer enter event">
Notification that this input device's pointer is focused on Notification that this input device's pointer is focused on
certain surface. When an input_device enters a surface, the certain surface. When an input_device enters a surface, the
pointer image is undefined and a client should respond to this pointer image is undefined and a client should respond to this
@ -638,12 +638,24 @@
<arg name="surface_y" type="int"/> <arg name="surface_y" type="int"/>
</event> </event>
<event name="keyboard_focus"> <event name="pointer_leave">
<description summary="pointer leave event">
</description>
<arg name="time" type="uint"/>
<arg name="surface" type="object" interface="wl_surface"/>
</event>
<event name="keyboard_enter">
<arg name="time" type="uint"/> <arg name="time" type="uint"/>
<arg name="surface" type="object" interface="wl_surface"/> <arg name="surface" type="object" interface="wl_surface"/>
<arg name="keys" type="array"/> <arg name="keys" type="array"/>
</event> </event>
<event name="keyboard_leave">
<arg name="time" type="uint"/>
<arg name="surface" type="object" interface="wl_surface"/>
</event>
<event name="touch_down"> <event name="touch_down">
<arg name="time" type="uint"/> <arg name="time" type="uint"/>
<arg name="surface" type="object" interface="wl_surface"/> <arg name="surface" type="object" interface="wl_surface"/>

View file

@ -568,19 +568,17 @@ wl_input_device_set_pointer_focus(struct wl_input_device *device,
if (device->pointer_focus == surface) if (device->pointer_focus == surface)
return; return;
if (device->pointer_focus_resource && if (device->pointer_focus_resource) {
(!surface ||
device->pointer_focus->resource.client != surface->resource.client))
wl_resource_post_event(device->pointer_focus_resource, wl_resource_post_event(device->pointer_focus_resource,
WL_INPUT_DEVICE_POINTER_FOCUS, WL_INPUT_DEVICE_POINTER_LEAVE,
time, NULL, 0, 0); time, device->pointer_focus);
if (device->pointer_focus_resource)
wl_list_remove(&device->pointer_focus_listener.link); wl_list_remove(&device->pointer_focus_listener.link);
}
resource = find_resource_for_surface(&device->resource_list, surface); resource = find_resource_for_surface(&device->resource_list, surface);
if (resource) { if (resource) {
wl_resource_post_event(resource, wl_resource_post_event(resource,
WL_INPUT_DEVICE_POINTER_FOCUS, WL_INPUT_DEVICE_POINTER_ENTER,
time, surface, sx, sy); time, surface, sx, sy);
wl_list_insert(resource->destroy_listener_list.prev, wl_list_insert(resource->destroy_listener_list.prev,
&device->pointer_focus_listener.link); &device->pointer_focus_listener.link);
@ -602,19 +600,17 @@ wl_input_device_set_keyboard_focus(struct wl_input_device *device,
if (device->keyboard_focus == surface) if (device->keyboard_focus == surface)
return; return;
if (device->keyboard_focus_resource && if (device->keyboard_focus_resource) {
(!surface ||
device->keyboard_focus->resource.client != surface->resource.client))
wl_resource_post_event(device->keyboard_focus_resource, wl_resource_post_event(device->keyboard_focus_resource,
WL_INPUT_DEVICE_KEYBOARD_FOCUS, WL_INPUT_DEVICE_KEYBOARD_LEAVE,
time, NULL, &device->keys); time, device->keyboard_focus);
if (device->keyboard_focus_resource)
wl_list_remove(&device->keyboard_focus_listener.link); wl_list_remove(&device->keyboard_focus_listener.link);
}
resource = find_resource_for_surface(&device->resource_list, surface); resource = find_resource_for_surface(&device->resource_list, surface);
if (resource) { if (resource) {
wl_resource_post_event(resource, wl_resource_post_event(resource,
WL_INPUT_DEVICE_KEYBOARD_FOCUS, WL_INPUT_DEVICE_KEYBOARD_ENTER,
time, surface, &device->keys); time, surface, &device->keys);
wl_list_insert(resource->destroy_listener_list.prev, wl_list_insert(resource->destroy_listener_list.prev,
&device->keyboard_focus_listener.link); &device->keyboard_focus_listener.link);