1
0
Fork 0
Commit graph

980 commits

Author SHA1 Message Date
Daniel Stone
f99a086444 xwayland: Fix lockfile size confusion
Similarly to Weston (where this code originated), there were two errors
in the X11 lockfile handling.

Firstly, after reading 11 characters from the lock file (which could
have been placed by any process), there was no guarantee of
NUL-termination, meaning strtol could've theoretically run off the end
of the string.

Secondly, whilst writing the new lock, the trailing NUL byte was not
correctly accounted for. The size passed as an input to snprintf takes
the maximum size of the string including the trailing NUL, whilst the
return (and the input to write) gives the actual size of the string
without the trailing NUL.

The code did attempt to check the return value, however snprintf returns
the size of the _potential_ string written, before snprintf culls it, so
this was off by one, and the LF was not being written.

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

https://bugzilla.gnome.org/show_bug.cgi?id=774613
2016-11-17 14:31:24 +01:00
Carlos Garnacho
b252771a8f clutter/evdev: Take over stylus configuration
Stylus configuration (stylus buttons, pressure) was handled
at the very high level, doing the button and pressure translations
right before sending these to wayland clients.

However, it makes more sense to store these settings into the
ClutterInputDeviceTool itself, and have clutter apply the config
at the lower level so 1) the settings actually apply desktop-wide,
not just in clients and 2) X11 and wayland may share similar
configuration paths. The settings are now just applied whenever
the tool enters proximity, in reaction to
ClutterDeviceManager::tool-changed.

This commit moves all handling of these two settings to
the clutter level, and removes the wayland-specific paths

https://bugzilla.gnome.org/show_bug.cgi?id=773779
2016-11-04 21:25:31 +01:00
Carlos Garnacho
1831a1dd9b core: Handle special actions associated to pad buttons in generic code
And remove the wayland-specific handling. This works for both Wayland and
X11 (provided the compositor receives pad events through a passive grab
there).

https://bugzilla.gnome.org/show_bug.cgi?id=773779
2016-11-04 21:25:31 +01:00
Carlos Garnacho
15db18901c wayland: Forward touchpad pinch n_fingers information to clients
We used to hardcode 2 because those were the only events we used to
handle. Now the ClutterTouchpadPinchEvent will tell us.

https://bugzilla.gnome.org/show_bug.cgi?id=765937
2016-11-04 16:28:30 +01:00
Carlos Garnacho
4cfc21d49d clutter: Rename touchpad gesture n_fingers getter to be more generic
This can also be used now on pinch events, so make a more generic name
for this function.

https://bugzilla.gnome.org/show_bug.cgi?id=765937
2016-11-04 16:28:30 +01:00
Olivier Fourdan
4295fdb892 wayland: do not explicitly focus xdg_popup
The keyboard focus semantics for non-grabbing xdg_shell v6 popups is
pretty undefined.

Same applies for subsurfaces, but in practice, subsurfaces never receive
keyboard focus, so it makes sense to do the same for non-grabbing
popups.

https://bugzilla.gnome.org/show_bug.cgi?id=773210
2016-10-27 17:21:21 +02:00
Jonas Ådahl
8a7876ded5 wayland: Don't cancel the pointer grab on compositor grabs
We shouldn't cancel the pointer grab when there is a compositor grab,
since that'd break things like drag-n-drop via the overview and
alt-tabs.

The original reason for cancelling the pointer grab on compositor grabs
was to avoid a re-entry when a compositor grab was activated while
there was an active pointer constraint grab. The re-entry would happen
when the compositor grab cleared the pointer focus. Clearing the focus
would trigger the pointer constraint to be deactivated, which would end
its grab. Ending the grab would reset the grab to the default one, which
could focus the same surface again, triggering the constraint to
re-enable before it finished disabling.

This is now avoided because the default grab handler is now aware of
compositor grabs, and won't override the cleared pointer focus until
the compositor grab ends.

