Commit graph

53 commits

Author SHA1 Message Date
Jason Ekstrand 8202d72054 data-device: Clean up the logic in start_drag
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.
2014-06-25 09:05:26 -07:00
Jonas Ådahl 1679f232e5 libinput: Forward frame events to clients
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=77353

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-04-21 16:03:28 -07:00
Jonas Ådahl 767d891c35 data-device: Fix surface configure function type
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>
2013-12-03 15:16:21 -08:00
Jason Ekstrand 918f2dd4cf Remove the weston_view.geometry.width/height fields
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.
2013-12-02 22:17:58 -08:00
Xiong Zhang fd51e7bb57 src/data_device.c: add dnd support for touch screen
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>
2013-11-25 16:32:00 -08:00
Giulio Camuffo 1959ab8d22 input: let the pointer motion handlers move the pointer
this allows to implement pointer barriers by using a custom handler
2013-11-15 16:17:51 -08:00
Jonas Ådahl 1ea343e1be Add cancel function to grab interfaces
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>
2013-10-28 14:44:06 -07:00
Jason Ekstrand a7af70436b Split the geometry information from weston_surface out into weston_view
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>
2013-10-22 13:34:11 -07:00
Neil Roberts 96d790e74b input: Emit events on all resources for a client
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>
2013-09-21 20:56:55 -07:00
Kristian Høgsberg 1702d4cfca input: Initialize data source to NULL
This way we do the right thing, when we get a NULL wl_resource for self-dnd.
2013-09-11 09:45:03 -07:00
Kristian Høgsberg 0abad07750 compositor: Return 0 on success
Add missing return statement.
2013-09-11 09:42:26 -07:00
Kristian Høgsberg 85de9c25fe compositor: Split dnd setup up into weston_seat_start_drag()
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.
2013-09-04 20:46:56 -07:00
Kristian Høgsberg a34e2f2adc data-device: Only bail out if we failed to allocate offer
It's valid to have a NULL data source (self-dnd) in which case we send
a NULL offer on enter.
2013-08-20 15:58:25 -07:00
Daniel Stone 8e7a8bdeea Add more missing config.h includes
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>
2013-08-16 10:56:00 -07:00
Rob Bradford 880ebc7ed9 input: For serial generation get the display from the compositor
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.
2013-08-12 16:54:10 -07:00
Peter Hutterer f3d62276d2 malloc + memset -> zalloc
And for clients using the xmalloc helper, use xzalloc.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-08-08 13:46:13 -07:00
Kristian Høgsberg 0ff7908767 compositor: Check wl_resource_create() return value
This fixes a number of call-sites to properly check for NULL and return
the no memory event when allocation fail.
2013-08-06 16:46:25 -07:00
Kristian Høgsberg b10b44b58c data-device.c: Handle failure to allocate offer in weston_drag_set_focus
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.
2013-08-06 11:15:22 -07:00
Kristian Høgsberg 3c30f0f950 data-device.c: Handle OOM in weston_data_source_send_offer()
If we fail to allocate the resource, clean up and return NULL.
2013-08-06 10:24:04 -07:00
Kristian Høgsberg 5e76a49d9c Rename wl_data_offer to weston_data_offer
Another left-over from when we moved the input structs.
2013-07-25 16:09:37 -07:00
Kristian Høgsberg 7ff3bdb5f7 Rename wl_data_source to weston_data_source
Missed this rename when we moved the input structs over from wayland.
2013-07-25 15:54:20 -07:00
Kristian Høgsberg 919cddb0ab Convert to wl_global_create/destroy() 2013-07-09 02:02:11 -04:00
Jason Ekstrand a85118c1b8 Use wl_resource_create() for creating resources
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>
2013-07-03 14:52:06 -04:00
Kristian Høgsberg e2173b5f36 data-device: Remove redundant and confusing assignment
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.
2013-06-25 11:28:18 -04:00
Kristian Høgsberg 489b279be9 data-device: Don't leak wl_data_source in destructor
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.
2013-06-25 11:26:31 -04:00
Kristian Høgsberg f00460771e compositor: Fix remaining double free()s
Previous commit didn't catch all double free()s, hopefully this one does.
2013-06-25 11:19:31 -04:00
Jason Ekstrand 8a4a9eb2e4 data-device: Change resources in wl_data_offer and wl_data_source to pointers.
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>
2013-06-20 23:54:29 -04:00
Jason Ekstrand a0d2dde6cd output: Use wl_resource_get accessors for weston_output resources
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-14 16:51:20 -04:00
Jason Ekstrand 0f2ef7ebd3 Use wl_resource_get_user_data for weston_surface resources
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2013-06-14 15:58:29 -04:00
Jason Ekstrand 26ed73cee8 Change weston_surface.resource to a wl_resource pointer.
This is the first in what will be a series of weston patches to convert
instances of wl_resource to pointers so we can make wl_resource opaque.
This patch handles weston_surface and should be the most invasive of the
entire series.  I am sending this one out ahead of the rest for review.

Specifically, my machine is not set up to build XWayland so I have no
ability to test it fully.  Could someone please test with XWayland and let
me know if this causes problems?

