1
0
Fork 0
Commit graph

1218 commits

Author SHA1 Message Date
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
Olivier Fourdan
1546989845 xwayland: Add MetaWindowXwayland
MetaWindowXwayland derives from MetaWindowX11 to allow for some Xwayland
specific vfunc that wouldn't apply to plain X11 windows, such as
shortcut inhibit routines.

https://bugzilla.gnome.org/show_bug.cgi?id=783342
2017-12-18 13:15:09 +01:00
Rui Matos
1923db97c1 wayland-outputs: Delay wl_output destruction
This tries to avoid wayland clients getting disconnected for binding
to a wl_output that we already destroyed which is a known protocol
race condition, see https://phabricator.freedesktop.org/T7722 .

https://bugzilla.gnome.org/show_bug.cgi?id=789070
2017-12-15 14:54:13 +01:00
Olivier Fourdan
db32047a5d wayland: Add xdg-output support
The xdg-output protocol aims at describing outputs in way which is
more in line with the concept of an output on desktop oriented systems.

For now it just features the position and logical size which describe
the output position and size in the global compositor space.

This is however much useful for Xwayland to advertise the output size
and position to X11 clients which need this to configure their surfaces
in the global compositor space as the compositor may apply a different
scale from what is advertised by the output scaling property (to achieve
fractional scaling, for example).

This was added in wayland-protocols 1.10.

https://bugzilla.gnome.org/show_bug.cgi?id=787363
2017-12-15 14:18:14 +01:00
Jonas Ådahl
4508978ea5 wayland/xdg-shell: Dismiss a popup on map if parent already dismissed
If a parent doesn't have a window, it means it could have been
dismissed (for example due to a input serial race), but the more recent
popup might win the input serial race and try to map anyway. This would
result in a crash later on when trying to process the placement rule,
as the parent already has no window.

https://bugzilla.gnome.org/show_bug.cgi?id=790358
2017-11-30 10:50:13 +08:00
Jonas Ådahl
c533a06e93 wayland/xdg-shell: Check popup parent type when assigning
We only allow mapping popups on top of surfaces with a xdg_surface
based role. Add a check and fail clients that doesn't follow this rule.

https://bugzilla.gnome.org/show_bug.cgi?id=790358
2017-11-30 10:50:13 +08:00
Jonas Ådahl
5d3b4f0134 wayland/xdg-shell: Fix top-most check when grabbing
Move the top-most-popup correctness check to the finish_popup_setup()
function after checking the serial. If we pass the serial check, we
should have reached a state that if there are any popups they should be
the one from the same client.

Also avoid failing a client that correctly set the top-most popup at map
time, but where at the time of processing the top most popup have
already been dismissed by the compositor for some arbitrary reason.

https://bugzilla.gnome.org/show_bug.cgi?id=790358
2017-11-30 10:50:13 +08:00
Olivier Fourdan
3fc2ea8297 wayland/keyboard: Apply sticky keys masks
MetaWaylandKeyboard maintains its own xkb_state used to update Wayland
clients.

Add the necessary hooks to make sure the sticky keys modifier masks set
in clutter-evdev are also applied in MetaWaylandKeyboard's xkb_state so
that Wayland clients also benefit from sticky keys.

https://bugzilla.gnome.org/show_bug.cgi?id=788564
2017-11-16 14:14:31 +01:00
Olivier Fourdan
0461eed0cb wayland: Disable AccessX in Xwayland
Keyboard accessibility features in Wayland are handled in the
compositor, we do not want AccessX in Xwayland to interfere with the
compositor.

https://bugzilla.gnome.org/show_bug.cgi?id=788564
2017-11-16 14:14:31 +01:00
Jonas Ådahl
0add6f62b6 window/wayland: Handle resizing when headless
We tried to get the geometry scale, which may depend on the main
logical monitor assigned to the window. To avoid dereferencing a NULL
logical monitor when headless, instead assume the geometry scale is 1.

https://bugzilla.gnome.org/show_bug.cgi?id=788764
2017-11-10 10:24:10 +08:00
Carlos Garnacho
180985018b wayland: Plug leak
The remote DBus error is leaked.

https://bugzilla.gnome.org/show_bug.cgi?id=789984
2017-11-07 10:48:45 +01:00
Jonas Ådahl
b6200ac3ff wayland/keyboard: Don't transfer layout group when replacing xkb state
The layout group determines what actual keyboard layout in the keymap
to use when translating modifier state and key codes to key syms.
When changing a keymap to another, the layout groups has no relation to
the layout groups in the old keymap, thus there is no reason to
transfer it to the new state.

This fixes an issue where the xkb state in meta-wayland-keyboard.c got
desynchronized with the xkb state in clutter-device-manager-evdev.c.

https://bugzilla.gnome.org/show_bug.cgi?id=789300
2017-11-02 12:10:10 +08:00
Jonas Ådahl
07745b3082 wayland/surface: Disconnect actor handlers before unassigning role
The handlers depend on a role being assigned. Destroying the window
causes it to become unmapped, which would sometimes trigger one of the
handlers, resulting in an is-assigned assert hitting in one of the
handlers. Avoid this by disconnecting the handlers earlier, so that
there is no risk that any them being triggered before the role is
assigned.

https://bugzilla.gnome.org/show_bug.cgi?id=789552
2017-10-27 19:08:38 +08:00
Daniel van Vugt
054c25f693 wayland: Allow Xwayland to leave core dumps
For historical Xorg-reasons, Xwayland would disable its own core dumps by
default. This is a problem because Xwayland crashing is the biggest cause of
gnome-shell crashes [1][2], and we still have no idea why due to there being
no dumps from Xwayland. So enable core dumping from Xwayland.

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

[1] https://bugs.launchpad.net/bugs/1505409
[2] https://bugs.launchpad.net/bugs/1556601
2017-10-26 19:50:40 -05:00
Carlos Garnacho
01de04d8c9 wayland: Update pointer confinement on surface actor relocations
In the unlikely case that a surface is moved by the compositor while
holding a pointer confinement, we also need to update the pointer
position when the surface actor gets moved.

https://bugzilla.gnome.org/show_bug.cgi?id=782344
2017-10-26 12:53:20 +02:00
Carlos Garnacho
08e4cb54a8 wayland: Trigger wl_output updates on actor position changes
Both notify::position on the surface actor and position-changed on
MetaWindow are listened to, in order to trigger wl_output updates for
wl_surfaces whenever the surfaces move across them.

Both signals are necessary in order to cater for toplevel and subsurface
relocations (Because it's the parent window actor what changes position
in this last case).

Also, shuffle signal disconnection, so each signal goes away with
the object reference held by MetaWaylandSurface.

https://bugzilla.gnome.org/show_bug.cgi?id=782344
2017-10-26 12:51:44 +02:00
Marco Trevisan (Treviño)
b31e545c9d backends: add 'monitors-updated-internal' signal to only update internal state
Adding an internal signal and use it to update the internal state before
emitting "monitors-changed" which will be repeated by the screen to the world.

https://bugzilla.gnome.org/show_bug.cgi?id=788860
2017-10-13 00:42:50 -05:00
Daniel Stone
32917f1922 wayland-dma-buf: Don't send modifiers to old clients
The modifier event was only added in v3 of the client; sending it to
older clients (e.g. GStreamer waylandsink) causes them to disconnect
immediately.

Send the older 'format' event to all clients, and only send the newer
'modifier' event to resource versions 3 or above.

https://bugzilla.gnome.org/show_bug.cgi?id=788558
2017-10-05 10:51:06 -04:00
Georges Basile Stavracas Neto
aea66ddff6 wayland: Send edge constraints
Following up the previous patch, this patch makes the
Wayland backend send the edge constraints through a
custom protocol extension internal to GTK.

As it mature, we can think of upstreaming the protocol
to Wayland itself.

https://bugzilla.gnome.org/show_bug.cgi?id=751857
2017-10-03 19:38:32 -03:00
Jonas Ådahl
4e7405aca9 wayland/surface: Send buffer release events immediately
Just queuing the buffer release event is prone to starvation, so send
the release immediately. See
https://lists.freedesktop.org/archives/wayland-devel/2017-September/035147.html
for more detailed explanation.

https://bugzilla.gnome.org/show_bug.cgi?id=788197
2017-09-28 09:58:17 -04:00
Olivier Fourdan
2bf7974076 wayland: do not leak shortcut inhibit data
We would free the shortcut inhibit data only when the client destroys
its request, which is not the case when the clients itself is
destroyed, leading to a leak of the shortcut inhibit data.

Free the data on resource destruction instead, and simply destroy the
resource on destroy request.

https://bugzilla.gnome.org/show_bug.cgi?id=787568
2017-09-14 09:32:26 +02:00
Olivier Fourdan
9c16e4e2f3 wayland: Keep the inhibit shortcut dialog
On Wayland, the grab()/ungrab() in gtk+/gdk are wired to the shortcut
inhibitor mechanism, which in turn shows the dialog, which can take
focus away from the client window when the dialog is shown.

If the client issues an ungrab() when the keyboard focus is lost, we
would hide the dialog, causing the keyboard focus to be returned to the
client surface, which in turn would issue a new grab(), so forth and so
on, causing a continuous show/hide of the shortcut inhibitor dialog.

To avoid this issue, keep the dialog around even if the shortcut inhibit
is canceled by the client, so that the user is forced to make a choice
that we can reuse on the next request without showing the dialog again.

Instead of hiding the dialog when the shortcut inhibitor is destroyed by
the client, we simply mark the request as canceled and do not apply the
user's choice.

https://bugzilla.gnome.org/show_bug.cgi?id=787568
2017-09-14 09:32:26 +02:00
Jonas Ådahl
07f6c85cc7 wayland/inhibit-shortcuts-dialog: Use g_new0 instead of g_new
The code assumed the newly allocated blocked was initialized to 0, but
it wasn't since g_new was used. Fix that by using g_new0.

https://bugzilla.gnome.org/show_bug.cgi?id=787570
2017-09-14 09:32:26 +02:00
Jonas Ådahl
807658e972 wayland: Don't free non-transferred string when cleaning up
When cleaning up the display name string management, the display name
string retrieved from libwayland-server was also passed to free() on
clean up. This is invalid as the display name string ownership is not
transferred to us. Fix this by strdup:ing the string before saving it.

https://bugzilla.gnome.org/show_bug.cgi?id=730551
2017-09-04 12:32:53 +08:00
Jonas Ådahl
2df4ccd1cd window: Handle being headless better
This avoids updating state (such as position, size etc) when going
headless. Eventually, when non-headless, things will be updated again,
and not until then will we be able to update to a valid state.

https://bugzilla.gnome.org/show_bug.cgi?id=730551
2017-08-30 13:44:05 +08:00
Jonas Ådahl
dcd15e6145 wayland: Don't free the Wayland display name string too early
We accidentally freed the Wayland display name string, meaning
retrieving it later retrieved freed memory.

https://bugzilla.gnome.org/show_bug.cgi?id=730551
2017-08-30 13:42:45 +08:00
Jonas Ådahl
2a318eb3f2 wayland/output: Flush clients after creating wl_output global
In order to give the clients the best chance to bind the wl_output
before we later remove it (for example on fast hot plugs or in the test
suite), flush the client sockets after creating the global.

https://bugzilla.gnome.org/show_bug.cgi?id=730551
2017-08-30 13:42:45 +08:00
Jonas Ådahl
34e7134db2 wayland/xdg-foreign: Move out ID generation helper to util.c
It'll be used to generate ID in the same way in other places later.

https://bugzilla.gnome.org/show_bug.cgi?id=784199
2017-08-29 11:49:01 +08:00
Daniel Stone
06d0989014 wayland-dma-buf: Fix 32bpp channel order inversion
Apparently my understanding of Cogl pixel formats, or at least their
use, was somewhat shaky.

Un-invert the inversion of the DRM FourCC -> Cogl pixel format mapping
when creating dmabufs from clients, fixing inverted channel ordering
seen from GL clients, e.g. gold highlights in gtk4-demo when using the
GSK GL backend when they should be blue.

https://bugzilla.gnome.org/show_bug.cgi?id=786677
2017-08-24 15:11:37 +02:00
Jonas Ådahl
66996dee4b wayland/inhibit-shortcuts-dialog: Destroy the dialog after response
We'll never actually show it again, but just use the last response, so
we can just destroy it now already.

https://bugzilla.gnome.org/show_bug.cgi?id=786385
2017-08-19 17:24:06 +08:00
Jonas Ådahl
2f45e88f06 wayland/inhibit-shortcuts-dialog: Just hide the dialog when hiding
The meta_wayland_surface_hide_inhibit_shortcuts_dialog() function
disconnected the "destroy" handler, but we'd still be listening on
response events. Change this to just hide the dialog, leaving the data
intact with the proper life time signal in place.

https://bugzilla.gnome.org/show_bug.cgi?id=786385
2017-08-19 17:24:06 +08:00
Jonas Ådahl
c1439e141e wayland/inhibit-shortcuts-dialog: Make the dialog ownership clearer
Make it clear that the data object is the owner of the dialog; it
creates it, and eventually destroys it.

https://bugzilla.gnome.org/show_bug.cgi?id=786385
2017-08-19 17:24:02 +08:00
Jonas Ådahl
dceb0f1f1f wayland/inhibit-shortcuts-dialog: Make data life cycle a bit clearer
The 'data' object is attached to the MetaWaylandSurface as a GObject
qdata. It is created once, and stays allocated until the surface is
destroyed. To make things clearer, connect to the "destroy" signal just
after creating, and from a on_surface_destroyed() callback call the
.._free() function.

https://bugzilla.gnome.org/show_bug.cgi?id=786385
2017-08-19 17:23:07 +08:00
Jonas Ådahl
a7915ff8ae wayland/inhibit-shortcuts-dialog: Only reuse last reply if there was one
We might have hidden the dialog, without a response. To avoid using the
not answered response, make sure we have actually got one before
reusing.

https://bugzilla.gnome.org/show_bug.cgi?id=786385
2017-08-19 17:11:21 +08:00
Jonas Ådahl
9a47e5c832 wayland/buffer: Add missing breaks in switch statement
We'd process damage, and no matter whether it succeeded or not we'd
pretend it succeeded, meaning any potential GError would be leaked.

https://bugzilla.gnome.org/show_bug.cgi?id=786300
2017-08-16 13:33:17 +08:00
Olivier Fourdan
46cb506f8f wayland: use the inhibit shortcuts dialog
Plug the new MetaInhbitShortcutsDialog to the relevant Wayland protocol
implementation.

Also, remember the last user choice for a given surface to avoid asking
continuously the same question.

https://bugzilla.gnome.org/show_bug.cgi?id=783342
2017-08-02 11:58:55 +02:00
Olivier Fourdan
2ca0871724 wayland: add keyboard shortcuts inhibitor protocol
https://bugzilla.gnome.org/show_bug.cgi?id=783342
2017-08-02 11:58:55 +02:00
Olivier Fourdan
dd12f569d9 wayland: add inhibit shortcut mechanism
Add a mechanism to MetaWaylandSurface that inhibits compositor's own
shortcuts when the surface has input focus, so that clients can receive
all key events regardless of the compositor own shortcuts.

This will help with implementing "fake" active grabs in Wayland and
XWayland clients.

https://bugzilla.gnome.org/show_bug.cgi?id=783342
2017-08-02 11:58:55 +02:00
Daniel Stone
b7b5fb293d wayland: Add zwp_linux_dmabuf_v1 support
https://bugzilla.gnome.org/show_bug.cgi?id=785262
Signed-off-by: Daniel Stone <daniels@collabora.com>
2017-08-01 19:05:50 +08:00
Carlos Garnacho
26fa7b8f6a wayland: Reset tablet tool cursor surface on proximity out
The cursor surface would be remembered until the next proximity in
event, causing flashing of the old cursor till the client underneath
the tablet tool sent the zwp_tablet_tool.set_cursor request.

Forgetting about the cursor surface on proximity out makes the cursor
invisible till the request is made.
2017-07-26 15:41:28 +02:00
Carlos Garnacho
5db48faca4 wayland: Update button state on motion/button events
More specifically, avoid crossing events, since clutter does not set
modifier/button state on those. Fixes implicit grabs being broken when
the pointer moves past the surface boundaries.

https://bugzilla.gnome.org/show_bug.cgi?id=785347
2017-07-24 17:57:31 +02:00
Daniel Stone
9a348aa859 wayland/buffer: Create EGLImage with no context
Since a wl_buffer is independent of the GL context in use (unlike, e.g.,
a GL renderbuffer), EGLImages with the EGL_WAYLAND_BUFFER_WL target must
pass EGL_NO_CONTEXT as the context. Quoting from the
EGL_WL_bind_wayland_display spec:

    After querying the wl_buffer layout, create EGLImages for the
    planes by calling eglCreateImageKHR with wl_buffer as
    EGLClientBuffer, EGL_WAYLAND_BUFFER_WL as the target, NULL
    context.

The check was already present inside _cogl_egl_create_image.

https://bugzilla.gnome.org/show_bug.cgi?id=785263
Signed-off-by: Daniel Stone <daniels@collabora.com>
2017-07-22 11:44:44 +02:00
Jason Gerecke
4d8cb5408b wayland: Provide basic tablet wheel event support
Adds basic support for the "wheel" event from the Wayland tablet protocol.
Ideally we would accumulate the angle and report a wheel event with an
appropriate value for "clicks". We can get away with a much cruder method
for the time being, however, since no Wacom tablet puck actually provides
a smooth scrollwheel. Checking whether the angle in CLUTTER_INPUT_AXIS_WHEEL
exceeds a nominally-small threshold is sufficient to determine that the
wheel has advanced by at least one physical click.

https://bugzilla.gnome.org/show_bug.cgi?id=783716
2017-07-17 21:22:15 +02:00
Jonas Ådahl
4afa66fe41 wayland/window: Update toplevel main monitor before non-toplevel
When updating the main monitor, make sure to update the toplevel main
monitor before trying to use that as the main monitor for non-toplevel
windows (such as popups). Without this, when the main monitor is
updated as a side effect to monitors being changed (for example due to
a hot plug event, or coming back from being suspended) the
main monitor pointer may, after 'monitors-changed' has completed, point to
freed memory resulting in undefined behaviour.

https://bugzilla.gnome.org/show_bug.cgi?id=784867
2017-07-17 09:59:34 +08:00
Jonas Ådahl
197401fbf8 cursor-renderer: Track cursor position using floats
To be able to render the pointer cursor sprite at sub-(logical)-pixel
positions, track the pointer position using floats instead of ints.
This also requires users of the cursor sprite rect to deal with
floating points, when e.g. finding the logical monitor etc.

https://bugzilla.gnome.org/show_bug.cgi?id=765011
2017-07-14 20:54:27 +08:00
Jonas Ådahl
10b0351a59 Add support for rudimentary fractional scaling
When the logical layout mode is used, allow configuring the scaling to
be non-integer. Supported scales are so far hard coded to include at
most 1, 1.5 and 2, and scales that doesn't result in non-fractional
logical monitor sizes are discarded.

Wayland outputs are set to have scale ceil(actual_scale) meaning well
behaving Wayland clients will provide buffers with buffer scale 2, thus
being scaled down to the fractional scale.

https://bugzilla.gnome.org/show_bug.cgi?id=765011
2017-07-14 20:54:26 +08:00
Jonas Ådahl
b64c69e4bc logical-monitor: Make scale a float
To support fractional scaling, the logical monitor scale must be stored
as a float. No other functional changes is part of this commit.

https://bugzilla.gnome.org/show_bug.cgi?id=765011
2017-07-14 20:54:26 +08:00
Jason Gerecke
ca600973ba wayland: Store and retrieve implicit grab information for tablet tools
Window moving and resizing depends on the `meta_wayland_seat_get_grab_info`
function succeeding. At the moment, tablet tools do not generate implicit
grabs like the pointer and touch. This commit adds the necessary elements
to track implicit grabs and retrieve their information.

https://bugzilla.gnome.org/show_bug.cgi?id=777333
2017-07-13 19:10:52 +02:00
Jonas Ådahl
538e402d71 wayland: Random whitespace fixes
https://bugzilla.gnome.org/show_bug.cgi?id=784080
2017-07-12 12:08:57 +08:00
Jonas Ådahl
9af6ec78ab wayland: Add support for wl_surface.damage_buffer
Implements support for the wl_surface.damage_buffer request, which
damages the buffer using buffer coordinate space.

https://bugzilla.gnome.org/show_bug.cgi?id=784080
2017-07-12 12:08:57 +08:00
Carlos Garnacho
529e5adb2e wayland: Base tablet tool coordinates on the current event
Instead of the last device position. This was copied a little bit too
straight from MetaWaylandPointer.

https://bugzilla.gnome.org/show_bug.cgi?id=783535
2017-07-03 13:56:21 +02:00
mitchmindtree
8457e2bad6 wayland/pointer: Check for subsurfaces when grabbing
Previously, the function only returned `TRUE` if the given surface was
equal to the given pointer's focused surface. This changes the behaviour
to also return `TRUE` if any of the given surface's subsurfaces are
equal to the pointer's focused surface.

https://bugzilla.gnome.org/show_bug.cgi?id=781811.
2017-06-07 09:47:29 +08:00
Jonas Ådahl
b4120a75e0 wayland/pointer: Track lifetime of current surface
Clear the pointer->current when the surface is destroyed.

https://bugzilla.gnome.org/show_bug.cgi?id=783113
2017-06-01 12:46:32 +08:00
Jonas Ådahl
b19e4592df wayland/pointer: Use glib signals tracking focus surface
Use the "destroy" MetaWaylandSurface signal instead of the wl_resource
destroy signal for tracking the lifetime of the surface with pointer
focus.

As unsetting the focus may have side effects due to handlers of the
"focus-surface-changed" signal, connect the signal after the default
handler to make sure other clean up facilities have the chance deal with
the surface destruction before we try to unset the focus.

https://bugzilla.gnome.org/show_bug.cgi?id=783113
2017-06-01 12:46:32 +08:00
Carlos Garnacho
498200776c wayland: Ensure we repick the pointer on synthesized crossing events
Relayouts in clutter may trigger synthesized crossing events if the
actor below the pointer changes. In that situation we do need to
repick() the MetaWaylandPointer to end up with the right current
wayland surface.

https://bugzilla.gnome.org/show_bug.cgi?id=755164
2017-05-22 17:45:17 +02:00
Carlos Garnacho
27ea62a79d wayland: Use notify::allocation to update pointer as per confinements
There is no need to constraint the pointer to the confinement on each redraw
if the surface actor didn't move/resize.

https://bugzilla.gnome.org/show_bug.cgi?id=782344
2017-05-22 17:27:11 +02:00
Carlos Garnacho
cf1edff9ed wayland: Use notify::allocation notification to update surface outputs
Instead of updating the surface outputs on each actor ::paint.

https://bugzilla.gnome.org/show_bug.cgi?id=782344
2017-05-22 17:27:11 +02:00
Olivier Fourdan
561d71b8ae wayland: place window if maximized before placement
If a client changes the state of a surface to issue a set_maximize, this
causes apply_pending_state() to be called before mutter has placed the
window.

If the monitor on which the window is to be shown initially is different
from the one where the pointer is placed, this causes the effect to be
played at the wrong location before the window eventually reaches its
location on another monitor.

Force the window to be placed prior to change its state to maximized in
xdg-shell so that mutter won't relocate the window afterwards.

This also avoids sending an xdg_toplevel.configure with a size of 0x0
which would cause the client to initially draw its surface with some
arbitrary size.

https://bugzilla.gnome.org/show_bug.cgi?id=782183
https://bugzilla.gnome.org/show_bug.cgi?id=781353
2017-05-22 09:22:11 +02:00
Carlos Garnacho
5758401443 xwayland: Use the right atom type for further selection requests to X11
If we translate between text/plain;charset-utf-8 from the wayland side to
UTF8_STRING on the X11 side, we want to continue all further X11 selection
requests using the same translated UTF8_STRING atom than we use in the
first XConvertSelection call.

https://bugzilla.gnome.org/show_bug.cgi?id=782472
2017-05-10 21:00:37 +02:00
Olivier Fourdan
f241bdba93 wayland: Apply size hints regardless of geometry
Previously we would bail out early in xdg_toplevel_role_commit() if no
geometry change was set, ignoring the possible min/max size hints
changes.

But setting a min/max size hint without changing the geometry is
perfectly valid, so we ought to apply the min/max changes regardless of
a geometry change.

https://bugzilla.gnome.org/show_bug.cgi?id=782213
2017-05-10 10:44:42 +02:00
Olivier Fourdan
410d66ca37 wayland: Make sure we have a pending geometry
If the client doesn't set a geometry using xdg_shell, we'll compute its
geometry based on its surface and subsurfaces.

Yet, we translate that as a window (re)size only when there is a pending
geometry, that we don't have when we computed the geometry by ourself.

Make sure we set the pending new geometry flag when computing the
geometry when it actually changed.

https://bugzilla.gnome.org/show_bug.cgi?id=782213
2017-05-10 10:44:37 +02:00
Carlos Garnacho
d6d01c85a6 wayland: Collect frame completion time once for all surfaces
Dispatch all surface frames with the same monotonic time to avoid
querying it too often.

https://bugzilla.gnome.org/show_bug.cgi?id=782344
2017-05-09 11:53:14 +02:00
Jonas Ådahl
704bd4c331 wayland/subsurface: Handle clients committing on destroyed subsurface
A client can still commit state to a destroyed subsurface. It wont
update anything on the screen, since the subsurface will not be
visible, but mutter should still handle it and not crash.

https://bugzilla.gnome.org/show_bug.cgi?id=781391
2017-04-21 17:46:17 +08:00
Jonas Ådahl
8163ca6821 Add support for scaled logical monitor framebuffers
This commit adds support for rendering onto enlarged per logical
monitor framebuffers, using the scaled clutter stage views, for HiDPI
enabled logical monitors.

