Commit Graph

162 Commits

Author SHA1 Message Date
Florian Müllner
d163aba030 gdkdisplay-wayland: Add API to set startup notification ID
For wayland clients, the startup notification ID is currently only set
from the DESKTOP_STARTUP_ID environment variable. As that variable is
only set for clients launched via exec(), startup completion is not
indicated correctly for DBus-activated applications unless an explicit
ID is specified - usually that is not the case, as the default handling
uses gdk_notify_startup_complete().
To address this, we need API to set the startup notification ID from GTK
as we have on X11.

https://bugzilla.gnome.org/show_bug.cgi?id=768531
2016-11-09 14:18:14 -05:00
Matthias Clasen
e041345fcb Remove the last uses of GDK_DISPLAY_OBJECT
This is an obsolete macro.
2016-10-25 16:01:50 -04:00
Benjamin Otte
89f2e17f91 API: Remove gdk_window_set_composited()
And the related call gdk_display_supports_composite().
2016-10-16 18:17:21 +02:00
Timm Bäder
476c1c44a5 gdkdisplay-wayland: Fix some memory leaks 2016-09-08 11:34:13 +02:00
Jonas Ådahl
340b5964dd wayland: Add API for setting an exported as a parent
Add an API that enables an application to, given an exported window
handle, set its own window as a transient of the window associated with
the exported window handle.

https://bugzilla.gnome.org/show_bug.cgi?id=769788
2016-08-29 13:20:44 -04:00
Jonas Ådahl
127d2ac956 wayland: Add API for creating exported window handles
Using the xdg_foreign protocol, expose a way to get handles to windows
that may be shared between processes.

https://bugzilla.gnome.org/show_bug.cgi?id=769788
2016-08-29 13:20:44 -04:00
Jonas Ådahl
ceada4adc2 wayland: Port to xdg_shell unstable v6
https://bugzilla.gnome.org/show_bug.cgi?id=769937
2016-08-25 12:31:40 +08:00
Jonas Ådahl
d2385bec09 wayland: Remove gdk_wayland_display_get_xdg_shell()
Don't expose the xdg_shell struct as it is not yet a stable type that
will stay the same.

https://bugzilla.gnome.org/show_bug.cgi?id=769937
2016-08-25 12:31:40 +08:00
Carlos Garnacho
536017646e wayland: Update current tablet support to using v2
Only update to using v2 headers/structs. The incompatible changes
to tool events are dealt with in the next commit. Pads aren't handled
in this commit either.
2016-07-22 19:35:09 +02:00
Ray Strode
2f3cb31e55 wayland: fall back to shm_open if memfd unavailable
Debian stable currently ships with a 3.16 kernel, so
it doesn't have memfd available.

This commit adds shm_open fall back code for that case
(for now).

https://bugzilla.gnome.org/show_bug.cgi?id=766341
2016-06-16 12:02:51 -04:00
Ray Strode
bb2ca3b94d wayland: fix error handling for memfd_create
We currently use syscall() directly to invoke memfd_create,
since the function isn't available in libc headers yet.

The code, though, mishandles how errors are passed from syscall().
It assumes syscall returns the error code directly (but negative),
when in fact, syscall() uses errno.

Also, the code fails to retry on EINTR.

This commit moves the handling of memfd create to a helper function,
and changes the code to use errno and handle EINTR.

https://bugzilla.gnome.org/show_bug.cgi?id=766341
2016-06-16 12:00:24 -04:00
Olivier Fourdan
b03784eb97 wayland: Add get_monitor_at_window to Wayland backend
Given that Wayland has no global coordinate, the only way for gdk to
retrieve the monitor a window last entered is to retrieve it from the
GdkWaylandWindow itself.

Implement the backend specific get_monitor_at_window() to return the
monitor that was last entered by the window.

https://bugzilla.gnome.org/show_bug.cgi?id=766566
2016-05-18 19:07:27 +02:00
Matthias Clasen
55ea6e4dcc wayland: Make gdk_display_get_name work
It should just return the same as gdk_screen_make_display_name.
2016-05-01 10:51:41 -04:00
Matthias Clasen
9026289381 wayland: Port to new monitor api 2016-04-27 23:18:16 -04:00
Jonas Ådahl
cb73becfb4 wayland: Clean up naming of GdkWaylandDisplay pointers
The naming of pointers to GdkWaylandDisplay's were inconsistent.
Running the following commands in gtk+/gdk/wayland illustrate the
inconsistency:

$ grep -r '\<display_wayland\>' *.[ch] | wc -l
195
$ grep -r '\<wayland_display\>' *.[ch] | wc -l
81

This patch renames all occurrences of "wayland_display" to
"display_wayland". This is also consistent with naming in the X11
backend. A couple of whitespace changes were done as well in places
where the rename was already done, that added line breaks to long lines
that stood out.

https://bugzilla.gnome.org/show_bug.cgi?id=765474
2016-04-26 08:38:18 -04:00
Stephen Chandler Paul
7cc0850a5a Wayland: Add initial support for drawing tablets
Only the management of tablets and tools is added so far. No tablet events
are yet interpreted.

As it's been the tradition in GTK+, erasers are split into their own device,
whereas the rest of the tools are meant to be routed through the
GDK_SOURCE_PEN device. Both pen/eraser devices are slaves to a master
pointer device, separate to wl_pointer's. This is so each tablet can
maintain its own cursor/positioning accounting.

Signed-off-by: Stephen Chandler Paul <thatslyude@gmail.com>
2016-04-06 16:12:12 +02:00
Matthias Clasen
1057f249bd wayland: Add debug output for pixel formats
Use GDK_DEBUG=misc to see information about wl_shm pixel formats
supported by the compositor.
2016-03-26 16:08:01 -04:00
Jonas Ådahl
ed430dc00a wayland: Add system bell support via gtk_shell
Invoke the system bell by calling the request added to the gtk_shell
protocol.

https://bugzilla.gnome.org/show_bug.cgi?id=763001
2016-03-10 12:31:15 +08:00
Jonas Ådahl
f68cf698fc wayland: Don't invent our own unstable protocol semantics
The gtk_shell protocol used some half baked unstable protocol semantics
that worked by only allowing binding the exact version of the
interface. This hack is a bit too confusing and it makes it impossible
to do any compatible changes without breaking things.

So, instead rename it to include a number in the interface names. This
way we can add requests and events without causing compatibility issues,
and we can later remove requests and events by bumping the number in
the interface names.

https://bugzilla.gnome.org/show_bug.cgi?id=763001
2016-03-10 12:31:15 +08:00
Paolo Borelli
4a6f8a065a gdk: remove the display->list_devices vfunc
gdk_display_list_devices is deprecated and all the backends
implement the same fallback by delegating to the device manager
and caching the list (caching it is needed since the method does
not transfer ownership of the container).
The compat code can be shared among all backends and we can
initialize the list lazily only in the case someone calls the
deprecated method.

https://bugzilla.gnome.org/show_bug.cgi?id=762891
2016-02-29 21:53:58 +01:00
Paolo Borelli
38ad57948c gdk: remove the core_pointer field from GdkDisplay
It is not used anymore, so no need to set it

https://bugzilla.gnome.org/show_bug.cgi?id=762820
2016-02-29 14:15:04 +01:00
Matthias Clasen
664b166838 wayland: Strip newlines from g_warning and g_error
g_logv adds one for us already.
2016-02-28 12:23:12 -05:00
Matthias Clasen
9f37557ffc Fix an memory overrun
This was detected by gccs address sanitizer.
2016-02-26 15:52:19 -05:00
Carlos Garnacho
ed3c87df7a wayland: Implement the (so far internal) primary selection protocol
Implement it using the internal copy of the protocol. Otherwise,
we just deal with it the same than clipboard selection, just mapping
it to the PRIMARY atom instead of the CLIPBOARD one.

https://bugzilla.gnome.org/show_bug.cgi?id=762561
2016-02-26 19:59:17 +01:00
Carlos Garnacho
ebb175021e wayland: Implement gtk_shell.set_startup_id
Fetch the DESKTOP_STARTUP_ID envvar at the same point it's done
for the X11 backend, and notify the startup ID gotten on
notify_startup_complete().
2016-02-19 17:45:42 +01:00
Olivier Fourdan
5a253c546a wayland: check for support of xdg_shell interface
When running with a Wayland compositor which doesn't support the
xdg_shell interface, gtk+ will segfault while trying to access the
corresponding wl proxy.

Check for xdg_shell support and do not use Wayland if not present, so
that it can fallback to X11, hoping that Xwayland is usable.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=762258
2016-02-18 15:29:01 +01:00
Ray Strode
40e91195ad wayland: don't handle buffer release centrally
Right now we handle buffer releases coming from the
compositor in a central place. We add a listener when
first creating the shared buffers.

This is problematic because a buffer can only have
one listener on it at once so users of the buffer
can't get notified when it's released.

This commit moves the buffer listener code from the
centrally managed display code to the cursor and window
code.

