swc

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

commit 27f27f19ddf850d5e20ee58cd8f6d970efe90254
parent 9b80eea9711caf49bfb6072a4d40f94800e643d4
Author: Michael Forney <mforney@mforney.org>
Date:   Fri, 14 Jun 2013 01:58:02 -0700

Use our own structs (removed in libwayland)

Diffstat:
MMakefile.am | 4++++
Mcompositor.c | 76+++++++++++++++++++++++++++++++++++++---------------------------------------
Adata_device.c | 27+++++++++++++++++++++++++++
Adata_device.h | 12++++++++++++
Adata_device_manager.c | 41+++++++++++++++++++++++++++++++++++++++++
Adata_device_manager.h | 9+++++++++
Akeyboard.c | 84+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Akeyboard.h | 53+++++++++++++++++++++++++++++++++++++++++++++++++++++
Apointer.c | 115+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apointer.h | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mseat.c | 103++++++++++++++++++++++++++++++++++++++++++++-----------------------------------
Mseat.h | 13+++++++------
Msurface.h | 3++-
13 files changed, 507 insertions(+), 91 deletions(-)

diff --git a/Makefile.am b/Makefile.am @@ -14,7 +14,11 @@ libswc_la_SOURCES = \ surface.c surface.h \ region.c region.h \ renderer.c renderer.h \ + keyboard.c keyboard.h \ + pointer.c pointer.h \ seat.c seat.h \ + data_device_manager.c data_device_manager.h \ + data_device.c data_device.h \ mode.c mode.h \ tty.c tty.h \ evdev_device.c evdev_device.h \ diff --git a/compositor.c b/compositor.c @@ -8,6 +8,8 @@ #include "output.h" #include "surface.h" #include "event.h" +#include "region.h" +#include "data_device_manager.h" const char default_seat[] = "seat0"; @@ -52,12 +54,10 @@ static void schedule_repaint_for_output(struct swc_compositor * compositor, output->repaint_scheduled = true; } -static void handle_key(struct wl_keyboard_grab * grab, uint32_t time, +static bool handle_key(struct swc_keyboard * keyboard, uint32_t time, uint32_t key, uint32_t state) { - struct wl_keyboard * keyboard = grab->keyboard; struct swc_seat * seat; - struct wl_resource * resource = keyboard->focus_resource; struct swc_binding * binding; struct swc_compositor * compositor; char keysym_name[64]; @@ -73,38 +73,44 @@ static void handle_key(struct wl_keyboard_grab * grab, uint32_t time, wl_array_for_each(binding, &compositor->key_bindings) { - if (binding->value == keysym && (binding->modifiers == SWC_MOD_ANY - || binding->modifiers == seat->active_modifiers)) + if (binding->value == keysym) { - binding->handler(time, keysym, binding->data); - return; + xkb_mod_mask_t mod_mask; + uint32_t modifiers = 0; + mod_mask = xkb_state_serialize_mods(seat->xkb.state, + XKB_STATE_MODS_EFFECTIVE); + mod_mask = xkb_state_mod_mask_remove_consumed(seat->xkb.state, key + 8, + mod_mask); + + if (mod_mask & (1 << seat->xkb.indices.ctrl)) + modifiers |= SWC_MOD_CTRL; + if (mod_mask & (1 << seat->xkb.indices.alt)) + modifiers |= SWC_MOD_ALT; + if (mod_mask & (1 << seat->xkb.indices.super)) + modifiers |= SWC_MOD_SUPER; + if (mod_mask & (1 << seat->xkb.indices.shift)) + modifiers |= SWC_MOD_SHIFT; + + if (binding->modifiers == SWC_MOD_ANY + || binding->modifiers == modifiers) + { + binding->handler(time, keysym, binding->data); + printf("\t-> handled\n"); + return true; + } } } } - if (resource) - { - struct wl_display * display; - uint32_t serial; - - display = wl_client_get_display(resource->client); - serial = wl_display_next_serial(display); - wl_keyboard_send_key(resource, serial, time, key, state); - } -} - -static void handle_modifiers(struct wl_keyboard_grab * grab, uint32_t serial, - uint32_t mods_depressed, uint32_t mods_latched, - uint32_t mods_locked, uint32_t group) -{ - //wl_keyboard_send_modifiers + return false; } -struct wl_keyboard_grab_interface binding_grab_interface = { +struct swc_keyboard_handler keyboard_handler = { .key = &handle_key, - .modifiers = &handle_modifiers }; + + /* XXX: maybe this should go in swc_drm */ static void handle_tty_event(struct wl_listener * listener, void * data) { @@ -196,19 +202,10 @@ static void create_surface(struct wl_client * client, wl_list_insert(&compositor->surfaces, &surface->link); surface->output_mask |= 1 << output->id; - /* For some reason there is no Wayland method to initialize a preallocated - * resource. */ - surface->wayland.resource = (struct wl_resource) { - .object = { - .interface = &wl_surface_interface, - .implementation = (void (**)()) &swc_surface_interface, - .id = id - }, - .destroy = &destroy_surface, - .data = surface - }; - - wl_client_add_resource(client, &surface->wayland.resource); + surface->resource + = wl_client_add_object(client, &wl_surface_interface, + &swc_surface_interface, id, surface); + wl_resource_set_destructor(surface->resource, &destroy_surface); } static void create_region(struct wl_client * client, @@ -284,7 +281,7 @@ bool swc_compositor_initialize(struct swc_compositor * compositor, } swc_seat_add_event_sources(&compositor->seat, event_loop); - compositor->seat.keyboard.default_grab.interface = &binding_grab_interface; + compositor->seat.keyboard.handler = &keyboard_handler; /* TODO: configurable seat */ if (!swc_drm_initialize(&compositor->drm, compositor->udev, default_seat)) @@ -393,6 +390,7 @@ void swc_compositor_add_globals(struct swc_compositor * compositor, wl_display_add_global(display, &wl_compositor_interface, compositor, &bind_compositor); + swc_data_device_manager_add_globals(display); swc_seat_add_globals(&compositor->seat, display); wl_list_for_each(output, &compositor->outputs, link) diff --git a/data_device.c b/data_device.c @@ -0,0 +1,27 @@ +#include "data_device.h" + +static void start_drag(struct wl_client * client, struct wl_resource * resource, + struct wl_resource * source_resource, + struct wl_resource * origin_resource, + struct wl_resource * icon_resource, uint32_t serial) +{ +} + +static void set_selection(struct wl_client * client, + struct wl_resource * resource, + struct wl_resource * source_resource, uint32_t serial) +{ +} + +struct wl_data_device_interface data_device_implementation = { + .start_drag = &start_drag, + .set_selection = &set_selection +}; + +void swc_data_device_initialize(struct wl_client * client, uint32_t id, + struct swc_seat * seat) +{ + wl_client_add_object(client, &wl_data_device_interface, + &data_device_implementation, id, NULL); +} + diff --git a/data_device.h b/data_device.h @@ -0,0 +1,12 @@ +#ifndef SWC_DATA_DEVICE_H +#define SWC_DATA_DEVICE_H 1 + +#include <wayland-server.h> + +struct swc_seat; + +void swc_data_device_initialize(struct wl_client * client, uint32_t id, + struct swc_seat * seat); + +#endif + diff --git a/data_device_manager.c b/data_device_manager.c @@ -0,0 +1,41 @@ +#include "data_device_manager.h" +#include "data_device.h" + +#include <stdio.h> + +static void create_data_source(struct wl_client * client, + struct wl_resource * resource, uint32_t id) +{ +} + +static void get_data_device(struct wl_client * client, + struct wl_resource * resource, uint32_t id, + struct wl_resource * seat_resource) +{ + struct swc_seat * seat = seat_resource->data; + + printf("get_data_device\n"); + + // TODO: keep track of resource? + swc_data_device_initialize(client, id, seat); +} + +static struct wl_data_device_manager_interface +data_device_manager_implementation = { + .create_data_source = &create_data_source, + .get_data_device = &get_data_device +}; + +static void bind_data_device_manager(struct wl_client * client, void * data, + uint32_t version, uint32_t id) +{ + wl_client_add_object(client, &wl_data_device_manager_interface, + &data_device_manager_implementation, id, NULL); +} + +void swc_data_device_manager_add_globals(struct wl_display * display) +{ + wl_display_add_global(display, &wl_data_device_manager_interface, NULL, + &bind_data_device_manager); +} + diff --git a/data_device_manager.h b/data_device_manager.h @@ -0,0 +1,9 @@ +#ifndef SWC_DATA_DEVICE_MANAGER_H +#define SWC_DATA_DEVICE_MANAGER_H 1 + +#include <wayland-server.h> + +void swc_data_device_manager_add_globals(struct wl_display * display); + +#endif + diff --git a/keyboard.c b/keyboard.c @@ -0,0 +1,84 @@ +#include "keyboard.h" +#include "util.h" + +#include <stdio.h> + +bool swc_keyboard_initialize(struct swc_keyboard * keyboard) +{ + wl_list_init(&keyboard->resources); + wl_array_init(&keyboard->keys); + //wl_signal_init(&keyboard->focus_signal); // ? + + keyboard->focus.surface = NULL; + keyboard->focus.resource = NULL; + + return true; +} + +void swc_keyboard_finish(struct swc_keyboard * keyboard) +{ + wl_array_release(&keyboard->keys); +} + +void swc_keyboard_set_focus(struct swc_keyboard * keyboard, + struct swc_surface * surface) +{ + struct wl_client * client; + struct wl_display * display; + struct wl_resource * resource; + uint32_t serial; + + /* Unfocus previously focused surface. */ + if (keyboard->focus.resource && keyboard->focus.surface != surface) + { + client = wl_resource_get_client(keyboard->focus.surface->resource); + display = wl_client_get_display(client); + serial = wl_display_next_serial(display); + wl_keyboard_send_leave(keyboard->focus.resource, serial, + keyboard->focus.surface->resource); + } + + /* Focus new surface, if given. */ + if (surface) + { + client = wl_resource_get_client(surface->resource); + resource = swc_find_resource_for_client(&keyboard->resources, client); + + printf("keyboard: focusing surface: %p\n", surface); + + if (resource) + { + display = wl_client_get_display(client); + serial = wl_display_next_serial(display); + wl_keyboard_send_enter(resource, serial, surface->resource, + &keyboard->keys); + + keyboard->focus.resource = resource; + } + else + keyboard->focus.resource = NULL; + + keyboard->focus.surface = surface; + } + else + { + keyboard->focus.surface = NULL; + keyboard->focus.resource = NULL; + } +} + +struct wl_resource * swc_keyboard_bind(struct swc_keyboard * keyboard, + struct wl_client * client, uint32_t id) +{ + struct wl_resource * client_resource; + + client_resource = wl_client_add_object(client, &wl_keyboard_interface, + NULL, id, NULL); + wl_resource_set_destructor(client_resource, &swc_unbind_resource); + wl_list_insert(&keyboard->resources, &client_resource->link); + + printf("keyboard: adding client %p, resource: %p\n", client, client_resource); + + return client_resource; +} + diff --git a/keyboard.h b/keyboard.h @@ -0,0 +1,53 @@ +#ifndef SWC_KEYBOARD_H +#define SWC_KEYBOARD_H 1 + +#include "surface.h" + +#include <wayland-server.h> + +struct swc_keyboard; + +struct swc_keyboard_handler +{ + bool (* key)(struct swc_keyboard * keyboard, uint32_t time, + uint32_t key, uint32_t state); + bool (* modifiers)(struct swc_keyboard * keyboyard, uint32_t serial, + uint32_t mods_depressed, uint32_t mods_latched, + uint32_t mods_locked, uint32_t group); +}; + +struct swc_keyboard +{ + struct wl_list resources; + + struct + { + struct swc_surface * surface; + struct wl_resource * resource; + } focus; + + //struct wl_listener focus_listener; + //struct wl_signal focus_signal; + + struct swc_keyboard_handler * handler; + + struct wl_array keys; + + struct + { + uint32_t mods_depressed; + uint32_t mods_latched; + uint32_t mods_locked; + uint32_t group; + } modifiers; +}; + +bool swc_keyboard_initialize(struct swc_keyboard * keyboard); +void swc_keyboard_finish(struct swc_keyboard * keyboard); +void swc_keyboard_set_focus(struct swc_keyboard * keyboard, + struct swc_surface * surface); +struct wl_resource * swc_keyboard_bind(struct swc_keyboard * keyboard, + struct wl_client * client, uint32_t id); + +#endif + diff --git a/pointer.c b/pointer.c @@ -0,0 +1,115 @@ +#include "pointer.h" +#include "util.h" +#include "event.h" + +#include <stdio.h> + +bool swc_pointer_initialize(struct swc_pointer * pointer) +{ + wl_list_init(&pointer->resources); + wl_signal_init(&pointer->event_signal); + + pointer->x = wl_fixed_from_int(0); + pointer->y = wl_fixed_from_int(0); + + pointer->focus.surface = NULL; + pointer->focus.resource = NULL; + + return true; +} + +void swc_pointer_finish(struct swc_pointer * pointer) +{ +} + +void swc_pointer_set_focus(struct swc_pointer * pointer, + struct swc_surface * surface) +{ + struct wl_client * client; + struct wl_display * display; + struct wl_resource * resource; + uint32_t serial; + + /* Unfocus previously focused surface. */ + if (pointer->focus.resource && pointer->focus.surface != surface) + { + client = wl_resource_get_client(pointer->focus.surface->resource); + display = wl_client_get_display(client); + serial = wl_display_next_serial(display); + wl_pointer_send_leave(pointer->focus.resource, serial, + pointer->focus.surface->resource); + } + + /* Focus new surface, if given. */ + if (surface) + { + client = wl_resource_get_client(surface->resource); + resource = swc_find_resource_for_client(&pointer->resources, client); + + printf("pointer: focusing surface: %p\n", surface); + + if (resource) + { + uint32_t surface_x, surface_y; + + surface_x = wl_fixed_to_int(pointer->x) - surface->geometry.x; + surface_y = wl_fixed_to_int(pointer->y) - surface->geometry.y; + + display = wl_client_get_display(client); + serial = wl_display_next_serial(display); + wl_pointer_send_enter(resource, serial, surface->resource, + wl_fixed_from_int(surface_x), + wl_fixed_from_int(surface_y)); + + pointer->focus.resource = resource; + } + + pointer->focus.surface = surface; + } + else + { + pointer->focus.surface = NULL; + pointer->focus.resource = NULL; + } +} + +static void set_cursor(struct wl_client * client, + struct wl_resource * resource, uint32_t serial, + struct wl_resource * surface_resource, + int32_t hotspot_x, int32_t hotspot_y) +{ + struct swc_pointer * pointer = resource->data; + struct swc_surface * surface = surface_resource->data; + struct swc_event event; + + printf("set_cursor\n"); + + pointer->cursor.surface = surface; + pointer->cursor.hotspot_x = hotspot_x; + pointer->cursor.hotspot_y = hotspot_y; + + event.type = SWC_POINTER_CURSOR_CHANGED; + event.data = surface; + + wl_signal_emit(&pointer->event_signal, &event); +} + +struct wl_pointer_interface pointer_implementation = { + .set_cursor = &set_cursor +}; + +struct wl_resource * swc_pointer_bind(struct swc_pointer * pointer, + struct wl_client * client, uint32_t id) +{ + struct wl_resource * client_resource; + + printf("pointer: adding client %p\n", client); + + client_resource = wl_client_add_object(client, &wl_pointer_interface, + &pointer_implementation, id, pointer); + wl_resource_set_destructor(client_resource, &swc_unbind_resource); + wl_list_insert(&pointer->resources, &client_resource->link); + + return client_resource; +} + diff --git a/pointer.h b/pointer.h @@ -0,0 +1,58 @@ +#ifndef SWC_POINTER_H +#define SWC_POINTER_H 1 + +#include "surface.h" + +#include <wayland-server.h> + +struct swc_pointer; + +struct swc_pointer_handler +{ + void (* focus)(struct swc_pointer * pointer); + void (* motion)(struct swc_pointer * pointer, uint32_t time); + void (* button)(struct swc_pointer * pointer, uint32_t time, + uint32_t button, uint32_t state); +}; + +enum swc_pointer_event +{ + SWC_POINTER_CURSOR_CHANGED +}; + +struct swc_pointer +{ + struct wl_list resources; + + struct + { + struct swc_surface * surface; + struct wl_resource * resource; + } focus; + + //uint32_t focus_serial; + //struct wl_signal focus_signal; + struct wl_signal event_signal; + + struct + { + struct swc_surface * surface; + int32_t hotspot_x, hotspot_y; + } cursor; + + struct swc_pointer_handler * handler; + + wl_fixed_t x, y; + + uint32_t button_count; +}; + +bool swc_pointer_initialize(struct swc_pointer * pointer); +void swc_pointer_finish(struct swc_pointer * pointer); +void swc_pointer_set_focus(struct swc_pointer * pointer, + struct swc_surface * surface); +struct wl_resource * swc_pointer_bind(struct swc_pointer * pointer, + struct wl_client * client, uint32_t id); + +#endif + diff --git a/seat.c b/seat.c @@ -22,12 +22,20 @@ static void bind_seat(struct wl_client * client, void * data, uint32_t version, resource = wl_client_add_object(client, &wl_seat_interface, &swc_seat_interface, id, seat); - wl_list_insert(&seat->wayland.base_resource_list, &resource->link); - resource->destroy = &swc_unbind_resource; + wl_list_insert(&seat->resources, &resource->link); + wl_resource_set_destructor(resource, &swc_unbind_resource); wl_seat_send_capabilities(resource, seat->capabilities); } +static void update_capabilities(struct swc_seat * seat) +{ + struct wl_resource * resource; + + wl_list_for_each(resource, &seat->resources, link) + wl_seat_send_capabilities(resource, seat->capabilities); +} + static void add_device(struct swc_seat * seat, struct udev_device * udev_device) { const char * device_seat; @@ -55,16 +63,18 @@ static void add_device(struct swc_seat * seat, struct udev_device * udev_device) && evdev_device->capabilities & WL_SEAT_CAPABILITY_POINTER) { printf("initializing pointer\n"); - wl_pointer_init(&seat->pointer); - wl_seat_set_pointer(&seat->wayland, &seat->pointer); + swc_pointer_initialize(&seat->pointer); + seat->capabilities |= WL_SEAT_CAPABILITY_POINTER; + update_capabilities(seat); } if (!(seat->capabilities & WL_SEAT_CAPABILITY_KEYBOARD) && evdev_device->capabilities & WL_SEAT_CAPABILITY_KEYBOARD) { printf("initializing keyboard\n"); - wl_keyboard_init(&seat->keyboard); - wl_seat_set_keyboard(&seat->wayland, &seat->keyboard); + swc_keyboard_initialize(&seat->keyboard); + seat->capabilities |= WL_SEAT_CAPABILITY_KEYBOARD; + update_capabilities(seat); } seat->capabilities |= evdev_device->capabilities; @@ -75,11 +85,8 @@ static void add_device(struct swc_seat * seat, struct udev_device * udev_device) bool swc_seat_initialize(struct swc_seat * seat, struct udev * udev, const char * seat_name) { - wl_seat_init(&seat->wayland); - seat->name = strdup(seat_name); seat->capabilities = 0; - seat->active_modifiers = 0; if (!swc_xkb_initialize(&seat->xkb)) { @@ -87,6 +94,8 @@ bool swc_seat_initialize(struct swc_seat * seat, struct udev * udev, goto error_name; } + wl_list_init(&seat->resources); + wl_signal_init(&seat->destroy_signal); wl_list_init(&seat->devices); swc_seat_add_devices(seat, udev); @@ -102,7 +111,14 @@ void swc_seat_finish(struct swc_seat * seat) { struct swc_evdev_device * device, * tmp; - wl_seat_release(&seat->wayland); + wl_signal_emit(&seat->destroy_signal, seat); + + if (seat->capabilities & WL_SEAT_CAPABILITY_KEYBOARD) + swc_keyboard_finish(&seat->keyboard); + + if (seat->capabilities & WL_SEAT_CAPABILITY_POINTER) + swc_pointer_finish(&seat->pointer); + free(seat->name); swc_xkb_finish(&seat->xkb); @@ -157,8 +173,10 @@ void swc_seat_handle_key(struct swc_seat * seat, uint32_t time, uint32_t key, uint32_t state) { uint32_t * pressed_key; - struct wl_keyboard * keyboard = &seat->keyboard; + struct swc_keyboard * keyboard = &seat->keyboard; struct swc_xkb * xkb = &seat->xkb; + struct wl_display * display; + uint32_t serial; enum xkb_key_direction direction; /* Update XKB state */ @@ -170,8 +188,8 @@ void swc_seat_handle_key(struct swc_seat * seat, uint32_t time, uint32_t key, if (state == WL_KEYBOARD_KEY_STATE_PRESSED) { - keyboard->grab_key = key; - keyboard->grab_time = time; + //keyboard->grab_key = key; + //keyboard->grab_time = time; pressed_key = wl_array_add(&keyboard->keys, sizeof key); *pressed_key = key; } @@ -191,10 +209,21 @@ void swc_seat_handle_key(struct swc_seat * seat, uint32_t time, uint32_t key, } } - keyboard->grab->interface->key(keyboard->grab, time, key, state); + /* See if the key press is not handled by the compositor */ + if (!(keyboard->handler && keyboard->handler->key) + || !keyboard->handler->key(keyboard, time, key, state)) + { + if (keyboard->focus.resource) + { + serial = wl_display_next_serial(display); + wl_keyboard_send_key(keyboard->focus.resource, serial, time, key, state); + + if (state == WL_KEYBOARD_KEY_STATE_PRESSED) + printf("\t-> sent to client\n"); + } + } { - struct wl_keyboard * keyboard = &seat->keyboard; uint32_t mods_depressed, mods_latched, mods_locked, mods_active; uint32_t layout; @@ -216,17 +245,6 @@ void swc_seat_handle_key(struct swc_seat * seat, uint32_t time, uint32_t key, keyboard->modifiers.mods_latched = mods_latched; keyboard->modifiers.mods_locked = mods_locked; keyboard->modifiers.group = layout; - - seat->active_modifiers = 0; - - if (mods_active & (1 << xkb->indices.ctrl)) - seat->active_modifiers |= MOD_CTRL; - if (mods_active & (1 << xkb->indices.alt)) - seat->active_modifiers |= MOD_ALT; - if (mods_active & (1 << xkb->indices.super)) - seat->active_modifiers |= MOD_SUPER; - if (mods_active & (1 << xkb->indices.shift)) - seat->active_modifiers |= MOD_SHIFT; } } @@ -239,20 +257,15 @@ void swc_seat_handle_button(struct swc_seat * seat, uint32_t time, void swc_seat_get_pointer(struct wl_client * client, struct wl_resource * resource, uint32_t id) { - struct wl_resource * client_resource; struct swc_seat * seat = resource->data; - struct wl_pointer * pointer = &seat->pointer; - - /* pointer interface? */ - client_resource = wl_client_add_object(client, &wl_pointer_interface, - NULL, id, seat); - client_resource->destroy = &swc_unbind_resource; + struct swc_pointer * pointer = &seat->pointer; - wl_list_insert(&pointer->resource_list, &client_resource->link); + swc_pointer_bind(pointer, client, id); - if (pointer->focus && pointer->focus->resource.client == client) + if (pointer->focus.surface + && wl_resource_get_client(pointer->focus.surface->resource) == client) { - //wl_pointer_set_focus(pointer, pointer->focus); + swc_pointer_set_focus(pointer, pointer->focus.surface); } } @@ -260,20 +273,20 @@ void swc_seat_get_keyboard(struct wl_client * client, struct wl_resource * resource, uint32_t id) { struct wl_resource * client_resource; - struct swc_seat * seat = resource->data; - struct wl_keyboard * keyboard = &seat->keyboard; - - client_resource = wl_client_add_object(client, &wl_keyboard_interface, - NULL, id, seat); - client_resource->destroy = &swc_unbind_resource; + struct swc_seat * seat = wl_resource_get_user_data(resource); + struct swc_keyboard * keyboard = &seat->keyboard; - wl_list_insert(&keyboard->resource_list, &client_resource->link); + client_resource = swc_keyboard_bind(keyboard, client, id); wl_keyboard_send_keymap(client_resource, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, seat->xkb.keymap.fd, seat->xkb.keymap.size); - if (keyboard->focus && keyboard->focus->resource.client == client) - wl_keyboard_set_focus(keyboard, keyboard->focus); + if (keyboard->focus.surface + && wl_resource_get_client(keyboard->focus.surface->resource) == client) + { + printf("focusing\n"); + swc_keyboard_set_focus(keyboard, keyboard->focus.surface); + } } void swc_seat_get_touch(struct wl_client * client, diff --git a/seat.h b/seat.h @@ -2,6 +2,8 @@ #define SWC_SEAT_H 1 #include "xkb.h" +#include "keyboard.h" +#include "pointer.h" #include <stdint.h> #include <stdbool.h> @@ -10,17 +12,16 @@ struct swc_seat { - struct wl_seat wayland; - char * name; + uint32_t capabilities; struct swc_xkb xkb; - struct wl_keyboard keyboard; - struct wl_pointer pointer; + struct wl_list resources; + struct wl_signal destroy_signal; - uint32_t active_modifiers; - uint32_t capabilities; + struct swc_keyboard keyboard; + struct swc_pointer pointer; struct wl_list devices; }; diff --git a/surface.h b/surface.h @@ -31,7 +31,7 @@ struct swc_surface_state struct swc_surface { - struct wl_surface wayland; + struct wl_resource * resource; struct swc_surface_state state; @@ -46,6 +46,7 @@ struct swc_surface struct { + uint32_t x, y; uint32_t width, height; } geometry;