https://bugzilla.gnome.org/show_bug.cgi?id=772914
2016-10-19 15:45:33 +08:00
Jonas Ådahl
b50da46f43 wayland/pointer: Don't set focus while during compositor grab
Teach the default grab about compositor grabs (i.e.
display->event_route) so that it can avoid setting a pointer focus when
after the compositor grab actively unset the pointer focus.

https://bugzilla.gnome.org/show_bug.cgi?id=772914
2016-10-19 15:45:33 +08:00
Rui Matos
3e2555667f MetaWaylandDataSourcePrimary: use the correct parent GType
https://bugzilla.gnome.org/show_bug.cgi?id=771019
2016-10-17 13:47:20 +02:00
Carlos Garnacho
2abee91dbc wayland: Cancel touches on meta_wayland_touch_disable()
When disabling the device/capability, we can't rely on cancelled events
being emitted timely, because the capability will be already disabled by
then, all touches must be cancelled immediately then.

https://bugzilla.gnome.org/show_bug.cgi?id=772929
2016-10-14 18:22:42 +02:00
Jonas Ådahl
68645df3a3 wayland/xdg-shell: Scale positioner coordinates
When the monitor is scaled (i.e. HiDPI scaling) the placement coordinates
ere still in unscaled xdg_surface window geometry coordinate space when
used to place the window. Fix this by scaling the coordinates by the
monitor scale of the parent toplevel window before using them.

https://bugzilla.gnome.org/show_bug.cgi?id=771841
2016-10-13 13:57:54 +08:00
Sjoerd Simons
d2f79afc1a wayland/xdg-shell: update popup window monitor early
As meta_window_place_with_placement_rule will trigger a configure event
being sent ensure that the popup is placed on the correct monitor first
to ensure the right scale factor is applied.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>

https://bugzilla.gnome.org/show_bug.cgi?id=771841
2016-10-13 13:57:54 +08:00
Sjoerd Simons
8a6fa726d3 wayland/xdg-popup: Force monitor of the top-level
Directly set the monitor of the toplevel window for the popup to avoid
the change not being applied due to later constraints calculation.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>

https://bugzilla.gnome.org/show_bug.cgi?id=771841
2016-10-13 13:57:54 +08:00
Jonas Ådahl
a3d7ae6214 wayland/xdg-shell: Scale configure relative popup coordinate
The parent local popup coordinate needs to be scaled according to the
monitor scale it is assigned.

https://bugzilla.gnome.org/show_bug.cgi?id=771841
2016-10-13 13:57:54 +08:00
Jonas Ådahl
c0c132a320 wayland/xdg-popup: Always use monitor of toplevel
Always use the monitor of the toplevel surface's window, so that the
popup menu and the parent will always have the same scale. This fixes
the dimensions sent in the xdg_popup configure event.

https://bugzilla.gnome.org/show_bug.cgi?id=771841
2016-10-13 13:57:54 +08:00
Jonas Ådahl
0dfb5d3ef7 wayland/touch: Use surface relative coordinate helper
Use the global to surface local coordinate converter helper, as that
will currently convert coordinates for Xwayland client more correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=768039
2016-10-13 13:57:54 +08:00
Jonas Ådahl
6480a7ee4a wayland/pointer-constraints: Don't include window frame in region
When Xwayland confines, the surface dimensions will include the server
side window manager decorations. We don't want the decorations to be
included in the constraint region so intersect the calculated input
region with the parts of the buffer rect that is not part of the window
frame.

https://bugzilla.gnome.org/show_bug.cgi?id=771859
2016-10-13 12:59:41 +08:00
Jonas Ådahl
6cc8450f8e wayland/pointer-constraints: Unify requirements for enablement
Put the conditions for enabling a pointer constraint in a helper
function, and use that in both maybe_enable() and maybe_remove(). The
constraint region checking is still only done in maybe_enable()
however.

This changes the conditions for maybe disabling the constraint on focus
change and other trigger points, namely it makes constraints by Xwayland
not disable when they shouldn't due to the constraining window being an
override-redirect window.

https://bugzilla.gnome.org/show_bug.cgi?id=771859
2016-10-13 12:59:41 +08:00
Jonas Ådahl
7ae4b28bda wayland/pointer-constraints: Disable or remove when grab is cancelled
When the grab is cancelled, for example because of an Alt-tab, VT
switch etc, disable or remove (depending on the constraint type) the
constraint. This avoids a re-entry issue when the focus is returned and
the focus listener tries to re-enable a disabled constraint.

https://bugzilla.gnome.org/show_bug.cgi?id=771859
2016-10-13 12:59:41 +08:00
Olivier Fourdan
d7f61e48ac wayland: apply size hints after placing the window
Otherwise the window will be shown initially in the wrong position then
moved quickly as soon as it's made visible, which is confusing.

https://bugzilla.gnome.org/show_bug.cgi?id=772729
2016-10-12 10:16:13 +02:00
Jonas Ådahl
9de6de5802 MetaWaylandPopup: Dismiss popup when grab is cancelled
Dismiss the popup when the grab is cancelled, so that if the grab is
ended for whatever reason (such as VT switching or the last pointer
being disconnected), it doesn't try to end the grab when it isn't
active.

This fixes a crash when VT switching back and forth while a popup grab
is active.

https://bugzilla.gnome.org/show_bug.cgi?id=771858
2016-10-12 10:08:59 +08:00
Jonas Ådahl
6e7057426e wayland/pointer: Add way to cancel current grab
Previously a grab could suddenly end without the grabber knowing
anything about it. Some grabs assume they won't suddenly end without
notice, and can use then new 'cancel' vfunc to be notified.

Currently a grab is cancelled when a new one is started (i.e. in
meta_wayland_pointer_grab_start()), when a non-popup compositor wide
event route is initiated, and when the seat looses the pointer
capability.

https://bugzilla.gnome.org/show_bug.cgi?id=771858
2016-10-12 10:08:59 +08:00
Jonas Ådahl
5306d36522 wayland/touch: Use helper for getting the next event serial
https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-11 22:51:54 +08:00
Jonas Ådahl
7990182f56 wayland/pointer: Use grab helper that doesn't focus when disabling
Instead of using meta_wayland_pointer_end_grab() which focuses the new
grab, add a new helper mean to be used to reset the grab state without
changing the pointer focus. When using this function, the call site is
supposed to explicitly manage focus.

https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-11 22:51:54 +08:00
Jonas Ådahl
93a6be08a5 wayland/pointer: Naming and coding style fixes
Some very long lines that stood out were shortened, and an old naming
convention from weston was removed.

https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-11 22:51:54 +08:00
Jonas Ådahl
d5d5084151 wayland/pointer: Check pointer presence at set focus call site
Make the caller of focus setting check whether there is a pointer to
update the focus state of. It makes it more obvious what to expect, as
the call would be a no-op in when no pointer is present.

Grabbing is still allowed without the presence of a pointer because it
is used by popups even on touch-only systems.

https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-11 22:51:54 +08:00
Jonas Ådahl
d3cff9a962 wayland/pointer: Use helper for getting the next event serial
Use the MetaWaylandInputDevice helper for serial retrieval.

https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-11 22:51:54 +08:00
Jonas Ådahl
133bbdfefa wayland/keyboard: Check keyboard presence at set focus call site
Make the caller of focus setting and grab starting check whether there
is a keyboard to update the focus state or start grabbing. It makes it
more obvious what to expect, as the call would be a no-op in when no
keyboard is present.

https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-11 22:51:54 +08:00
Jonas Ådahl
a8c3470cf2 wayland/seat: Use seat capability checking helper
https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-11 22:51:54 +08:00
Jonas Ådahl
578e527869 wayland/keyboard: Cleanup resource list management
Initialize on init(), unlink and reinitialize the list headers on
disable() so that any delayed resource destruction doesn't affect future
state.

https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-11 22:51:54 +08:00
Jonas Ådahl
312f215fc3 wayland/keyboard: Cleanup grab state managing
Initialize on init() and just end grab on disable().

https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-11 22:51:54 +08:00
Jonas Ådahl
d639c28e3b wayland/keyboard: Cleanup xkb state managing
Initialize and cleanup properly in a _init()/_destroy() function pair.

https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-11 22:51:54 +08:00
Jonas Ådahl
c3f7259cbb wayland/keyboard: Initialize static state in GObject init func
https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-11 22:51:54 +08:00
Jonas Ådahl
56e8f98c13 wayland/keyboard: Naming and coding style fixes
Some very long lines that stood out were shortened, and an old naming
convention from weston was removed.

https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-11 22:51:54 +08:00
Jonas Ådahl
c2217373df wayland/keyboard: Scope variable correctly
https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-11 22:51:54 +08:00
Jonas Ådahl
4a3781d7db wayland/keyboard: Stop using temporary wl_list 'l'
The variable name 'l' usually refers to a GList iterator, but here it's
just a short hand for a specific list. Stop using this shorthand, since
it just makes it harder to read what list is used.

https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-11 22:51:53 +08:00
Jonas Ådahl
911a838c3a wayland/keyboard: Simplify getting the serial serial
Use the MetaWaylandInputDevice helper for getting the next event serial
number.

https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-11 22:51:53 +08:00
Jonas Ådahl
c6106f90d4 wayland/input-device: Add next serial helper
Add a helper function for getting the next input device serial number.
Will be used by keyboard, pointer and touch devices.

https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-11 22:51:50 +08:00
Florian Müllner
e9944350d3 delete: Share some code between X11 and wayland
In order to kill a window, on both X11 and wayland we first try to
kill(3) the corresponding process, so we can add the newly added
get_client_pid() method to share that code.

https://bugzilla.gnome.org/show_bug.cgi?id=772613
2016-10-10 23:35:02 +02:00
Florian Müllner
1fab6e69b7 window: Add get_client_pid() method
It is often useful to identify the client process that created
a particular window, however the existing meta_window_get_pid()
method relies on _NET_WM_PID, which is only available on X11 and
depends on applications to set it correctly (which may not even
be possible when the app runs in its own PID namespace as Flatpak
apps do). So add a get_client_pid() method that uses windowing
system facilities to resolve the PID associated with a particular
window.

https://bugzilla.gnome.org/show_bug.cgi?id=772613
2016-10-10 23:35:01 +02:00
Jonas Ådahl
f89162ee73 wayland/pointer: Unset pointer focus when disabled
Previously the focus was reset implicitly by a memset() on the whole
MetaWaylandPointer struct. When MetaWaylandPointer was turned into a
GObject, this was not possible any more, and the focus was not updated
properly.

https://bugzilla.gnome.org/show_bug.cgi?id=771646
2016-10-10 23:35:01 +02:00
Carlos Garnacho
b3eac93c4c xwayland: Ignore selection request not meant to our internal window
There may be other windows managing selection whose events are seen in
our GDK event filter, like st-clipboard in gnome-shell, we should in
that case not interfere on Selection/SelectionRequest events that are
not meant for us.

This fixes an odd feedback loop where requesting clipboard contents from
wayland results in a XConvertRequest call and a SelectionRequest event
that is interpreted by mutter as a request from another X11 client, so
the current data source is poked for content, which happens to be the
X11 bridge, which does a XConvertRequest to get contents... This is only
broken after the many nested async operations create enough pipes and
cancellables to run out of fds.

Adding checks to ensure only events meant to our "selection owner"
window are managed prevent this unintended loop to happen in the first
place.

