[PATCH weston 3/4] data-device: Lookup drag resources using the focussed surface
From: Rob Bradford Rather than relying on focussed resource to get the client to lookup the drag resource with instead derive the client from the focussed surface. This is equivalent as the focussed resource is derived from the focussed surface in the weston_keyboard_set_focus function. --- src/data-device.c | 31 +++ 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/data-device.c b/src/data-device.c index 1eb1925..e062875 100644 --- a/src/data-device.c +++ b/src/data-device.c @@ -421,15 +421,14 @@ destroy_selection_data_source(struct wl_listener *listener, void *data) struct weston_seat *seat = container_of(listener, struct weston_seat, selection_data_source_listener); struct wl_resource *data_device; - struct wl_resource *focus = NULL; + struct wl_client *client; seat->selection_data_source = NULL; - if (seat->keyboard) - focus = seat->keyboard->focus_resource; - if (focus) { + if (seat->keyboard && seat->keyboard->focus) { + client = wl_resource_get_client(seat->keyboard->focus->resource); data_device = wl_resource_find_for_client(&seat->drag_resource_list, - wl_resource_get_client(focus)); + client); if (data_device) wl_data_device_send_selection(data_device, NULL); } @@ -442,7 +441,7 @@ weston_seat_set_selection(struct weston_seat *seat, struct weston_data_source *source, uint32_t serial) { struct wl_resource *data_device, *offer; - struct wl_resource *focus = NULL; + struct wl_client *client; if (seat->selection_data_source && seat->selection_serial - serial < UINT32_MAX / 2) @@ -457,11 +456,10 @@ weston_seat_set_selection(struct weston_seat *seat, seat->selection_data_source = source; seat->selection_serial = serial; - if (seat->keyboard) - focus = seat->keyboard->focus_resource; - if (focus) { + if (seat->keyboard && seat->keyboard->focus) { + client = wl_resource_get_client(seat->keyboard->focus->resource); data_device = wl_resource_find_for_client(&seat->drag_resource_list, - wl_resource_get_client(focus)); + client); if (data_device && source) { offer = weston_data_source_send_offer(seat->selection_data_source, data_device); @@ -615,18 +613,19 @@ bind_manager(struct wl_client *client, WL_EXPORT void wl_data_device_set_keyboard_focus(struct weston_seat *seat) { - struct wl_resource *data_device, *focus, *offer; + struct wl_resource *data_device = NULL, *offer; struct weston_data_source *source; + struct wl_client *client; if (!seat->keyboard) return; - focus = seat->keyboard->focus_resource; - if (!focus) - return; + if (seat->keyboard && seat->keyboard->focus) { + client = wl_resource_get_client(seat->keyboard->focus->resource); + data_device = wl_resource_find_for_client(&seat->drag_resource_list, + client); + } - data_device = wl_resource_find_for_client(&seat->drag_resource_list, - wl_resource_get_client(focus)); if (!data_device) return; -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 2/4] input: Use a client destroy listener for resetting the focus resource
From: Rob Bradford This is currently equivalent as there is no way for the pointer, keyboard or touch resource to be destroyed without the client being destroyed. This removes another place where a single resource for the focus is assumed. --- src/input.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/input.c b/src/input.c index e6d074e..7344c4d 100644 --- a/src/input.c +++ b/src/input.c @@ -451,8 +451,8 @@ weston_pointer_set_focus(struct weston_pointer *pointer, } wl_pointer_send_enter(resource, serial, surface->resource, sx, sy); - wl_resource_add_destroy_listener(resource, -&pointer->focus_listener); + wl_client_add_destroy_listener(wl_resource_get_client(surface->resource), + &pointer->focus_listener); pointer->focus_serial = serial; } @@ -490,8 +490,8 @@ weston_keyboard_set_focus(struct weston_keyboard *keyboard, keyboard->modifiers.group); wl_keyboard_send_enter(resource, serial, surface->resource, &keyboard->keys); - wl_resource_add_destroy_listener(resource, -&keyboard->focus_listener); + wl_client_add_destroy_listener(wl_resource_get_client(surface->resource), + &keyboard->focus_listener); keyboard->focus_serial = serial; } @@ -997,8 +997,8 @@ weston_touch_set_focus(struct weston_seat *seat, struct weston_surface *surface) seat->touch->focus = surface; seat->touch->focus_resource = resource; - wl_resource_add_destroy_listener(resource, -&seat->touch->focus_listener); + wl_client_add_destroy_listener(wl_resource_get_client(surface->resource), + &seat->touch->focus_listener); } } -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH wayland] wayland-server: Add a wl_resource_for_each_safe macro
From: Rob Bradford A version of wl_resource_for_each that is safe for iteration when items in the list are removed. --- src/wayland-server.h | 8 1 file changed, 8 insertions(+) diff --git a/src/wayland-server.h b/src/wayland-server.h index d77050d..c0365c0 100644 --- a/src/wayland-server.h +++ b/src/wayland-server.h @@ -313,6 +313,14 @@ wl_resource_get_destroy_listener(struct wl_resource *resource, wl_resource_get_link(resource) != (list); \ resource = wl_resource_from_link(wl_resource_get_link(resource)->next)) +#define wl_resource_for_each_safe(resource, tmp, list) \ + for (resource = 0, tmp = 0, \ +resource = wl_resource_from_link((list)->next),\ +tmp = wl_resource_from_link((list)->next->next); \ +wl_resource_get_link(resource) != (list); \ +resource = tmp, \ +tmp = wl_resource_from_link(wl_resource_get_link(resource)->next)) + struct wl_shm_buffer; struct wl_shm_buffer * -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 1/4] input: Use new wl_resource_for_each for sending updated seat caps
From: Rob Bradford --- src/input.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/input.c b/src/input.c index aa40b4e..e6d074e 100644 --- a/src/input.c +++ b/src/input.c @@ -398,8 +398,8 @@ weston_touch_destroy(struct weston_touch *touch) static void seat_send_updated_caps(struct weston_seat *seat) { - struct wl_list *link; enum wl_seat_capability caps = 0; + struct wl_resource *resource; if (seat->pointer) caps |= WL_SEAT_CAPABILITY_POINTER; @@ -408,9 +408,8 @@ seat_send_updated_caps(struct weston_seat *seat) if (seat->touch) caps |= WL_SEAT_CAPABILITY_TOUCH; - for (link = seat->base_resource_list.next; -link != &seat->base_resource_list; link = link->next) { - wl_seat_send_capabilities(wl_resource_from_link(link), caps); + wl_resource_for_each(resource, &seat->base_resource_list) { + wl_seat_send_capabilities(resource, caps); } } -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
WIP patches for multi resource using in place lists
As per your feedback i've dropped the per client list of resources stored in array indexed by a new client ID and replaced that with logic that munges the focussed resources from each list. The first three patches in the series were common with the previous solution. Unfortunately this last patch must be seen as a WIP as: 1. There are lots of long lines! 2. Some common code could probable be factored into its own function (like sending modifiers out) 3. When starting a client it doesn't seem to get focus I'm posting this patch set as it's very close to behaving as before and perhaps yourself and others can find the problems before I get the time to do so! Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 4/4] input: Emit events on all resources for a client
From: Rob Bradford The Wayland protocol permits a client to request the pointer, keyboard and touch multiple times from the seat global. This is very useful in a component like Clutter-GTK where we are combining two libraries that use Wayland together. This change migrates the weston input handling code to emit the events for all the resources for the client by using the newly added wl_resource_for_each macro to iterate over the resources that are associated with the focussed surface's client. We maintain a list of focussed resources on the pointer and keyboard which is updated when the focus changes. However since we can have resources created after the focus has already been set we must add the resources to the right list and also update any state. --- src/bindings.c | 17 ++- src/compositor.h | 6 +- src/input.c | 344 +++ src/shell.c | 33 +++--- 4 files changed, 248 insertions(+), 152 deletions(-) diff --git a/src/bindings.c b/src/bindings.c index a871c26..55823e0 100644 --- a/src/bindings.c +++ b/src/bindings.c @@ -160,7 +160,6 @@ binding_key(struct weston_keyboard_grab *grab, struct weston_keyboard *keyboard = grab->keyboard; struct wl_display *display = keyboard->seat->compositor->wl_display; - resource = grab->keyboard->focus_resource; if (key == b->key) { if (state == WL_KEYBOARD_KEY_STATE_RELEASED) { weston_keyboard_end_grab(grab->keyboard); @@ -168,9 +167,11 @@ binding_key(struct weston_keyboard_grab *grab, keyboard->grab = &keyboard->input_method_grab; free(b); } - } else if (resource) { + } else { serial = wl_display_next_serial(display); - wl_keyboard_send_key(resource, serial, time, key, state); + wl_resource_for_each(resource, &keyboard->focus_resource_list) { + wl_keyboard_send_key(resource, serial, time, key, state); + } } } @@ -181,12 +182,10 @@ binding_modifiers(struct weston_keyboard_grab *grab, uint32_t serial, { struct wl_resource *resource; - resource = grab->keyboard->focus_resource; - if (!resource) - return; - - wl_keyboard_send_modifiers(resource, serial, mods_depressed, - mods_latched, mods_locked, group); + wl_resource_for_each(resource, &grab->keyboard->focus_resource_list) { + wl_keyboard_send_modifiers(resource, serial, mods_depressed, + mods_latched, mods_locked, group); + } } static const struct weston_keyboard_grab_interface binding_grab = { diff --git a/src/compositor.h b/src/compositor.h index 6db3c61..23201cf 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -300,8 +300,8 @@ struct weston_pointer { struct weston_seat *seat; struct wl_list resource_list; + struct wl_list focus_resource_list; struct weston_surface *focus; - struct wl_resource *focus_resource; struct wl_listener focus_listener; uint32_t focus_serial; struct wl_signal focus_signal; @@ -326,8 +326,8 @@ struct weston_touch { struct weston_seat *seat; struct wl_list resource_list; + struct wl_list focus_resource_list; struct weston_surface *focus; - struct wl_resource *focus_resource; struct wl_listener focus_listener; uint32_t focus_serial; struct wl_signal focus_signal; @@ -415,8 +415,8 @@ struct weston_keyboard { struct weston_seat *seat; struct wl_list resource_list; + struct wl_list focus_resource_list; struct weston_surface *focus; - struct wl_resource *focus_resource; struct wl_listener focus_listener; uint32_t focus_serial; struct wl_signal focus_signal; diff --git a/src/input.c b/src/input.c index 7344c4d..d63ca77 100644 --- a/src/input.c +++ b/src/input.c @@ -71,12 +71,33 @@ weston_compositor_idle_release(struct weston_compositor *compositor) } static void +move_resources(struct wl_list *destination, struct wl_list *source) +{ + struct wl_resource *resource, *tmp; + wl_resource_for_each_safe(resource, tmp, source) { + wl_list_remove(wl_resource_get_link(resource)); + wl_list_insert(destination, wl_resource_get_link(resource)); + } +} + +static void +move_resources_for_client(struct wl_list *destination, struct wl_list *source, struct wl_client *client) +{ + struct wl_resource *resource, *tmp; + wl_resource_for_each_safe(resource, tmp, source) { + if (wl_resource_get_client(resource) == client) { + wl_list_remove(wl_resource_get_link(resource)); +
Re: [PATCH] autotools: Add configure summary
On 14 August 2013 04:48, Kristian Høgsberg wrote: > On Wed, Aug 14, 2013 at 03:13:53AM +0200, Armin K wrote: >> --- >> configure.ac | 43 ++- >> 1 file changed, 42 insertions(+), 1 deletion(-) > > That looks very nice, thanks. Cool patch - going to save me a lot of time looking through config.log. Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston 1/2] compositor: Implement release request for input interfaces
On 13 August 2013 20:11, Rob Bradford wrote: > +static void > +pointer_release(struct wl_client *client, struct wl_resource *resource) > +{ > + wl_resource_destroy(resource); > +} > + Wondering if we should also send leave events here if the pointer has a focus...The only other time we destroy an input resource is because the client has gone away and in that case the surface too. Perhaps worth extending the testing to enable pairs of get_pointer/release. Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 2/2] window: Use new wl_pointer/keyboard_release request
From: Rob Bradford Since we bump the version we ask for from the compositor it is also necessary to implement the new "name" event in the seat listener. --- clients/window.c | 23 ++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/clients/window.c b/clients/window.c index 3410354..325d184 100644 --- a/clients/window.c +++ b/clients/window.c @@ -130,6 +130,7 @@ struct display { void *dummy_surface_data; int has_rgb565; + int seat_version; }; enum { @@ -3377,8 +3378,16 @@ seat_handle_capabilities(void *data, struct wl_seat *seat, } } +static void +seat_handle_name(void *data, struct wl_seat *seat, +const char *name) +{ + +} + static const struct wl_seat_listener seat_listener = { seat_handle_capabilities, + seat_handle_name }; void @@ -4915,6 +4924,8 @@ fini_xkb(struct input *input) xkb_map_unref(input->xkb.keymap); } +#define MAX(a,b) ((a) > (b) ? a : b) + static void display_add_input(struct display *d, uint32_t id) { @@ -4925,7 +4936,8 @@ display_add_input(struct display *d, uint32_t id) return; input->display = d; - input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, 1); + input->seat = wl_registry_bind(d->registry, id, &wl_seat_interface, + MAX(d->seat_version, 3)); input->pointer_focus = NULL; input->keyboard_focus = NULL; wl_list_init(&input->touch_point_list); @@ -4962,6 +4974,14 @@ input_destroy(struct input *input) data_offer_destroy(input->selection_offer); wl_data_device_destroy(input->data_device); + + if (input->display->seat_version >= 3) { + if (input->pointer) + wl_pointer_release(input->pointer); + if (input->keyboard) + wl_keyboard_release(input->keyboard); + } + fini_xkb(input); wl_surface_destroy(input->pointer_surface); @@ -5016,6 +5036,7 @@ registry_handle_global(void *data, struct wl_registry *registry, uint32_t id, } else if (strcmp(interface, "wl_output") == 0) { display_add_output(d, id); } else if (strcmp(interface, "wl_seat") == 0) { + d->seat_version = version; display_add_input(d, id); } else if (strcmp(interface, "wl_shell") == 0) { d->shell = wl_registry_bind(registry, -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 1/2] compositor: Implement release request for input interfaces
From: Kristian Høgsberg v2 (Rob Bradford): Update the version numbering for this change --- src/input.c | 37 - 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/input.c b/src/input.c index daa6e4c..caa0fcb 100644 --- a/src/input.c +++ b/src/input.c @@ -1243,8 +1243,15 @@ pointer_set_cursor(struct wl_client *client, struct wl_resource *resource, weston_surface_buffer_height(surface)); } +static void +pointer_release(struct wl_client *client, struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + static const struct wl_pointer_interface pointer_interface = { - pointer_set_cursor + pointer_set_cursor, + pointer_release }; static void @@ -1310,6 +1317,16 @@ seat_get_pointer(struct wl_client *client, struct wl_resource *resource, } static void +keyboard_release(struct wl_client *client, struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + +static const struct wl_keyboard_interface keyboard_interface = { + keyboard_release +}; + +static void seat_get_keyboard(struct wl_client *client, struct wl_resource *resource, uint32_t id) { @@ -1327,7 +1344,7 @@ seat_get_keyboard(struct wl_client *client, struct wl_resource *resource, } add_client_resource(&seat->keyboard->resources, client, cr); - wl_resource_set_implementation(cr, NULL, seat, unbind_resource); + wl_resource_set_implementation(cr, &keyboard_interface, seat, unbind_resource); if (seat->compositor->use_xkbcommon) { wl_keyboard_send_keymap(cr, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, @@ -1350,6 +1367,16 @@ seat_get_keyboard(struct wl_client *client, struct wl_resource *resource, } static void +touch_release(struct wl_client *client, struct wl_resource *resource) +{ + wl_resource_destroy(resource); +} + +static const struct wl_touch_interface touch_interface = { + touch_release +}; + +static void seat_get_touch(struct wl_client *client, struct wl_resource *resource, uint32_t id) { @@ -1367,7 +1394,7 @@ seat_get_touch(struct wl_client *client, struct wl_resource *resource, } add_client_resource(&seat->touch->resources, client, cr); - wl_resource_set_implementation(cr, NULL, seat, unbind_resource); + wl_resource_set_implementation(cr, &touch_interface, seat, unbind_resource); } static const struct wl_seat_interface seat_interface = { @@ -1384,7 +1411,7 @@ bind_seat(struct wl_client *client, void *data, uint32_t version, uint32_t id) enum wl_seat_capability caps = 0; resource = wl_resource_create(client, - &wl_seat_interface, MIN(version, 2), id); + &wl_seat_interface, MIN(version, 3), id); wl_list_insert(&seat->base_resource_list, wl_resource_get_link(resource)); wl_resource_set_implementation(resource, &seat_interface, data, unbind_resource); @@ -1651,7 +1678,7 @@ weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec, wl_list_init(&seat->drag_resource_list); wl_signal_init(&seat->destroy_signal); - seat->global = wl_global_create(ec->wl_display, &wl_seat_interface, 2, + seat->global = wl_global_create(ec->wl_display, &wl_seat_interface, 3, seat, bind_seat); seat->compositor = ec; -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH wayland 2/2] scanner: Emit wl_*_destroy stub even if interface has a destructor
From: Kristian Høgsberg If an interface has a destructor but no 'destroy' method we used to not emit a destroy method. Now with the fix for missing destroy requests for wl_pointer etc we need to emit the local wl_*_destroy always. --- src/scanner.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scanner.c b/src/scanner.c index 5124000..d02d865 100644 --- a/src/scanner.c +++ b/src/scanner.c @@ -606,7 +606,7 @@ emit_stubs(struct wl_list *message_list, struct interface *interface) exit(EXIT_FAILURE); } - if (!has_destructor && strcmp(interface->name, "wl_display") != 0) + if (!has_destroy && strcmp(interface->name, "wl_display") != 0) printf("static inline void\n" "%s_destroy(struct %s *%s)\n" "{\n" -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH wayland 1/2] protocol: Add release requests for wl_pointer, wl_keyboard, and wl_touch
From: Kristian Høgsberg We missed destroy requests in the 1.0 protocol and since the scanner generates local-only *_destroy requests in that case we can't add destroy requests without breaking protocol. A client needs to verify that the server provides a version 3 seat to use the protocol destructor so the name needs to be something else than wl_*_destroy. v2 (Rob Bradford): Rebased, bumped the protocol versions and added since attributes to the requests. --- protocol/wayland.xml | 18 +++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/protocol/wayland.xml b/protocol/wayland.xml index d79..6d2884e 100644 --- a/protocol/wayland.xml +++ b/protocol/wayland.xml @@ -1235,7 +1235,7 @@ - + A seat is a group of keyboards, pointer and touch devices. This object is published as a global during start up, or when such a @@ -1308,7 +1308,7 @@ - + The wl_pointer interface represents one or more input devices, such as mice, which control the pointer location and pointer_focus @@ -1357,6 +1357,10 @@ + + + + Notification that this seat's pointer is focused on a certain @@ -1456,12 +1460,16 @@ - + The wl_keyboard interface represents one or more keyboards associated with a seat. + + + + This specifies the format of the keymap provided to the @@ -1551,6 +1559,10 @@ contact point can be identified by the ID of the sequence. + + + + A new touch point has appeared on the surface. This touch point is -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Destructors for pointer/keyboard/touch
Hi folks, One of the prerequisites for pointer lock support is the client being able to request the destruction of the client. Kristian wrote the patches below some time ago and i've rebased and bumped the versions appropriately. Unfortunately in order to maintain API we must call our destructor _release and _destroy will be an autogenerated client-side version that will not send a request to the server. As well as the patches to add the protocol patches to support this request in Weston are also provided along with a change to make toytoolkit use the new request. Cheers, Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH wayland] wayland-server: Add a numerical id per client
From: Rob Bradford Assign each client a numerical id when the client is created for the display. We do not want the client ids to be sparse so that they can be used for space efficient lookups in the compositor; so when the client is destroyed we release the id either into the next counter if it was the most recent client or into a free pool. The next id is provided using a most recently freed strategy. Since the structure is opaque this change also adds an accessor function for the client to retrieve the id. --- src/wayland-server.c | 45 + src/wayland-server.h | 1 + 2 files changed, 46 insertions(+) diff --git a/src/wayland-server.c b/src/wayland-server.c index 771309f..2ffa3a4 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -77,6 +77,7 @@ struct wl_client { struct wl_signal destroy_signal; struct ucred ucred; int error; + uint32_t id; }; struct wl_display { @@ -94,6 +95,9 @@ struct wl_display { struct wl_signal destroy_signal; struct wl_array additional_shm_formats; + + struct wl_array free_client_ids; + uint32_t next_client_id; }; struct wl_global { @@ -331,6 +335,26 @@ static void bind_display(struct wl_client *client, void *data, uint32_t version, uint32_t id); +static uint32_t +get_next_client_id (struct wl_display *display) +{ + uint32_t id = 0; + uint32_t *p; + + if (display->free_client_ids.size > 0) { + p = display->free_client_ids.data + + display->free_client_ids.size - + sizeof(uint32_t); + id = *p; + display->free_client_ids.size -= sizeof(uint32_t); + return id; + } + + id = display->next_client_id; + display->next_client_id++; + return id; +} + WL_EXPORT struct wl_client * wl_client_create(struct wl_display *display, int fd) { @@ -372,6 +396,8 @@ wl_client_create(struct wl_display *display, int fd) wl_list_insert(display->client_list.prev, &client->link); + client->id = get_next_client_id(display); + return client; err_map: @@ -572,9 +598,24 @@ wl_client_destroy(struct wl_client *client) wl_event_source_remove(client->source); wl_connection_destroy(client->connection); wl_list_remove(&client->link); + + if (client->id == client->display->next_client_id - 1) { + client->display->next_client_id--; + } else { + uint32_t *p; + p = wl_array_add(&client->display->free_client_ids, sizeof *p); + *p = client->id; + } + free(client); } +WL_EXPORT uint32_t +wl_client_get_id(struct wl_client *client) +{ + return client->id; +} + static void registry_bind(struct wl_client *client, struct wl_resource *resource, uint32_t name, @@ -710,6 +751,9 @@ wl_display_create(void) wl_signal_init(&display->destroy_signal); + wl_array_init(&display->free_client_ids); + display->next_client_id = 1; + display->id = 1; display->serial = 0; @@ -747,6 +791,7 @@ wl_display_destroy(struct wl_display *display) free(global); wl_array_release(&display->additional_shm_formats); + wl_array_release(&display->free_client_ids); free(display); } diff --git a/src/wayland-server.h b/src/wayland-server.h index e5e0ed8..a541e25 100644 --- a/src/wayland-server.h +++ b/src/wayland-server.h @@ -128,6 +128,7 @@ struct wl_resource * wl_client_get_object(struct wl_client *client, uint32_t id); void wl_client_post_no_memory(struct wl_client *client); +uint32_t wl_client_get_id(struct wl_client *client); struct wl_listener { struct wl_list link; -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 6/6] input: Use new wl_resource_for_each for sending updated seat caps
From: Rob Bradford --- src/input.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/input.c b/src/input.c index 396e35e..daa6e4c 100644 --- a/src/input.c +++ b/src/input.c @@ -458,8 +458,8 @@ weston_touch_destroy(struct weston_touch *touch) static void seat_send_updated_caps(struct weston_seat *seat) { - struct wl_list *link; enum wl_seat_capability caps = 0; + struct wl_resource *resource; if (seat->pointer) caps |= WL_SEAT_CAPABILITY_POINTER; @@ -468,9 +468,8 @@ seat_send_updated_caps(struct weston_seat *seat) if (seat->touch) caps |= WL_SEAT_CAPABILITY_TOUCH; - for (link = seat->base_resource_list.next; -link != &seat->base_resource_list; link = link->next) { - wl_seat_send_capabilities(wl_resource_from_link(link), caps); + wl_resource_for_each(resource, &seat->base_resource_list) { + wl_seat_send_capabilities(resource, caps); } } -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 5/6] input: Free the memory allocated to store the device resource lists
From: Rob Bradford v2: Walk the array manually as wl_array_for_each is bytewise we're storing pointers that we need to free. --- src/input.c | 27 --- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/input.c b/src/input.c index 1fa3f48..396e35e 100644 --- a/src/input.c +++ b/src/input.c @@ -365,10 +365,17 @@ weston_pointer_create(void) WL_EXPORT void weston_pointer_destroy(struct weston_pointer *pointer) { + void **p; + if (pointer->sprite) pointer_unmap_sprite(pointer); - /* XXX: What about pointer->resource_list? */ + for (p = pointer->resources.data; +p < (void **)(pointer->resources.data + pointer->resources.size); +p+= sizeof(struct wl_list *)) + free(*p); + wl_array_release(&pointer->resources); + if (!wl_list_empty(pointer->focus_resource_list)) wl_list_remove(&pointer->focus_listener.link); free(pointer); @@ -398,7 +405,14 @@ weston_keyboard_create(void) WL_EXPORT void weston_keyboard_destroy(struct weston_keyboard *keyboard) { - /* XXX: What about keyboard->resource_list? */ + void **p; + + for (p = keyboard->resources.data; +p < (void **)(keyboard->resources.data + keyboard->resources.size); +p+= sizeof(struct wl_list *)) + free(*p); + wl_array_release(&keyboard->resources); + if (!wl_list_empty(keyboard->focus_resource_list)) wl_list_remove(&keyboard->focus_listener.link); wl_array_release(&keyboard->keys); @@ -428,7 +442,14 @@ weston_touch_create(void) WL_EXPORT void weston_touch_destroy(struct weston_touch *touch) { - /* XXX: What about touch->resource_list? */ + void **p; + + for (p = touch->resources.data; +p < (void **)(touch->resources.data + touch->resources.size); +p+= sizeof(struct wl_list *)) + free(*p); + wl_array_release(&touch->resources); + if (!wl_list_empty(touch->focus_resource_list)) wl_list_remove(&touch->focus_listener.link); free(touch); -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 4/6] input: Emit events on all resources for a client
From: Rob Bradford The Wayland protocol permits a client to request the pointer, keyboard and touch multiple times from the seat global. This is very useful in a component like Clutter-GTK where we are combining two libraries that use Wayland together. This change migrates the weston input handling code to emit the events for all the resources for the client by using the newly added wl_resource_for_each macro to iterate over the resources that are associated with the focussed surface's client. A pointer to the list of resources is stored as a member on the device structures. In order to handle the loss of focus or the non-availability of a list of resources an empty list sentinel is used. v2: Only save the resource list if we successfully found resources for the destination surface. This avoids a problem where the surface can be focussed before we have any pointer or keyboard resources setup. In that case the surface would appear to be focussed but the state would be inconsistent. --- src/bindings.c | 17 ++--- src/compositor.h | 6 +- src/input.c | 228 +-- src/shell.c | 33 4 files changed, 169 insertions(+), 115 deletions(-) diff --git a/src/bindings.c b/src/bindings.c index a871c26..e51c5ed 100644 --- a/src/bindings.c +++ b/src/bindings.c @@ -160,7 +160,6 @@ binding_key(struct weston_keyboard_grab *grab, struct weston_keyboard *keyboard = grab->keyboard; struct wl_display *display = keyboard->seat->compositor->wl_display; - resource = grab->keyboard->focus_resource; if (key == b->key) { if (state == WL_KEYBOARD_KEY_STATE_RELEASED) { weston_keyboard_end_grab(grab->keyboard); @@ -168,9 +167,11 @@ binding_key(struct weston_keyboard_grab *grab, keyboard->grab = &keyboard->input_method_grab; free(b); } - } else if (resource) { + } else { serial = wl_display_next_serial(display); - wl_keyboard_send_key(resource, serial, time, key, state); + wl_resource_for_each(resource, keyboard->focus_resource_list) { + wl_keyboard_send_key(resource, serial, time, key, state); + } } } @@ -181,12 +182,10 @@ binding_modifiers(struct weston_keyboard_grab *grab, uint32_t serial, { struct wl_resource *resource; - resource = grab->keyboard->focus_resource; - if (!resource) - return; - - wl_keyboard_send_modifiers(resource, serial, mods_depressed, - mods_latched, mods_locked, group); + wl_resource_for_each(resource, grab->keyboard->focus_resource_list) { + wl_keyboard_send_modifiers(resource, serial, mods_depressed, + mods_latched, mods_locked, group); + } } static const struct weston_keyboard_grab_interface binding_grab = { diff --git a/src/compositor.h b/src/compositor.h index 6d5ba62..6ea0440 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -300,8 +300,8 @@ struct weston_pointer { struct weston_seat *seat; struct wl_array resources; + struct wl_list *focus_resource_list; struct weston_surface *focus; - struct wl_resource *focus_resource; struct wl_listener focus_listener; uint32_t focus_serial; struct wl_signal focus_signal; @@ -326,8 +326,8 @@ struct weston_touch { struct weston_seat *seat; struct wl_array resources; + struct wl_list *focus_resource_list; struct weston_surface *focus; - struct wl_resource *focus_resource; struct wl_listener focus_listener; uint32_t focus_serial; struct wl_signal focus_signal; @@ -415,8 +415,8 @@ struct weston_keyboard { struct weston_seat *seat; struct wl_array resources; + struct wl_list *focus_resource_list; struct weston_surface *focus; - struct wl_resource *focus_resource; struct wl_listener focus_listener; uint32_t focus_serial; struct wl_signal focus_signal; diff --git a/src/input.c b/src/input.c index 45c21f1..1fa3f48 100644 --- a/src/input.c +++ b/src/input.c @@ -31,6 +31,8 @@ #include "../shared/os-compatibility.h" #include "compositor.h" +static struct wl_list empty_list = {&empty_list, &empty_list}; + static void empty_region(pixman_region32_t *region) { @@ -74,7 +76,7 @@ lose_pointer_focus(struct wl_listener *listener, void *data) struct weston_pointer *pointer = container_of(listener, struct weston_pointer, focus_listener); - pointer->focus_resource = NULL; + pointer->focus_resource_list = &empty_list; } static void @@ -83,7 +85,7 @@ lose_keyboard_focus(struct wl_listener *l
[PATCH weston 3/6] data-device: Lookup drag resources using the focussed surface
From: Rob Bradford Rather than relying on focussed resource to get the client to lookup the drag resource with instead derive the client from the focussed surface. This is equivalent as the focussed resource is derived from the focussed surface in the weston_keyboard_set_focus function. --- src/data-device.c | 31 +++ 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/data-device.c b/src/data-device.c index 4bf6256..7de1f53 100644 --- a/src/data-device.c +++ b/src/data-device.c @@ -418,15 +418,14 @@ destroy_selection_data_source(struct wl_listener *listener, void *data) struct weston_seat *seat = container_of(listener, struct weston_seat, selection_data_source_listener); struct wl_resource *data_device; - struct wl_resource *focus = NULL; + struct wl_client *client; seat->selection_data_source = NULL; - if (seat->keyboard) - focus = seat->keyboard->focus_resource; - if (focus) { + if (seat->keyboard && seat->keyboard->focus) { + client = wl_resource_get_client(seat->keyboard->focus->resource); data_device = wl_resource_find_for_client(&seat->drag_resource_list, - wl_resource_get_client(focus)); + client); if (data_device) wl_data_device_send_selection(data_device, NULL); } @@ -439,7 +438,7 @@ weston_seat_set_selection(struct weston_seat *seat, struct weston_data_source *source, uint32_t serial) { struct wl_resource *data_device, *offer; - struct wl_resource *focus = NULL; + struct wl_client *client; if (seat->selection_data_source && seat->selection_serial - serial < UINT32_MAX / 2) @@ -454,11 +453,10 @@ weston_seat_set_selection(struct weston_seat *seat, seat->selection_data_source = source; seat->selection_serial = serial; - if (seat->keyboard) - focus = seat->keyboard->focus_resource; - if (focus) { + if (seat->keyboard && seat->keyboard->focus) { + client = wl_resource_get_client(seat->keyboard->focus->resource); data_device = wl_resource_find_for_client(&seat->drag_resource_list, - wl_resource_get_client(focus)); + client); if (data_device && source) { offer = weston_data_source_send_offer(seat->selection_data_source, data_device); @@ -612,18 +610,19 @@ bind_manager(struct wl_client *client, WL_EXPORT void wl_data_device_set_keyboard_focus(struct weston_seat *seat) { - struct wl_resource *data_device, *focus, *offer; + struct wl_resource *data_device = NULL, *offer; struct weston_data_source *source; + struct wl_client *client; if (!seat->keyboard) return; - focus = seat->keyboard->focus_resource; - if (!focus) - return; + if (seat->keyboard && seat->keyboard->focus) { + client = wl_resource_get_client(seat->keyboard->focus->resource); + data_device = wl_resource_find_for_client(&seat->drag_resource_list, + client); + } - data_device = wl_resource_find_for_client(&seat->drag_resource_list, - wl_resource_get_client(focus)); if (!data_device) return; -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 2/6] input: Use a client id indexed array for input device resources
From: Rob Bradford Replace the list of resources per pointer/keyboard/touch with an array of pointers to lists of resources from that client. For compatability with the existing code find_resource_for_surface has been modified to return the resource associated with the first entry in the list and this is used to fill the focussed resource member on pointer, keyboard and touch. --- src/compositor.h | 6 +++--- src/input.c | 66 2 files changed, 55 insertions(+), 17 deletions(-) diff --git a/src/compositor.h b/src/compositor.h index 7600ce3..6d5ba62 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -299,7 +299,7 @@ struct weston_data_source { struct weston_pointer { struct weston_seat *seat; - struct wl_list resource_list; + struct wl_array resources; struct weston_surface *focus; struct wl_resource *focus_resource; struct wl_listener focus_listener; @@ -325,7 +325,7 @@ struct weston_pointer { struct weston_touch { struct weston_seat *seat; - struct wl_list resource_list; + struct wl_array resources; struct weston_surface *focus; struct wl_resource *focus_resource; struct wl_listener focus_listener; @@ -414,7 +414,7 @@ struct weston_xkb_info { struct weston_keyboard { struct weston_seat *seat; - struct wl_list resource_list; + struct wl_array resources; struct weston_surface *focus; struct wl_resource *focus_resource; struct wl_listener focus_listener; diff --git a/src/input.c b/src/input.c index cc2b417..45c21f1 100644 --- a/src/input.c +++ b/src/input.c @@ -229,15 +229,30 @@ default_grab_key(struct weston_keyboard_grab *grab, } static struct wl_resource * -find_resource_for_surface(struct wl_list *list, struct weston_surface *surface) +find_resource_for_surface(struct wl_array *array, struct weston_surface *surface) { + struct wl_client *client; + struct wl_list *list; + uint32_t id; + if (!surface) return NULL; if (!surface->resource) return NULL; - - return wl_resource_find_for_client(list, wl_resource_get_client(surface->resource)); + + client = wl_resource_get_client(surface->resource); + id = wl_client_get_id(client); + + if (array->size < (id + 1) * sizeof(struct wl_list *)) + return NULL; + + list = ((struct wl_list **)array->data)[id]; + + if (wl_list_empty(list)) + return NULL; + else + return wl_resource_from_link(list->next); } static void @@ -257,7 +272,7 @@ default_grab_modifiers(struct weston_keyboard_grab *grab, uint32_t serial, mods_latched, mods_locked, group); if (pointer && pointer->focus && pointer->focus != keyboard->focus) { - pr = find_resource_for_surface(&keyboard->resource_list, + pr = find_resource_for_surface(&keyboard->resources, pointer->focus); if (pr) { wl_keyboard_send_modifiers(pr, @@ -307,7 +322,7 @@ weston_pointer_create(void) if (pointer == NULL) return NULL; - wl_list_init(&pointer->resource_list); + wl_array_init(&pointer->resources); pointer->focus_listener.notify = lose_pointer_focus; pointer->default_grab.interface = &default_pointer_grab_interface; pointer->default_grab.pointer = pointer; @@ -344,7 +359,7 @@ weston_keyboard_create(void) if (keyboard == NULL) return NULL; - wl_list_init(&keyboard->resource_list); + wl_array_init(&keyboard->resources); wl_array_init(&keyboard->keys); keyboard->focus_listener.notify = lose_keyboard_focus; keyboard->default_grab.interface = &default_keyboard_grab_interface; @@ -374,7 +389,7 @@ weston_touch_create(void) if (touch == NULL) return NULL; - wl_list_init(&touch->resource_list); + wl_array_init(&touch->resources); touch->focus_listener.notify = lose_touch_focus; touch->default_grab.interface = &default_touch_grab_interface; touch->default_grab.touch = touch; @@ -430,14 +445,14 @@ weston_pointer_set_focus(struct weston_pointer *pointer, wl_list_remove(&pointer->focus_listener.link); } - resource = find_resource_for_surface(&pointer->resource_list, + resource = find_resource_for_surface(&pointer->resources, surface); if (resource && (pointer->focus != surface || pointer->focus_resource != resource)) {
[PATCH weston 1/6] input: Use a client destroy listener for resetting the focus resource
From: Rob Bradford This is currently equivalent as there is no way for the pointer, keyboard or touch resource to be destroyed without the client being destroyed. This removes another place where a single resource for the focus is assumed. --- src/input.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/input.c b/src/input.c index 68cbbc8..cc2b417 100644 --- a/src/input.c +++ b/src/input.c @@ -450,8 +450,8 @@ weston_pointer_set_focus(struct weston_pointer *pointer, } wl_pointer_send_enter(resource, serial, surface->resource, sx, sy); - wl_resource_add_destroy_listener(resource, -&pointer->focus_listener); + wl_client_add_destroy_listener(wl_resource_get_client(surface->resource), + &pointer->focus_listener); pointer->focus_serial = serial; } @@ -489,8 +489,8 @@ weston_keyboard_set_focus(struct weston_keyboard *keyboard, keyboard->modifiers.group); wl_keyboard_send_enter(resource, serial, surface->resource, &keyboard->keys); - wl_resource_add_destroy_listener(resource, -&keyboard->focus_listener); + wl_client_add_destroy_listener(wl_resource_get_client(surface->resource), + &keyboard->focus_listener); keyboard->focus_serial = serial; } @@ -996,8 +996,8 @@ weston_touch_set_focus(struct weston_seat *seat, struct weston_surface *surface) seat->touch->focus = surface; seat->touch->focus_resource = resource; - wl_resource_add_destroy_listener(resource, -&seat->touch->focus_listener); + wl_client_add_destroy_listener(wl_resource_get_client(surface->resource), + &seat->touch->focus_listener); } } -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Multiple input resource support (v2)
Hi folks, The wayland protocol lets you support multiple wl_pointer/wl_keyboard/wl_touch in a client - unfortunately Weston makes the assumption that there is only one input resource of a given class. These patches support the multiple resources and are a key step in the enabling of libraries like Clutter-GTK where we combine two wayland client library stacks together; each only vaguely aware of the other. This is a resend of the patches incorporating some bugfixes. There are 6 patches for weston and one remaining for Wayland (the other enabling patches have already been integrated.) Cheers, Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH web] building: add --with-cairo=gl to weston autogen step
On 13 August 2013 16:00, U. Artie Eoff wrote: > From: "U. Artie Eoff" > > The option --with-cairo=[image|gl|glesv2] was added to Weston's > configure and it defaults to --with-cairo=image. Since the > preceding instructions elude to compiling and using cairo-gl, > Weston needs to be configured to use it. Is cairo-gl in a mature enough state to be used by everyone? Turning this on will disable the subsurfaces example. Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston] build: Allow more control over cairo use in the clients
From: Rob Bradford Previously the configure script would silently disable the use of accelerated cairo in the clients if cairo-gl could not be found (or cairo-glesv2 if that was requested.) Conversely the use of cairo-gl would be automatically enabled if it was found with no way to disable that feature This change adds --with-cairo which takes one of "image", "gl" or "glesv2" (defaulting to "image"). If "gl" or "glesv2" is specified cairo-egl is checked for as well as the specified renderer. If the check fails then the configure process errors out. --- configure.ac | 43 ++- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index f9f1c53..f08693a 100644 --- a/configure.ac +++ b/configure.ac @@ -201,14 +201,35 @@ if test x$enable_rdp_compositor = xyes; then PKG_CHECK_MODULES(RDP_COMPOSITOR, [freerdp >= 1.1.0]) fi +AC_ARG_WITH(cairo, + AS_HELP_STRING([--with-cairo=@<:@image|gl|glesv2@:>@] + [Which Cairo renderer to use for the clients]), + [],[with_cairo="image"]) + +if test "x$with_cairo" = "ximage"; then + cairo_modules="cairo" +else +if test "x$with_cairo" = "xgl"; then + cairo_modules="cairo-gl" +else +if test "x$with_cairo" = "xglesv2"; then + cairo_modules="cairo-glesv2" +else + AC_ERROR([Unknown cairo renderer requested]) +fi +fi +fi + +# Included for legacy compat AC_ARG_WITH(cairo-glesv2, AS_HELP_STRING([--with-cairo-glesv2], - [Use GLESv2 cairo instead of full GL])) + [Use GLESv2 cairo])) if test "x$with_cairo_glesv2" = "xyes"; then cairo_modules="cairo-glesv2" - AC_DEFINE([USE_CAIRO_GLESV2], [1], [Use the GLESv2 GL cairo backend]) -else - cairo_modules="cairo-gl" +fi + +if test "x$cairo_modules" = "xcairo-glesv2"; then +AC_DEFINE([USE_CAIRO_GLESV2], [1], [Use the GLESv2 GL cairo backend]) fi PKG_CHECK_MODULES(PIXMAN, [pixman-1]) @@ -257,11 +278,15 @@ if test x$enable_clients = xyes; then PKG_CHECK_MODULES(POPPLER, [poppler-glib glib-2.0 gobject-2.0 gio-2.0 ], [have_poppler=yes], [have_poppler=no]) - PKG_CHECK_MODULES(CAIRO_EGL, [wayland-egl egl >= 7.10 cairo-egl >= 1.11.3 $cairo_modules], - [have_cairo_egl=yes], [have_cairo_egl=no]) - AS_IF([test "x$have_cairo_egl" = "xyes"], -[AC_DEFINE([HAVE_CAIRO_EGL], [1], [Have cairo-egl])], -[AC_MSG_WARN([clients will use cairo image, cairo-egl not used because $CAIRO_EGL_PKG_ERRORS])]) + + # Only check for cairo-egl if a GL or GLES renderer requested + AS_IF([test "x$cairo_modules" = "xcairo-gl" -o "x$cairo_modules" = "xcairo-glesv2"], [ +PKG_CHECK_MODULES(CAIRO_EGL, [wayland-egl egl >= 7.10 cairo-egl >= 1.11.3 $cairo_modules], + [have_cairo_egl=yes], [have_cairo_egl=no]) +AS_IF([test "x$have_cairo_egl" = "xyes"], + [AC_DEFINE([HAVE_CAIRO_EGL], [1], [Have cairo-egl])], + [AC_ERROR([cairo-egl not used because $CAIRO_EGL_PKG_ERRORS])])]) + PKG_CHECK_MODULES(PANGO, [pangocairo], [have_pango=yes], [have_pango=no]) fi -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston] weston-launch: Only pass non-NULL value into setenv()
From: Rob Bradford getenv() can return NULL is the key is not set, passing NULL into setenv() is an error --- src/weston-launch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/weston-launch.c b/src/weston-launch.c index 5b03094..7264f7e 100644 --- a/src/weston-launch.c +++ b/src/weston-launch.c @@ -515,7 +515,8 @@ setup_session(struct weston_launch *wl) term = getenv("TERM"); clearenv(); - setenv("TERM", term, 1); + if (term) + setenv("TERM", term, 1); setenv("USER", wl->pw->pw_name, 1); setenv("LOGNAME", wl->pw->pw_name, 1); setenv("HOME", wl->pw->pw_dir, 1); -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH wayland 1/2] text-backend: remove the weston_seat destruction listener on destroy
On 30 July 2013 00:41, Kristian Høgsberg wrote: > On Wed, Jul 24, 2013 at 04:57:32PM +0100, Rob Bradford wrote: >> From: Rob Bradford >> >> Prior to freeing the memory in which the link node for the signal is >> emedded we should remove the link node from the list to prevent the list >> from being corrupted. >> >> https://bugs.freedesktop.org/show_bug.cgi?id=67231 > > This and 2/2 look good, and I've applied them. It wasn't clear from > the bug that this was enough though, it sounds like there's still some > linked list corruption in there. Good catches here though. Yes...it's a bit of a game of whack-a-mole :-) The first fix exposed the second. I can't reproduce the remaining valgrind error in the bug but I understand where it's coming from and will try and look into it further. Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston 04/11] compositor-fbdev: Avoid dereferencing a pointer in freed memory
On 27 July 2013 00:21, Bill Spitzak wrote: >> + device = output->device; >> fbdev_output_destroy(base); > > > Are you sure this does not free the memory that is now at *device? Maybe I missed something - can you point me at the code which makes you think it does? My reading of the code indicates the string is a const char * passed into fbdev_ouput_create and saved into that device struct. It is not strdup()ed into there. This patch is to avoid a dereference into a block of memory freed in fbdev_output_destroy() Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 11/11] desktop-shell: Refactor launcher configuration reading to avoid leaking
From: Rob Bradford --- clients/desktop-shell.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c index eb550c8..ad324ba 100644 --- a/clients/desktop-shell.c +++ b/clients/desktop-shell.c @@ -1205,15 +1205,13 @@ panel_add_launchers(struct panel *panel, struct desktop *desktop) if (icon != NULL && path != NULL) { panel_add_launcher(panel, icon, path); + count++; } else { fprintf(stderr, "invalid launcher section\n"); - continue; } free(icon); free(path); - - count++; } if (count == 0) { -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 10/11] compositor-x11: Don't leak the looked up name for skipped outputs
From: Rob Bradford --- src/compositor-x11.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compositor-x11.c b/src/compositor-x11.c index 6baf522..4a73253 100644 --- a/src/compositor-x11.c +++ b/src/compositor-x11.c @@ -1525,8 +1525,10 @@ x11_compositor_create(struct wl_display *display, if (strcmp(section_name, "output") != 0) continue; weston_config_section_get_string(section, "name", &name, NULL); - if (name == NULL || name[0] != 'X') + if (name == NULL || name[0] != 'X') { + free(name); continue; + } weston_config_section_get_string(section, "mode", &mode, "1024x600"); -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 09/11] window: Free the allocated display if we fail to setup libxkbcommon
From: Rob Bradford --- clients/window.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/clients/window.c b/clients/window.c index 8d956ae..d9f7d5a 100644 --- a/clients/window.c +++ b/clients/window.c @@ -4970,6 +4970,13 @@ display_create(int *argc, char *argv[]) return NULL; } + d->xkb_context = xkb_context_new(0); + if (d->xkb_context == NULL) { + fprintf(stderr, "Failed to create XKB context\n"); + free(d); + return NULL; + } + d->epoll_fd = os_epoll_create_cloexec(); d->display_fd = wl_display_get_fd(d->display); d->display_task.run = handle_display_data; @@ -4981,12 +4988,6 @@ display_create(int *argc, char *argv[]) wl_list_init(&d->output_list); wl_list_init(&d->global_list); - d->xkb_context = xkb_context_new(0); - if (d->xkb_context == NULL) { - fprintf(stderr, "Failed to create XKB context\n"); - return NULL; - } - d->workspace = 0; d->workspace_count = 1; -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 08/11] tablet-shell: Avoid leaking the path on failed icon loading
From: Rob Bradford --- clients/tablet-shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/tablet-shell.c b/clients/tablet-shell.c index 3d5e79a..d7aac70 100644 --- a/clients/tablet-shell.c +++ b/clients/tablet-shell.c @@ -396,7 +396,6 @@ tablet_shell_add_launcher(struct tablet *tablet, struct homescreen *homescreen = tablet->homescreen; launcher = malloc(sizeof *launcher); - launcher->path = strdup(path); launcher->icon = load_cairo_surface(icon); if ( !launcher->icon || cairo_surface_status (launcher->icon) != CAIRO_STATUS_SUCCESS) { @@ -404,6 +403,7 @@ tablet_shell_add_launcher(struct tablet *tablet, free(launcher); return; } + launcher->path = strdup(path); launcher->homescreen = homescreen; launcher->widget = widget_add_widget(homescreen->widget, launcher); -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 07/11] image: Free filename saved into structure on error path
From: Rob Bradford --- clients/image.c | 1 + 1 file changed, 1 insertion(+) diff --git a/clients/image.c b/clients/image.c index cbd466c..1f3c77c 100644 --- a/clients/image.c +++ b/clients/image.c @@ -373,6 +373,7 @@ image_create(struct display *display, const char *filename, if (!image->image) { fprintf(stderr, "could not find the image %s!\n", b); + free(image->filename); free(image); return NULL; } -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 06/11] compositor-drm: Use a format width parameter for the modeline sscanf
From: Rob Bradford --- src/compositor-drm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compositor-drm.c b/src/compositor-drm.c index cf626ba..c7d6c04 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -1673,7 +1673,7 @@ parse_modeline(const char *s, drmModeModeInfo *mode) mode->vrefresh = 0; mode->flags = 0; - if (sscanf(s, "%f %hd %hd %hd %hd %hd %hd %hd %hd %s %s", + if (sscanf(s, "%f %hd %hd %hd %hd %hd %hd %hd %hd %15s %15s", &fclock, &mode->hdisplay, &mode->hsync_start, -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 05/11] compositor-fbdev: Close fd used for re-enabling if that fails
From: Rob Bradford The device will be opened again in fbdev_output_create(). --- src/compositor-fbdev.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c index 36631f3..10ba7db 100644 --- a/src/compositor-fbdev.c +++ b/src/compositor-fbdev.c @@ -695,6 +695,8 @@ fbdev_output_reenable(struct fbdev_compositor *compositor, "Attempting to re-open output anyway.\n"); } + close(fb_fd); + /* Remove and re-add the output so that resources depending on * the frame buffer X/Y resolution (such as the shadow buffer) * are re-initialised. */ -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 04/11] compositor-fbdev: Avoid dereferencing a pointer in freed memory
From: Rob Bradford fbdev_output_destroy will free the memory passed into in and since we want to pass the device name into fbdev_output_create we need to save this to an intermediate value --- src/compositor-fbdev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c index 9c3d17e..36631f3 100644 --- a/src/compositor-fbdev.c +++ b/src/compositor-fbdev.c @@ -673,6 +673,7 @@ fbdev_output_reenable(struct fbdev_compositor *compositor, struct fbdev_output *output = to_fbdev_output(base); struct fbdev_screeninfo new_screen_info; int fb_fd; + const char *device; weston_log("Re-enabling fbdev output.\n"); @@ -697,8 +698,9 @@ fbdev_output_reenable(struct fbdev_compositor *compositor, /* Remove and re-add the output so that resources depending on * the frame buffer X/Y resolution (such as the shadow buffer) * are re-initialised. */ + device = output->device; fbdev_output_destroy(base); - fbdev_output_create(compositor, output->device); + fbdev_output_create(compositor, device); return 0; } -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 03/11] tty: Correctly check if the opening of the file descriptor failed
From: Rob Bradford --- src/tty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tty.c b/src/tty.c index 2324f6c..38079a4 100644 --- a/src/tty.c +++ b/src/tty.c @@ -161,7 +161,7 @@ tty_create(struct weston_compositor *compositor, tty_vt_func_t vt_func, tty->fd = try_open_vt(tty); } - if (tty->fd <= 0) { + if (tty->fd < 0) { weston_log("failed to open tty: %m\n"); free(tty); return NULL; -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 02/11] wcap-decode: Close file descriptor when destroying the decoder
From: Rob Bradford --- wcap/wcap-decode.c | 1 + 1 file changed, 1 insertion(+) diff --git a/wcap/wcap-decode.c b/wcap/wcap-decode.c index f7cabe3..2b9304d 100644 --- a/wcap/wcap-decode.c +++ b/wcap/wcap-decode.c @@ -144,6 +144,7 @@ void wcap_decoder_destroy(struct wcap_decoder *decoder) { munmap(decoder->map, decoder->size); + close(decoder->fd); free(decoder->frame); free(decoder); } -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 01/11] drm: close the drm file descriptor when the compositor is destroyed
From: Rob Bradford --- src/compositor-drm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compositor-drm.c b/src/compositor-drm.c index 5a5d79c..cf626ba 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -2260,6 +2260,8 @@ drm_destroy(struct weston_compositor *ec) weston_log("failed to drop master: %m\n"); tty_destroy(d->tty); + close(d->drm.fd); + free(d); } -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: problem when running wayland
On 25 July 2013 13:55, M.hanny sabbagh wrote: > wl_global_create Was added in 4cffa0fd - you need to make sure the wayland you're linking to is new enough. Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston 5/6] input: Emit events on all resources for a client
Thanks for the feedback Daniel. > Implementation-wise, it mostly looks good, but - do we leak > focus_resource_list and friends when releasing? I can't find where > they're freed, but if you're freeing empty_list unconditionally, > you're going to have a bad time ... The list use here is kinda different to the way we normally use it in weston. The list isn't embedded in the structure and is instead a pointer to the memory we malloc to contain the list node. The focus_resource_list pointer acts as a cache which we only ever use for iterating. The list may change if the client brings a new resource online but that will be reflected in the list itself. In the original set for this I made the focus_resource_list pointer point to NULL if we had no focus. But that meant I had to change the iterat macro to check for NULLness and also in a lot more places. The empty list sentinel is used in place of setting the pointer to NULL. The memory for the nodes gets freed in the last patch in the set. Rob Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH wayland 1/2] text-backend: remove the weston_seat destruction listener on destroy
The eagle eyed amongst you will notice these are patches for weston..whoops :-) Rob On 24 July 2013 16:57, Rob Bradford wrote: > From: Rob Bradford > > Prior to freeing the memory in which the link node for the signal is > emedded we should remove the link node from the list to prevent the list > from being corrupted. > > https://bugs.freedesktop.org/show_bug.cgi?id=67231 > --- > src/text-backend.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/src/text-backend.c b/src/text-backend.c > index 3a1d68c..6c7430c 100644 > --- a/src/text-backend.c > +++ b/src/text-backend.c > @@ -792,6 +792,7 @@ input_method_notifier_destroy(struct wl_listener > *listener, void *data) > deactivate_text_input(input_method->model, input_method); > > wl_global_destroy(input_method->input_method_global); > + wl_list_remove(&input_method->destroy_listener.link); > > free(input_method); > } > -- > 1.8.3.1 > ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH wayland 2/2] clipboard: remove the weston_seat destruction listener on destroy
From: Rob Bradford Prior to freeing the memory in which the link node for the signal is emedded we should remove the link node from the list to prevent the list from being corrupted. https://bugs.freedesktop.org/show_bug.cgi?id=67231 --- src/clipboard.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/clipboard.c b/src/clipboard.c index 21a7e69..3a9e5aa 100644 --- a/src/clipboard.c +++ b/src/clipboard.c @@ -250,6 +250,7 @@ clipboard_destroy(struct wl_listener *listener, void *data) container_of(listener, struct clipboard, destroy_listener); wl_list_remove(&clipboard->selection_listener.link); + wl_list_remove(&clipboard->destroy_listener.link); free(clipboard); } -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH wayland 1/2] text-backend: remove the weston_seat destruction listener on destroy
From: Rob Bradford Prior to freeing the memory in which the link node for the signal is emedded we should remove the link node from the list to prevent the list from being corrupted. https://bugs.freedesktop.org/show_bug.cgi?id=67231 --- src/text-backend.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/text-backend.c b/src/text-backend.c index 3a1d68c..6c7430c 100644 --- a/src/text-backend.c +++ b/src/text-backend.c @@ -792,6 +792,7 @@ input_method_notifier_destroy(struct wl_listener *listener, void *data) deactivate_text_input(input_method->model, input_method); wl_global_destroy(input_method->input_method_global); + wl_list_remove(&input_method->destroy_listener.link); free(input_method); } -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v2] input: Free the memory allocated to store the device resource lists
From: Rob Bradford v2: Walk the array manually as wl_array_for_each is bytewise we're storing pointers that we need to free. --- src/input.c | 27 --- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/input.c b/src/input.c index 25f2a3e..08b138c 100644 --- a/src/input.c +++ b/src/input.c @@ -366,10 +366,17 @@ weston_pointer_create(void) WL_EXPORT void weston_pointer_destroy(struct weston_pointer *pointer) { + void **p; + if (pointer->sprite) pointer_unmap_sprite(pointer); - /* XXX: What about pointer->resource_list? */ + for (p = pointer->resources.data; +p < (void **)(pointer->resources.data + pointer->resources.size); +p+= sizeof(struct wl_list *)) + free(*p); + wl_array_release(&pointer->resources); + if (!wl_list_empty(pointer->focus_resource_list)) wl_list_remove(&pointer->focus_listener.link); free(pointer); @@ -400,7 +407,14 @@ weston_keyboard_create(void) WL_EXPORT void weston_keyboard_destroy(struct weston_keyboard *keyboard) { - /* XXX: What about keyboard->resource_list? */ + void **p; + + for (p = keyboard->resources.data; +p < (void **)(keyboard->resources.data + keyboard->resources.size); +p+= sizeof(struct wl_list *)) + free(*p); + wl_array_release(&keyboard->resources); + if (!wl_list_empty(keyboard->focus_resource_list)) wl_list_remove(&keyboard->focus_listener.link); wl_array_release(&keyboard->keys); @@ -431,7 +445,14 @@ weston_touch_create(void) WL_EXPORT void weston_touch_destroy(struct weston_touch *touch) { - /* XXX: What about touch->resource_list? */ + void **p; + + for (p = touch->resources.data; +p < (void **)(touch->resources.data + touch->resources.size); +p+= sizeof(struct wl_list *)) + free(*p); + wl_array_release(&touch->resources); + if (!wl_list_empty(touch->focus_resource_list)) wl_list_remove(&touch->focus_listener.link); free(touch); -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH wayland 2/3] wayland-server: Add a wl_resource_for_each macro
From: Rob Bradford This macro allows you to correctly iterate through a list of resources handling the opaque nature of this type. --- src/wayland-server.h | 5 + 1 file changed, 5 insertions(+) diff --git a/src/wayland-server.h b/src/wayland-server.h index 5109530..6dbd68d 100644 --- a/src/wayland-server.h +++ b/src/wayland-server.h @@ -299,6 +299,11 @@ struct wl_listener * wl_resource_get_destroy_listener(struct wl_resource *resource, wl_notify_func_t notify); +#define wl_resource_for_each(resource, list) \ + for (resource = 0, resource = wl_resource_from_link((list)->next); \ +wl_resource_get_link(resource) != (list); \ +resource = wl_resource_from_link(wl_resource_get_link(resource)->next)) + struct wl_shm_buffer; struct wl_shm_buffer * -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH wayland 1/3] wayland-server: Add a numerical id per client
From: Rob Bradford Assign each client a numerical id when the client is created for the display. We do not want the client ids to be sparse so that they can be used for space efficient lookups in the compositor; so when the client is destroyed we release the id either into the next counter if it was the most recent client or into a free pool. The next id is provided using a most recently freed strategy. Since the structure is opaque this change also adds an accessor function for the client to retrieve the id. --- src/wayland-server.c | 45 + src/wayland-server.h | 1 + 2 files changed, 46 insertions(+) diff --git a/src/wayland-server.c b/src/wayland-server.c index 0a6e112..d3f396a 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -77,6 +77,7 @@ struct wl_client { struct wl_signal destroy_signal; struct ucred ucred; int error; + uint32_t id; }; struct wl_display { @@ -92,6 +93,8 @@ struct wl_display { struct wl_list client_list; struct wl_signal destroy_signal; + struct wl_array free_client_ids; + uint32_t next_client_id; }; struct wl_global { @@ -335,6 +338,26 @@ static void bind_display(struct wl_client *client, void *data, uint32_t version, uint32_t id); +static uint32_t +get_next_client_id (struct wl_display *display) +{ + uint32_t id = 0; + uint32_t *p; + + if (display->free_client_ids.size > 0) { + p = display->free_client_ids.data + + display->free_client_ids.size - + sizeof(uint32_t); + id = *p; + display->free_client_ids.size -= sizeof(uint32_t); + return id; + } + + id = display->next_client_id; + display->next_client_id++; + return id; +} + WL_EXPORT struct wl_client * wl_client_create(struct wl_display *display, int fd) { @@ -376,6 +399,8 @@ wl_client_create(struct wl_display *display, int fd) wl_list_insert(display->client_list.prev, &client->link); + client->id = get_next_client_id(display); + return client; err_map: @@ -576,9 +601,24 @@ wl_client_destroy(struct wl_client *client) wl_event_source_remove(client->source); wl_connection_destroy(client->connection); wl_list_remove(&client->link); + + if (client->id == client->display->next_client_id - 1) { + client->display->next_client_id--; + } else { + uint32_t *p; + p = wl_array_add(&client->display->free_client_ids, sizeof *p); + *p = client->id; + } + free(client); } +WL_EXPORT uint32_t +wl_client_get_id(struct wl_client *client) +{ + return client->id; +} + static void registry_bind(struct wl_client *client, struct wl_resource *resource, uint32_t name, @@ -714,6 +754,9 @@ wl_display_create(void) wl_signal_init(&display->destroy_signal); + wl_array_init(&display->free_client_ids); + display->next_client_id = 1; + display->id = 1; display->serial = 0; @@ -748,6 +791,8 @@ wl_display_destroy(struct wl_display *display) wl_list_for_each_safe(global, gnext, &display->global_list, link) free(global); + wl_array_release(&display->free_client_ids); + free(display); } diff --git a/src/wayland-server.h b/src/wayland-server.h index 9e16d0e..5109530 100644 --- a/src/wayland-server.h +++ b/src/wayland-server.h @@ -128,6 +128,7 @@ struct wl_resource * wl_client_get_object(struct wl_client *client, uint32_t id); void wl_client_post_no_memory(struct wl_client *client); +uint32_t wl_client_get_id(struct wl_client *client); struct wl_listener { struct wl_list link; -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston 6/6] input: Free the memory allocated to store the device resource lists
Urgh - I misread the implementation of wl_array_for_each - I missed that it works bytewise through the array rather than sizeof(char *) steps. I'll follow-up with some patches to solve this. Rob On 22 July 2013 17:31, Rob Bradford wrote: > From: Rob Bradford > > --- > src/input.c | 21 ++--- > 1 file changed, 18 insertions(+), 3 deletions(-) > > diff --git a/src/input.c b/src/input.c > index 25f2a3e..d4c28fb 100644 > --- a/src/input.c > +++ b/src/input.c > @@ -366,10 +366,15 @@ weston_pointer_create(void) > WL_EXPORT void > weston_pointer_destroy(struct weston_pointer *pointer) > { > + void *p; > + > if (pointer->sprite) > pointer_unmap_sprite(pointer); > > - /* XXX: What about pointer->resource_list? */ > + wl_array_for_each(p, &pointer->resources) > + free(p); > + wl_array_release(&pointer->resources); > + > if (!wl_list_empty(pointer->focus_resource_list)) > wl_list_remove(&pointer->focus_listener.link); > free(pointer); > @@ -400,7 +405,12 @@ weston_keyboard_create(void) > WL_EXPORT void > weston_keyboard_destroy(struct weston_keyboard *keyboard) > { > - /* XXX: What about keyboard->resource_list? */ > + void *p; > + > + wl_array_for_each(p, &keyboard->resources) > + free(p); > + wl_array_release(&keyboard->resources); > + > if (!wl_list_empty(keyboard->focus_resource_list)) > wl_list_remove(&keyboard->focus_listener.link); > wl_array_release(&keyboard->keys); > @@ -431,7 +441,12 @@ weston_touch_create(void) > WL_EXPORT void > weston_touch_destroy(struct weston_touch *touch) > { > - /* XXX: What about touch->resource_list? */ > + void *p; > + > + wl_array_for_each(p, &touch->resources) > + free(p); > + wl_array_release(&touch->resources); > + > if (!wl_list_empty(touch->focus_resource_list)) > wl_list_remove(&touch->focus_listener.link); > free(touch); > -- > 1.8.3.1 > ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 1/6] input: For serial generation get the display from the compositor
From: Rob Bradford This removes the use of wl_client_get_display() where the client is derived from the focussed resource. This starts the removal of the assumption of a single resource on a client that would be notified about events on the focussed surface. --- src/bindings.c| 5 + src/data-device.c | 3 +-- src/input.c | 20 ++-- src/shell.c | 9 +++-- 4 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/bindings.c b/src/bindings.c index 3194414..a871c26 100644 --- a/src/bindings.c +++ b/src/bindings.c @@ -155,11 +155,10 @@ binding_key(struct weston_keyboard_grab *grab, struct binding_keyboard_grab *b = container_of(grab, struct binding_keyboard_grab, grab); struct wl_resource *resource; - struct wl_client *client; - struct wl_display *display; enum wl_keyboard_key_state state = state_w; uint32_t serial; struct weston_keyboard *keyboard = grab->keyboard; + struct wl_display *display = keyboard->seat->compositor->wl_display; resource = grab->keyboard->focus_resource; if (key == b->key) { @@ -170,8 +169,6 @@ binding_key(struct weston_keyboard_grab *grab, free(b); } } else if (resource) { - client = wl_resource_get_client(resource); - display = wl_client_get_display(client); serial = wl_display_next_serial(display); wl_keyboard_send_key(resource, serial, time, key, state); } diff --git a/src/data-device.c b/src/data-device.c index c89379c..f6f90b5 100644 --- a/src/data-device.c +++ b/src/data-device.c @@ -204,7 +204,7 @@ weston_drag_set_focus(struct weston_drag *drag, struct weston_surface *surface, { struct weston_pointer *pointer = drag->grab.pointer; struct wl_resource *resource, *offer = NULL; - struct wl_display *display; + struct wl_display *display = pointer->seat->compositor->wl_display; uint32_t serial; if (drag->focus_resource) { @@ -226,7 +226,6 @@ weston_drag_set_focus(struct weston_drag *drag, struct weston_surface *surface, if (!resource) return; - display = wl_client_get_display(wl_resource_get_client(resource)); serial = wl_display_next_serial(display); if (drag->data_source) diff --git a/src/input.c b/src/input.c index 1887e7f..8757097 100644 --- a/src/input.c +++ b/src/input.c @@ -137,12 +137,11 @@ default_grab_button(struct weston_pointer_grab *grab, struct wl_resource *resource; uint32_t serial; enum wl_pointer_button_state state = state_w; - struct wl_display *display; + struct wl_display *display = compositor->wl_display; wl_fixed_t sx, sy; resource = pointer->focus_resource; if (resource) { - display = wl_client_get_display(wl_resource_get_client(resource)); serial = wl_display_next_serial(display); wl_pointer_send_button(resource, serial, time, button, state_w); } @@ -170,11 +169,10 @@ default_grab_touch_down(struct weston_touch_grab *grab, uint32_t time, int touch_id, wl_fixed_t sx, wl_fixed_t sy) { struct weston_touch *touch = grab->touch; - struct wl_display *display; + struct wl_display *display = touch->seat->compositor->wl_display; uint32_t serial; if (touch->focus_resource && touch->focus) { - display = wl_client_get_display(wl_resource_get_client(touch->focus_resource)); serial = wl_display_next_serial(display); wl_touch_send_down(touch->focus_resource, serial, time, touch->focus->resource, @@ -187,11 +185,10 @@ default_grab_touch_up(struct weston_touch_grab *grab, uint32_t time, int touch_id) { struct weston_touch *touch = grab->touch; - struct wl_display *display; + struct wl_display *display = touch->seat->compositor->wl_display; uint32_t serial; if (touch->focus_resource) { - display = wl_client_get_display(wl_resource_get_client(touch->focus_resource)); serial = wl_display_next_serial(display); wl_touch_send_up(touch->focus_resource, serial, time, touch_id); } @@ -221,12 +218,11 @@ default_grab_key(struct weston_keyboard_grab *grab, { struct weston_keyboard *keyboard = grab->keyboard; struct wl_resource *resource; - struct wl_display *display; + struct wl_display *display = keyboard->seat->compositor->wl_display; uint32_t serial; resource = keyboard->focus_resource; if (resource) { - display = wl_client_get_display(wl_resource_get_client(resource))
[PATCH wayland 3/3] wayland-client: Add wl_proxy_get_listener
From: Rob Bradford This is the mirror function to wl_proxy_add_listener and is useful inside client libraries to differentiate events on listeners for which multiple proxies have been created. --- src/wayland-client.c | 19 +++ src/wayland-client.h | 1 + 2 files changed, 20 insertions(+) diff --git a/src/wayland-client.c b/src/wayland-client.c index 2887a40..fa74918 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -325,6 +325,25 @@ wl_proxy_add_listener(struct wl_proxy *proxy, return 0; } +/** Get a proxy's listener + * + * \param proxy The proxy object + * \return The address of the proxy's listener or NULL if no listener is set + * + * Gets the address to the proxy's listener; which is the listener set with + * \ref wl_proxy_add_listener. + * + * This function is useful in client with multiple listeners on the same + * interface to allow the identification of which code to eexecute. + * + * \memberof wl_proxy + */ +WL_EXPORT const void * +wl_proxy_get_listener(struct wl_proxy *proxy) +{ + return proxy->object.implementation; +} + /** Prepare a request to be sent to the compositor * * \param proxy The proxy object diff --git a/src/wayland-client.h b/src/wayland-client.h index 216773a..32ed373 100644 --- a/src/wayland-client.h +++ b/src/wayland-client.h @@ -128,6 +128,7 @@ struct wl_proxy *wl_proxy_create(struct wl_proxy *factory, void wl_proxy_destroy(struct wl_proxy *proxy); int wl_proxy_add_listener(struct wl_proxy *proxy, void (**implementation)(void), void *data); +const void *wl_proxy_get_listener(struct wl_proxy *proxy); void wl_proxy_set_user_data(struct wl_proxy *proxy, void *user_data); void *wl_proxy_get_user_data(struct wl_proxy *proxy); uint32_t wl_proxy_get_id(struct wl_proxy *proxy); -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 6/6] input: Free the memory allocated to store the device resource lists
From: Rob Bradford --- src/input.c | 21 ++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/input.c b/src/input.c index 25f2a3e..d4c28fb 100644 --- a/src/input.c +++ b/src/input.c @@ -366,10 +366,15 @@ weston_pointer_create(void) WL_EXPORT void weston_pointer_destroy(struct weston_pointer *pointer) { + void *p; + if (pointer->sprite) pointer_unmap_sprite(pointer); - /* XXX: What about pointer->resource_list? */ + wl_array_for_each(p, &pointer->resources) + free(p); + wl_array_release(&pointer->resources); + if (!wl_list_empty(pointer->focus_resource_list)) wl_list_remove(&pointer->focus_listener.link); free(pointer); @@ -400,7 +405,12 @@ weston_keyboard_create(void) WL_EXPORT void weston_keyboard_destroy(struct weston_keyboard *keyboard) { - /* XXX: What about keyboard->resource_list? */ + void *p; + + wl_array_for_each(p, &keyboard->resources) + free(p); + wl_array_release(&keyboard->resources); + if (!wl_list_empty(keyboard->focus_resource_list)) wl_list_remove(&keyboard->focus_listener.link); wl_array_release(&keyboard->keys); @@ -431,7 +441,12 @@ weston_touch_create(void) WL_EXPORT void weston_touch_destroy(struct weston_touch *touch) { - /* XXX: What about touch->resource_list? */ + void *p; + + wl_array_for_each(p, &touch->resources) + free(p); + wl_array_release(&touch->resources); + if (!wl_list_empty(touch->focus_resource_list)) wl_list_remove(&touch->focus_listener.link); free(touch); -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 5/6] input: Emit events on all resources for a client
From: Rob Bradford The Wayland protocol permits a client to request the pointer, keyboard and touch multiple times from the seat global. This is very useful in a component like Clutter-GTK where we are combining two libraries that use Wayland together. This change migrates the weston input handling code to emit the events for all the resources for the client by using the newly added wl_resource_for_each macro to iterate over the resources that are associated with the focussed surface's client. A pointer to the list of resources is stored as a member on the device structures. In order to handle the loss of focus or the non-availability of a list of resources an empty list sentinel is used. --- src/bindings.c | 17 ++--- src/compositor.h | 6 +- src/input.c | 228 +-- src/shell.c | 33 4 files changed, 169 insertions(+), 115 deletions(-) diff --git a/src/bindings.c b/src/bindings.c index a871c26..e51c5ed 100644 --- a/src/bindings.c +++ b/src/bindings.c @@ -160,7 +160,6 @@ binding_key(struct weston_keyboard_grab *grab, struct weston_keyboard *keyboard = grab->keyboard; struct wl_display *display = keyboard->seat->compositor->wl_display; - resource = grab->keyboard->focus_resource; if (key == b->key) { if (state == WL_KEYBOARD_KEY_STATE_RELEASED) { weston_keyboard_end_grab(grab->keyboard); @@ -168,9 +167,11 @@ binding_key(struct weston_keyboard_grab *grab, keyboard->grab = &keyboard->input_method_grab; free(b); } - } else if (resource) { + } else { serial = wl_display_next_serial(display); - wl_keyboard_send_key(resource, serial, time, key, state); + wl_resource_for_each(resource, keyboard->focus_resource_list) { + wl_keyboard_send_key(resource, serial, time, key, state); + } } } @@ -181,12 +182,10 @@ binding_modifiers(struct weston_keyboard_grab *grab, uint32_t serial, { struct wl_resource *resource; - resource = grab->keyboard->focus_resource; - if (!resource) - return; - - wl_keyboard_send_modifiers(resource, serial, mods_depressed, - mods_latched, mods_locked, group); + wl_resource_for_each(resource, grab->keyboard->focus_resource_list) { + wl_keyboard_send_modifiers(resource, serial, mods_depressed, + mods_latched, mods_locked, group); + } } static const struct weston_keyboard_grab_interface binding_grab = { diff --git a/src/compositor.h b/src/compositor.h index 8429b9b..fc6354c 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -297,8 +297,8 @@ struct weston_pointer { struct weston_seat *seat; struct wl_array resources; + struct wl_list *focus_resource_list; struct weston_surface *focus; - struct wl_resource *focus_resource; struct wl_listener focus_listener; uint32_t focus_serial; struct wl_signal focus_signal; @@ -323,8 +323,8 @@ struct weston_touch { struct weston_seat *seat; struct wl_array resources; + struct wl_list *focus_resource_list; struct weston_surface *focus; - struct wl_resource *focus_resource; struct wl_listener focus_listener; uint32_t focus_serial; struct wl_signal focus_signal; @@ -409,8 +409,8 @@ struct weston_keyboard { struct weston_seat *seat; struct wl_array resources; + struct wl_list *focus_resource_list; struct weston_surface *focus; - struct wl_resource *focus_resource; struct wl_listener focus_listener; uint32_t focus_serial; struct wl_signal focus_signal; diff --git a/src/input.c b/src/input.c index 3cf3f3f..25f2a3e 100644 --- a/src/input.c +++ b/src/input.c @@ -31,6 +31,8 @@ #include "../shared/os-compatibility.h" #include "compositor.h" +static struct wl_list empty_list = {&empty_list, &empty_list}; + static void empty_region(pixman_region32_t *region) { @@ -74,7 +76,7 @@ lose_pointer_focus(struct wl_listener *listener, void *data) struct weston_pointer *pointer = container_of(listener, struct weston_pointer, focus_listener); - pointer->focus_resource = NULL; + pointer->focus_resource_list = &empty_list; } static void @@ -83,7 +85,7 @@ lose_keyboard_focus(struct wl_listener *listener, void *data) struct weston_keyboard *keyboard = container_of(listener, struct weston_keyboard, focus_listener); - keyboard->focus_resource = NULL; + keyboard->focus_resource_list = &empty_list; } static void @@ -92,7
[PATCH weston 4/6] data-device: Lookup drag resources using the focussed surface
From: Rob Bradford Rather than relying on focussed resource to get the client to lookup the drag resource with instead derive the client from the focussed surface. This is equivalent as the focussed resource is derived from the focussed surface in the weston_keyboard_set_focus function. --- src/data-device.c | 31 +++ 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/data-device.c b/src/data-device.c index f6f90b5..ae77b90 100644 --- a/src/data-device.c +++ b/src/data-device.c @@ -410,15 +410,14 @@ destroy_selection_data_source(struct wl_listener *listener, void *data) struct weston_seat *seat = container_of(listener, struct weston_seat, selection_data_source_listener); struct wl_resource *data_device; - struct wl_resource *focus = NULL; + struct wl_client *client; seat->selection_data_source = NULL; - if (seat->keyboard) - focus = seat->keyboard->focus_resource; - if (focus) { + if (seat->keyboard && seat->keyboard->focus) { + client = wl_resource_get_client(seat->keyboard->focus->resource); data_device = wl_resource_find_for_client(&seat->drag_resource_list, - wl_resource_get_client(focus)); + client); if (data_device) wl_data_device_send_selection(data_device, NULL); } @@ -431,7 +430,7 @@ weston_seat_set_selection(struct weston_seat *seat, struct wl_data_source *source, uint32_t serial) { struct wl_resource *data_device, *offer; - struct wl_resource *focus = NULL; + struct wl_client *client; if (seat->selection_data_source && seat->selection_serial - serial < UINT32_MAX / 2) @@ -446,11 +445,10 @@ weston_seat_set_selection(struct weston_seat *seat, seat->selection_data_source = source; seat->selection_serial = serial; - if (seat->keyboard) - focus = seat->keyboard->focus_resource; - if (focus) { + if (seat->keyboard && seat->keyboard->focus) { + client = wl_resource_get_client(seat->keyboard->focus->resource); data_device = wl_resource_find_for_client(&seat->drag_resource_list, - wl_resource_get_client(focus)); + client); if (data_device && source) { offer = wl_data_source_send_offer(seat->selection_data_source, data_device); @@ -594,18 +592,19 @@ bind_manager(struct wl_client *client, WL_EXPORT void wl_data_device_set_keyboard_focus(struct weston_seat *seat) { - struct wl_resource *data_device, *focus, *offer; + struct wl_resource *data_device = NULL, *offer; struct wl_data_source *source; + struct wl_client *client; if (!seat->keyboard) return; - focus = seat->keyboard->focus_resource; - if (!focus) - return; + if (seat->keyboard && seat->keyboard->focus) { + client = wl_resource_get_client(seat->keyboard->focus->resource); + data_device = wl_resource_find_for_client(&seat->drag_resource_list, + client); + } - data_device = wl_resource_find_for_client(&seat->drag_resource_list, - wl_resource_get_client(focus)); if (!data_device) return; -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 2/6] input: Use a client destroy listener for resetting the focus resource
From: Rob Bradford This is currently equivalent as there is no way for the pointer, keyboard or touch resource to be destroyed without the client being destroyed. This removes another place where a single resource for the focus is assumed. --- src/input.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/input.c b/src/input.c index 8757097..7e308d6 100644 --- a/src/input.c +++ b/src/input.c @@ -453,8 +453,8 @@ weston_pointer_set_focus(struct weston_pointer *pointer, } wl_pointer_send_enter(resource, serial, surface->resource, sx, sy); - wl_resource_add_destroy_listener(resource, -&pointer->focus_listener); + wl_client_add_destroy_listener(wl_resource_get_client(surface->resource), + &pointer->focus_listener); pointer->focus_serial = serial; } @@ -492,8 +492,8 @@ weston_keyboard_set_focus(struct weston_keyboard *keyboard, keyboard->modifiers.group); wl_keyboard_send_enter(resource, serial, surface->resource, &keyboard->keys); - wl_resource_add_destroy_listener(resource, -&keyboard->focus_listener); + wl_client_add_destroy_listener(wl_resource_get_client(surface->resource), + &keyboard->focus_listener); keyboard->focus_serial = serial; } @@ -999,8 +999,8 @@ touch_set_focus(struct weston_seat *seat, struct weston_surface *surface) seat->touch->focus = surface; seat->touch->focus_resource = resource; - wl_resource_add_destroy_listener(resource, -&seat->touch->focus_listener); + wl_client_add_destroy_listener(wl_resource_get_client(surface->resource), + &seat->touch->focus_listener); } } -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 3/6] input: Use a client id indexed array for input device resources
From: Rob Bradford Replace the list of resources per pointer/keyboard/touch with an array of pointers to lists of resources from that client. For compatability with the existing code find_resource_for_surface has been modified to return the resource associated with the first entry in the list and this is used to fill the focussed resource member on pointer, keyboard and touch. --- src/compositor.h | 6 +++--- src/input.c | 66 2 files changed, 55 insertions(+), 17 deletions(-) diff --git a/src/compositor.h b/src/compositor.h index 84f39e2..8429b9b 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -296,7 +296,7 @@ struct wl_data_source { struct weston_pointer { struct weston_seat *seat; - struct wl_list resource_list; + struct wl_array resources; struct weston_surface *focus; struct wl_resource *focus_resource; struct wl_listener focus_listener; @@ -322,7 +322,7 @@ struct weston_pointer { struct weston_touch { struct weston_seat *seat; - struct wl_list resource_list; + struct wl_array resources; struct weston_surface *focus; struct wl_resource *focus_resource; struct wl_listener focus_listener; @@ -408,7 +408,7 @@ struct weston_xkb_info { struct weston_keyboard { struct weston_seat *seat; - struct wl_list resource_list; + struct wl_array resources; struct weston_surface *focus; struct wl_resource *focus_resource; struct wl_listener focus_listener; diff --git a/src/input.c b/src/input.c index 7e308d6..3cf3f3f 100644 --- a/src/input.c +++ b/src/input.c @@ -229,15 +229,30 @@ default_grab_key(struct weston_keyboard_grab *grab, } static struct wl_resource * -find_resource_for_surface(struct wl_list *list, struct weston_surface *surface) +find_resource_for_surface(struct wl_array *array, struct weston_surface *surface) { + struct wl_client *client; + struct wl_list *list; + uint32_t id; + if (!surface) return NULL; if (!surface->resource) return NULL; - - return wl_resource_find_for_client(list, wl_resource_get_client(surface->resource)); + + client = wl_resource_get_client(surface->resource); + id = wl_client_get_id(client); + + if (array->size < (id + 1) * sizeof(struct wl_list *)) + return NULL; + + list = ((struct wl_list **)array->data)[id]; + + if (wl_list_empty(list)) + return NULL; + else + return wl_resource_from_link(list->next); } static void @@ -257,7 +272,7 @@ default_grab_modifiers(struct weston_keyboard_grab *grab, uint32_t serial, mods_latched, mods_locked, group); if (pointer && pointer->focus && pointer->focus != keyboard->focus) { - pr = find_resource_for_surface(&keyboard->resource_list, + pr = find_resource_for_surface(&keyboard->resources, pointer->focus); if (pr) { wl_keyboard_send_modifiers(pr, @@ -308,7 +323,7 @@ weston_pointer_create(void) return NULL; memset(pointer, 0, sizeof *pointer); - wl_list_init(&pointer->resource_list); + wl_array_init(&pointer->resources); pointer->focus_listener.notify = lose_pointer_focus; pointer->default_grab.interface = &default_pointer_grab_interface; pointer->default_grab.pointer = pointer; @@ -346,7 +361,7 @@ weston_keyboard_create(void) return NULL; memset(keyboard, 0, sizeof *keyboard); - wl_list_init(&keyboard->resource_list); + wl_array_init(&keyboard->resources); wl_array_init(&keyboard->keys); keyboard->focus_listener.notify = lose_keyboard_focus; keyboard->default_grab.interface = &default_keyboard_grab_interface; @@ -377,7 +392,7 @@ weston_touch_create(void) return NULL; memset(touch, 0, sizeof *touch); - wl_list_init(&touch->resource_list); + wl_array_init(&touch->resources); touch->focus_listener.notify = lose_touch_focus; touch->default_grab.interface = &default_touch_grab_interface; touch->default_grab.touch = touch; @@ -433,14 +448,14 @@ weston_pointer_set_focus(struct weston_pointer *pointer, wl_list_remove(&pointer->focus_listener.link); } - resource = find_resource_for_surface(&pointer->resource_list, + resource = find_resource_for_surface(&pointer->resources, surface); if (resource && (pointer->focus != surface || poin
Re: [PATCH weston] window: fix NULL pointer dereference
On 16 July 2013 01:25, Mariusz Ceier wrote: > > NULL pointer dereference happens when input->focus_widget == NULL > and input->grab == NULL. > I worry this is working around the problem rather than addressing the root cause. Why are we getting NULL for the focus_widget? What steps did you take to generate a segfault here? Perhaps you could open a bug Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston] window: Disregard motion events outside our current surface dimensions
From: Rob Bradford It is possible to receive a motion event that was generated by the compositor based on a pick of a surface of old dimensions. This was triggerable on toytoolkit clients when minimising. The new window dimensions were propagated through the widget hierarchy before the event was dispatched. This issue was triggering a segfault due to the focussed widget being lost as the client code tried to identify which widget should have the focus using co-ordinates outside the dimensions of the surface. https://bugs.freedesktop.org/show_bug.cgi?id=66795 --- clients/window.c | 8 1 file changed, 8 insertions(+) diff --git a/clients/window.c b/clients/window.c index 93a0a2c..1ca13ed 100644 --- a/clients/window.c +++ b/clients/window.c @@ -2795,6 +2795,14 @@ pointer_handle_motion(void *data, struct wl_pointer *pointer, float sx = wl_fixed_to_double(sx_w); float sy = wl_fixed_to_double(sy_w); + /* when making the window smaller - e.g. after a unmaximise we might +* still have a pending motion event that the compositor has picked +* based on the old surface dimensions +*/ + if (sx > window->main_surface->allocation.width || + sy > window->main_surface->allocation.height) + return; + input->sx = sx; input->sy = sy; -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston] editor: Support shift-left/right for selecting text
From: Rob Bradford If the shift modifier is active then we don't make the cursor and the anchor the same and as a result we develop a selection in the direction that the arrow key gets pressed in. https://bugs.freedesktop.org/show_bug.cgi?id=66802 --- clients/editor.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clients/editor.c b/clients/editor.c index 7e69403..1300ccf 100644 --- a/clients/editor.c +++ b/clients/editor.c @@ -1141,7 +1141,8 @@ key_handler(struct window *window, new_char = utf8_prev_char(entry->text, entry->text + entry->cursor); if (new_char != NULL) { entry->cursor = new_char - entry->text; - entry->anchor = entry->cursor; + if (!(input_get_modifiers(input) & MOD_SHIFT_MASK)) + entry->anchor = entry->cursor; widget_schedule_redraw(entry->widget); } break; @@ -1151,7 +1152,8 @@ key_handler(struct window *window, new_char = utf8_next_char(entry->text + entry->cursor); if (new_char != NULL) { entry->cursor = new_char - entry->text; - entry->anchor = entry->cursor; + if (!(input_get_modifiers(input) & MOD_SHIFT_MASK)) + entry->anchor = entry->cursor; widget_schedule_redraw(entry->widget); } break; -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston] shell: Respect output transformation for input panel surface
From: Rob Bradford Rather than using the dimensions in the mode we can use the recently added output width and height members which are updated to reflect any output rotation. https://bugs.freedesktop.org/show_bug.cgi?id=66798 --- src/shell.c | 7 ++- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/shell.c b/src/shell.c index 69345b0..7e98831 100644 --- a/src/shell.c +++ b/src/shell.c @@ -3732,7 +3732,6 @@ input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy, in { struct input_panel_surface *ip_surface = surface->configure_private; struct desktop_shell *shell = ip_surface->shell; - struct weston_mode *mode; float x, y; uint32_t show_surface = 0; @@ -3752,10 +3751,8 @@ input_panel_configure(struct weston_surface *surface, int32_t sx, int32_t sy, in x = shell->text_input.surface->geometry.x + shell->text_input.cursor_rectangle.x2; y = shell->text_input.surface->geometry.y + shell->text_input.cursor_rectangle.y2; } else { - mode = ip_surface->output->current; - - x = ip_surface->output->x + (mode->width - width) / 2; - y = ip_surface->output->y + mode->height - height; + x = ip_surface->output->x + (ip_surface->output->width - width) / 2; + y = ip_surface->output->y + ip_surface->output->height - height; } weston_surface_configure(surface, -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston] window: Allow popup menu when the window is maximised
From: Rob Bradford https://bugs.freedesktop.org/show_bug.cgi?id=66793 --- clients/window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clients/window.c b/clients/window.c index cff7102..93a0a2c 100644 --- a/clients/window.c +++ b/clients/window.c @@ -2553,7 +2553,7 @@ frame_button_handler(struct widget *widget, struct display *display = window->display; int location; - if (window->type != TYPE_TOPLEVEL) + if (!(window->type == TYPE_TOPLEVEL || window->type == TYPE_MAXIMIZED)) return; location = theme_get_location(display->theme, input->sx, input->sy, -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH] wayland-client: Treat EOF when reading the wayland socket as an error
Hi Neil, On 9 July 2013 14:10, Neil Roberts wrote: > If EOF is encountered while reading from the Wayland socket, > wl_display_read_events() will now return -1 so that it will be treated > as an error. The documentation for this function states that it will > set errno when there is an error so it additionally makes up an errno > of EPIPE. > > If we don't do this then when the compositor quits the Wayland socket > will be become ready for reading but wl_display_dispatch will do > nothing which typically makes the application take up 100% CPU. In > particular eglSwapBuffers will likely get stuck in an infinite busy > loop because it repeatedly calls wl_display_dispatch_queue while it > waits for the frame callback. Good discovery - the only thing that confused me was the past tense sentence: "If EOF is encountered while reading from the Wayland socket, wl_display_read_events() will now return -1 so that it will be treated as an error." It sound like you're reacting to some changed behaviour rather than changing behaviour. I propose "If EOF is encountered while reading from the Wayland socket, make wl_display_read_events() -1 so that it will be treated as an error" It does feel like a slight hack and instead we should some how propagate the EOF/zero to read up rather than synthesizing an error. However we'd have to change every client / toolkit and so using a fatal display error is nicer since the toolkits should already be handling that. Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 3/3] tablet-shell: Avoid infinite loop when unlocking
From: Rob Bradford weston_compositor_wake will fire the signal that the unlock handler is setup as the listener for. Instead lets change the state to HOME which unlocks. --- src/tablet-shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tablet-shell.c b/src/tablet-shell.c index e8ac82d..b89c333 100644 --- a/src/tablet-shell.c +++ b/src/tablet-shell.c @@ -417,7 +417,7 @@ tablet_shell_unlock(struct wl_listener *listener, void *data) struct tablet_shell *shell = container_of(listener, struct tablet_shell, unlock_listener); - weston_compositor_wake(shell->compositor); + tablet_shell_set_state(shell, STATE_HOME); } static void -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 2/3] tablet-shell: Fix copy and paste error in unlock handler
From: Rob Bradford The signal handler was using the wrong member to find the containing structure of the unlock listener. https://bugs.freedesktop.org/show_bug.cgi?id=57637 --- src/tablet-shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tablet-shell.c b/src/tablet-shell.c index 76a4010..e8ac82d 100644 --- a/src/tablet-shell.c +++ b/src/tablet-shell.c @@ -415,7 +415,7 @@ static void tablet_shell_unlock(struct wl_listener *listener, void *data) { struct tablet_shell *shell = - container_of(listener, struct tablet_shell, lock_listener); + container_of(listener, struct tablet_shell, unlock_listener); weston_compositor_wake(shell->compositor); } -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 1/3] compositor: Make --modules always override other module loading
From: Rob Bradford This allows the test suite to strictly control the modules that get loaded by the compositor. https://bugs.freedesktop.org/show_bug.cgi?id=57636 --- man/weston.man | 3 ++- src/compositor.c | 11 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/man/weston.man b/man/weston.man index 39d854b..04db1ec 100644 --- a/man/weston.man +++ b/man/weston.man @@ -128,7 +128,8 @@ instead of writing them to stderr. Load the comma-separated list of modules. Only used by the test suite. The file is searched for in .IR "__weston_modules_dir__" , -or you can pass an absolute path. +or you can pass an absolute path. This overrides the loading of modules from +the weston.ini file. .TP \fB\-\^S\fR\fIname\fR, \fB\-\-socket\fR=\fIname\fR Weston will listen in the Wayland socket called diff --git a/src/compositor.c b/src/compositor.c index 92d89a7..6dfa01e 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -3350,10 +3350,13 @@ int main(int argc, char *argv[]) setenv("WAYLAND_DISPLAY", socket_name, 1); - if (load_modules(ec, modules, &argc, argv) < 0) - goto out; - if (load_modules(ec, option_modules, &argc, argv) < 0) - goto out; + if (option_modules) { + if (load_modules(ec, option_modules, &argc, argv) < 0) + goto out; + } else { + if (load_modules(ec, modules, &argc, argv) < 0) + goto out; + } for (i = 1; i < argc; i++) weston_log("fatal: unhandled option: %s\n", argv[i]); -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH] xdg_shell: Add a new shell protocol.
Hi Rafael, Right now when the implicit grab that the popup takes is broken the compositor emits popup_done on the shell_surface. We now have a better idiom for doing this by returning a new object from set_popup that would be using a new interface that has a "done" event on that interface. This means that the popup_done can be removed from the shell surface interface itself. This isn't necessary for transient role surfaces as unlike popups these do not create a grab in the compositor and hence there is no need for a mechanism for the compositor to tell the client that the grab is over. Rob On 8 July 2013 19:04, Rafael Antognolli wrote: > On Mon, Jul 8, 2013 at 11:56 AM, Rob Bradford > wrote: >> If we're talking changes... >> >> Let's make the popup return an object with a done event on rather than >> stick the event in the interface like popup_done is. > > So, you want that set_popup automatically sending a done event after > called? Then set_transient should also do the same, right? > > Anyway, I can do it in a change after this one, since here I'm just > copying the files and changing the names, right? > > Or maybe I didn't get what you want... > >> I'd also like to see us standardise on the naming of the request to >> create the new object - I think create_xdg_surface is better than >> get_xdg_surface and aligns with the create_surface request on >> wl_compositor. > > OK, added that to the new patch. We end up with: > > interface: xdg_shell > - function create_xdg_surface > > interface: xdg_surface > > Is this good? > > Ah, the new patch went to another thread, I guess that I should have > used --chain-reply-to to avoid that. > > Regards, > -- > Rafael Antognolli ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston] input: remove seat global object when destroying the seat
From: Rob Bradford The RDP compositor dynamically creates and destroys seats for the different connecting clients. Althrough the memory for the seat was being freed and it was also being removed from the list of seats in the compositor the client was not being informed of that the seat was no longer a valid global. Because the client still thought this global was valid when it tried to bind it the compositor would attempt to access freed memory. https://bugs.freedesktop.org/show_bug.cgi?id=65913 --- src/compositor.h | 1 + src/input.c | 7 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/compositor.h b/src/compositor.h index 8070409..0c5623f 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -469,6 +469,7 @@ struct weston_seat { struct input_method *input_method; char *seat_name; + struct wl_global *global; }; enum { diff --git a/src/input.c b/src/input.c index 644487a..ed114de 100644 --- a/src/input.c +++ b/src/input.c @@ -1531,8 +1531,8 @@ weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec, wl_list_init(&seat->drag_resource_list); wl_signal_init(&seat->destroy_signal); - wl_display_add_global(ec->wl_display, &wl_seat_interface, seat, - bind_seat); + seat->global = wl_display_add_global(ec->wl_display, &wl_seat_interface, +seat, bind_seat); seat->compositor = ec; seat->modifier_state = 0; @@ -1550,7 +1550,8 @@ WL_EXPORT void weston_seat_release(struct weston_seat *seat) { wl_list_remove(&seat->link); - /* The global object is destroyed at wl_display_destroy() time. */ + + wl_display_remove_global(seat->compositor->wl_display, seat->global); #ifdef ENABLE_XKBCOMMON if (seat->compositor->use_xkbcommon) { -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH] Allow null surface arguments in wl_pointer.leave and wl_keyboard.leave
On 8 July 2013 17:25, Jason Ekstrand wrote: > That's exactly what weston *was* doing. However, thanks to the destroyed > proxies, the clients were getting NULL anyway. We could to go through a > bunch of trouble to keep the resource valid and call wl_pointer.leave on a > valid resource. However, that's a lot more work than I thought it was worth > for no change client-side. Right - you spell this out nice and clearly in your excellent commit message. So although this is technically an API change all the clients already deal with this anyway - so I guess it's right to spell that out in the protocol. Out of interest - when does the compositor emit a motion event without a resource? Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH] xdg_shell: Add a new shell protocol.
If we're talking changes... Let's make the popup return an object with a done event on rather than stick the event in the interface like popup_done is. I'd also like to see us standardise on the naming of the request to create the new object - I think create_xdg_surface is better than get_xdg_surface and aligns with the create_surface request on wl_compositor. Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston] input: check if the resource is valid in seat_get_pointer
On 8 July 2013 15:15, Giulio Camuffo wrote: Hi Giulio, > There is not much else to say. surfaces created with weston_surface_create > have > a NULL resource, and if that gets picked by default_grab_focus (in input.c) > the next > seat_get_pointer will break. I guess my point is that I wanted you to highlight that it is the non-client surfaces (like the lock surface) that don't have a resource. Most of surfaces created by weston_surface_create are through the compositor_create_surface which does set the resource. > I guess another solution could be to make weston_compositor_pick_surface not > pick surfaces without a valid resource, but i'm not sure that wouldn't break > something > else. That might be worth exploring - these surfaces don't accept input right? So the pick shouldn't do anything anyway..and how did one of these surfaces get assigned as the pointer focus? That might be the thing to look at. Rob > > 2013/7/8 Rob Bradford >> >> Can you provide some more explanation in your commit message about why >> the pointer might have a surface focussed but that surface does not >> have a valid resource. (I'm wondering if this is fixing the symptom of >> a problem elsewhere.) >> >> Rob >> >> On 7 July 2013 16:38, Giulio Camuffo wrote: >> > seat->pointer->focus->resource can be NULL, if the surface was >> > created with weston_surface_create. >> > --- >> > src/input.c | 2 +- >> > 1 file changed, 1 insertion(+), 1 deletion(-) >> > >> > diff --git a/src/input.c b/src/input.c >> > index 644487a..a7a37e5 100644 >> > --- a/src/input.c >> > +++ b/src/input.c >> > @@ -1181,7 +1181,7 @@ seat_get_pointer(struct wl_client *client, struct >> > wl_resource *resource, >> > wl_resource_set_implementation(cr, &pointer_interface, >> > seat->pointer, >> >unbind_resource); >> > >> > - if (seat->pointer->focus && >> > + if (seat->pointer->focus && seat->pointer->focus->resource && >> > wl_resource_get_client(seat->pointer->focus->resource) == >> > client) { >> > struct weston_surface *surface; >> > wl_fixed_t sx, sy; >> > -- >> > 1.8.3.2 >> > >> > ___ >> > wayland-devel mailing list >> > wayland-devel@lists.freedesktop.org >> > http://lists.freedesktop.org/mailman/listinfo/wayland-devel > > ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston] input: check if the resource is valid in seat_get_pointer
Can you provide some more explanation in your commit message about why the pointer might have a surface focussed but that surface does not have a valid resource. (I'm wondering if this is fixing the symptom of a problem elsewhere.) Rob On 7 July 2013 16:38, Giulio Camuffo wrote: > seat->pointer->focus->resource can be NULL, if the surface was > created with weston_surface_create. > --- > src/input.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/input.c b/src/input.c > index 644487a..a7a37e5 100644 > --- a/src/input.c > +++ b/src/input.c > @@ -1181,7 +1181,7 @@ seat_get_pointer(struct wl_client *client, struct > wl_resource *resource, > wl_resource_set_implementation(cr, &pointer_interface, seat->pointer, >unbind_resource); > > - if (seat->pointer->focus && > + if (seat->pointer->focus && seat->pointer->focus->resource && > wl_resource_get_client(seat->pointer->focus->resource) == client) > { > struct weston_surface *surface; > wl_fixed_t sx, sy; > -- > 1.8.3.2 > > ___ > wayland-devel mailing list > wayland-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/wayland-devel ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH] Allow null surface arguments in wl_pointer.leave and wl_keyboard.leave
*bump* This is a fix for: https://bugs.freedesktop.org/show_bug.cgi?id=65726&list_id=320167 Although it might be much better if we could emit the event (especially the leave) before we destroy the surface - that being said the destruction of the object will also result in the proxy being removed from the map and so when the event is received the callback will still have a NULL pointer. Rob On 17 June 2013 23:56, Jason Ekstrand wrote: > The current specified behavior does not allow a null surface in either of > these events. However, if the client calls wl_surface.destroy while the > surface has focus then the leave handler will get a null surface anyway > because the proxy corresponding to the wl_surface no longer exists. This > change makes this edge-case explicit and allows the server to avoid sending > an event with an argument it knows the client has destroyed. > > Signed-off-by: Jason Ekstrand > --- > protocol/wayland.xml | 10 ++ > 1 file changed, 6 insertions(+), 4 deletions(-) > > diff --git a/protocol/wayland.xml b/protocol/wayland.xml > index 3d4ec9b..faa284e 100644 > --- a/protocol/wayland.xml > +++ b/protocol/wayland.xml > @@ -1313,13 +1313,14 @@ > > > Notification that this seat's pointer is no longer focused on > - a certain surface. > + a certain surface. The surface parameter may be null if the > + surface has been destroyed. > > The leave notification is sent before the enter notification > for the new focus. > > > - > + allow-null="true"/> > > > > @@ -1430,13 +1431,14 @@ > > > Notification that this seat's keyboard focus is no longer on > - a certain surface. > + a certain surface. The surface parameter may be null if the > + surface has been destroyed. > > The leave notification is sent before the enter notification > for the new focus. > > > - > + allow-null="true"/> > > > > -- > 1.8.1.4 > > ___ > wayland-devel mailing list > wayland-devel@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/wayland-devel ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston] compositor: rebuild the global list if we've removed a surface from it
Hi Pekka, You raise a good point. I don't think the increase in complexity is worth it - we have good way to construct a surface list from the layers (and we do it at the start of every frame) anyway: I think it's nice that the management of this cache is really encapsulated in a single place. Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH 8/8] shell: Fix calculation of center point in surface rotation
I think the change is correct but i'd like to see more explanation about the change in the commit message and the problem that it caused. Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston] shell: Allow ending of popup grabs from within the starting of the grab
From: Rob Bradford Calling weston_pointer_start_grab can lead to a code path (in this case when the shell surface is unresponsive) that can try and remove the popup grab to setup a shell grab. Ending the popup grab requires removing the surface from the grab's surfaces list - however the grab had not yet been fully setup so the grabbed surface was not yet in this list. With this change we ensure we add the surface to the list before setting up the pointer grab. https://bugs.freedesktop.org/show_bug.cgi?id=66167 --- src/shell.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/shell.c b/src/shell.c index 9869db5..b20b1e1 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2121,9 +2121,11 @@ add_popup_grab(struct shell_surface *shsurf, struct shell_seat *shseat) if (shseat->seat->pointer->button_count > 0) shseat->popup_grab.initial_up = 0; + wl_list_insert(&shseat->popup_grab.surfaces_list, &shsurf->popup.grab_link); weston_pointer_start_grab(seat->pointer, &shseat->popup_grab.grab); + } else { + wl_list_insert(&shseat->popup_grab.surfaces_list, &shsurf->popup.grab_link); } - wl_list_insert(&shseat->popup_grab.surfaces_list, &shsurf->popup.grab_link); } static void -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston] compositor: rebuild the global list if we've removed a surface from it
From: Rob Bradford The list of surfaces used by weston_compositor_pick_surface() is maintained in list of surfaces stored on the compositor. This list is generated from the surfaces across all the layers using weston_compositor_build_surface_list. When destroying a surface the surface is "unmapped" with weston_surface_unmap which removes it from the layer list. However since the compositor surface list was only being rebuilt when the output was repainted a call to weston_compositor_pick_surface before the next output repaint would use an outdated surface list containing surfaces that have been partially destroyed. https://bugs.freedesktop.org/show_bug.cgi?id=65986 --- src/compositor.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/compositor.c b/src/compositor.c index 43d8965..0a8cfff 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -93,6 +93,9 @@ static void weston_output_transform_scale_init(struct weston_output *output, uint32_t transform, uint32_t scale); +static void +weston_compositor_build_surface_list(struct weston_compositor *compositor); + WL_EXPORT int weston_output_switch_mode(struct weston_output *output, struct weston_mode *mode, int32_t scale) { @@ -1011,8 +1014,10 @@ weston_surface_destroy(struct weston_surface *surface) assert(wl_list_empty(&surface->subsurface_list_pending)); assert(wl_list_empty(&surface->subsurface_list)); - if (weston_surface_is_mapped(surface)) + if (weston_surface_is_mapped(surface)) { weston_surface_unmap(surface); + weston_compositor_build_surface_list(compositor); + } wl_list_for_each_safe(cb, next, &surface->pending.frame_callback_list, link) -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v2 4/4] man: Add documentation for output seat confining
From: Rob Bradford v2: Add some explanation about the default seat --- man/weston.ini.man | 9 + 1 file changed, 9 insertions(+) diff --git a/man/weston.ini.man b/man/weston.ini.man index c3e5747..9c22b3f 100644 --- a/man/weston.ini.man +++ b/man/weston.ini.man @@ -288,6 +288,15 @@ be one of the following 8 strings: .BR "flipped-270 " "Flipped and 90 degrees counter clockwise" .fi .RE +.TP 7 +.BI "seat=" name +The logical seat name that that this output should be associated with. If this +is set then the seat's input will be confined to the output that has the seat +set on it. The expectation is that this functionality will be used in a +multiheaded environment with a single compositor for multiple output and input +configurations. The default seat is called "default" and will always be +present. This seat can be constrained like any other. +.RE .SH "INPUT-METHOD SECTION" .TP 7 .BI "path=" "/usr/libexec/weston-keyboard" -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v2 3/4] compositor-drm: Enable seat constraining when configured in weston.ini
From: Rob Bradford This change tweaks weston_pointer_clamp to take into consideration if a seat is constrained to a particular output by only considering the pointer position valid if it is within the output we a constrained to. This function is also used for the initial warping of the pointer when a constraint is first established. The other two changes are the application of the constraint when either a new device added or a new output created and therefore outputs and input devices can be brought up in either order. v2: the code in create_output_for_connector has been spun off into a new function setup_output_seat_constraint (Ander). The inappropriate warping behaviour has been resolved by using weston_pointer_clamp (Pekka). --- src/compositor-drm.c | 23 +++ src/compositor.h | 2 ++ src/input.c | 7 ++- src/udev-seat.c | 5 + 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/compositor-drm.c b/src/compositor-drm.c index e704c9f..45e7e9b 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -1728,6 +1728,25 @@ parse_transform(const char *transform, const char *output_name) return WL_OUTPUT_TRANSFORM_NORMAL; } +static void +setup_output_seat_constraint(struct drm_compositor *ec, +struct weston_output *output, +const char *s) +{ + if (strcmp(s, "") != 0) { + struct udev_seat *seat; + + seat = udev_seat_get_named(&ec->base, s); + if (seat) + seat->base.output = output; + + if (seat && seat->base.pointer) + weston_pointer_clamp(seat->base.pointer, +&seat->base.pointer->x, +&seat->base.pointer->y); + } +} + static int create_output_for_connector(struct drm_compositor *ec, drmModeRes *resources, @@ -1796,6 +1815,10 @@ create_output_for_connector(struct drm_compositor *ec, transform = parse_transform(s, output->base.name); free(s); + weston_config_section_get_string(section, "seat", &s, ""); + setup_output_seat_constraint(ec, &output->base, s); + free(s); + output->crtc_id = resources->crtcs[i]; output->pipe = i; ec->crtc_allocator |= (1 << output->crtc_id); diff --git a/src/compositor.h b/src/compositor.h index 45a14d6..4191950 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -437,6 +437,8 @@ struct weston_seat { struct weston_keyboard *keyboard; struct weston_touch *touch; + struct weston_output *output; /* constraint */ + struct wl_signal destroy_signal; struct weston_compositor *compositor; diff --git a/src/input.c b/src/input.c index 6d17bc4..d83fd9c 100644 --- a/src/input.c +++ b/src/input.c @@ -575,6 +575,8 @@ weston_pointer_clamp(struct weston_pointer *pointer, wl_fixed_t *fx, wl_fixed_t old_y = wl_fixed_to_int(pointer->y); wl_list_for_each(output, &ec->output_list, link) { + if (pointer->seat->output && pointer->seat->output != output) + continue; if (pixman_region32_contains_point(&output->region, x, y, NULL)) valid = 1; @@ -583,7 +585,10 @@ weston_pointer_clamp(struct weston_pointer *pointer, wl_fixed_t *fx, wl_fixed_t prev = output; } - if (!valid) { + if (!prev) + prev = pointer->seat->output; + + if (prev && !valid) { if (x < prev->x) *fx = wl_fixed_from_int(prev->x); else if (x >= prev->x + prev->width) diff --git a/src/udev-seat.c b/src/udev-seat.c index bd25535..ec6dc4b 100644 --- a/src/udev-seat.c +++ b/src/udev-seat.c @@ -115,6 +115,11 @@ device_added(struct udev_device *udev_device, struct udev_input *input) wl_list_insert(seat->devices_list.prev, &device->link); + if (seat->base.output && seat->base.pointer) + weston_pointer_clamp(seat->base.pointer, +&seat->base.pointer->x, +&seat->base.pointer->y); + return 0; } -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v2 2/4] input: Add weston_pointer_clamp function to ensure pointer visible
From: Rob Bradford This refactors the code out from clip_pointer_motion into a function of its own which can then be used elsewhere to clamp the pointer coordinates to the range of the outputs. This change also makes the caller of clip_pointer_motion use this new function. --- src/compositor.h | 3 +++ src/input.c | 12 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/compositor.h b/src/compositor.h index 3206e45..45a14d6 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -345,6 +345,9 @@ weston_pointer_start_grab(struct weston_pointer *pointer, struct weston_pointer_grab *grab); void weston_pointer_end_grab(struct weston_pointer *pointer); +void +weston_pointer_clamp(struct weston_pointer *pointer, + wl_fixed_t *fx, wl_fixed_t *fy); struct weston_keyboard * weston_keyboard_create(void); diff --git a/src/input.c b/src/input.c index ad4512d..6d17bc4 100644 --- a/src/input.c +++ b/src/input.c @@ -562,17 +562,17 @@ weston_touch_end_grab(struct weston_touch *touch) touch->grab = &touch->default_grab; } -static void -clip_pointer_motion(struct weston_seat *seat, wl_fixed_t *fx, wl_fixed_t *fy) +WL_EXPORT void +weston_pointer_clamp(struct weston_pointer *pointer, wl_fixed_t *fx, wl_fixed_t *fy) { - struct weston_compositor *ec = seat->compositor; + struct weston_compositor *ec = pointer->seat->compositor; struct weston_output *output, *prev = NULL; int x, y, old_x, old_y, valid = 0; x = wl_fixed_to_int(*fx); y = wl_fixed_to_int(*fy); - old_x = wl_fixed_to_int(seat->pointer->x); - old_y = wl_fixed_to_int(seat->pointer->y); + old_x = wl_fixed_to_int(pointer->x); + old_y = wl_fixed_to_int(pointer->y); wl_list_for_each(output, &ec->output_list, link) { if (pixman_region32_contains_point(&output->region, @@ -606,7 +606,7 @@ move_pointer(struct weston_seat *seat, wl_fixed_t x, wl_fixed_t y) struct weston_output *output; int32_t ix, iy; - clip_pointer_motion(seat, &x, &y); + weston_pointer_clamp (pointer, &x, &y); pointer->x = x; pointer->y = y; -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v2 1/4] udev-seat: Refactor out seat lookup and possible creation
From: Rob Bradford This change spills the code for looking up a seat by name and then potentially creating it if it doesn't exist into a new function called udev_seat_get_named. This change allows us to reuse this code when looking up the seat when parsing seat constraints per output. --- src/udev-seat.c | 29 - src/udev-seat.h | 2 ++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/udev-seat.c b/src/udev-seat.c index a8790b3..bd25535 100644 --- a/src/udev-seat.c +++ b/src/udev-seat.c @@ -66,18 +66,11 @@ device_added(struct udev_device *udev_device, struct udev_input *input) if (!seat_name) seat_name = default_seat_name; - wl_list_for_each(seat, &c->seat_list, base.link) { - if (strcmp(seat->base.seat_name, seat_name) == 0) - goto seat_found; - } + seat = udev_seat_get_named(c, seat_name); - seat = udev_seat_create(c, seat_name); - - if (!seat) + if (seat == NULL) return -1; -seat_found: - /* Use non-blocking mode so that we can loop on read on * evdev_device_data() until all events on the fd are * read. mtdev_get() also expects this. */ @@ -350,3 +343,21 @@ udev_seat_destroy(struct udev_seat *seat) weston_seat_release(&seat->base); free(seat); } + +struct udev_seat * +udev_seat_get_named(struct weston_compositor *c, const char *seat_name) +{ + struct udev_seat *seat; + + wl_list_for_each(seat, &c->seat_list, base.link) { + if (strcmp(seat->base.seat_name, seat_name) == 0) + return seat; + } + + seat = udev_seat_create(c, seat_name); + + if (!seat) + return NULL; + + return seat; +} diff --git a/src/udev-seat.h b/src/udev-seat.h index 7dd5987..3543e7c 100644 --- a/src/udev-seat.h +++ b/src/udev-seat.h @@ -48,4 +48,6 @@ int udev_input_init(struct udev_input *input, const char *seat_id); void udev_input_destroy(struct udev_input *input); +struct udev_seat *udev_seat_get_named(struct weston_compositor *c, + const char *seat_name); #endif -- 1.8.3.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v3 3/3] build: Make libxkbcommon build-time optional in the compositor
From: Rob Bradford v2: Incorporate review feedback from Daniel Stone - improved configure message about the purpose of this option and reorganisation of #ifdefs. --- configure.ac | 15 ++- src/compositor.c | 2 +- src/input.c | 39 --- 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index b625221..726eb4f 100644 --- a/configure.ac +++ b/configure.ac @@ -54,7 +54,7 @@ AC_CHECK_HEADERS([execinfo.h]) AC_CHECK_FUNCS([mkostemp strchrnul]) -COMPOSITOR_MODULES="wayland-server >= 1.1.90 xkbcommon pixman-1" +COMPOSITOR_MODULES="wayland-server >= 1.1.90 pixman-1" AC_ARG_ENABLE(egl, [ --disable-egl],, enable_egl=yes) @@ -64,6 +64,19 @@ if test x$enable_egl = xyes; then COMPOSITOR_MODULES="$COMPOSITOR_MODULES egl >= 7.10 glesv2" fi +AC_ARG_ENABLE(xkbcommon, + AS_HELP_STRING([--disable-xkbcommon], [Disable libxkbcommon + support: This is only useful in environments + where you do not have a hardware keyboard. If + libxkbcommon support is disabled clients will not + be sent a keymap and and must know how to + interpret the keycode sent for any key event.]),, + enable_xkbcommon=yes) +if test x$enable_xkbcommon = xyes; then + AC_DEFINE(ENABLE_XKBCOMMON, [1], [Build Weston with libxkbcommon support]) + COMPOSITOR_MODULES="$COMPOSITOR_MODULES xkbcommon" +fi + PKG_CHECK_MODULES(COMPOSITOR, [$COMPOSITOR_MODULES]) AC_ARG_ENABLE(setuid-install, [ --enable-setuid-install],, diff --git a/src/compositor.c b/src/compositor.c index c9ee67b..884e949 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -2795,7 +2795,6 @@ weston_compositor_init(struct weston_compositor *ec, weston_plane_init(&ec->primary_plane, 0, 0); weston_compositor_stack_plane(ec, &ec->primary_plane, NULL); - ec->use_xkbcommon = 1; s = weston_config_get_section(ec->config, "keyboard", NULL, NULL); weston_config_section_get_string(s, "keymap_rules", (char **) &xkb_names.rules, NULL); @@ -2807,6 +2806,7 @@ weston_compositor_init(struct weston_compositor *ec, (char **) &xkb_names.variant, NULL); weston_config_section_get_string(s, "keymap_options", (char **) &xkb_names.options, NULL); + if (weston_compositor_xkb_init(ec, &xkb_names) < 0) return -1; diff --git a/src/input.c b/src/input.c index 9eb980a..e0e552c 100644 --- a/src/input.c +++ b/src/input.c @@ -740,6 +740,7 @@ notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis, value); } +#ifdef ENABLE_XKBCOMMON WL_EXPORT void notify_modifiers(struct weston_seat *seat, uint32_t serial) { @@ -829,6 +830,18 @@ update_modifier_state(struct weston_seat *seat, uint32_t serial, uint32_t key, notify_modifiers(seat, serial); } +#else +WL_EXPORT void +notify_modifiers(struct weston_seat *seat, uint32_t serial) +{ +} + +static void +update_modifier_state(struct weston_seat *seat, uint32_t serial, uint32_t key, + enum wl_keyboard_key_state state) +{ +} +#endif WL_EXPORT void notify_key(struct weston_seat *seat, uint32_t time, uint32_t key, @@ -1272,16 +1285,12 @@ bind_seat(struct wl_client *client, void *data, uint32_t version, uint32_t id) wl_seat_send_name(resource, seat->seat_name); } +#ifdef ENABLE_XKBCOMMON int weston_compositor_xkb_init(struct weston_compositor *ec, struct xkb_rule_names *names) { - /* -* If we're operating in raw keyboard mode, libxkbcommon isn't used and -* shouldn't be initialized. -*/ - if (!ec->use_xkbcommon) - return 0; + ec->use_xkbcommon = 1; if (ec->xkb_context == NULL) { ec->xkb_context = xkb_context_new(0); @@ -1419,6 +1428,19 @@ weston_compositor_build_global_keymap(struct weston_compositor *ec) return 0; } +#else +int +weston_compositor_xkb_init(struct weston_compositor *ec, + struct xkb_rule_names *names) +{ + return 0; +} + +void +weston_compositor_xkb_destroy(struct weston_compositor *ec) +{ +} +#endif WL_EXPORT int weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap) @@ -1428,7 +1450,7 @@ weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap) if (seat->keyboard) return 0; - +#ifdef ENABLE_XKBCOMMON if (seat->compositor->use_xkbcommon) { if (keymap != N
[PATCH weston v3 2/3] input: Add support for making libxkbcommon optional
From: Matt Roper In embedded environments, devices that appear as evdev "keyboards" often have no resemblence to PC-style keyboards. It is not uncommon for such environments to have no concept of modifier keys and no need for XKB key mapping; in these cases libxkbcommon initialization becomes unnecessary startup overhead. On some SOC platforms, xkb keymap compilation can account for as much as 1/3 - 1/2 of the total compositor startup time. This patch introduces a 'use_xkbcommon' flag in the core compositor structure that indicates whether the compositor is running in "raw keyboard" mode. In raw keyboard mode, the compositor bypasses all libxkbcommon initialization and processing. 'key' events containing the integer keycode will continue to be delivered via the wl_keyboard interface, but no 'keymap' event will be sent to clients. No modifier handling or keysym mapping is performed in this mode. Note that upstream sample apps (e.g., weston-terminal or the desktop-shell client) will not recognize raw keycodes and will not react to keypresses when the compositor is operating in raw keyboard mode. This is expected behavior; key events are still being sent to the client, the client (and/or its toolkit) just isn't written to handle keypresses without doing xkb keysym mapping. Applications written specifically for such embedded environments would be handling keypresses via the raw keycode delivered as part of the 'key' event rather than using xkb keysym mapping. Whether to use xkbcommon is a global option that applies to all compositor keyboard devices on the system; it is an all-or-nothing flag. This patch simply adds conditional checks on whether xkbcommon is to be used or not. v3 don't send zero as the file descriptor - instead send the result of opening /dev/null v2 by Rob Bradford : the original version of the patch used a "raw_keycodes" flag instead of the "use_xkbcommon" used in this patch. v1: Reviewed-by: Singh, Satyeshwar v1: Reviewed-by: Bob Paauwe --- src/compositor.c | 1 + src/compositor.h | 3 +++ src/input.c | 74 3 files changed, 57 insertions(+), 21 deletions(-) diff --git a/src/compositor.c b/src/compositor.c index 5c82413..c9ee67b 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -2795,6 +2795,7 @@ weston_compositor_init(struct weston_compositor *ec, weston_plane_init(&ec->primary_plane, 0, 0); weston_compositor_stack_plane(ec, &ec->primary_plane, NULL); + ec->use_xkbcommon = 1; s = weston_config_get_section(ec->config, "keyboard", NULL, NULL); weston_config_section_get_string(s, "keymap_rules", (char **) &xkb_names.rules, NULL); diff --git a/src/compositor.h b/src/compositor.h index 297f971..9fa31e5 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -572,6 +572,9 @@ struct weston_compositor { struct xkb_rule_names xkb_names; struct xkb_context *xkb_context; struct weston_xkb_info xkb_info; + + /* Raw keyboard processing (no libxkbcommon initialization or handling) */ + int use_xkbcommon; }; struct weston_buffer_reference { diff --git a/src/input.c b/src/input.c index ad4512d..9eb980a 100644 --- a/src/input.c +++ b/src/input.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "../shared/os-compatibility.h" #include "compositor.h" @@ -813,6 +814,10 @@ update_modifier_state(struct weston_seat *seat, uint32_t serial, uint32_t key, { enum xkb_key_direction direction; + /* Keyboard modifiers don't exist in raw keyboard mode */ + if (!seat->compositor->use_xkbcommon) + return; + if (state == WL_KEYBOARD_KEY_STATE_PRESSED) direction = XKB_KEY_DOWN; else @@ -1202,9 +1207,17 @@ seat_get_keyboard(struct wl_client *client, struct wl_resource *resource, wl_list_insert(&seat->keyboard->resource_list, wl_resource_get_link(cr)); wl_resource_set_destructor(cr, unbind_resource); - wl_keyboard_send_keymap(cr, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, - seat->xkb_info.keymap_fd, - seat->xkb_info.keymap_size); + if (seat->compositor->use_xkbcommon) { + wl_keyboard_send_keymap(cr, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, + seat->xkb_info.keymap_fd, + seat->xkb_info.keymap_size); + } else { + int null_fd = open("/dev/null", O_RDONLY); + wl_keyboard_send_keymap(cr, WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP, + null_fd, + 0); + clos
[PATCH weston v3 1/3] toytoolkit: Allow operation without a keymap
From: Matt Roper In preparation for upcoming changes, we want to make sure that apps written with the toy toolkit continue to operate properly if no XKB keymap is received. If there's no XKB keymap, then we shouldn't try to figure out keyboard modifier states (since we probably don't even have equivalents of PC-style modifiers). Reviewed-by: Singh, Satyeshwar Reviewed-by: Bob Paauwe --- clients/window.c | 4 1 file changed, 4 insertions(+) diff --git a/clients/window.c b/clients/window.c index c13d207..c8e421b 100644 --- a/clients/window.c +++ b/clients/window.c @@ -3067,6 +3067,10 @@ keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, struct input *input = data; xkb_mod_mask_t mask; + /* If we're not using a keymap, then we don't handle PC-style modifiers */ + if (!input->xkb.keymap) + return; + xkb_state_update_mask(input->xkb.state, mods_depressed, mods_latched, mods_locked, 0, 0, group); mask = xkb_state_serialize_mods(input->xkb.state, -- 1.8.2.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH wayland v2] protocol: add no_keymap format to keymap formats
From: Rob Bradford This format is used to specify that the key button events received are not in relation to any key map and that the codes should be interpreted directly. v2: Use zero for the no keymap enum value and enhance the documentation for the enum entry. --- protocol/wayland.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/protocol/wayland.xml b/protocol/wayland.xml index 3d4ec9b..1442b6a 100644 --- a/protocol/wayland.xml +++ b/protocol/wayland.xml @@ -1404,6 +1404,8 @@ This specifies the format of the keymap provided to the client with the wl_keyboard.keymap event. + -- 1.8.2.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston v2 3/3] build: Make libxkbcommon build-time optional in the compositor
On Sat, Jun 22, 2013 at 12:57:06AM +0100, Daniel Stone wrote: > And lastly, you need to bump the dependency on wayland to a version > which introduces the WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP enum. I don't think we've done this prior to release before. The expectation being if you run tip of weston you need to run tip of wayland. Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v2 3/3] build: Make libxkbcommon build-time optional in the compositor
From: Rob Bradford --- configure.ac | 9 - src/compositor.c | 6 +- src/input.c | 20 +++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index b625221..5e5e7bb 100644 --- a/configure.ac +++ b/configure.ac @@ -54,7 +54,7 @@ AC_CHECK_HEADERS([execinfo.h]) AC_CHECK_FUNCS([mkostemp strchrnul]) -COMPOSITOR_MODULES="wayland-server >= 1.1.90 xkbcommon pixman-1" +COMPOSITOR_MODULES="wayland-server >= 1.1.90 pixman-1" AC_ARG_ENABLE(egl, [ --disable-egl],, enable_egl=yes) @@ -64,6 +64,13 @@ if test x$enable_egl = xyes; then COMPOSITOR_MODULES="$COMPOSITOR_MODULES egl >= 7.10 glesv2" fi +AC_ARG_ENABLE(xkbcommon, [ --disable-xkbcommon],, + enable_xkbcommon=yes) +if test x$enable_xkbcommon = xyes; then + AC_DEFINE(ENABLE_XKBCOMMON, [1], [Build Weston with libxkbcommon support]) + COMPOSITOR_MODULES="$COMPOSITOR_MODULES xkbcommon" +fi + PKG_CHECK_MODULES(COMPOSITOR, [$COMPOSITOR_MODULES]) AC_ARG_ENABLE(setuid-install, [ --enable-setuid-install],, diff --git a/src/compositor.c b/src/compositor.c index c9ee67b..d96560b 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -2795,7 +2795,6 @@ weston_compositor_init(struct weston_compositor *ec, weston_plane_init(&ec->primary_plane, 0, 0); weston_compositor_stack_plane(ec, &ec->primary_plane, NULL); - ec->use_xkbcommon = 1; s = weston_config_get_section(ec->config, "keyboard", NULL, NULL); weston_config_section_get_string(s, "keymap_rules", (char **) &xkb_names.rules, NULL); @@ -2807,8 +2806,11 @@ weston_compositor_init(struct weston_compositor *ec, (char **) &xkb_names.variant, NULL); weston_config_section_get_string(s, "keymap_options", (char **) &xkb_names.options, NULL); +#ifdef ENABLE_XKBCOMMON + ec->use_xkbcommon = 1; if (weston_compositor_xkb_init(ec, &xkb_names) < 0) return -1; +#endif ec->ping_handler = NULL; @@ -3314,7 +3316,9 @@ int main(int argc, char *argv[]) for (i = ARRAY_LENGTH(signals); i;) wl_event_source_remove(signals[--i]); +#ifdef ENABLE_XKBCOMMON weston_compositor_xkb_destroy(ec); +#endif ec->destroy(ec); wl_display_destroy(display); diff --git a/src/input.c b/src/input.c index 9eb980a..6140340 100644 --- a/src/input.c +++ b/src/input.c @@ -740,6 +740,7 @@ notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis, value); } +#ifdef ENABLE_XKBCOMMON WL_EXPORT void notify_modifiers(struct weston_seat *seat, uint32_t serial) { @@ -829,6 +830,18 @@ update_modifier_state(struct weston_seat *seat, uint32_t serial, uint32_t key, notify_modifiers(seat, serial); } +#else +WL_EXPORT void +notify_modifiers(struct weston_seat *seat, uint32_t serial) +{ +} + +static void +update_modifier_state(struct weston_seat *seat, uint32_t serial, uint32_t key, + enum wl_keyboard_key_state state) +{ +} +#endif WL_EXPORT void notify_key(struct weston_seat *seat, uint32_t time, uint32_t key, @@ -1272,6 +1285,7 @@ bind_seat(struct wl_client *client, void *data, uint32_t version, uint32_t id) wl_seat_send_name(resource, seat->seat_name); } +#ifdef ENABLE_XKBCOMMON int weston_compositor_xkb_init(struct weston_compositor *ec, struct xkb_rule_names *names) @@ -1419,6 +1433,7 @@ weston_compositor_build_global_keymap(struct weston_compositor *ec) return 0; } +#endif WL_EXPORT int weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap) @@ -1428,7 +1443,7 @@ weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap) if (seat->keyboard) return 0; - +#ifdef ENABLE_XKBCOMMON if (seat->compositor->use_xkbcommon) { if (keymap != NULL) { seat->xkb_info.keymap = xkb_map_ref(keymap); @@ -1449,6 +1464,7 @@ weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap) seat->xkb_state.leds = 0; } +#endif keyboard = weston_keyboard_create(); if (keyboard == NULL) { @@ -1533,11 +1549,13 @@ weston_seat_release(struct weston_seat *seat) wl_list_remove(&seat->link); /* The global object is destroyed at wl_display_destroy() time. */ +#ifdef ENABLE_XKBCOMMON if (seat->compositor->use_xkbcommon) { if (seat->xkb_state.state != NULL) xkb_state_unref(seat->xkb_state.state); xkb_info_destroy(&seat->xkb_info);
[PATCH weston v2 2/3] input: Add support for making libxkbcommon optional
From: Matt Roper In embedded environments, devices that appear as evdev "keyboards" often have no resemblence to PC-style keyboards. It is not uncommon for such environments to have no concept of modifier keys and no need for XKB key mapping; in these cases libxkbcommon initialization becomes unnecessary startup overhead. On some SOC platforms, xkb keymap compilation can account for as much as 1/3 - 1/2 of the total compositor startup time. This patch introduces a 'use_xkbcommon' flag in the core compositor structure that indicates whether the compositor is running in "raw keyboard" mode. In raw keyboard mode, the compositor bypasses all libxkbcommon initialization and processing. 'key' events containing the integer keycode will continue to be delivered via the wl_keyboard interface, but no 'keymap' event will be sent to clients. No modifier handling or keysym mapping is performed in this mode. Note that upstream sample apps (e.g., weston-terminal or the desktop-shell client) will not recognize raw keycodes and will not react to keypresses when the compositor is operating in raw keyboard mode. This is expected behavior; key events are still being sent to the client, the client (and/or its toolkit) just isn't written to handle keypresses without doing xkb keysym mapping. Applications written specifically for such embedded environments would be handling keypresses via the raw keycode delivered as part of the 'key' event rather than using xkb keysym mapping. Whether to use xkbcommon is a global option that applies to all compositor keyboard devices on the system; it is an all-or-nothing flag. This patch simply adds conditional checks on whether xkbcommon is to be used or not. v3 don't send zero as the file descriptor - instead send the result of opening /dev/null v2 by Rob Bradford : the original version of the patch used a "raw_keycodes" flag instead of the "use_xkbcommon" used in this patch. v1: Reviewed-by: Singh, Satyeshwar v1: Reviewed-by: Bob Paauwe --- src/compositor.c | 1 + src/compositor.h | 3 +++ src/input.c | 74 3 files changed, 57 insertions(+), 21 deletions(-) diff --git a/src/compositor.c b/src/compositor.c index 5c82413..c9ee67b 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -2795,6 +2795,7 @@ weston_compositor_init(struct weston_compositor *ec, weston_plane_init(&ec->primary_plane, 0, 0); weston_compositor_stack_plane(ec, &ec->primary_plane, NULL); + ec->use_xkbcommon = 1; s = weston_config_get_section(ec->config, "keyboard", NULL, NULL); weston_config_section_get_string(s, "keymap_rules", (char **) &xkb_names.rules, NULL); diff --git a/src/compositor.h b/src/compositor.h index 297f971..9fa31e5 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -572,6 +572,9 @@ struct weston_compositor { struct xkb_rule_names xkb_names; struct xkb_context *xkb_context; struct weston_xkb_info xkb_info; + + /* Raw keyboard processing (no libxkbcommon initialization or handling) */ + int use_xkbcommon; }; struct weston_buffer_reference { diff --git a/src/input.c b/src/input.c index ad4512d..9eb980a 100644 --- a/src/input.c +++ b/src/input.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "../shared/os-compatibility.h" #include "compositor.h" @@ -813,6 +814,10 @@ update_modifier_state(struct weston_seat *seat, uint32_t serial, uint32_t key, { enum xkb_key_direction direction; + /* Keyboard modifiers don't exist in raw keyboard mode */ + if (!seat->compositor->use_xkbcommon) + return; + if (state == WL_KEYBOARD_KEY_STATE_PRESSED) direction = XKB_KEY_DOWN; else @@ -1202,9 +1207,17 @@ seat_get_keyboard(struct wl_client *client, struct wl_resource *resource, wl_list_insert(&seat->keyboard->resource_list, wl_resource_get_link(cr)); wl_resource_set_destructor(cr, unbind_resource); - wl_keyboard_send_keymap(cr, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, - seat->xkb_info.keymap_fd, - seat->xkb_info.keymap_size); + if (seat->compositor->use_xkbcommon) { + wl_keyboard_send_keymap(cr, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, + seat->xkb_info.keymap_fd, + seat->xkb_info.keymap_size); + } else { + int null_fd = open("/dev/null", O_RDONLY); + wl_keyboard_send_keymap(cr, WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP, + null_fd, + 0); + clos
[PATCH weston v2 1/3] toytoolkit: Allow operation without a keymap
From: Matt Roper In preparation for upcoming changes, we want to make sure that apps written with the toy toolkit continue to operate properly if no XKB keymap is received. If there's no XKB keymap, then we shouldn't try to figure out keyboard modifier states (since we probably don't even have equivalents of PC-style modifiers). Reviewed-by: Singh, Satyeshwar Reviewed-by: Bob Paauwe --- clients/window.c | 4 1 file changed, 4 insertions(+) diff --git a/clients/window.c b/clients/window.c index c13d207..c8e421b 100644 --- a/clients/window.c +++ b/clients/window.c @@ -3067,6 +3067,10 @@ keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, struct input *input = data; xkb_mod_mask_t mask; + /* If we're not using a keymap, then we don't handle PC-style modifiers */ + if (!input->xkb.keymap) + return; + xkb_state_update_mask(input->xkb.state, mods_depressed, mods_latched, mods_locked, 0, 0, group); mask = xkb_state_serialize_mods(input->xkb.state, -- 1.8.2.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston v2 3/3] build: Make libxkbcommon build-time optional in the compositor
From: Rob Bradford --- configure.ac | 9 - src/compositor.c | 6 +- src/input.c | 20 +++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index b625221..5e5e7bb 100644 --- a/configure.ac +++ b/configure.ac @@ -54,7 +54,7 @@ AC_CHECK_HEADERS([execinfo.h]) AC_CHECK_FUNCS([mkostemp strchrnul]) -COMPOSITOR_MODULES="wayland-server >= 1.1.90 xkbcommon pixman-1" +COMPOSITOR_MODULES="wayland-server >= 1.1.90 pixman-1" AC_ARG_ENABLE(egl, [ --disable-egl],, enable_egl=yes) @@ -64,6 +64,13 @@ if test x$enable_egl = xyes; then COMPOSITOR_MODULES="$COMPOSITOR_MODULES egl >= 7.10 glesv2" fi +AC_ARG_ENABLE(xkbcommon, [ --disable-xkbcommon],, + enable_xkbcommon=yes) +if test x$enable_xkbcommon = xyes; then + AC_DEFINE(ENABLE_XKBCOMMON, [1], [Build Weston with libxkbcommon support]) + COMPOSITOR_MODULES="$COMPOSITOR_MODULES xkbcommon" +fi + PKG_CHECK_MODULES(COMPOSITOR, [$COMPOSITOR_MODULES]) AC_ARG_ENABLE(setuid-install, [ --enable-setuid-install],, diff --git a/src/compositor.c b/src/compositor.c index c9ee67b..d96560b 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -2795,7 +2795,6 @@ weston_compositor_init(struct weston_compositor *ec, weston_plane_init(&ec->primary_plane, 0, 0); weston_compositor_stack_plane(ec, &ec->primary_plane, NULL); - ec->use_xkbcommon = 1; s = weston_config_get_section(ec->config, "keyboard", NULL, NULL); weston_config_section_get_string(s, "keymap_rules", (char **) &xkb_names.rules, NULL); @@ -2807,8 +2806,11 @@ weston_compositor_init(struct weston_compositor *ec, (char **) &xkb_names.variant, NULL); weston_config_section_get_string(s, "keymap_options", (char **) &xkb_names.options, NULL); +#ifdef ENABLE_XKBCOMMON + ec->use_xkbcommon = 1; if (weston_compositor_xkb_init(ec, &xkb_names) < 0) return -1; +#endif ec->ping_handler = NULL; @@ -3314,7 +3316,9 @@ int main(int argc, char *argv[]) for (i = ARRAY_LENGTH(signals); i;) wl_event_source_remove(signals[--i]); +#ifdef ENABLE_XKBCOMMON weston_compositor_xkb_destroy(ec); +#endif ec->destroy(ec); wl_display_destroy(display); diff --git a/src/input.c b/src/input.c index 9eb980a..6140340 100644 --- a/src/input.c +++ b/src/input.c @@ -740,6 +740,7 @@ notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis, value); } +#ifdef ENABLE_XKBCOMMON WL_EXPORT void notify_modifiers(struct weston_seat *seat, uint32_t serial) { @@ -829,6 +830,18 @@ update_modifier_state(struct weston_seat *seat, uint32_t serial, uint32_t key, notify_modifiers(seat, serial); } +#else +WL_EXPORT void +notify_modifiers(struct weston_seat *seat, uint32_t serial) +{ +} + +static void +update_modifier_state(struct weston_seat *seat, uint32_t serial, uint32_t key, + enum wl_keyboard_key_state state) +{ +} +#endif WL_EXPORT void notify_key(struct weston_seat *seat, uint32_t time, uint32_t key, @@ -1272,6 +1285,7 @@ bind_seat(struct wl_client *client, void *data, uint32_t version, uint32_t id) wl_seat_send_name(resource, seat->seat_name); } +#ifdef ENABLE_XKBCOMMON int weston_compositor_xkb_init(struct weston_compositor *ec, struct xkb_rule_names *names) @@ -1419,6 +1433,7 @@ weston_compositor_build_global_keymap(struct weston_compositor *ec) return 0; } +#endif WL_EXPORT int weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap) @@ -1428,7 +1443,7 @@ weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap) if (seat->keyboard) return 0; - +#ifdef ENABLE_XKBCOMMON if (seat->compositor->use_xkbcommon) { if (keymap != NULL) { seat->xkb_info.keymap = xkb_map_ref(keymap); @@ -1449,6 +1464,7 @@ weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap) seat->xkb_state.leds = 0; } +#endif keyboard = weston_keyboard_create(); if (keyboard == NULL) { @@ -1533,11 +1549,13 @@ weston_seat_release(struct weston_seat *seat) wl_list_remove(&seat->link); /* The global object is destroyed at wl_display_destroy() time. */ +#ifdef ENABLE_XKBCOMMON if (seat->compositor->use_xkbcommon) { if (seat->xkb_state.state != NULL) xkb_state_unref(seat->xkb_state.state); xkb_info_destroy(&seat->xkb_info);
[PATCH weston v2 2/3] input: Add support for making libxkbcommon optional
From: Matt Roper In embedded environments, devices that appear as evdev "keyboards" often have no resemblence to PC-style keyboards. It is not uncommon for such environments to have no concept of modifier keys and no need for XKB key mapping; in these cases libxkbcommon initialization becomes unnecessary startup overhead. On some SOC platforms, xkb keymap compilation can account for as much as 1/3 - 1/2 of the total compositor startup time. This patch introduces a 'use_xkbcommon' flag in the core compositor structure that indicates whether the compositor is running in "raw keyboard" mode. In raw keyboard mode, the compositor bypasses all libxkbcommon initialization and processing. 'key' events containing the integer keycode will continue to be delivered via the wl_keyboard interface, but no 'keymap' event will be sent to clients. No modifier handling or keysym mapping is performed in this mode. Note that upstream sample apps (e.g., weston-terminal or the desktop-shell client) will not recognize raw keycodes and will not react to keypresses when the compositor is operating in raw keyboard mode. This is expected behavior; key events are still being sent to the client, the client (and/or its toolkit) just isn't written to handle keypresses without doing xkb keysym mapping. Applications written specifically for such embedded environments would be handling keypresses via the raw keycode delivered as part of the 'key' event rather than using xkb keysym mapping. Whether to use xkbcommon is a global option that applies to all compositor keyboard devices on the system; it is an all-or-nothing flag. This patch simply adds conditional checks on whether xkbcommon is to be used or not. v3 don't send zero as the file descriptor - instead send the result of opening /dev/null v2 by Rob Bradford : the original version of the patch used a "raw_keycodes" flag instead of the "use_xkbcommon" used in this patch. v1: Reviewed-by: Singh, Satyeshwar v1: Reviewed-by: Bob Paauwe --- src/compositor.c | 1 + src/compositor.h | 3 +++ src/input.c | 74 3 files changed, 57 insertions(+), 21 deletions(-) diff --git a/src/compositor.c b/src/compositor.c index 5c82413..c9ee67b 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -2795,6 +2795,7 @@ weston_compositor_init(struct weston_compositor *ec, weston_plane_init(&ec->primary_plane, 0, 0); weston_compositor_stack_plane(ec, &ec->primary_plane, NULL); + ec->use_xkbcommon = 1; s = weston_config_get_section(ec->config, "keyboard", NULL, NULL); weston_config_section_get_string(s, "keymap_rules", (char **) &xkb_names.rules, NULL); diff --git a/src/compositor.h b/src/compositor.h index 297f971..9fa31e5 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -572,6 +572,9 @@ struct weston_compositor { struct xkb_rule_names xkb_names; struct xkb_context *xkb_context; struct weston_xkb_info xkb_info; + + /* Raw keyboard processing (no libxkbcommon initialization or handling) */ + int use_xkbcommon; }; struct weston_buffer_reference { diff --git a/src/input.c b/src/input.c index ad4512d..9eb980a 100644 --- a/src/input.c +++ b/src/input.c @@ -26,6 +26,7 @@ #include #include #include +#include #include "../shared/os-compatibility.h" #include "compositor.h" @@ -813,6 +814,10 @@ update_modifier_state(struct weston_seat *seat, uint32_t serial, uint32_t key, { enum xkb_key_direction direction; + /* Keyboard modifiers don't exist in raw keyboard mode */ + if (!seat->compositor->use_xkbcommon) + return; + if (state == WL_KEYBOARD_KEY_STATE_PRESSED) direction = XKB_KEY_DOWN; else @@ -1202,9 +1207,17 @@ seat_get_keyboard(struct wl_client *client, struct wl_resource *resource, wl_list_insert(&seat->keyboard->resource_list, wl_resource_get_link(cr)); wl_resource_set_destructor(cr, unbind_resource); - wl_keyboard_send_keymap(cr, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, - seat->xkb_info.keymap_fd, - seat->xkb_info.keymap_size); + if (seat->compositor->use_xkbcommon) { + wl_keyboard_send_keymap(cr, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, + seat->xkb_info.keymap_fd, + seat->xkb_info.keymap_size); + } else { + int null_fd = open("/dev/null", O_RDONLY); + wl_keyboard_send_keymap(cr, WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP, + null_fd, + 0); + clos
[PATCH weston v2 1/3] toytoolkit: Allow operation without a keymap
From: Matt Roper In preparation for upcoming changes, we want to make sure that apps written with the toy toolkit continue to operate properly if no XKB keymap is received. If there's no XKB keymap, then we shouldn't try to figure out keyboard modifier states (since we probably don't even have equivalents of PC-style modifiers). Reviewed-by: Singh, Satyeshwar Reviewed-by: Bob Paauwe --- clients/window.c | 4 1 file changed, 4 insertions(+) diff --git a/clients/window.c b/clients/window.c index c13d207..c8e421b 100644 --- a/clients/window.c +++ b/clients/window.c @@ -3067,6 +3067,10 @@ keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, struct input *input = data; xkb_mod_mask_t mask; + /* If we're not using a keymap, then we don't handle PC-style modifiers */ + if (!input->xkb.keymap) + return; + xkb_state_update_mask(input->xkb.state, mods_depressed, mods_latched, mods_locked, 0, 0, group); mask = xkb_state_serialize_mods(input->xkb.state, -- 1.8.2.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 3/3] build: Make libxkbcommon build-time optional in the compositor
From: Rob Bradford --- configure.ac | 9 - src/compositor.c | 6 +- src/input.c | 20 +++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index b625221..5e5e7bb 100644 --- a/configure.ac +++ b/configure.ac @@ -54,7 +54,7 @@ AC_CHECK_HEADERS([execinfo.h]) AC_CHECK_FUNCS([mkostemp strchrnul]) -COMPOSITOR_MODULES="wayland-server >= 1.1.90 xkbcommon pixman-1" +COMPOSITOR_MODULES="wayland-server >= 1.1.90 pixman-1" AC_ARG_ENABLE(egl, [ --disable-egl],, enable_egl=yes) @@ -64,6 +64,13 @@ if test x$enable_egl = xyes; then COMPOSITOR_MODULES="$COMPOSITOR_MODULES egl >= 7.10 glesv2" fi +AC_ARG_ENABLE(xkbcommon, [ --disable-xkbcommon],, + enable_xkbcommon=yes) +if test x$enable_xkbcommon = xyes; then + AC_DEFINE(ENABLE_XKBCOMMON, [1], [Build Weston with libxkbcommon support]) + COMPOSITOR_MODULES="$COMPOSITOR_MODULES xkbcommon" +fi + PKG_CHECK_MODULES(COMPOSITOR, [$COMPOSITOR_MODULES]) AC_ARG_ENABLE(setuid-install, [ --enable-setuid-install],, diff --git a/src/compositor.c b/src/compositor.c index fc407dd..6657c7a 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -2811,7 +2811,6 @@ weston_compositor_init(struct weston_compositor *ec, weston_plane_init(&ec->primary_plane, 0, 0); weston_compositor_stack_plane(ec, &ec->primary_plane, NULL); - ec->use_xkbcommon = 1; s = weston_config_get_section(ec->config, "keyboard", NULL, NULL); weston_config_section_get_string(s, "keymap_rules", (char **) &xkb_names.rules, NULL); @@ -2823,8 +2822,11 @@ weston_compositor_init(struct weston_compositor *ec, (char **) &xkb_names.variant, NULL); weston_config_section_get_string(s, "keymap_options", (char **) &xkb_names.options, NULL); +#ifdef ENABLE_XKBCOMMON + ec->use_xkbcommon = 1; if (weston_compositor_xkb_init(ec, &xkb_names) < 0) return -1; +#endif ec->ping_handler = NULL; @@ -3330,7 +3332,9 @@ int main(int argc, char *argv[]) for (i = ARRAY_LENGTH(signals); i;) wl_event_source_remove(signals[--i]); +#ifdef ENABLE_XKBCOMMON weston_compositor_xkb_destroy(ec); +#endif ec->destroy(ec); wl_display_destroy(display); diff --git a/src/input.c b/src/input.c index 8ffbd10..4816f4b 100644 --- a/src/input.c +++ b/src/input.c @@ -741,6 +741,7 @@ notify_axis(struct weston_seat *seat, uint32_t time, uint32_t axis, value); } +#ifdef ENABLE_XKBCOMMON WL_EXPORT void notify_modifiers(struct weston_seat *seat, uint32_t serial) { @@ -830,6 +831,18 @@ update_modifier_state(struct weston_seat *seat, uint32_t serial, uint32_t key, notify_modifiers(seat, serial); } +#else +WL_EXPORT void +notify_modifiers(struct weston_seat *seat, uint32_t serial) +{ +} + +static void +update_modifier_state(struct weston_seat *seat, uint32_t serial, uint32_t key, + enum wl_keyboard_key_state state) +{ +} +#endif WL_EXPORT void notify_key(struct weston_seat *seat, uint32_t time, uint32_t key, @@ -1266,6 +1279,7 @@ bind_seat(struct wl_client *client, void *data, uint32_t version, uint32_t id) wl_seat_send_name(resource, seat->seat_name); } +#ifdef ENABLE_XKBCOMMON int weston_compositor_xkb_init(struct weston_compositor *ec, struct xkb_rule_names *names) @@ -1413,6 +1427,7 @@ weston_compositor_build_global_keymap(struct weston_compositor *ec) return 0; } +#endif WL_EXPORT int weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap) @@ -1422,7 +1437,7 @@ weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap) if (seat->keyboard) return 0; - +#ifdef ENABLE_XKBCOMMON if (seat->compositor->use_xkbcommon) { if (keymap != NULL) { seat->xkb_info.keymap = xkb_map_ref(keymap); @@ -1443,6 +1458,7 @@ weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap) seat->xkb_state.leds = 0; } +#endif keyboard = weston_keyboard_create(); if (keyboard == NULL) { @@ -1527,11 +1543,13 @@ weston_seat_release(struct weston_seat *seat) wl_list_remove(&seat->link); /* The global object is destroyed at wl_display_destroy() time. */ +#ifdef ENABLE_XKBCOMMON if (seat->compositor->use_xkbcommon) { if (seat->xkb_state.state != NULL) xkb_state_unref(seat->xkb_state.state); xkb_info_destroy(&seat->xkb_info);
[PATCH weston 2/3] input: Add support for making libxkbcommon optional
From: Matt Roper In embedded environments, devices that appear as evdev "keyboards" often have no resemblence to PC-style keyboards. It is not uncommon for such environments to have no concept of modifier keys and no need for XKB key mapping; in these cases libxkbcommon initialization becomes unnecessary startup overhead. On some SOC platforms, xkb keymap compilation can account for as much as 1/3 - 1/2 of the total compositor startup time. This patch introduces a 'use_xkbcommon' flag in the core compositor structure that indicates whether the compositor is running in "raw keyboard" mode. In raw keyboard mode, the compositor bypasses all libxkbcommon initialization and processing. 'key' events containing the integer keycode will continue to be delivered via the wl_keyboard interface, but no 'keymap' event will be sent to clients. No modifier handling or keysym mapping is performed in this mode. Note that upstream sample apps (e.g., weston-terminal or the desktop-shell client) will not recognize raw keycodes and will not react to keypresses when the compositor is operating in raw keyboard mode. This is expected behavior; key events are still being sent to the client, the client (and/or its toolkit) just isn't written to handle keypresses without doing xkb keysym mapping. Applications written specifically for such embedded environments would be handling keypresses via the raw keycode delivered as part of the 'key' event rather than using xkb keysym mapping. Whether to use xkbcommon is a global option that applies to all compositor keyboard devices on the system; it is an all-or-nothing flag. This patch simply adds conditional checks on whether xkbcommon is to be used or not. v2 by Rob Bradford : the original version of the patch used a "raw_keycodes" flag instead of the "use_xkbcommon" used in this patch. v1: Reviewed-by: Singh, Satyeshwar v1: Reviewed-by: Bob Paauwe --- src/compositor.c | 1 + src/compositor.h | 3 +++ src/input.c | 71 +++- 3 files changed, 54 insertions(+), 21 deletions(-) diff --git a/src/compositor.c b/src/compositor.c index 42011f5..fc407dd 100644 --- a/src/compositor.c +++ b/src/compositor.c @@ -2811,6 +2811,7 @@ weston_compositor_init(struct weston_compositor *ec, weston_plane_init(&ec->primary_plane, 0, 0); weston_compositor_stack_plane(ec, &ec->primary_plane, NULL); + ec->use_xkbcommon = 1; s = weston_config_get_section(ec->config, "keyboard", NULL, NULL); weston_config_section_get_string(s, "keymap_rules", (char **) &xkb_names.rules, NULL); diff --git a/src/compositor.h b/src/compositor.h index c87d9f1..b80388e 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -558,6 +558,9 @@ struct weston_compositor { struct xkb_rule_names xkb_names; struct xkb_context *xkb_context; struct weston_xkb_info xkb_info; + + /* Raw keyboard processing (no libxkbcommon initialization or handling) */ + int use_xkbcommon; }; struct weston_buffer_reference { diff --git a/src/input.c b/src/input.c index 5463d78..8ffbd10 100644 --- a/src/input.c +++ b/src/input.c @@ -815,6 +815,10 @@ update_modifier_state(struct weston_seat *seat, uint32_t serial, uint32_t key, { enum xkb_key_direction direction; + /* Keyboard modifiers don't exist in raw keyboard mode */ + if (!seat->compositor->use_xkbcommon) + return; + if (state == WL_KEYBOARD_KEY_STATE_PRESSED) direction = XKB_KEY_DOWN; else @@ -1199,9 +1203,15 @@ seat_get_keyboard(struct wl_client *client, struct wl_resource *resource, wl_list_insert(&seat->keyboard->resource_list, &cr->link); cr->destroy = unbind_resource; - wl_keyboard_send_keymap(cr, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, - seat->xkb_info.keymap_fd, - seat->xkb_info.keymap_size); + if (seat->compositor->use_xkbcommon) { + wl_keyboard_send_keymap(cr, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, + seat->xkb_info.keymap_fd, + seat->xkb_info.keymap_size); + } else { + wl_keyboard_send_keymap(cr, WL_KEYBOARD_KEYMAP_FORMAT_NO_KEYMAP, + 0, + 0); + } if (seat->keyboard->focus && wl_resource_get_client(seat->keyboard->focus->resource) == client) { @@ -1260,6 +1270,13 @@ int weston_compositor_xkb_init(struct weston_compositor *ec, struct xkb_rule_names *names) { + /* +* If we're operating in raw key
[PATCH weston 1/3] toytoolkit: Allow operation without a keymap
From: Matt Roper In preparation for upcoming changes, we want to make sure that apps written with the toy toolkit continue to operate properly if no XKB keymap is received. If there's no XKB keymap, then we shouldn't try to figure out keyboard modifier states (since we probably don't even have equivalents of PC-style modifiers). Reviewed-by: Singh, Satyeshwar Reviewed-by: Bob Paauwe --- clients/window.c | 4 1 file changed, 4 insertions(+) diff --git a/clients/window.c b/clients/window.c index c13d207..c8e421b 100644 --- a/clients/window.c +++ b/clients/window.c @@ -3067,6 +3067,10 @@ keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, struct input *input = data; xkb_mod_mask_t mask; + /* If we're not using a keymap, then we don't handle PC-style modifiers */ + if (!input->xkb.keymap) + return; + xkb_state_update_mask(input->xkb.state, mods_depressed, mods_latched, mods_locked, 0, 0, group); mask = xkb_state_serialize_mods(input->xkb.state, -- 1.8.2.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH wayland] protocol: add no_keymap format to keymap formats
From: Rob Bradford This format is used to specify that the key button events received are not in relation to any key map and that the codes should be interpreted directly. --- protocol/wayland.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/protocol/wayland.xml b/protocol/wayland.xml index 3d4ec9b..8e0e76e 100644 --- a/protocol/wayland.xml +++ b/protocol/wayland.xml @@ -1405,6 +1405,7 @@ client with the wl_keyboard.keymap event. + -- 1.8.2.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston 3/4] compositor-drm: Enable seat constraining when configured in weston.ini
On Tue, Jun 11, 2013 at 03:33:46PM +0300, Pekka Paalanen wrote: > Hi Rob, > > I think patches 2, 3, and 4 should be all squashed, and I would like to > know more of what is the use case here. > > More questions below. > > > On Mon, 10 Jun 2013 15:17:30 +0100 > Rob Bradford wrote: > > > From: Rob Bradford > > > > --- > > src/compositor-drm.c | 16 > > src/compositor.h | 2 ++ > > src/input.c | 2 ++ > > src/udev-seat.c | 3 +++ > > 4 files changed, 23 insertions(+) > > > > diff --git a/src/compositor-drm.c b/src/compositor-drm.c > > index 76d0810..7d33977 100644 > > --- a/src/compositor-drm.c > > +++ b/src/compositor-drm.c > > @@ -1796,6 +1796,22 @@ create_output_for_connector(struct drm_compositor > > *ec, > > transform = parse_transform(s, output->base.name); > > free(s); > > > > + weston_config_section_get_string(section, "seat", &s, ""); > > + if (strcmp(s, "") != 0) { > > + struct udev_seat *seat; > > + > > + seat = udev_seat_get_named(&ec->base, s); > > + if (seat) { > > + seat->base.output = &output->base; > > + if (seat->base.pointer) { > > + weston_pointer_output_center(seat->base.pointer, > > +&output->base); Hi Pekka, Thanks for the feedback below. I'll do my best to answer everything. > Does this mean, that every time an output is hotplugged in this seat, > the pointer will warp? > > What if a seat has several outputs? > Excellent point. I think I could instead go with a weston_pointer_ensure_valid_location. This function would be based off of the code in pointer_clip_motion() and then that function could be written in terms of this. Thus warping would only happen if the seat was previously unconstrained and the output that came about wanted it constrained to it. > > + if (seat->base.output && seat->base.pointer) > > + weston_pointer_output_center(seat->base.pointer, > > seat->base.output); > > Do I understand right, that whenever any input device is hotplugged, > like a keyboard, the pointer will warp? Yeh I think you're right here. The function I mentioned above could probably fix this too. But it would be nice to be cleverer about when to call this function > > + > > return 0; > > } > > > > From the man page patch: > > +.BI "seat=" name > +The logical seat name that that this output should be associated with. If > this > +is set then the seat's input will be confined to the output that has the seat > +set on it. The expectation is that this functionality will be used in a > +multiheaded environment with a single compositor for multiple output and > +input configurations. > > So, this is an output key. It is almost as if you were trying to > implement seats by using wl_seats. I don't think that will work. Like > here, you try to confine the pointer, but what if a user alt+tabs? No > constraints there. I'm confused what this is trying to achieve. > > Let me explain. I believe that wl_seat is misnamed. wl_seat is a set of > foci for a set on input devices, used by one person, or by several > people collaborating on a common desktop. Everyone has access to > everything, using their own input devices. > > A seat is a physical entity, a console; an output or outputs, and the > associated input devices. Each seat has its own user session(s), which > is easiest to implement by running a compositor per seat. Sessions are > separate by definition, and for security. Separating the sessions within > a compositor is very hard. > > I think, that seats are configured in udev, and wl_seats will be > configured in weston.ini or equivalent per-session configuration. A seat > may have multiple wl_seats, if you want e.g. multi-pointer. Currently, > we have no implementation for configuring multiple wl_seats; > device_added() will ignore all devices that do not match the wanted > ID_SEAT property, and only one udev_input with a wanted seat_id is > created in a backend. > > Could you elaborate on what you are trying to do? The requirement we have for this this is to be able to run a single compositor (with it's own custom shell) that would be driving multiple outputs using the same GPU. Clients might need to multiple outputs or move outputs - so having multiple compositor instances would be complicated. (Also can we have multiple compositor instances using the same GP
[PATCH wayland 2/2] protocol: Add missing since attribute for name event on wl_seat
From: Rob Bradford This event was added in version 2 of the protocol. --- protocol/wayland.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/wayland.xml b/protocol/wayland.xml index f5d08b5..3d4ec9b 100644 --- a/protocol/wayland.xml +++ b/protocol/wayland.xml @@ -1234,7 +1234,7 @@ - + In a multiseat configuration this can be used by the client to help identify which physical devices the seat represents. Based on -- 1.8.2.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH wayland 1/2] build: Fix warning message on syscall failures
From: Rob Bradford --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 7f3a694..7ca70da 100644 --- a/configure.ac +++ b/configure.ac @@ -42,13 +42,13 @@ AC_SUBST(GCC_CFLAGS) AC_CHECK_FUNCS([accept4 mkostemp]) AC_CHECK_DECL(SFD_CLOEXEC,[], - [AC_MSG_ERROR("SFD_CLOEXEC is needed to compile weston")], + [AC_MSG_ERROR("SFD_CLOEXEC is needed to compile wayland")], [[#include ]]) AC_CHECK_DECL(TFD_CLOEXEC,[], - [AC_MSG_ERROR("TFD_CLOEXEC is needed to compile weston")], + [AC_MSG_ERROR("TFD_CLOEXEC is needed to compile wayland")], [[#include ]]) AC_CHECK_DECL(CLOCK_MONOTONIC,[], - [AC_MSG_ERROR("CLOCK_MONOTONIC is needed to compile weston")], + [AC_MSG_ERROR("CLOCK_MONOTONIC is needed to compile wayland")], [[#include ]]) AC_CHECK_HEADERS([execinfo.h]) -- 1.8.2.1 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: [PATCH weston 2/4] input: Add a weston_pointer_output_center
On Tue, Jun 11, 2013 at 03:08:23PM +0300, Pekka Paalanen wrote: > On Mon, 10 Jun 2013 15:17:29 +0100 > Rob Bradford wrote: > > > From: Rob Bradford > > > > Centre the pointer on a the provided output. This function provides the > > basis of ensuring that the pointer starts on the output when we start to > > constrain a seat to a given output. > > WL_EXPORT void > > +weston_pointer_output_center(struct weston_pointer *pointer, > > +struct weston_output *output) > > +{ > > + pointer->x = wl_fixed_from_int(output->x + output->width / 2); > > + pointer->y = wl_fixed_from_int(output->y + output->height / 2); > > What about all the processing that happens in input.c notify_motion() > and move_pointer(), is that really not needed here? Hi Pekka, Thanks for highlighting this. I should write this function in terms of move_pointer(). Rob ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 4/4] man: Add documentation for output seat confining
From: Rob Bradford --- man/weston.ini.man | 8 1 file changed, 8 insertions(+) diff --git a/man/weston.ini.man b/man/weston.ini.man index c3e5747..93bd982 100644 --- a/man/weston.ini.man +++ b/man/weston.ini.man @@ -288,6 +288,14 @@ be one of the following 8 strings: .BR "flipped-270 " "Flipped and 90 degrees counter clockwise" .fi .RE +.TP 7 +.BI "seat=" name +The logical seat name that that this output should be associated with. If this +is set then the seat's input will be confined to the output that has the seat +set on it. The expectation is that this functionality will be used in a +multiheaded environment with a single compositor for multiple output and +input configurations. +.RE .SH "INPUT-METHOD SECTION" .TP 7 .BI "path=" "/usr/libexec/weston-keyboard" -- 1.8.1.4 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 3/4] compositor-drm: Enable seat constraining when configured in weston.ini
From: Rob Bradford --- src/compositor-drm.c | 16 src/compositor.h | 2 ++ src/input.c | 2 ++ src/udev-seat.c | 3 +++ 4 files changed, 23 insertions(+) diff --git a/src/compositor-drm.c b/src/compositor-drm.c index 76d0810..7d33977 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -1796,6 +1796,22 @@ create_output_for_connector(struct drm_compositor *ec, transform = parse_transform(s, output->base.name); free(s); + weston_config_section_get_string(section, "seat", &s, ""); + if (strcmp(s, "") != 0) { + struct udev_seat *seat; + + seat = udev_seat_get_named(&ec->base, s); + if (seat) { + seat->base.output = &output->base; + if (seat->base.pointer) { + weston_pointer_output_center(seat->base.pointer, +&output->base); + } + } + } + + free(s); + output->crtc_id = resources->crtcs[i]; output->pipe = i; ec->crtc_allocator |= (1 << output->crtc_id); diff --git a/src/compositor.h b/src/compositor.h index d2ca844..68845ab 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -425,6 +425,8 @@ struct weston_seat { struct weston_keyboard *keyboard; struct weston_touch *touch; + struct weston_output *output; /* constraint */ + struct wl_signal destroy_signal; struct weston_compositor *compositor; diff --git a/src/input.c b/src/input.c index 7c7aa95..ef99899 100644 --- a/src/input.c +++ b/src/input.c @@ -585,6 +585,8 @@ clip_pointer_motion(struct weston_seat *seat, wl_fixed_t *fx, wl_fixed_t *fy) old_y = wl_fixed_to_int(seat->pointer->y); wl_list_for_each(output, &ec->output_list, link) { + if (seat->output && seat->output != output) + continue; if (pixman_region32_contains_point(&output->region, x, y, NULL)) valid = 1; diff --git a/src/udev-seat.c b/src/udev-seat.c index bd25535..8df588a 100644 --- a/src/udev-seat.c +++ b/src/udev-seat.c @@ -115,6 +115,9 @@ device_added(struct udev_device *udev_device, struct udev_input *input) wl_list_insert(seat->devices_list.prev, &device->link); + if (seat->base.output && seat->base.pointer) + weston_pointer_output_center(seat->base.pointer, seat->base.output); + return 0; } -- 1.8.1.4 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 2/4] input: Add a weston_pointer_output_center
From: Rob Bradford Centre the pointer on a the provided output. This function provides the basis of ensuring that the pointer starts on the output when we start to constrain a seat to a given output. --- src/compositor.h | 3 +++ src/input.c | 8 2 files changed, 11 insertions(+) diff --git a/src/compositor.h b/src/compositor.h index 22700b7..d2ca844 100644 --- a/src/compositor.h +++ b/src/compositor.h @@ -333,6 +333,9 @@ weston_pointer_start_grab(struct weston_pointer *pointer, struct weston_pointer_grab *grab); void weston_pointer_end_grab(struct weston_pointer *pointer); +void +weston_pointer_output_center(struct weston_pointer *pointer, +struct weston_output *output); struct weston_keyboard * weston_keyboard_create(void); diff --git a/src/input.c b/src/input.c index d299d98..7c7aa95 100644 --- a/src/input.c +++ b/src/input.c @@ -473,6 +473,14 @@ weston_pointer_set_focus(struct weston_pointer *pointer, } WL_EXPORT void +weston_pointer_output_center(struct weston_pointer *pointer, +struct weston_output *output) +{ + pointer->x = wl_fixed_from_int(output->x + output->width / 2); + pointer->y = wl_fixed_from_int(output->y + output->height / 2); +} + +WL_EXPORT void weston_keyboard_set_focus(struct weston_keyboard *keyboard, struct weston_surface *surface) { -- 1.8.1.4 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH weston 1/4] udev-seat: Refactor out seat lookup and possible creation
From: Rob Bradford This change spills the code for looking up a seat by name and then potentially creating it if it doesn't exist into a new function called udev_seat_get_named. This change allows us to reuse this code when looking up the seat when parsing seat constraints per output. --- src/udev-seat.c | 29 - src/udev-seat.h | 2 ++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/udev-seat.c b/src/udev-seat.c index a8790b3..bd25535 100644 --- a/src/udev-seat.c +++ b/src/udev-seat.c @@ -66,18 +66,11 @@ device_added(struct udev_device *udev_device, struct udev_input *input) if (!seat_name) seat_name = default_seat_name; - wl_list_for_each(seat, &c->seat_list, base.link) { - if (strcmp(seat->base.seat_name, seat_name) == 0) - goto seat_found; - } + seat = udev_seat_get_named(c, seat_name); - seat = udev_seat_create(c, seat_name); - - if (!seat) + if (seat == NULL) return -1; -seat_found: - /* Use non-blocking mode so that we can loop on read on * evdev_device_data() until all events on the fd are * read. mtdev_get() also expects this. */ @@ -350,3 +343,21 @@ udev_seat_destroy(struct udev_seat *seat) weston_seat_release(&seat->base); free(seat); } + +struct udev_seat * +udev_seat_get_named(struct weston_compositor *c, const char *seat_name) +{ + struct udev_seat *seat; + + wl_list_for_each(seat, &c->seat_list, base.link) { + if (strcmp(seat->base.seat_name, seat_name) == 0) + return seat; + } + + seat = udev_seat_create(c, seat_name); + + if (!seat) + return NULL; + + return seat; +} diff --git a/src/udev-seat.h b/src/udev-seat.h index 7dd5987..3543e7c 100644 --- a/src/udev-seat.h +++ b/src/udev-seat.h @@ -48,4 +48,6 @@ int udev_input_init(struct udev_input *input, const char *seat_id); void udev_input_destroy(struct udev_input *input); +struct udev_seat *udev_seat_get_named(struct weston_compositor *c, + const char *seat_name); #endif -- 1.8.1.4 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel