1
0
Fork 0
Commit graph

1134 commits

Author SHA1 Message Date
Carlos Garnacho
423c5f8e77 wayland: Let IM events go through
These paths implicitly relied on the forwarded IM key events having
a source_device backed by a real HW device. This assumption is no
longer held true since commit b5328c977.

Explicitly check the INPUT_METHOD flag so they are handled as they
should despite not being "real HW" events.
2018-04-24 23:48:01 +02:00
Carlos Garnacho
4ef886f51e wayland: Avoid actor updates non actor_surface role wl_surface.commit
We used to maintain an actor for cursors, even though we would possibly
use hw overlays or even some other overlay actor for those. This happens
no more, so check whether we are dealing with an actor-backed surface role
before fiddling with it.
2018-04-23 21:31:19 +02:00
Carlos Garnacho
22485ba36f wayland: Refactor surface actor into MetaWaylandActorSurface
All surface roles that do need a backing actor inherit from this
class, it makes sense to move actor management there. This also
means the MetaWaylandActorSurface is in charge of emitting
::geometry-changed on the MetaWaylandSurface.
2018-04-23 21:31:19 +02:00
Carlos Garnacho
8df2a1452c wayland: Notify actively of xwayland window/surface associations
Instead of scheduling a meta_later, keep track of the unassociated
windows, and look for matches as soon as the MetaWaylandSurface is
created on our side.

This will ensure the surface is given the Xwayland role before receiving
the first wl_surface.commit.
2018-04-23 21:31:19 +02:00
Carlos Garnacho
b12c92e206 wayland: Add MetaWaylandSurface::geometry-changed signal
Abstract this instead of having callers connect to notify:: signals
on the surface actor.
2018-04-23 21:31:19 +02:00
Carlos Garnacho
70036429bd wayland: Abstract access to the actor corresponding to a wl_surface
The actor itself will be shuffled around, abstract all external
access to it behind a function to make that easier later on.
2018-04-23 12:24:46 +02:00
Carlos Garnacho
44502be560 wayland: Do not reset frame list when merging pending state
In the synchronized subsurface case, the destination list may
contain other elements from previous wl_surface.commit calls.
Resetting the list will leave those dangling frame callbacks
that will lead to invalid writes when those get to be destroyed
(eg. on client shutdown).
2018-04-22 00:52:48 +02:00
Ray Strode
2d80fd02e7 xwayland: Don't abort if Xwayland crashes
Right now if Xwayland crashes, we crash, too.

On some level that makes sense, since we're supposed to control the
lifecycle of Xwayland, and by it crashing we've lost that control.

But practically speaking, the knock-on crash adds noise to the logs,
bug trackers, and retrace servers that only makes debugging harder.
And the crash isn't something mutter can "fix", since it's
ultimately from a bug in Xwayland anyway.

This commit makes mutter exit instead of crash if Xwayland goes away
unexpectedly.
2018-04-17 11:14:00 -04:00
Ray Strode
bb65854065 xwayland: use g_autoptr for GError in xserver_died
Right now we explicitly g_clear_error any error we find, but that
makes it tricky to return early from the function, which a
subsequent commit will want to to do.

This commit switches GError to use g_autoptr so the error clearing
happens automatically.
2018-04-17 11:14:00 -04:00
Carlos Garnacho
b6f5bab212 wayland: Plug surface pending state contents leak
When moving the pending state of an effectively synchronized subsurface
so it is applied together with the parent, perform a merge of the source
MetaWaylandPendingState into the destination one, instead of simply
overwriting the struct.

The other approach had 2 kind of leaks, one that would happen everytime
a wl_surface.commit happens on a sync subsurface (both surface/buffer
damage regions are leaked). The other more unlikely one would apply on
the rest of pending state data, happening whenever the compositor gets
>1 wl_surface.commit calls on the subsurface before the parent surface
gets its own.

The function has also been renamed to use the more descriptive "merge"
term.

Related: gnome-shell#64
2018-04-12 23:35:20 +02:00
Olivier Fourdan
17a745bf81 wayland: update enter/leave output after effects
Compositor effects change the actor size and position, which can lead to
inconsistent output enter/leave notifications, leaving clients' surfaces
without any output set.

Update output enter/leave notifications after all compositor effects are
completed so that we give clients accurate output location.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/104
2018-04-09 10:19:26 +02:00
Olivier Fourdan
67917db45f wayland: Use cursor position in logical monitor
When using two monitors size by side with different scales, once the
cursor moves from one output to another one, its size changes based on
the scale of the given output.

Changing the size of the cursor can cause the cursor area to change
output again if the hotspot is not exactly at the top left corner of the
area, causing the texture of the cursor to change, which will trigger
another output change, so on and so forth causing continuous surface
enter/leave event which flood the clients and eventually kill them.

Change the logic to use only the actual cursor position to determine if
its on the given logical monitor, so that it remains immune to scale
changes induced by output scale differences.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/83
2018-03-23 15:12:37 +01:00
handsome-feng
b8a81128e0 Fix some spelling errors
https://gitlab.gnome.org/GNOME/mutter/merge_requests/45
2018-03-21 13:22:35 +08:00
Carlos Garnacho
817a76a7f5 wayland: Add parentheses around logical AND
As "suggested" by gcc and -Werror. Introduced by commit cb40049ec.
2018-03-16 16:59:14 +01:00
Carlos Garnacho
cb40049ec1 wayland: Ignore IM/synthetic key events when updating XKB state
This state tracks hardware devices' state, thus shouldn't be triggered by
events that were emulated/forwarded by the IM. Those may include modifiers
and would result in xkb_state being doubly set, and possibly stuck.

https://gitlab.gnome.org/GNOME/mutter/issues/74

Closes: #74
2018-03-15 18:44:07 +01:00
Carlos Garnacho
419fb81d40 wayland: Fix wrong condition in xdg_exporter.export
Commit d714a94d9 added support for stable xdg-shell surfaces while
preserving old unstable zxdg-shell v6 ones, but committed a mistake
in checking for both in the xdg_exporter.export error condition
paths. We want to check that the surface is neither of both.

https://gitlab.gnome.org/GNOME/mutter/issues/63

Closes: #63
2018-03-12 17:15:07 +00:00
Jonas Ådahl
4345906663 wayland: Define abstract role types as actually abstract
They should not be instantiated by themself, only as actual roles.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 19:07:49 +08:00
Jonas Ådahl
d714a94d97 wayland: Add support for stable xdg-shell
This commit adds support for xdg_shell (the stable version). This was
done by first copying the old xdg-shell unstable v6 implementation into
a separate .c .h file pair (including various symbol renaming) then
porting the old xdg-shell unstable v6 implementation to the new stable
version.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:53 +08:00
Jonas Ådahl
514c7028f4 wayland: Use helper to set shell surface window
The helper deals with updating the surface output state.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:50 +08:00
Jonas Ådahl
44624736c5 wayland: Push actor state instead of itself pulling
Make the Wayland objects push the state relevant to their role to the
MetaSurfaceActor instead of MetaSurfaceActorWayland pulling the state
from the associated surface.

This makes the relationship between the actor and the objects that
constructs it more clear; the actor is a drawable that the protocol
objects control, not the other way around.

This will make it easier to "detach" a surface actor from a surface,
which is necessary when unmapping a window while the underlying surface
is yet to be destroyed and potentially reused.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:47 +08:00
Jonas Ådahl
7e17dd0098 xwayland: Base Xwayland surface role object on the actor role
The Xwayland role uses a MetaSurfaceActorWayland just so lets share
logic related to it. As a side effect, wl_surface.enter/leave starts
working for Xwayland surfaces.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:42 +08:00
Jonas Ådahl
704b73b041 wayland: Restructure surface role building blocks code
This commit moves out non-core wl_surface related code into separate
code units, while renaming types to fit a common scheme. The changes
done are:

 * ClutterActor based surface roles built upon
   MetaWalyandSurfaceRoleActorSurface. This object has been renamed to
   MetaWaylandActorSurface and related functionality has moved into
   meta-wayland-actor-surface.c.

 * The code related to roles backed by a MetaWindow (i.e. built upon
   MetaWaylandShellSurface) was moved into meta-wayland-shell-surface.c

 * The majority of subsurface related code was moved into into
   meta-wayland-subsurface.c and the object was renamed
   MetaWaylandSubsurface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:40 +08:00