https://bugzilla.gnome.org/show_bug.cgi?id=761312
2016-02-06 08:02:57 -05:00
Ray Strode
2c300081c4 wayland: always return FALSE from begin_paint
The client and compositor share access to the window
pixel buffers. After the client hands off (commits)
the buffer to the compositor it's not supposed to write
to it again until it's released by the compositor.

The code tries to deal with this contention by allocating
a temporary buffer and using that in the mean time. This
temporary buffer is allocated by a higher layer of the code
when begin_paint returns TRUE. Unfortunately, that layer of
the code has no idea when the buffer is released, so it ends
up blitting the temporary buffer back to the shared buffer
prematurely.

This commit changes begin_paint to always return FALSE.

A future commit will address the contention problem in
a different way.

https://bugzilla.gnome.org/show_bug.cgi?id=761312
2016-02-06 08:02:57 -05:00
Ray Strode
e6f92df57e wayland: rename cairo surface user data key to be more specific
This commit renames the key name to be more specific for clarity.

https://bugzilla.gnome.org/show_bug.cgi?id=761312
2016-02-06 07:59:25 -05:00
Ray Strode
05f0e9a5c2 wayland: __NR_memfd_create instead of SYS_memfd_create
It looks like the gnome-continuous headers haven't quite
caught up yet, so try __NR_memfd_create instead.

If that doesn't work, i'll likely just add in a fallback
code path.
2016-01-25 13:55:25 -05:00
Ray Strode
df70e28d92 wayland: use memfd_create instead of open in tmpdir
The tmpdir is used for a wide assortment of things, and
can easily fill up. If it fills then desktop will start
crashing with SIGBUS errors.

This commit changes the shm pool allocation code, to use
memfd_create, instead, so the shared memory files will
be anonymous and not associated with /tmp

https://bugzilla.gnome.org/show_bug.cgi?id=761095
2016-01-25 13:36:23 -05:00
Matthias Clasen
eb2ef63211 wayland: Don't hardcode /tmp
As pointed out in https://bugzilla.gnome.org/show_bug.cgi?id=760964,
we should use the GLib facilities for determining the preferred
location for temporary files.
2016-01-21 22:57:39 -05:00
Ray Strode
5150849a67 wayland: don't pass in width and height to create_shm_pool
create_shm_pool doesn't need the width or height, it just needs
the total size.  By passing it in, we're requiring it to redo
stride calculation unnecessarily.

This commit drops the width and height parameters and makes the
function just take the total size directly.

https://bugzilla.gnome.org/show_bug.cgi?id=760897
2016-01-20 14:29:15 -05:00
Ray Strode
1e001eaa78 wayland: clean up stride calculation when creating shm surface
Right now, we assume the stride for the image surface needs to
be 4 byte aligned.  This is, in fact, true, but it's better to
ask cairo for the alignment requirement directly rather than
assume we know the alignment rules.

This commit changes the code to use cairo_format_stride_for_width
to calculate a suitable rowstride for pixman.

https://bugzilla.gnome.org/show_bug.cgi?id=760897
2016-01-20 14:29:15 -05:00
Ray Strode
c8deaeabdd wayland: unlink shm file earlier in create function
create_shm_pool unlinks the temporary file a little,
too late. It should be unlinked before ftruncate()
is called for two reasons:

1) if ftruncate fails, the file is currently not
getting cleaned up at all
2) in theory, if the file is public some other process
could muck with it

This commit just moves the unlink call a little higher
up.

https://bugzilla.gnome.org/show_bug.cgi?id=760897
2016-01-20 14:29:15 -05:00
Carlos Garnacho
1045dda035 wayland: Implement DnD actions as per wl_data_device v3
Implement as a managed GdkDragContext, which actually fits nicely
with the drag-and-drop model in wayland.
2016-01-19 14:17:36 +01:00
Peter Hutterer
3fca36169a wayland: add support for wl_pointer frame/axis_source/axis_discrete/axis_stop
This adds support for the new wl_pointer events available in v5.

The wl_pointer.axis_source events can be ignored for the purposes here, the
main reason they exist is so that the combination of axis_source=finger and
axis_stop triggers kinetic scrolling. We don't need to care about the source,
axis_stop is enough for us to tell us when we're scrolling.

The wl_pointer.frame events group events together and is intended as a
mechanism to coalesce events together. This for example allows us to now
send a single GTK scroll event for a diagonal scroll. Previously, the two
wl_pointer.axis events had to be handled separately.

The wl_pointer.axis_discrete event sends mouse wheel clicks where
appropriate, and is translated into up/down/left/right scroll events.

