Commit Graph

143 Commits

Author SHA1 Message Date
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
Matthias Clasen
b2e19866ea wayland: Wait for output and seat information
When we open the connection, we get the wl_output object,
but we return before all the information such as monitor
geometry has arrived, which causes us to misinform early
users of this information. Do a roundtrip here that causes
us to wait until the information is complete. Do the same
for seats, just in case.
https://bugzilla.gnome.org/show_bug.cgi?id=747471
2015-04-09 00:14:20 -04:00
Matthias Clasen
cb750f60f9 wayland: Don't mix free and g_strdup
While it works most of the time, this is technically
not correct.
2015-04-05 18:59:51 -04:00
Jonas Ådahl
4e930ada32 wayland: Move gtk-shell compatibility version define too
https://bugzilla.gnome.org/show_bug.cgi?id=745721
2015-03-16 13:58:14 -04:00
Jonas Ådahl
7372ddd2a1 wayland: Ignore setting the same cursor theme as was already set
If the name and size of the theme is identical to the current
configuration, do nothing.

https://bugzilla.gnome.org/show_bug.cgi?id=746141
2015-03-16 19:53:37 +08:00
Jonas Ådahl
465647e964 wayland: Support scaling of theme based cursors
Support scaling of cursors created from themes. The default scale is
always 1, but if the pointer cursor surface enters an output with a
higher scale, load the larger version of the cursor theme and use the
image from that theme.

This assumes the theme size is set to one that fits with an output scale
= 1.

https://bugzilla.gnome.org/show_bug.cgi?id=746141
2015-03-16 19:53:37 +08:00
Jonas Ådahl
b4344861a0 wayland: Only bind to supported gtk-shell versions
The gtk-shell Wayland protocol extension is not meant to be backward
compatible right now, so avoid binding to any version that is not the
one supported.

https://bugzilla.gnome.org/show_bug.cgi?id=745721
2015-03-11 11:37:37 +08:00
Matthias Clasen
af86bc58b9 wayland: Add debug spew 2015-02-28 00:58:05 -05:00
Matthias Clasen
94c5d691df wayland: Formatting fixes 2015-02-28 00:02:30 -05:00
Jonas Ådahl
f13157f4bb wayland: Don't allocate a full size SHM buffer when drawing using OpenGL
Before this patch, we'd always allocate a full size SHM buffer via
the wl_shm_pool, even though it would never be used. Instead allocate a
logical 1x1 cairo image surface.

https://bugzilla.gnome.org/show_bug.cgi?id=745076
2015-02-24 20:22:03 -05:00
Pier Luigi Fiorini
6ae521bb32 wayland: Do not require latest wl_seat
Some compositors might not offer wl_seat 4 resulting in GTK+ clients not
working on that compositor.

wl_seat 4 introduces keyboard repeat information, but when that information
is missing it is retrieved from settings, hence there's no reason to
require wl_seat 4.

This patch was tested against QtCompositor (5.5, dev branch)
and Weston 1.6.1.

Reviewed-by: Daniel Stone <daniels@collabora.com>

https://bugzilla.gnome.org/show_bug.cgi?id=744172
2015-02-13 19:05:32 -05:00
Matthias Clasen
95fad690d2 wayland: Don't claim to support selection notification
We don't support selection notification, so don't claim
we do, only to fail later.

https://bugzilla.gnome.org/show_bug.cgi?id=743229
2015-01-24 17:25:43 -05:00
Javier Jardón
710f332082 configure.ac: Depend on cairo 1.14.0
This is needed for cairo_set_device_scale()
2014-11-10 15:12:17 +00:00
Alexander Larsson
fb50015519 GdkGLContext: Change the way we track the current context
To properly support multithreaded use we use a global GPrivate
to track the current context. Since we also don't need to track
the current context on the display we move gdk_display_destroy_gl_context
to GdkGLContext::discard.
2014-10-30 12:43:03 +01:00
Jasper St. Pierre
887b7356c3 gdkdisplay: Provide a default event_data_copy / event_data_free
Every single implementation but Quartz is a no-op for this, so just
provide it once rather than in every backend.
2014-10-27 22:13:23 -07:00
Ryan Lortie
6d7f5d4431 wayland: don't init if XDG_RUNTIME_DIR missing
wayland doesn't strictly follow the XDG_RUNTIME_DIR spec by falling back
to another directory in case the runtime dir is not properly set.

When this variable is unset, wayland will log an error to us, which we
treat as fatal, aborting the entire program.

Skip ourselves all the trouble and don't try to bring up the wayland
backend when we know it will fail in this way.

https://bugzilla.gnome.org/show_bug.cgi?id=738873
2014-10-21 08:12:12 -04:00
Alexander Larsson
7eae4985e8 wayland: Add OpenGL support
This uses EGL to implement GdkGLContext for wayland.
2014-10-13 10:43:31 -04:00
Matthias Clasen
52578945bd Wayland: Fix various compiler warnings
Mostly missing declarations, missing statics and unused functions.
2014-09-05 20:41:06 -04:00
Jasper St. Pierre
4764ba4b0e wayland: Don't leak the tmp_keymap
This is a static variable, so setting it every time will leak the
previous one.
2014-09-05 15:06:19 -07:00
Jasper St. Pierre
b692d779b2 wayland: Correctly find the keyboard for the keymap
The list of devices was being scanned over incorrectly, causing us to
never actually fetch the keymap from the keyboard, as the keyboard was
the second device in the list, not the first.

This causes us to create a new temporary keymap every time, which is
quite expensive, because it involves parsing the entire XKB
file. Scanning the list correctly will cause us to use the XKB rules
file that was passed to us.
2014-09-05 15:06:19 -07:00