Jonas Ådahl
bd5e36cf0e wayland/surface: Stop using deprecated g_object_newv
Replace it with g_object_new_with_properties. This fixes a warning
about using deprecated API.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:38 +08:00
Jonas Ådahl
dbf56e24cb wayland/xdg-shell: Minor cosmetic cleanups
https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:36 +08:00
Jonas Ådahl
0371897e22 wayland/xdg-shell: Standardize xdg_positioner Wayland vfunc naming
Use the convention [interface]_[request] (..) used elsewhere in the
file.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:34 +08:00
Jonas Ådahl
cc5fe05c4d wayland/xdg-shell: Standardize object class interface vfunc names
Follow the convention that MetaSomeObject's class vfuncs should be
named meta_some_object_said_vfunc.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:28 +08:00
Jonas Ådahl
d8f13f6b4c wayland: Shorten MetaWaylandSurfaceRoleShellSurface name
It was annoyingly long, so rename it to MetaWaylandShellSurface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/5
https://bugzilla.gnome.org/show_bug.cgi?id=791938
2018-02-23 18:57:25 +08:00
Carlos Garnacho
6934b83f44 wayland: Avoid clutter_input_focus method calls when unfocused
If text_input_enable() is called when there no active IM (eg. running plain
mutter), some ClutterInputFocus method calls that are not allowed while
unfocused will end up called, triggering critical warnings.

If there is no IM return early here, all other calls are superfluous then.
2018-02-12 14:44:30 +01:00
Carlos Garnacho
c75eac27a8 wayland: Handle NULL event node/vendor/product on tablet methods
We currently don't handle NULLs on these correctly, yet they can be
so when running nested. Just refrain from sending those wp_tablet(_pad)
events in that case.
2018-02-09 13:39:15 +01:00
Carlos Garnacho
5149d6eb40 wayland: Fix handling of INCR transactions
The window checks in the XPropertyEvent handler were wrong both
ways, so transfers would be left stale after the first chunk was
dealt with.

https://gitlab.gnome.org/GNOME/mutter/issues/1

Closes: #1
2018-02-07 19:29:28 +01:00
Carlos Garnacho
006cdac531 wayland: Use read_all() when reading wayland selections
Plain input stream read() calls don't provide hard guarantees about
the number of bytes read, but the async method callback sort of
relies on bytes being less than requested only when reaching the
end of the transmitted data. If that happens mid transfer, that
doesn't bode well.

This is actually the behavior of g_input_stream_read_all(), so
switch to using it.
2018-02-07 19:29:28 +01:00
Olivier Fourdan
589e999049 wayland: Do not fail on stalled .X11-unix entries
If for whatever reason, there are stalled files in /tmp/.X11-unix/ the
bind() to the abstract socket will succeed but not the bind() to the
to the UNIX socket.

This causes gnome-shell/mutter to fail because it cannot start Xwayland
(while it could actually, by using a different display).

In case of failure to bind to the UNIX socket, try the next display
instead of failing, to avoid stalled entries in /tmp/.X11-unix.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/13
2018-02-05 11:36:19 +00:00
Olivier Fourdan
db866eb052 wayland: send shortcut inhibit “active” event
The shortcut inhibitor protocol states that the “active” event should be
sent every time compositor shortcuts are inhibited on behalf of the
surface.

However, mutter would send that event only if the surface is focused,
which might not be the case if focus is on a shell surface.