https://bugzilla.gnome.org/show_bug.cgi?id=756729
2016-01-18 21:36:23 +01:00
Carlos Garnacho
1fbf2fe4d7 wayland: Avoid GdkDeviceManager APIs
In most places, we can do with the pointer/keyboard of the default seat
instead of the client pointer. We can also remove some code from
gdk_input_init() because we know for sure there's no floating devices to
care about here.
2015-12-16 19:47:06 +01:00
Jonas Ådahl
912e79dbe2 wayland: Use pointer gestures protocol from wayland-protocols
Instead of having our own copy of the pointer gestures XML file, use
the one installed by wayland-protocols.

Since pointer gestures is an unstable protocol, it went through the
unstable protocol naming convention changes, which is reflected in this
commit.

https://bugzilla.gnome.org/show_bug.cgi?id=758634
2015-11-26 16:54:32 +08:00
Carlos Garnacho
de7e27bc97 wayland: remove embarrassing g_print()s 2015-11-24 20:57:03 +01:00
Carlos Garnacho
d62febcf97 wayland: Plug surface leak
Other backends take care of the cairo surface destruction in
GdkWindow::destroy. We must do the same here, or the cairo_surface
and its corresponding wl_buffer are left dangling.

https://bugzilla.gnome.org/show_bug.cgi?id=747295
2015-11-24 20:52:12 +01:00
Matthias Clasen
ea66300cf9 wayland: Make display closing work
The code in _gdk_wayland_window_dispose was not safe against
being called twice - it would call g_hash_table_destroy twice
on the known_globals hash table, the second time operating on
freed memory. It was also leaking the list of async_roundtrips.

After fixing both of these issues, the displayclose testcase
now works on Wayland.
2015-08-28 16:15:26 -04:00
Jonas Ådahl
32cd1a7447 wayland: Only bind supported unstable pointer gestures global
As the protocol is still considered unstable (meaning not backward
compatible), we should, as stated in the protocol, only bind the version
advertised is the version we implement.

https://bugzilla.gnome.org/show_bug.cgi?id=753856
2015-08-21 10:04:02 +08:00
Ray Strode
83c25169e8 Revert "wayland: require WAYLAND_DISPLAY be set to open wayland display"
This reverts commit 35489f5d31.

It snuck in when i was trying to push

commit f4d2022d46
2015-08-14 11:24:44 -04:00
Ray Strode
f4d2022d46 wayland: change wl_log level to G_LOG_LEVEL_DEBUG
wl_log() currently logs using G_LOG_LEVEL_ERROR
(which is fatal). The wayland client library doesn't
expect this behavior. It uses wl_log to log recoverable
errors.

This commit changes the log level to G_LOG_LEVEL_DEBUG
instead.

https://bugzilla.gnome.org/show_bug.cgi?id=753635
2015-08-14 11:06:48 -04:00
Ray Strode
35489f5d31 wayland: require WAYLAND_DISPLAY be set to open wayland display
The wayland client libraries now require WAYLAND_DISPLAY be set
to use them.

See:

http://cgit.freedesktop.org/wayland/wayland/commit/?id=fb7e13021730d0a5516ecbd3712ea4235e05d24d

This commit makes _gdk_wayland_display_open bail early if
WAYLAND_DISPLAY is unset, just as it does for XDG_RUNTIME_DIR.
2015-08-14 10:28:31 -04:00
Carlos Garnacho
45d15b302e wayland: Implement touchpad gesture events
On wayland, the gestures protocol defines a wl_pointer_gestures global
object, that will match in number with wl_seats, swipe and pinch
interfaces can be obtained from it, which events are translated into
GdkEventTouchpadSwipe/Pinch events.
2015-08-12 23:20:25 +02:00
Jonas Ådahl
7fef713224 wayland: Use on globals closure for loading cursor themes
Instead of putting a 'load cursor themes' call when receiving an wl_shm
global, make it a closure that is prepared during initialization.

https://bugzilla.gnome.org/show_bug.cgi?id=719819
2015-05-20 11:45:13 +08:00
Jonas Ådahl
4e9be39518 wayland: Add global object depedency tracking
Some features need certain globals to initialize. In order to deal with
these dependencies, add a way to postpone closures that depend on a
certain set of globals, that later will be invoked when required
globals are all received.

https://bugzilla.gnome.org/show_bug.cgi?id=719819
2015-05-20 11:45:13 +08:00
Jonas Ådahl
181e4399f6 wayland: Don't round trip recursively during initialization
Instead use asynchronous round trips that is synchronized in the end of
the initialization. This makes it easier to track state, as we won't
dispatch arbitrary Wayland messages while processing globals.

https://bugzilla.gnome.org/show_bug.cgi?id=719819
2015-05-20 10:59:47 +08:00