Commit Graph

808 Commits

Author SHA1 Message Date
Carlos Garnacho
942d144d3b gdk: Pass hardware ID on gdk_device_tool_new()
And implement this on wayland, where this information is already obtained.

https://bugzilla.gnome.org/show_bug.cgi?id=770026
2016-08-23 21:01:44 +02:00
Olivier Fourdan
f9b91197c0 wayland: Use keyboard serial for implicit grab
An xdg-popup requires a serial that the compositor will compare against
its own serial and will dismiss the popup if it doesn't match.

gtk+ uses either a pointer or touch serial for its helper function
_gdk_wayland_seat_get_last_implicit_grab_serial() but if the menu is
triggered before the user has had any pointer or touch interaction with
the client, using a keyboard shortcut, there is neither pointer nor
touch serial available, and gtk+ will use 0 as the default.

As a result, the compositor will instantly dismiss the xdg-popup. In
this case, gtk+ should use the keyboard serial instead.

Track keyboard serial as well and use the keyboard serial as the value
if there is no newer pointer or touch serial available.

https://bugzilla.gnome.org/show_bug.cgi?id=768017
2016-08-19 23:50:14 -04:00
Matthias Clasen
88248e34b1 Remove an outdated comment
It described as TODO what the code right below it already does.
2016-08-19 23:24:08 -04:00
Jonas Ådahl
cc019de6a5 wayland: Postpone processing move_to_rect params until showing
At the time of move_to_rect() is called, not all state may have been set
up on the impl gdk window, causing the position to sometimes be
slightly offset due to drap shadow margins. For now, work around this
by postponing the processing of the move_to_rect() parameters until
showing, when its more likely that all state (such as shadow margin)
has been set correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=769402
2016-08-18 04:52:03 -04:00
Jonas Ådahl
4e0ebd0cdf wayland: Don't traverse transient-ofs when faking root coordinate space
The position of each transient-of will be in fake-root coordinate
space; thus we should not accumulate all the positions making it an
offset; each window is already in fake root coordinate space.

https://bugzilla.gnome.org/show_bug.cgi?id=769402
2016-08-18 04:51:51 -04:00
Jonas Ådahl
1f7094a3e5 wayland: Use effective toplevel as popup parent
When using the set transient-for as a popup parent, fetch the effective
toplevel instead, otherwise we will position against the wrong
coordinate.

https://bugzilla.gnome.org/show_bug.cgi?id=769402
2016-08-18 04:51:46 -04:00
Matthias Clasen
a12ee84ec3 wayland: Link against librt
This is required for shm_open.

https://bugzilla.gnome.org/show_bug.cgi?id=769603
2016-08-07 16:11:55 -04:00
Simon McVittie
f65c116d2a Don't apply GDK_HINT_RESIZE_INC to GDK_WINDOW_STATE_TILED windows
This matches the behaviour of Mutter, Metacity and traditional X11
window managers on the window manager side, and is what we want
for at least gnome-terminal. I can't think of any reason why we'd
want incremental resize in any other tiled window.

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=760944

https://bugzilla.gnome.org/show_bug.cgi?id=755947
2016-07-25 09:00:01 -04:00
Matthias Clasen
82fd72a477 Opt in to structured logging
Define G_LOG_USE_STRUCTURED, so that all our g_debug, g_warning,
etc calls directly use structured logging and provide source information.
2016-07-22 23:13:20 -04:00
Carlos Garnacho
4a9f17c690 wayland: Fix build
Missing include pointing to tablet-unstable-v1-client-protocol.h,
pays me for not testing on a clean checkout.
2016-07-22 20:58:55 +02:00
Carlos Garnacho
9fe0c1e126 wayland: Use wl_fixed_t on wp_tablet_tool angle arguments
This is an incompatible change in tablet protocol v2.
2016-07-22 19:35:28 +02: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
Olivier Fourdan
e032c83822 wayland: remove unneeded statement
seat->pointer_info.focus is already set to NULL 2 lines above, no need to
repeat it there.
2016-07-04 09:46:24 +02:00
Olivier Fourdan
298221bfba wayland: return child only in device_query_state()
On X11, device_query_state() uses XIQueryPointer() which will return a
child window only if the pointer is within an actual child of the given
window.

