commit e03df4d

Michael Forney  ·  2013-06-14 11:17:15 +0000 UTC
parent 441ff74
Move seat interface to seat.c
2 files changed,  +59, -71
M seat.c
M seat.h
M seat.c
+59, -59
  1@@ -17,12 +17,6 @@ struct evdev_device_entry
  2     struct wl_list link;
  3 };
  4 
  5-struct wl_seat_interface swc_seat_interface = {
  6-    .get_pointer = &swc_seat_get_pointer,
  7-    .get_keyboard = &swc_seat_get_keyboard,
  8-    .get_touch = &swc_seat_get_touch
  9-};
 10-
 11 static void handle_key(struct swc_seat * seat, uint32_t time, uint32_t key,
 12                        uint32_t state)
 13 {
 14@@ -161,6 +155,64 @@ static void handle_evdev_event(struct wl_listener * listener, void * data)
 15     }
 16 }
 17 
 18+/* Wayland Seat Interface */
 19+static void get_pointer(struct wl_client * client, struct wl_resource * resource,
 20+                        uint32_t id)
 21+{
 22+    struct swc_seat * seat = resource->data;
 23+    struct swc_pointer * pointer = &seat->pointer;
 24+
 25+    swc_pointer_bind(pointer, client, id);
 26+
 27+    if (pointer->focus.surface
 28+        && wl_resource_get_client(pointer->focus.surface->resource) == client)
 29+    {
 30+        swc_pointer_set_focus(pointer, pointer->focus.surface);
 31+    }
 32+}
 33+
 34+static void get_keyboard(struct wl_client * client, struct wl_resource * resource,
 35+                         uint32_t id)
 36+{
 37+    struct wl_resource * client_resource;
 38+    struct swc_seat * seat = wl_resource_get_user_data(resource);
 39+    struct swc_keyboard * keyboard = &seat->keyboard;
 40+
 41+    client_resource = swc_keyboard_bind(keyboard, client, id);
 42+
 43+    wl_keyboard_send_keymap(client_resource, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
 44+                            seat->xkb.keymap.fd, seat->xkb.keymap.size);
 45+
 46+    if (keyboard->focus.surface
 47+        && wl_resource_get_client(keyboard->focus.surface->resource) == client)
 48+    {
 49+        printf("focusing\n");
 50+        swc_keyboard_set_focus(keyboard, keyboard->focus.surface);
 51+    }
 52+}
 53+
 54+static void get_touch(struct wl_client * client, struct wl_resource * resource,
 55+               uint32_t id)
 56+{
 57+    /*
 58+    struct wl_resource * client_resource;
 59+    struct swc_seat * seat = resource->data;
 60+    struct wl_touch * touch = &seat->touch;
 61+
 62+    client_resource = wl_client_add_object(client, &wl_touch_interface,
 63+                                           NULL, id, seat);
 64+    client_resource->destroy = &swc_unbind_resource;
 65+
 66+    wl_list_insert(&touch->resources, &client_resource->link);
 67+    */
 68+}
 69+
 70+struct wl_seat_interface seat_implementation = {
 71+    .get_pointer = &get_pointer,
 72+    .get_keyboard = &get_keyboard,
 73+    .get_touch = &get_touch
 74+};
 75+
 76 static void bind_seat(struct wl_client * client, void * data, uint32_t version,
 77                       uint32_t id)
 78 {
 79@@ -168,7 +220,7 @@ static void bind_seat(struct wl_client * client, void * data, uint32_t version,
 80     struct wl_resource * resource;
 81 
 82     resource = wl_client_add_object(client, &wl_seat_interface,
 83-                                    &swc_seat_interface, id, seat);
 84+                                    &seat_implementation, id, seat);
 85     wl_list_insert(&seat->resources, &resource->link);
 86     wl_resource_set_destructor(resource, &swc_unbind_resource);
 87 
 88@@ -327,55 +379,3 @@ void swc_seat_add_devices(struct swc_seat * seat, struct udev * udev)
 89     udev_enumerate_unref(enumerate);
 90 }
 91 
 92-/* Wayland Seat Interface */
 93-void swc_seat_get_pointer(struct wl_client * client,
 94-                          struct wl_resource * resource, uint32_t id)
 95-{
 96-    struct swc_seat * seat = resource->data;
 97-    struct swc_pointer * pointer = &seat->pointer;
 98-
 99-    swc_pointer_bind(pointer, client, id);
100-
101-    if (pointer->focus.surface
102-        && wl_resource_get_client(pointer->focus.surface->resource) == client)
103-    {
104-        swc_pointer_set_focus(pointer, pointer->focus.surface);
105-    }
106-}
107-
108-void swc_seat_get_keyboard(struct wl_client * client,
109-                           struct wl_resource * resource, uint32_t id)
110-{
111-    struct wl_resource * client_resource;
112-    struct swc_seat * seat = wl_resource_get_user_data(resource);
113-    struct swc_keyboard * keyboard = &seat->keyboard;
114-
115-    client_resource = swc_keyboard_bind(keyboard, client, id);
116-
117-    wl_keyboard_send_keymap(client_resource, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1,
118-                            seat->xkb.keymap.fd, seat->xkb.keymap.size);
119-
120-    if (keyboard->focus.surface
121-        && wl_resource_get_client(keyboard->focus.surface->resource) == client)
122-    {
123-        printf("focusing\n");
124-        swc_keyboard_set_focus(keyboard, keyboard->focus.surface);
125-    }
126-}
127-
128-void swc_seat_get_touch(struct wl_client * client,
129-                        struct wl_resource * resource, uint32_t id)
130-{
131-    /*
132-    struct wl_resource * client_resource;
133-    struct swc_seat * seat = resource->data;
134-    struct wl_touch * touch = &seat->touch;
135-
136-    client_resource = wl_client_add_object(client, &wl_touch_interface,
137-                                           NULL, id, seat);
138-    client_resource->destroy = &swc_unbind_resource;
139-
140-    wl_list_insert(&touch->resource_list, &client_resource->link);
141-    */
142-}
143-
M seat.h
+0, -12
 1@@ -38,17 +38,5 @@ void swc_seat_add_event_sources(struct swc_seat * seat,
 2 
 3 void swc_seat_add_devices(struct swc_seat * seat, struct udev * udev);
 4 
 5-/* Wayland Seat Interface */
 6-extern struct wl_seat_interface swc_seat_interface;
 7-
 8-void swc_seat_get_pointer(struct wl_client * client,
 9-                          struct wl_resource * resource, uint32_t id);
10-
11-void swc_seat_get_keyboard(struct wl_client * client,
12-                           struct wl_resource * resource, uint32_t id);
13-
14-void swc_seat_get_touch(struct wl_client * client,
15-                        struct wl_resource * resource, uint32_t id);
16-
17 #endif
18