https://bugzilla.gnome.org/show_bug.cgi?id=760745
2016-10-07 16:05:22 +02:00
Jonas Ådahl
417757eab8 wayland: Handle parent-less popup commits
A xdg_popup, when active, always has a parent surface. However, a popup
created may immediately become invalid, for example when it is not
granted a grab, in which case it won't be assigned a parent since it
will never be mapped.

This case needs to be handled elsewhere, as one cannot assume a
MetaWaylandXdgPoup that is processed (via wl_surface commit handling
etc) will have a parent_surface.

https://bugzilla.gnome.org/show_bug.cgi?id=771495
2016-09-18 10:58:38 +08:00
Jonas Ådahl
b1d95438d6 wayland/xwayland: Gracefully handle Xdnd start drag focus race
If a X11 client would initiate a Xdnd session after it had lost pointer
focus (for example when the Xdnd event starting the drag happens after
the implicit pointer grab is already broken due to the button being
released), just end the drag operation instead of dereferencing the
non-existing focus surface.

Also avoid using a native Wayland surface as a drag origin, as that can
never happen, but allow any arbitrary Xwayland client, since there is
no way to find out the actual drag origin.

https://bugzilla.gnome.org/show_bug.cgi?id=770940
2016-09-15 10:21:48 +08:00
Jonas Ådahl
60bc6798f4 wayland/data-device: Don't disconnect valid dnd client
We cannot check 'has-target' or 'has-seat' when verifying a
wl_data_offer.finish request is valid or not, since the source may have
effected 'has-target' or whether theh source has a seat or not when the
finish request was already on the wire.

Instead of checking against the source state, keep track whether the
required operations has been done on the offer in question (i.e.
whether an action has been sent, or a mime type been accepted).

This fixes incorrectly raised error when dragging from gtk+'s testdnd
via Xwayland onto gtk+'s testdnd using Wayland.

https://bugzilla.gnome.org/show_bug.cgi?id=770937
2016-09-15 10:19:08 +08:00
Jonas Ådahl
22173fde15 MetaWaylandOutput: Cleanup type declaration
Use G_DECLARE_FINAL_TYPE instead of the set of macros.

https://bugzilla.gnome.org/show_bug.cgi?id=770672
2016-09-15 10:14:20 +08:00
Jonas Ådahl
4c8dd08c77 MetaWaylandOutput: Pretend outputs are always untransformed
Since wl_surface.set_buffer_transform() is not supported, until it is
added, pretend outputs are never transformed, so that clients are less
likely to attach pre-transformed buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=770672
2016-09-15 10:14:20 +08:00
Jonas Ådahl
e1516e4f31 wayland/pointer-constraints: Maybe remove when pointer focus changes
Also maybe remove a constraint when the pointer focus changes. This is
needed because when Xwayland has a constraint focus may change, the
constraint object will not receive a 'appears-focused' event on its
window since it never changed.

This happens for example when an override-redirect window (which never
appears focused) holds the constraint, and alt-tab happens. In this case
focus changes, but from the constraint's point of view, none of the
windows it knows about changed its focus appearance.

https://bugzilla.gnome.org/show_bug.cgi?id=771345
2016-09-15 10:12:25 +08:00
Jonas Ådahl
32276cf418 wayland/pointer-constraints: Move window-unmanaging check
We should never enable a pointer constraint for an unmanaging window.

https://bugzilla.gnome.org/show_bug.cgi?id=771345
2016-09-15 10:12:25 +08:00
Jonas Ådahl
98f0578f9d MetaWaylandPointer: Initialize default grab on init
Instead of initializing the default grab when the device class is
enabled, initialize it on object initialization. This way other device
classes can still grab the pointer, as if there was one. This may be
useful for example if a touch grab is active and a mouse is connected.

This also makes it possible for popup grabs, which currently use a
pointer grab for controlling, to be triggered by touch devices, while
still holding an active pointer grab.

https://bugzilla.gnome.org/show_bug.cgi?id=771305
2016-09-15 09:55:34 +08:00