Wayland backend would return the pointer->focus window independently of
the given window, but that breaks the logic in get_device_state() and
later in gdk_window_get_device_position_double() because the window is
searched based on coordinates from another window without sibling
relationship, breaking gtkmenu sub-menus further down the line.

Fix the Wayland backend to mimic X11's XIQueryPointer() to return a
child only if really a child of the given window.

That's the most sensible thing to do to fix the issue, but the API here
seems to be modeled after the X11 implementation and the description of
gdk_window_get_device_position_double() is not entirely accurate.

https://bugzilla.gnome.org/show_bug.cgi?id=768016
2016-07-04 09:46:18 +02:00
Carlos Garnacho
0d30ad279f wayland: Separate selection buffers and other per-selection atom data
This has most notably impact in selection buffers, because those were
shared across all selection atoms. This turned out wrong on 2 situations:
- Because the selection atom was set at SelectionBuffer creation time, the
  GDK_SELECTION_NOTIFY events generated will have unexpected info if the
  buffer is attempted to be reused for another selection.
- Anytime different selections imply different stored content for the same
  target.

This is better separated into per-selection buffers, so it's not possible
to get collisions if a same target is used across different selections.

https://bugzilla.gnome.org/show_bug.cgi?id=768177
2016-06-30 14:10:26 +02:00
Carlos Garnacho
4b003a75aa wayland: Implement gdk_utf8_to_string_target
The sanitize_utf8() function has been copied from X11 so both
backends behave the same. This allows interaction with older clients
(mainly through Xwayland, and the STRING selection target) that
request non-utf8 text.

https://bugzilla.gnome.org/show_bug.cgi?id=768082
2016-06-30 14:10:26 +02:00
Olivier Fourdan
0eeaa935b9 wayland: do not set PRIMARY selection if focus is lost
If keyboard focus is (already) lost, do not advertise PRIMARY selection.

https://bugzilla.gnome.org/show_bug.cgi?id=767848
2016-06-20 14:13:29 -04: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
Timm Bäder
d9a6517d5f wayland: Make sure window titles fit into a wl_buffer
A wl_buffer has a max size of 4096 bytes, of which 8 are needed for the
header and another 4 for the string argument length (in this case), so
make sure the we only save the first 4083 bytes that are still valid
UTF8.

https://bugzilla.gnome.org/show_bug.cgi?id=767241
2016-06-08 15:06:51 +02:00
Olivier Fourdan
85407180cf wayland: add extended state for tiled
xdg-shell allows desktop environments to extend the list of states
within a given range.

Use this possibility to add a new state for tiled so that gtk+ can
benefit from this.

https://bugzilla.gnome.org/show_bug.cgi?id=766860
2016-06-08 14:46:37 +02:00
Matthias Clasen
3d0f76801d wayland: Provide information about scroll devices
The Wayland protocol does not share XI2's wealth of information
about individual devices, but it does provide discriminating
information about the source for scroll events. Pass this on to
the application by creating separate slave devices for these,
and setting them as source device on the scroll events.

These devices can be discriminated by their input-source property:
wheel      - GDK_SOURCE_MOUSE
finger     - GDK_SOURCE_TOUCHPAD
continuous - GDK_SOURCE_TRACKPOINT

https://bugzilla.gnome.org/show_bug.cgi?id=767093

