summaryrefslogtreecommitdiff
path: root/wayland
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2010-12-01 10:17:47 -0500
committerKristian Høgsberg <krh@bitplanet.net>2010-12-01 10:17:47 -0500
commit26437073910d0e0850dd5d6ee7483f6f26172004 (patch)
treeafbd9a725b4d12898c28d5e5557441544cfd658e /wayland
parent06bc26401c53fb36c3cacfaeaaa55d127dc2fdf1 (diff)
Move pointer and keyboard focus tracking into libwayland-server
Diffstat (limited to 'wayland')
-rw-r--r--wayland/wayland-server.c51
-rw-r--r--wayland/wayland-server.h18
2 files changed, 69 insertions, 0 deletions
diff --git a/wayland/wayland-server.c b/wayland/wayland-server.c
index 0b4480b..ad1637d 100644
--- a/wayland/wayland-server.c
+++ b/wayland/wayland-server.c
@@ -301,6 +301,57 @@ wl_client_destroy(struct wl_client *client)
free(client);
}
+WL_EXPORT void
+wl_input_device_set_pointer_focus(struct wl_input_device *device,
+ struct wl_surface *surface,
+ uint32_t time,
+ int32_t x, int32_t y,
+ int32_t sx, int32_t sy)
+{
+ if (device->pointer_focus == surface)
+ return;
+
+ if (device->pointer_focus &&
+ (!surface || device->pointer_focus->client != surface->client))
+ wl_client_post_event(device->pointer_focus->client,
+ &device->base,
+ WL_INPUT_DEVICE_POINTER_FOCUS,
+ time, NULL, 0, 0, 0, 0);
+ if (surface)
+ wl_client_post_event(surface->client,
+ &device->base,
+ WL_INPUT_DEVICE_POINTER_FOCUS,
+ time, surface, x, y, sx, sy);
+
+ device->pointer_focus = surface;
+ device->pointer_focus_time = time;
+}
+
+WL_EXPORT void
+wl_input_device_set_keyboard_focus(struct wl_input_device *device,
+ struct wl_surface *surface,
+ uint32_t time)
+{
+ if (device->keyboard_focus == surface)
+ return;
+
+ if (device->keyboard_focus &&
+ (!surface || device->keyboard_focus->client != surface->client))
+ wl_client_post_event(device->keyboard_focus->client,
+ &device->base,
+ WL_INPUT_DEVICE_KEYBOARD_FOCUS,
+ time, NULL, &device->keys);
+
+ if (surface)
+ wl_client_post_event(surface->client,
+ &device->base,
+ WL_INPUT_DEVICE_KEYBOARD_FOCUS,
+ time, surface, &device->keys);
+
+ device->keyboard_focus = surface;
+ device->keyboard_focus_time = time;
+}
+
static void
display_sync(struct wl_client *client,
struct wl_display *display, uint32_t key)
diff --git a/wayland/wayland-server.h b/wayland/wayland-server.h
index f2b9297..34fea86 100644
--- a/wayland/wayland-server.h
+++ b/wayland/wayland-server.h
@@ -128,6 +128,11 @@ struct wl_shell {
struct wl_input_device {
struct wl_object base;
+ struct wl_surface *pointer_focus;
+ struct wl_surface *keyboard_focus;
+ struct wl_array keys;
+ uint32_t pointer_focus_time;
+ uint32_t keyboard_focus_time;
};
struct wl_visual {
@@ -174,6 +179,19 @@ wl_client_get_display(struct wl_client *client);
void
wl_resource_destroy(struct wl_resource *resource, struct wl_client *client);
+void
+wl_input_device_set_pointer_focus(struct wl_input_device *device,
+ struct wl_surface *surface,
+ uint32_t time,
+ int32_t x, int32_t y,
+ int32_t sx, int32_t sy);
+
+void
+wl_input_device_set_keyboard_focus(struct wl_input_device *device,
+ struct wl_surface *surface,
+ uint32_t time);
+
+
#ifdef __cplusplus
}
#endif