Send the “active” event unconditionally to match the protocol
definition.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/10
2018-02-05 09:06:49 +00:00
Olivier Fourdan
206ca43c91 wayland: No need to check for keyboard
meta_wayland_compositor_is_shortcuts_inhibited() does not need to check
if the provided source is an actual keyboard.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/8
2018-01-31 16:04:20 +01:00
Carlos Garnacho
18b8f9bfed wayland: Bolt MetaWaylandTextInput in.
Offer the text-input interface global, so it can be used by clients. The
MetaWaylandSeat will also let MetaWaylandTextInput intercept key events
before the keyboard interface handles those.
2018-01-18 16:20:45 +01:00
Carlos Garnacho
f08417b618 wayland: Let IM-processed key events go through MetaWaylandKeyboard
Those have the "synthetic" flag as set by Clutter guts, but should be
processed anyway. Perhaps a "key-repeat" flat would make sense...
2018-01-18 16:20:45 +01:00
Carlos Garnacho
62c9713361 wayland: Implement text input protocol
This is the implementation of the internal text-input protocol that will
be used to communicate IMs (to be implemented by gnome-shell) with clients.
The text_input protocol has its own focus expressed through enter/leave
events, that will typically follow the keyboard's.

The client will be able to communicate its current status (eg. focus state,
cursor rectangle in surface coordinates, text surrounding the cursor
position, ...) and will receive commands from the compositor (eg. preedit
text, committing a string, ...).

Whenever there is an active input method, the compositor will route key
events directly through it. The client will not receive wl_keyboard
events if the event is consumed by the IM.
2018-01-18 16:20:45 +01:00
Carlos Garnacho
efd7a4af5e protocol: Add internal text input protocol
The text input protocol has been made internal thus far, so mutter ships an
internal copy.
2018-01-18 16:20:45 +01:00
Olivier Fourdan
13cf19e0b6 wayland: shortcuts inhibitor requires a window
Issuing a shortcut inhibit request for a surface without a window set
will lead to a crash when trying to show the shortcut inhibitor dialog.

In such a case, it's safer to deny the request.

https://bugzilla.gnome.org/show_bug.cgi?id=792599
2018-01-18 14:08:13 +01:00
Carlos Garnacho
eac0e253e1 wayland: Add missing breaks on MetaWaylandSeat event handler
The events might fall through if there's no corresponding active
pointer/keyboard/touch interface. Barring bugs this should be safe to do,
just a bit wasteful.
2018-01-17 14:00:44 +01:00
Olivier Fourdan
3e77f6704b wayland: send xdg-output size as size, not position
https://bugzilla.gnome.org/show_bug.cgi?id=792527
2018-01-15 10:41:01 +01:00
Olivier Fourdan
5f05112b9a wayland: update location prior to maximize
When maximizing a window, the previous location is saved so that
un-maximize would restore the same original window location.

However, if a Wayland client starts with a window maximized, the
previous location will be 0x0, so if we have to force placement in
xdg_toplevel_set_maximized(), we should update the location as well so
that the window is placed on the right monitor when un-maximizing.

For that purpose, add a new flag to force the update of the window
location, and use that flag from xdg_toplevel_set_maximized().

https://bugzilla.gnome.org/show_bug.cgi?id=783901
2018-01-11 11:03:04 +01:00
Olivier Fourdan
6cf7d2d47f wayland: Do not enforce a size on un-maximize
When un-maximizing, use a zero size to pass to the client so that it can
use the right un-maximized size that fits.

https://bugzilla.gnome.org/show_bug.cgi?id=783901
2018-01-11 11:03:04 +01:00
Olivier Fourdan
bd9a300801 window: Defer stack placement without a buffer
When closing a window and showing a new one, the new one may not be
granted input focus until it gets a buffer on Wayland.

If another window is chosen to receive focus and raised on top of stack,
the newly mapped window is focused but placed underneath that other
window.

Meaning that for Wayland surfaces, we need to defer adding the window to
the stack until we actually get to show it, once we have a buffer
attached.

Rather that checking the windowing backend prior to decide if a window
is stackable or not, introduce a new vfunc is_stackable() which tells
if a window should be added to the stack regardless of the underlying
windowing system.