fix up
2016-06-01 14:51:33 -04:00
Matthias Clasen
11e22aadda wayland: Better debug info for scroll axes
Print human readable names for axes and axis sources.
2016-05-31 22:18:08 -04:00
Matthias Clasen
d14305f380 wayland: Survive lack of settings
This can be made to happen eg by setting XDG_DATA_DIRS and
XDG_DATA_HOME to /. Not a useful value, but not a good reason
to crash either.
2016-05-19 07:38:33 -04:00
Olivier Fourdan
0b58c96f06 wayland: Make gdk_wayland_window_get_wl_output() private
There is no need to make it a public API, move it to the private header
instead.

https://bugzilla.gnome.org/show_bug.cgi?id=766566
2016-05-19 09:48:46 +02: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
Olivier Fourdan
ca77de055b wayland: Add API to retrieve the Wayland output
In Wayland, surfaces get an enter/leave notification each time they
enter or leave an output.

Add an API to GdkWaylandWindow to retrieve the output the window has
last entered.

https://bugzilla.gnome.org/show_bug.cgi?id=766566
2016-05-18 19:07:27 +02:00
Carlos Garnacho
783c302198 wayland: Avoid spurious crossing events from master touch device
Only generate crossing events on wl_touch.down for the virtual master
device used for touch events, and only whenever this virtual device
actually moves across surfaces. This behavior resembles better what is
expected in X11, where the pointer is warped to the touch position
on XITouchBegin.

This avoids the double emission of leave events when the pointer
emulating touch is lifted, that crossing event will be instead
generated when/if the focus surface changes.

https://bugzilla.gnome.org/show_bug.cgi?id=766314
2016-05-18 12:50:08 +02:00
Matthew Waters
2893526a48 gdk/wayland: use the multi-thread safe wayland API
This is required for proper integration with any other library/application that
may perform wayland API calls and poll() the wayland fd from multiple threads.
Using wl_display_dispatch{_queue}() is thread-safe if not mixed with custom
poll() usage, which GSource/GMainContext does.

Essentially, the problem is that multiple threads polling and reading
the same fd is extremely racy.  Use the wayland provided API for allowing
concurrent access to the wayland display fd.

See the wayland man pages for wl_display_prepare_read(),
wl_display_cancel_read() and wl_display_read_events() for more details.

https://bugzilla.gnome.org/show_bug.cgi?id=763852
2016-05-17 22:58:03 -04:00
Matthias Clasen
e463e09577 wayland: Avoid unitialized memory reads
I didn't pay attention when I replaced g_new0 with g_newa. Oops.
2016-05-12 11:38:46 -04:00
Matthias Clasen
0f476590fb Make gdk_event_get_pointer_emulated public
There is not strong reason to keep the getter private.
At the same time, strip _-prefixes from a few other GdkEvent
APIs. Update all callers.
2016-05-10 15:16:45 -04:00
Christian Hergert
ebb894cd64 wayland: use g_signal_handler_disconnect()
Use of g_signal_handlers_disconnect_by_func() needs to do more work than
necessary to find all the matching handlers. Instead, just hold on to the
signal identifier and remove it directly so we hit the fast path.

Not terribly ground breaking in terms of performance gains, but its done
enough to be worthwhile.

https://bugzilla.gnome.org/show_bug.cgi?id=766049
2016-05-06 11:33:12 +03:00
Matthias Clasen
adc90b9e9d wayland: Small improvements to update_direction
Avoid memory allocation if possible, and use the proper
min/max keycodes.
2016-05-03 23:14:05 -04:00
Matthias Clasen
09aa48b748 wayland: Don't emit direction-changed unless it did
We can easily check this, so lets do it.
2016-05-03 22:52:38 -04:00
Matthias Clasen
3b75cadc41 trivial formatting fixes 2016-05-03 22:36:20 -04:00
Olivier Fourdan
e74ecfe22e wayland: fix up/down mix up in discrete events
The wayland specification for discrete step information for scroll and
other axes reads:

| The discrete value carries the directional information. e.g. a
| value of -2 is two steps towards the negative direction of this axis.