Because a surface may be created from XWayland, the resource may not always
exist.  Therefore, a destroy signal was added to weston_surface and
everything used to listen to surface->resource.destroy_signal now listens
to surface->destroy_signal.
2013-06-12 15:04:49 -04:00
Kristian Høgsberg 6848c25677 input: Move surface picking into the pointer grab focus callback
Currently the core input code does surface picking before calling into
the focus callback of the current grab.  Not all grabs need to pick a
surface however, so we're doing work we don't have to in those cases.

For example, the shell move and resize grabs don't need to pick and the
default grab in implicit grab mode doesn't either.

With this change, the pointer grab mechanism is now very simple:
the focus callback is called whenever the pointer may have a new focus,
the motion callback is called whenever the pointer moves and
the button callback whenever a button is pressed or released.
2013-05-08 22:03:45 -04:00
Kristian Høgsberg be6403ed5c input: Get rid of grab focus concept
This was another complication that we had to have to support the
split between libwayland-server and weston.  Different grabs want to send
events relative to different surfaces at different times.  The default
grab switches between sending coordinates relative to the 'current' surface,
that is the surface the pointer is currently above, or the 'clicked'
surface, in case of an implicit grab.

The grab focus was set by the grab implementation and the core input code
would transform the pointer position to surface relative coordinates for the
grab focus and store in grab->x/y.

Now we can just let the grab implementation transform the pointer
coordinates itself, leaving the implementation free to transform
according to whichever surface it wants.  Or not transform at all if
it doesn't need surface relative coordinates (like the shell move and resize
grabs).
2013-05-08 21:03:23 -04:00
Kristian Høgsberg dba25868bc data-device: Verify that the client has an implicit grab when starting a drag
Make sure that the implicit is valid and still in effect as we start
the drag.  Fixes a long standing FIXME.
2013-05-08 15:58:49 -04:00
Kristian Høgsberg 5a9fb35c89 data-device: Eliminate two small helper functions
device_setup_new_drag_surface() and device_release_drag_surface() are both
now fairly small and only called from data_device_start_drag() and
data_device_end_grab() respectively.  Folding the two functions in where
they're called from simplifies the code flow a bit.
2013-05-08 15:58:49 -04:00
Kristian Høgsberg c43aad1ab4 data-device: Rename generic weston_drag 'surface' field to 'icon' 2013-05-08 15:58:49 -04:00
Kristian Høgsberg 054c50a6de data-device: Move all drag-related fields out of weston_seat
We can now allocate a temporary weston_drag structure that we keep all
this drag-and-drop related state in.
2013-05-08 15:58:49 -04:00
Kristian Høgsberg 195b869f0e input: Move sprite fields into weston_pointer from weston_seat 2013-05-08 15:58:49 -04:00
Kristian Høgsberg fe7aa90ed4 compositor: Adapt to wl_surface going away
struct weston_surface is now the only surface type we have (in core, shell.c
has shell_surface, of course).  A lot of code gets simpler and we never
have to try to guess whether an API takes a wl_surface or a weston_surface.
2013-05-08 09:54:37 -04:00
Kristian Høgsberg aad8099c2f data-device: Update drag icon position from configure and motion handlers
We can now update the drag icon position directly from the configure
handler or the grab motion handler, and no longer need
weston_seat_update_drag_surface().
2013-05-07 22:57:15 -04:00
Kristian Høgsberg 415f30cc08 data-device: Map drag icon in configure handler
This how we usually do it, and we avoid 'polling' for mapping in
weston_seat_update_drag_surface().
2013-05-07 22:42:31 -04:00
Kristian Høgsberg 5f95557631 data-device: Setup and release drag surface and beginning and end of drag
Previously we just got the drag_icon signal and had to figure out what
changed.  Now we can directly setup or release the drag icon when the
drag starts and stops.
2013-05-07 21:06:38 -04:00
Kristian Høgsberg 40e44ab18d data-device: Fix dnd regression from weston_seat rewrite
We had a drag_surface in wl_seat and weston_seat which confused me during
the rewrite.
2013-05-07 20:50:26 -04:00
Kristian Høgsberg 624d8f2293 data-device: Don't emit a signal for drag icon changes
The signal used to be in libwayland-server and the listener in weston, but
now they're both in the same file, so lets stop using signal.
2013-05-07 20:46:04 -04:00
Kristian Høgsberg 7848bb687c input: Move drag handling to data-device.c 2013-05-07 11:18:46 -04:00
Kristian Høgsberg e314875d00 input: Merge wl_seat into weston_seat 2013-05-07 09:07:43 -04:00
Kristian Høgsberg 02bbabbd56 input: Rename wl_pointer to weston_pointer
This is now a weston object.
2013-05-06 22:15:05 -04:00
Kristian Høgsberg 2158a889a1 Import input structs and helper functions from wayland 2013-05-06 21:40:32 -04:00
Kristian Høgsberg dade64968c Move wl_data_device implementation to wayland-server 2012-01-06 11:28:53 -05:00
Kristian Høgsberg 9ddb826077 Use new grab api 2012-01-05 11:00:01 -05:00
Kristian Høgsberg a33d0c38d2 data-device: Use a listener list to decouple the x11 selection bridge 2012-01-03 23:01:47 -05:00