Also add meta_window_is_in_stack() API rather than checking the stack
position directly (replacing the define WINDOW_IN_STACK only available
in stack.c) and remove a window from the stack only if it is present
in the stack, so that the test in meta_stack_remote() becomes
irrelevant.

https://bugzilla.gnome.org/show_bug.cgi?id=780820
2018-01-11 11:03:04 +01:00
Daniel van Vugt
1c8aebd811 wayland: Ensure wl_shell_surfaces are set reactive
Wayland clients using the wl_shell interface were never receiving mouse
input. It meant they also couldn't be raised with a click.

This was because the call to meta_wayland_surface_set_window for wl_shell
surfaces did nothing while surface->window == window already. As such, it
never called clutter_actor_set_reactive() and the wl_shell window remained
a non-reactive actor.

Just make sure surface->window isn't already set before calling
meta_wayland_surface_set_window so it can actually do what it's meant to.

https://bugzilla.gnome.org/show_bug.cgi?id=790309
2018-01-09 11:27:30 -05:00
Ting-Wei Lan
31eafba93a build: Fix build when native backend is disabled
https://bugzilla.gnome.org/show_bug.cgi?id=792281
2018-01-09 12:01:08 +08:00
Carlos Garnacho
798026498d wayland: Only send full sequences of touch events to clients
If input happens to be grabbed somewhere along the shell, and ungrabbed
while a touch operation is ongoing, the wayland bits will happily start
sending wl_touch.update events from an undeterminate point, without
clients having ever received wl_touch.down for that id.

Consider those touches grabbed for the entirety of their lifetime, if
wl_touch.down wasn't received by the client, no other events will.

https://bugzilla.gnome.org/show_bug.cgi?id=776220
2017-12-21 12:37:20 +01:00
Olivier Fourdan
7f5f5eb847 wayland/keyboard: preserve layout index
On VT switch, the xkb state layout index is lost and reset to the first
group, so if the first layout is not the last one being used, the xkb
state used in both meta-wayland-keyboard.c and clutter/evdev will be
desynchronized with the keyboard source indicator in the gnome-shell UI.

Save the effective layout chosen along with the seat so it can be
restored when reclaiming devices.

Use the saved layout index from the clutter/evdev's seat to restore the
layout in meta-wayland-keyboard, so that switching VT doesn't reset the
layout and causes further discrepancies with the layout indicator in the
gnome-shell UI.

https://bugzilla.gnome.org/show_bug.cgi?id=791383
2017-12-20 09:56:34 +01:00
Olivier Fourdan
072afa5fa3 wayland: Add Xwayland grab keyboard support
This protocol is limited to Xwayland only and is not visible/usable by
any other client.

Mutter uses the following mechanisms to determine if an X11 client
should be granted a grab:

 - is "xwayland-allow-grabs" set?
 - if set, is the client blacklisted?
 - otherwise, has the client set the X11 window property
   _XWAYLAND_MAY_GRAB_KEYBOARD on the window using a client message?
 - if not, is it a client white-listed either via the default system
   list or the settings "xwayland-grab-access-rules"?

https://bugzilla.gnome.org/show_bug.cgi?id=783342
2017-12-18 13:15:20 +01:00
Olivier Fourdan
5f132f3975 xwayland: add _XWAYLAND_MAY_GRAB_KEYBOARD property
Add a new client message "_XWAYLAND_MAY_GRAB_KEYBOARD" that X11 clients
can use to tell mutter this is a well behaving X11 client so it may
grant the keyboard grabs when requested.

An X11 client wishing to be granted Xwayland grabs by gnome-shell/mutter
must send a ClientMessage to the root window with:

 - message_type set to "_XWAYLAND_MAY_GRAB_KEYBOARD"
 - window set to the xid of the window on which the grab is to be issued
 - data.l[0] to a non-zero value

Note: Sending this client message when running a plain native X11
environment would have no effect.

https://bugzilla.gnome.org/show_bug.cgi?id=783342
2017-12-18 13:15:13 +01:00