This works by scaling the mode of the monitors in a logical monitors by
the scale, no longer relying on scaling the window actors and window
geometry for making windows have the correct size on HiDPI monitors.

It is disabled by default, as in automatically created configurations
will still use the old mode. This is partly because Xwayland clients
will not yet work good enough to make it feasible.

To enable, add the 'scale-monitor-framebuffer' keyword to the
org.gnome.mutter.experimental-features gsettings array.

It is still possible to specify the mode via the new D-Bus API, which
has been adapted.

The adaptations to the D-Bus API means the caller need to be aware of
how to position logical monitors on the stage grid. This depends on the
'layout-mode' property that is used (see the DisplayConfig D-Bus
documentation).

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-04-07 22:30:48 +08:00
Jonas Ådahl
1c54c7a1bb window: Replace monitor scale getter with geometry scale
All places that get the 'main monitor scale' of a window really just
wants the window geometry scale, so call it that.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-04-07 22:30:48 +08:00
Carlos Garnacho
29b240e883 wayland: Use clutter_input_device_is_grouped() for tablet grouping
Instead of poking the internal libinput device.

https://bugzilla.gnome.org/show_bug.cgi?id=779986
2017-03-13 19:34:10 +01:00
Olivier Fourdan
4b86af839f xwayland: Raise the dnd window each time
If the dnd window ends up lower in the overall stack than the window
it's supposed to fence, the drop might end up in some other window
underneath the expected target window.

Maps and raises the dnd window each time it's shown so that it's always
placed above.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=779800
2017-03-09 14:09:36 +01:00
Carlos Garnacho
38c5a1610e xwayland: Use timestamp from XdndPosition/Drop on XConvertSelection
QT apps reject DnD if the timestamp received in the SelectionRequest
event isn't the same it gave in XdndPosition/Drop client messages.
Bookkeeping and using it in XConvertSelection makes it happy again.

https://bugzilla.gnome.org/show_bug.cgi?id=779757
2017-03-08 19:18:04 +01:00
Carlos Garnacho
572610d01e xwayland: Check MetaDndBridge focus_window when updating X11 proxy window
We are keeping accounting of the focus window as seen by the DnD bridge
right here, so use it instead of the MetaWaylandDragGrab focus as it may
lag behind the real focus (i.e. till the drag source notices the window
and sends XdndEnter to it).

This leads to the window trying to be repositioned more often than
necessary when the drag source takes long to send the XdndEnter client
message, and maybe not repositioned at all if the pointer leaves the
surface while no XdndEnter message was received.

https://bugzilla.gnome.org/show_bug.cgi?id=763246
2017-03-08 16:58:59 +01:00
Carlos Garnacho
21b2eff334 xwayland: Release xdnd grabs ASAP
We currently wait for the selection being cleared by the drag source,
which might not happen on not quite educated clients. This may leave
a stuck XDND grab in the compositor side.

We can actually do a bit better, and clear the grab if:
1) The drag source sent XdndDrop to the wayland drag destination.
2) There's no accepting drag destination and all pointer buttons are
   released.
3) As usual, whenever the drag source clears the selection data

https://bugzilla.gnome.org/show_bug.cgi?id=763246
2017-03-08 16:58:19 +01:00
Hyungwon Hwang
65e9c89ed9 dnd: Implement DnD handling code in Wayland
No XDnD events which notify DnD status change comes in Wayland. To emulate XDnD
behavior, MetaDnd checks whether there is a grab or not when the modal window
starts showing. When there is a grab, it processes the raw events from
compositor, and emits DnD signals for plugin.

https://bugzilla.gnome.org/show_bug.cgi?id=765003
2017-03-07 08:28:36 +08:00
Rui Matos
1fe10f09d7 wayland-xdg-shell: Handle the wl_output on the set_fullscreen request
This makes us fullscreen wayland windows on the requested monitor.

https://bugzilla.gnome.org/show_bug.cgi?id=772525
2017-02-21 19:51:16 +01:00
Rui Matos
36ee6f656a wayland/keyboard: Avoid a division by zero
We don't further sanitize the values since the protocol allows for
everything as long as it's non-negative.

https://bugzilla.gnome.org/show_bug.cgi?id=776919
2017-02-16 16:49:44 +01:00
Carlos Garnacho
6b384dc8d1 wayland: Update tool cursor scale when crossing monitors
This makes tool cursors properly scaled on hidpi.

https://bugzilla.gnome.org/show_bug.cgi?id=778474
2017-02-15 23:33:44 +01:00
Carlos Garnacho
a25915f4f9 wayland: Keep pointer to cursor sprite on MetaWaylandTabletTool
https://bugzilla.gnome.org/show_bug.cgi?id=778474
2017-02-15 23:33:44 +01:00
Carlos Garnacho
5af848d991 wayland: Clean up MetaWaylandTabletPadGroup
Using the clutter counterparts, some backend-specific code can be removed
from here.

https://bugzilla.gnome.org/show_bug.cgi?id=771098
2017-02-10 20:11:19 +01:00
Peter Hutterer
4f31b53521 wayland: fix copy/pasto sending tool removed on rings/strips
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