mutter sets a value of 1 for SCROLL_DOWN events and -1 for SCROLL_UP
events.

gdkdevice Wayland backend does the opposite, it translates a positive
discrete value as SCROLL_UP and a negative value as SCROLL_DOWN, which
ends up inverting the scrolling direction.

Fix the logic in gdkdevice Wayland to use a positive value as
SCROLL_DOWN and a negative value as SCROLL_UP so that it matches mutter
and weston logic.

https://bugzilla.gnome.org/show_bug.cgi?id=765907
2016-05-03 11:38:06 +02:00
Matthias Clasen
75e44c50ed wayland: drop a useless list
We were keeping all the event sources in a list, only to remove
them at the end of their life. Not useful.
2016-05-01 13:26:35 -04:00
Matthias Clasen
a829b26de1 wayland: Tag the event source with the acutal display name 2016-05-01 10:52:31 -04: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
Daniel Stone
210a747ff0 wayland: Ignore NoSymbol keys
NoSymbol is not a valid GDK symbol (it only has the concept of
VoidSymbol, for some reason, which is neither the same thing nor
produced by any sane keymap). Passing NoSymbol events through to GTK+
apps is unlikely to produce anything useful.

In particular, this meant VTE would scroll to the end of the buffer when
pressing Fn (required for Page Up/Down on Macs), as it was receiving a
keypress that wasn't a modifeir. This does not happen on X11, as the
KEY_FN keycode is above 255, so does not get sent to clients.

https://bugzilla.gnome.org/show_bug.cgi?id=764825
2016-04-27 14:00:30 +01:00
Carlos Garnacho
14967d8d7d wayland: Perform seat grab focus checks on native windows
We don't care about the specific (possibly client-side) window that
requested the focus here, only the toplevel. Fixes mistakenly sent
focus events when the grab happens inside the current focus window.

https://bugzilla.gnome.org/show_bug.cgi?id=762756
2016-04-27 13:29:19 +02:00
Jonas Ådahl
1a4f000f3b gdk/dnd: Don't use default display when getting cursor
Always associate a drag context with a GdkDisplay and use that when
getting a cursor for a given action.

If we don't do this, dragging on a window that doesn't use the default
display will make us use cursors from the wrong display.

https://bugzilla.gnome.org/show_bug.cgi?id=765565
2016-04-26 23:03:24 +08:00
Jonas Ådahl
145b626c2f wayland: Track orphaned dialogs per display
Don't track all orphaned dialogs globally, as mixing them up with each
other would in most cases trigger errors when we try to pass bogus
values to Wayland requests.

https://bugzilla.gnome.org/show_bug.cgi?id=765474
2016-04-26 08:38:18 -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
Christian Hergert
724d3be794 wayland: avoid jitter in keyboard repeat
When synthesizing keyboard repeat, we can potentially drift further from
the mark depending on the timing of the frame callback and how long it
took to deliver the event.

This patch attempts to reduce this by tracking from a stable epoch the
time of our next keyboard repeat.

https://bugzilla.gnome.org/show_bug.cgi?id=765567
2016-04-25 18:15:24 -07:00
Emmanuele Bassi
74f4e6e046 wayland: Bind the appropriate OpenGL API
If we want to use OpenGL ES with EGL then we need to bind the API before
creating the EGL context.
2016-04-25 12:29:37 +01:00
Emmanuele Bassi
7d1da94455 wayland: Add debugging notes for EGL context creation 2016-04-25 12:29:37 +01:00
Emmanuele Bassi
d40778f728 wayland: Honour GDK_GL=gles on context creation 2016-04-25 12:29:37 +01:00
Emmanuele Bassi
2849f2fc9a wayland: Implement asking for a GLES context
Wayland uses EGL, which allows us to ask for a GLES context.

https://bugzilla.gnome.org/show_bug.cgi?id=743746
2016-04-25 12:29:37 +01:00