summaryrefslogtreecommitdiff
path: root/src/data-device.c
Commit message (Collapse)AuthorAgeFilesLines
* data-device: Update current action even if source version is oldJonas Ådahl2016-04-221-10/+12
| | | | | | | | | | | | | | If the version of the source object is old enough to not have wl_data_source.set_actions() the current action would never be updated since source->set_actions would never be set. To fix this, instead of checking whether source->set_actions before proceeding with updating the current action, just always update the action when we know all parts are valid dnd data device objects. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Mike Blumenkrantz <zmike@osg.samsung.com> Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
* data-device: Check harder for selection/non-wayland sourcesCarlos Garnacho2016-02-011-2/+6
| | | | | | | | | We're not always dealing with weston_data_sources that have a wl_resource, or data_sources that belong to drag-and-drop. Check harder for these on the drag-and-drop code paths triggered from common code. Signed-off-by: Carlos Garnacho <carlosg@gnome.org>
* data-device: Implement compositor-chosen actionsCarlos Garnacho2016-01-191-0/+76
| | | | | | | | | | | | | | | | | | | | | | | Set up a keyboard grab during drag-and-drop, so we can translate modifiers into preferred actions. The compositor chosen action is stored in the current weston_data_source in order to make it accessible to the source/offer at the time of calculating the new action, but would conceptually be part of weston_drag. The mapping has been made similar to what GTK+/QT usually do, the shift key defaults to "move" and ctrl defaults to "copy". Changes since v2: - Use enum types and values for the compositor action. Fix code formatting issues. Changes since v1: - Handle the keyboard grab being cancelled. Initialize new wl_data_source fields. Signed-off-by: Carlos Garnacho <carlosg@gnome.org> Reviewed-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
* data-device: Implement DnD actionsCarlos Garnacho2016-01-191-4/+178
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The policy in weston in order to determine the chosen DnD action is deliberately simple, and is probably the minimals that any compositor should be doing here. Besides honoring the set_actions requests on both wl_data_source and wl_data_offer, weston now will emit the newly added "action" events notifying both source and dest of the chosen action. The "dnd" client has been updated too (although minimally), so it notifies the compositor of a "move" action on both sides. Changes since v8: - Add back wl_data_offer.source_actions emission, gone during last code shuffling. Fix nits found in review. Changes since v7: - Fixes spotted during review. Add client-side version checks. Implement .action emission as specified in protocol patch v11. Changes since v6: - Emit errors as defined in DnD actions patch v10. Changes since v5: - Use enum types and values for not-a-bitfield stored values. handle errors when finding unexpected dnd_actions values. Changes since v4: - Added compositor-side version checks. Spaces vs tabs fixes. Fixed resource versioning. Initialized new weston_data_source/offer fields. Changes since v3: - Put data_source.action to use in the dnd client, now updates the dnd surface like data_source.target events do. Changes since v2: - Split from DnD progress notification changes. Changes since v1: - Updated to v2 of DnD actions protocol changes, implement wl_data_offer.source_actions. - Fixed coding style issues. Signed-off-by: Carlos Garnacho <carlosg@gnome.org> Reviewed-by: Michael Catanzaro <mcatanzaro@igalia.com> Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
* data-device: Implement DnD progress notificationCarlos Garnacho2016-01-191-16/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Weston now sends wl_data_source.dnd_drop_performed and .dnd_finished in order to notify about the different phases of DnD. wl_data_source.cancelled is also used as mentioned in the docs, being emitted also on DnD when the operation is meant to fail (eg. source and dest didn't agree on a mimetype). The dnd demo is also fixed so the struct dnd_drag isn't leaked. https://bugs.freedesktop.org/show_bug.cgi?id=91943 https://bugs.freedesktop.org/show_bug.cgi?id=91944 Changes since v6: - Add client-side version checks. Minor code shuffling. Changes since v5: - Dissociate source and offer after cancel. Updated to apply on top of c9f8f8a7f. Changes since v4: - Make wl_data_offer.finish with the wrong state an error. Changes since v3: - Fixed wl_data_source.dnd_finished vs cancelled emission on when interoperating with version < 3 drag destinations. Changes since v2: - Handle wl_data_offer.finish. Fixed commit log inconsistencies. Added version checks. Spaces vs tabs fixes. Fixed resource versioning. Changes since v1: - Updated to protocol v2. Signed-off-by: Carlos Garnacho <carlosg@gnome.org> Reviewed-by: Michael Catanzaro <mcatanzaro@igalia.com> Reviewed-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
* Support axis source, axis discrete, frame and axis stop eventsPeter Hutterer2016-01-191-0/+12
| | | | | | | | [jonas: only send focus wl_pointer.frame if resource supports it] Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jonas Ådahl <jadahl@gmail.com> Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
* Add a weston_pointer_axis_eventPeter Hutterer2016-01-191-1/+1
| | | | | | | | Use an event struct to pass axis events around. This helps dealing with the upcoming axis discrete changes. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
* compositor: create_data_source(): Fix potential crash on OOMcpaul@redhat.com2016-01-131-2/+8
| | | | | | | | | | | Noticed this while working on primary selection, in the event we run out of memory when trying to create a new data source, there's a chance we'll fail on wl_resource_create() and crash from source->resource being set to NULL. Signed-off-by: Lyude <cpaul@redhat.com> Reviewed-by: Marek Chalupa <mchqwerty@gmail.com> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
* input: Make pointer grab motion callbacks take an event structJonas Ådahl2015-11-201-2/+2
| | | | | | | | | | | | | Instead of only passing absolute pointer coordinates, effectively loosing motion event data, pass a struct that can potentially contain different types of motion events, currently being absolute and relative. A helper function to get resulting absolute coordinates was added for when previous callbacks simply used the (x, y) coordinates. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Derek Foreman <derekf@osg.samsung.com>
* input: Pass axis events through pointer grab interfacesJonas Ådahl2015-11-021-0/+7
| | | | | | | | Don't only send motions and buttons but also axis events through the pointer grab interface. Signed-off-by: Jonas Ådahl <jadahl@gmail.com> Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
* input: add a weston_pointer_clear_focus() helper functionDerek Foreman2015-08-061-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Valgrind has shown that in at least one place (default_grab_pointer_focus) we're testing uninitialized values coming out of weston_compositor_pick_view. This is happening when default_grab_pointer_focus is called when there is nothing on the view list, and during the first repaint when only the black surface with no input region exists. This patch adds a function to clear pointer focus and also set the sx,sy co-ordinates to a sentinel value we shouldn't compute with. Assertions are added to make sure any time pointer focus is set to NULL these values are used. weston_compositor_pick_view() now returns these values too. Now the values are always initialized, even when no view exists, and they're initialized in such a way that actually doing computation with them should fail in an obvious way, but we can compare them safely for equality. Signed-off-by: Derek Foreman <derekf@osg.samsung.com> Reviewed-by: Daniel Stone <daniels@collabora.com>
* input: pass the global touch coordinates to the touch grabGiulio Camuffo2015-08-061-1/+1
| | | | | | | | This makes it consistent with the pointer grab, which also gets global coordinates and not surface relative ones, and allows to easily filter out gestures based on compositor global hotspots. Reviewed-by: Daniel Stone <daniels@collabora.com>
* input: Don't test keyboard/pointer/touch pointersDerek Foreman2015-07-311-18/+23
| | | | | | | | | | | | | | Keyboards and pointers aren't freed when devices are removed, so we should really be testing keyboard_device_count and pointer_device_count in most cases, not the actual pointers. Otherwise we end up with different behaviour after removing a device than we had before it was inserted. This commit renames the touch/keyboard/pointer pointers and adds helper functions to get them that hide this complexity and return NULL when *_device_count is 0. Signed-off-by: Derek Foreman <derekf@osg.samsung.com> Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
* Unified multiple definitions of container_of() macro.Jon Cruz2015-06-151-0/+1
| | | | | | | | | Removed duplicate definitions of the container_of() macro and refactored sources to use the single implementation. Signed-off-by: Jon A. Cruz <jonc@osg.samsung.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
* src: Update boilerplate from MIT X11 license to MIT Expat licenseBryce Harrington2015-06-151-16/+19
|
* data-device: send the selection to all the wl_data_device resources of a clientGiulio Camuffo2015-05-011-8/+11
| | | | | | | | As we do for the input interfaces such as wl_pointer, we must send the selection event to all the wl_data_device resources the client created for a specified seat. Reviewed-by: Daniel Stone <daniels@collabora.com>
* data-device: add a function to send the selection to a clientGiulio Camuffo2015-05-011-22/+32
| | | | | | | | This commit adds a new exported function, weston_seat_send_selection(), which sends the current selection to a specified client. This is useful e.g. to implement a clipboard manager as a special client. Reviewed-by: Daniel Stone <daniels@collabora.com>
* compositor: add weston_surface_set_label_func()Pekka Paalanen2014-12-081-0/+19
| | | | | | | | | | | | | | | | | | | | When printing out logs from Weston's actions, mainly for debugging, it can be very difficult to identify the different surfaces. Inspecting the configure function pointer is not useful, as the configure functions may live in modules. Add vfunc get_label to weston_surface, which will produce a short, human-readable description of the surface, which allows identifying it better, rather than just looking at the surface size, for instance. Set the label function from most parts of Weston, to identify cursors and drag icons, and panels, backgrounds, screensavers and lock surfaces, and the desktop shell's application surfaces. v2: renamed 'description' to 'label', so we get weston_surface_set_label_func(). Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* data_device : change version while initializing data_device_manager ↵kabeer khan2014-11-041-5/+13
| | | | | | | | | interface and data_device interface [Pekka Paalanen: split long lines, dropped MIN().] Signed-off-by: kabeer khan <kabeer.khan@samsung.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
* compositor: send error for surface role resetsPekka Paalanen2014-10-081-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the more accurate definition of wl_surface roles in Wayland, enforce the restriction: a role is always set permanently, and attempting to change it is a protocol error. This patch is based on Jasper's patch: http://lists.freedesktop.org/archives/wayland-devel/2014-August/016811.html The difference in this patch compared to his are: - send role errors on the interface whose request triggers it, not on wl_surface - an interface could have several requests assigning different roles, cannot use wl_interface as the unique key; use an arbitary string instead - ensure in window-manager.c that create_shell_surface() -> create_common_surface() is never called with surface->configure set, to avoid compositor abort - use wl_resource_post_no_memory() where appropriate instead of hand-rolling it with wl_resource_post_error() Ideally we would not add weston_surface::role_name field, but use weston_surface::configure. At the moment this is not possible though, because at least shell.c uses several different roles with the same configure function. Drag'n'drop uses two configure functions for the same role. The configure hook is also reset in several places, which is not good for role tracking. This patch overlooks the wl_surface roles assigned in privileged extensions: screensaver, panel, background, lock, input panel. Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk> Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
* compositor: keep track of the weston_layer a weston_view is inGiulio Camuffo2014-07-231-3/+3
| | | | | | | | | This introduces a new struct, weston_layer_entry, which is now used in place of wl_list to keep the link for the layer list in weston_view and the head of the list in weston_layer. weston_layer_entry also has a weston_layer*, which points to the layer the view is in or, in the case the entry it's the head of the list, to the layer itself.
* Use pixman_region32_clear instead of our own empty_regionJason Ekstrand2014-07-051-9/+2
| | | | | | This requires pixman 0.25.2 Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
* data-device: Clean up the logic in start_dragJason Ekstrand2014-06-251-14/+17
| | | | | | | Previoiusly, we had a mess of logic that was repeated with one of the repeats negated. Not only was this unnecisaraly confusing, but it segfaulted and one of the negations was wrong. This cleans the whole mess up and should fix bug #79725.
* libinput: Forward frame events to clientsJonas Ådahl2014-04-211-0/+6
| | | | | | Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=77353 Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
* data-device: Fix surface configure function typeJonas Ådahl2013-12-031-8/+9
| | | | | | | | | The commit "Remove the weston_view.geometry.width/height fields" changed the type of the surface configure callback function, but did not change the callbacks in data-device.c. This commit fixes the type of the functions left needed to be changed. Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
* Remove the weston_view.geometry.width/height fieldsJason Ekstrand2013-12-021-1/+1
| | | | | | | | | | This has a couple of additional implications for the internal weston API: 1) weston_view_configure no longer exists. Use weston_view_set_position instead. 2) The weston_surface.configure callback no longer takes a width and height. If you need these, surface.width/height are set before configure is called. If you need to know when the width/height changes, you must track that yourself.
* src/data_device.c: add dnd support for touch screenXiong Zhang2013-11-251-65/+281
| | | | | | | | | Adding the drag and drop grab interface for touch screen in src/data-device.c, so the server can handle touch screen drag and drop operation. Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com> Reviewed-by: Kristian Hogsberg <hoegsberg@gmail.com>
* input: let the pointer motion handlers move the pointerGiulio Camuffo2013-11-151-1/+4
| | | | this allows to implement pointer barriers by using a custom handler
* Add cancel function to grab interfacesJonas Ådahl2013-10-281-0/+13
| | | | | | | | | | | | | | | A grab can potentially allocate memory and would normally end the grab itself, freeing the allocated memory in the process. However at in some situations the compositor may want to abort a grab. The grab owner still needs to free some memory and abort the grab properly. To do this a new function 'cancel' is introduced in all the grab interfaces instructing the grabs owner to abort the grab. This patch also hooks up grab cancelling to seat device releasing and when the compositor looses focus, which would potentially leak memory before. Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
* Split the geometry information from weston_surface out into weston_viewJason Ekstrand2013-10-221-36/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The weston_surface structure is split into two structures: * The weston_surface structure storres everything required for a client-side or server-side surface. This includes buffers; callbacks; backend private data; input, damage, and opaque regions; and a few other bookkeeping bits. * The weston_view structure represents an entity in the scenegraph and storres all of the geometry information. This includes clip region, alpha, position, and the transformation list as well as all of the temporary information derived from the geometry state. Because a view, and not a surface, is a scenegraph element, the view is what is placed in layers and planes. There are a few things worth noting about the surface/view split: 1. This is *not* a modification to the protocol. It is, instead, a modification to Weston's internal scenegraph to allow a single surface to exist in multiple places at a time. Clients are completely unaware of how many views to a particular surface exist. 2. A view is considered a direct child of a surface and is destroyed when the surface is destroyed. Because of this, the view.surface pointer is always valid and non-null. 3. The compositor's surface_list is replaced with a view_list. Due to subsurfaces, building the view list is a little more complicated than it used to be and involves building a tree of views on the fly whenever subsurfaces are used. However, this means that backends can remain completely subsurface-agnostic. 4. Surfaces and views both keep track of which outputs they are on. 5. The weston_surface structure now has width and height fields. These are populated when a new buffer is attached before surface.configure is called. This is because there are many surface-based operations that really require the width and height and digging through the views didn't work well. Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
* input: Emit events on all resources for a clientNeil Roberts2013-09-211-12/+13
| | | | | | | | | | | | | | | | | | | | | | | | | 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 focused surface's client. We maintain a list of focused 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. Additionally when setting the pointer focus it will now send the keyboard modifiers regardless of whether the focused client has a pointer resource. This is important because otherwise if the client gets the pointer later than you getting the keyboard then the modifiers might not be up-to-date. Co-author: Neil Roberts <neil@linux.intel.com>
* input: Initialize data source to NULLKristian Høgsberg2013-09-111-1/+1
| | | | This way we do the right thing, when we get a NULL wl_resource for self-dnd.
* compositor: Return 0 on successKristian Høgsberg2013-09-111-0/+2
| | | | Add missing return statement.
* compositor: Split dnd setup up into weston_seat_start_drag()Kristian Høgsberg2013-09-041-29/+41
| | | | | | | This makes the drag-and-drop code available to in-weston data sources, similar to how we can set a selection data source internally. The wl_data_device.start_drag entry point now calls this function after validating protocol arguments.
* data-device: Only bail out if we failed to allocate offerKristian Høgsberg2013-08-201-3/+4
| | | | | It's valid to have a NULL data source (self-dnd) in which case we send a NULL offer on enter.
* Add more missing config.h includesDaniel Stone2013-08-161-0/+2
| | | | | | | | config.h includes were missing in a few files, including input.c, the lack of which caused the X11 backend to segfault instantly due to not having an xkbcommon context. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* input: For serial generation get the display from the compositorRob Bradford2013-08-121-2/+1
| | | | | | | 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.
* malloc + memset -> zallocPeter Hutterer2013-08-081-2/+1
| | | | | | And for clients using the xmalloc helper, use xzalloc. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* compositor: Check wl_resource_create() return valueKristian Høgsberg2013-08-061-4/+13
| | | | | This fixes a number of call-sites to properly check for NULL and return the no memory event when allocation fail.
* data-device.c: Handle failure to allocate offer in weston_drag_set_focusKristian Høgsberg2013-08-061-0/+2
| | | | | If we fail to allocate and send the offer, don't send the drag enter and don't set the drag focus so we don't send motion events or leave.
* data-device.c: Handle OOM in weston_data_source_send_offer()Kristian Høgsberg2013-08-061-0/+5
| | | | If we fail to allocate the resource, clean up and return NULL.
* Rename wl_data_offer to weston_data_offerKristian Høgsberg2013-07-251-6/+6
| | | | Another left-over from when we moved the input structs.
* Rename wl_data_source to weston_data_sourceKristian Høgsberg2013-07-251-15/+18
| | | | Missed this rename when we moved the input structs over from wayland.
* Convert to wl_global_create/destroy()Kristian Høgsberg2013-07-091-3/+3
|
* Use wl_resource_create() for creating resourcesJason Ekstrand2013-07-031-15/+21
| | | | | | | | | | This commit sets the version numbers for all added/created objects. The wl_compositor.create_surface implementation was altered to create a surface with the same version as the underlying wl_compositor. Since no other "child interfaces" have version greater than 1, they were all hard-coded to version 1. Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
* data-device: Remove redundant and confusing assignmentKristian Høgsberg2013-06-251-1/+1
| | | | | | We were assigning drag from the resource user data, which was wrong (resource data is the weston_seat) and confusing since drag is later assigned newly malloc()ed memory.
* data-device: Don't leak wl_data_source in destructorKristian Høgsberg2013-06-251-1/+1
| | | | | | We used to refcount the data source, but switched to using a destroy signal instead. When we switched we forgot to free the source insted of unreffing it.
* compositor: Fix remaining double free()sKristian Høgsberg2013-06-251-1/+0
| | | | Previous commit didn't catch all double free()s, hopefully this one does.
* data-device: Change resources in wl_data_offer and wl_data_source to pointers.Jason Ekstrand2013-06-201-55/+45
| | | | | | | | | Because of its links to selection.c and xwayland, a destroy_signal field was also added to wl_data_source. Before selection.c and xwayland were manually initializing the resource.destroy_signal field so that it could be used without a valid resource. Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
* output: Use wl_resource_get accessors for weston_output resourcesJason Ekstrand2013-06-141-3/+3
| | | | Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>