https://bugzilla.gnome.org/show_bug.cgi?id=778262
2017-02-07 14:04:52 +01:00
Jonas Ådahl
0b4d80d74f wayland/output: Operate on monitors instead of outputs
Operate on MetaMonitor's instead of MetaOutput's, as the latter may be
only a subset of an actual "monitor" when referring to the physical
computer equipment.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:55 +08:00
Jonas Ådahl
6262b46928 wayland/output: Pass 'unknown' subpixel order when mismatch
When a logical monitor constains monitors with different subpixel
ordering, make the wl_output have the subpixel order 'unknown' so that
clients don't make assumptions given only a subset of the monitors of
the given region.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:55 +08:00
Jonas Ådahl
3c6d688c87 logical-monitor: Don't mirror refresh rate
Let the callers figure out how to associate a logical monitor with a
refresh rate, instead of exposing an arbitrary one.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:54 +08:00
Jonas Ådahl
5d66a13397 logical-monitor: Don't mirror physical dimensions
Don't try to mirror the physical dimension, since that's a property of
one of the monitors, not of the logical monitor. Callers are changed to
deal with choosing the monitor to represent the logical monitor.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:54 +08:00
Jonas Ådahl
ff633f295e logical-monitor: Don't duplicate output list
Just use the monitor list and the output lists of each monitor.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:54 +08:00
Jonas Ådahl
4e812410cc monitor-manager: Move logical monitor into its own file
https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:53 +08:00
Jonas Ådahl
239671f882 wayland: Add API to override display name
Add API that the tests can use in order to override the Wayland display
name.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:53 +08:00
Jonas Ådahl
1fb0e8e9bb monitor-manager: Store logical monitors in a GList
Instead of storing the logical monitors in an array and having users
either look up them in the array given an index or iterate using
indices, put it in a GList, and use GList iterators when iterating and
alternative API where array indices were previously used.

This allows for more liberty regarding the type of the logical monitor.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:52 +08:00
Jonas Ådahl
a422d6fe08 Move logical monitor neighbor API into monitor manager
Move the last piece of monitor grid getter API to the monitor manager
away from MetaScreen. The public facing API are still there, but are
thin wrappers around the MetaMonitorManager API.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:52 +08:00
Jonas Ådahl
98ee85ce82 Let the MetaWindow calculate its main logical monitor itself
There is no point in going via a MetaScreen API to calculate the "main
monitor" of a window, so let the window do that calculation itself.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:52 +08:00
Jonas Ådahl
af616c96d4 Move more logical monitor getters from the screen to the monitor manager
Turning a rectangle into a logical monitor also has nothing to do with
the screen (MetaScreen) so move it to MetaMonitorManager which has that
information.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:52 +08:00
Jonas Ådahl
2df4ebff47 Put logical monitor grid lookup API in MetaMonitorManager
Don't falsely assume the screen has anything to do with the monitor
grid, and thus move the related API to MetaMonitorManager.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:52 +08:00
Jonas Ådahl
317b734dcc Move cursor tracker ownership to the backend
Let the backend initialize the cursor tracker, and change all call
sites to get the cursor tracker from the backend instead of from the
screen. It wasn't associated with the screen anyway, so the API was
missleading.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:51 +08:00
Jonas Ådahl
36f2d5b0f1 wayland: Make surface role vfunc better named
It checks whether a surface is on a given "logical monitor", not
output. Output here is the Wayland name for the same thing, but should
not be confused with MetaOutput.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:51 +08:00
Jonas Ådahl
842ff5d6aa Rename MetaMonitorInfo MetaLogicalMonitor
In preparation for further refactorizations, rename the MetaMonitorInfo
struct to MetaLogicalMonitor. Eventually, part of MetaLogicalMonitor
will be split into a MetaMonitor type.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:51 +08:00
Jonas Ådahl
2df35d636e MetaWaylandEglStream: Use EGL_WL_wayland_eglstream instead of fd hack
Use the proposed EGL_WL_wayland_eglstream EGL extension instead of the
file descriptor hack that was used as a temporary solution.

Note that this results in EGL clients will no longer work if they are
running on a Nvidia driver with a version older than 370.

https://bugzilla.gnome.org/show_bug.cgi?id=773629
2017-01-03 17:50:03 +08:00
Jonas Ådahl
f7fd018cf8 wayland/buffer: Remove unnecessary break
https://bugzilla.gnome.org/show_bug.cgi?id=773629
2017-01-03 17:50:03 +08:00
Jonas Ådahl
405aa8fb9e wayland/buffer: Add 'realization' concept to buffers
Instead of having a way to determine the type of a buffer, add a
realization step that implicitly detects the buffer type. This makes it
possible to both realize (i.e. creating needed objects from the buffer)
and determine the type at the same time, which may be the only possible
way (for example, the only way to know whether a buffer is a EGLStream
is to create the EGLStream from it).

https://bugzilla.gnome.org/show_bug.cgi?id=773629
2017-01-03 17:50:03 +08:00
Jonas Ådahl
81b11929f7 wayland/xdg-shell: Scale window menu coordinates
When the monitor the surface is on has a scale other than 1, the
coordinate of the window menu popup position needs to be scaled, as it
is reported in logical pixels, while the stage is still in physical
pixels.

