Commit graph

44 commits

Author SHA1 Message Date
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
Kristian Høgsberg db9bf1e818 data-device: Fix a few bugs in the commit to drop ref-counting
Did not test that change.
2012-01-03 22:43:36 -05:00
Kristian Høgsberg 82d9ee929b data-device: Handle source going away instead of ref-counting it
We have to deal with the data source going away.  Even if we have a
reference to the server side data source, we can't do anything if the
client that provided the source went away.  So just NULL the offers
source pointer in the destroy callback for the source.
2012-01-03 14:11:18 -05:00
Kristian Høgsberg 8334bc1ef9 Rename wayland-compositor to weston
This rename addresses a few problems around the split between core
Wayland and the wayland-demos repository.

1) Initially, we had one big repository with protocol code, sample
compositor and sample clients.  We split that repository to make it
possible to implement the protocol without pulling in the sample/demo
code.  At this point, the compositor is more than just a "demo" and
wayland-demos doesn't send the right message.  The sample compositor
is a useful, self-contained project in it's own right, and we want to
move away from the "demos" label.

2) Another problem is that the wayland-demos compositor is often
called "the wayland compsitor", but it's really just one possible
compositor.  Existing X11 compositors are expected to add Wayland
support and then gradually phase out/modularize the X11 support, for
example.  Conversely, it's hard to talk about the wayland-demos
compositor specifically as opposed to, eg, the wayland protocol or a
wayland compositor in general.

We are also renaming the repo to weston, and the compositor
subdirectory to src/, to emphasize that the main "output" is the
compositor.
2012-01-03 11:04:04 -05:00
Renamed from compositor/data-device.c (Browse further)