https://bugzilla.gnome.org/show_bug.cgi?id=776055
2016-12-30 21:44:51 +08:00
Olivier Fourdan
76012506ff wayland: Preserve the event mask on the root window
A window manager must select the SubstructureRedirect mask on the root
window to receive the MapRequest from the X11 clients and manage the
windows. Without this event mask set, a window manager won't be able to
map any new window.

The Wayland selection code in mutter can change/clear the event mask on
the requestor window from a XSelectionRequest event when the window is
not managed by mutter/gnome-shell.

A rogue or simply buggy X11 client may send a XConvertSelection() on the
root window and mutter will happily change/clear its own event mask on
the root window, effectively turning itself into a regular X11 client
unable to map any new X11 window from the other X11 clients.

To avoid this, simply check that the requestor window is not the root
window prior to change/clear the event mask on that window.

https://bugzilla.gnome.org/show_bug.cgi?id=776128
2016-12-15 13:01:57 +01:00
Olivier Fourdan
1ab6ac2996 wayland: disconnect mapped signal handler on destroy
Commit 5eb5f72 - wayland: Check surface outputs after mapped state
changes connected the ::mapped signal handler, we need to disconnect it
on destroy to avoid a possible assertion failure in
update_surface_output_state()

https://bugzilla.gnome.org/show_bug.cgi?id=776036
2016-12-13 15:34:03 +01:00
Rui Matos
c98d5448ec wayland: Ensure we don't focus xdg_popups iff they're non-grabbing
Commit 4295fdb892 made us skip focusing
all xdg_popups instead of just non-grabbing ones as intended. This
means that when unmanaging a window we might select a xdg_popup window
to focus (in meta_stack_get_default_focus_window() ) but then since we
don't actually focus it we go on unmanaging the focused window which
triggers an assertion, as it should.

To avoid this and still fixing bug 771694 we can make use of the
MetaWindow->input property for non-grabbing xdg_popup windows since
their semantics, in this regard, are the same as no input X11 windows.

This way, when unmanaging a focused window while a xdg_popup is up,
we'll either give focus to the xdg_popup or not select the popup at
all to be focused if it's non-grabbing.

https://bugzilla.gnome.org/show_bug.cgi?id=775986
2016-12-13 15:03:39 +01:00
Carlos Garnacho
5eb5f72434 wayland: Check surface outputs after mapped state changes
So they consistently receive wl_surface.leave after the surface
is not visible anymore.

https://bugzilla.gnome.org/show_bug.cgi?id=775478
2016-12-02 12:04:40 +01:00
Rui Matos
5df5b00927 Revert "wayland: Mark pending moved as moved"
This reverts commit 989ec7fc60.

We now rely on accurately knowing if a window moved and/or resized in
meta_window_move_resize_internal() so the wayland implementation can't
lie any longer.

https://bugzilla.gnome.org/show_bug.cgi?id=770345
2016-11-23 18:37:43 +01:00
Florian Müllner
4af62438f2 wayland: Fix cogl include
Do not include cogl.h in a way that may pick up the header from a
system-installed cogl version, which is incompatible with our
internal fork.
2016-11-23 18:03:59 +01:00
Jonas Ådahl
eed4dab0fc wayland: Add support for EGLStream client buffers
This commit adds for a new type of buffer being attached to a Wayland
surface: buffers from an EGLStream. These buffers behave very
differently from regular Wayland buffers; instead of each buffer
reperesenting an actual frame, the same buffer is attached over and
over again, and EGL API is used to switch the content of the OpenGL
texture associated with the buffer attached. It more or less
side-tracks the Wayland buffer handling.

It is implemented by creating a MetaWaylandEglStream object, dealing
with the EGLStream state. The lifetime of the MetaWaylandEglStream is
tied to the texture object (CoglTexture), which is referenced-counted
and owned by both the actors and the MetaWaylandBuffer.

When the buffer is reattached and committed, the EGLStream is triggered
to switch the content of the associated texture to the new content.
This means that one cannot keep old texture content around without
copying, so any feature relying on that will effectively be broken.

https://bugzilla.gnome.org/show_bug.cgi?id=773629
2016-11-18 00:00:10 +08:00
Jonas Ådahl
41c96921d6 wayland: Add support for EGL_WAYLAND_Y_INVERTED_WL
Add support for inverted Y Wayland buffers. OpenGL textures are by
default inverted, so adding support for EGL_WAYLAND_Y_INVERTED_WL
effectively means adding support for non-inverted, which makes the
MetaShapedTexture apply a transformation when drawing only when querying
EGL_WAYLAND_Y_INVERTED_WL resulted in the response "EGL_FALSE".

https://bugzilla.gnome.org/show_bug.cgi?id=773629
2016-11-18 00:00:10 +08:00
Jonas Ådahl
23455985cd wayland: Make MetaWaylandBuffer handle texture generation itself
Don't rely on the Cogl layer having Wayland specific paths by
determining the buffer type and creating the EGLImage ourself, while
using the newly exposed CoglTexture from EGLImage API. This changes the
API used by MetaWaylandSurface to make the MetaWaylandBuffer API be
aware when the buffer is being attached. For SHM and EGL buffers, only
the first time it is attached will result in a new texture being
allocated, but later for EGLStream's, more logic on every attach is
needed.

https://bugzilla.gnome.org/show_bug.cgi?id=773629
2016-11-18 00:00:10 +08:00
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