1
0
Fork 0
Commit graph

7694 commits

Author SHA1 Message Date
Georges Basile Stavracas Neto
2d7adb90c8 wayland/tablet-tool: Use meta_wayland_surface_get_relative_coordinates()
Instead of directly calling into clutter_actor_transform_stage_point().

https://gitlab.gnome.org/GNOME/mutter/merge_requests/409
2019-08-23 13:23:07 +00:00
Georges Basile Stavracas Neto
6b35a4901e shaped-texture: Move private function to private header
meta_shaped_texture_update_area() is a private function that
is exposed in the public headers. It is not used anywhere
outside Mutter, and should really be in the private header.

Move it to the private header.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/409
2019-08-23 13:23:07 +00:00
Georges Basile Stavracas Neto
4c1fde9deb shaped-texture: Move MetaCullable helpers to MetaSurfaceActor
Now that MetaShapedTexture is not a ClutterActor anymore, it does
not make sense to make it a MetaCullable semi-implementation. This
is, naturally, a responsibility of MetaSurfaceActor, since now
MetaShapedTexture is a ClutterContent and as such, it only cares
about what to draw.

Move the MetaCullable implementation of MetaShapedTexture to
MetaSurfaceActor.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/409
2019-08-23 13:23:07 +00:00
Georges Basile Stavracas Neto
425e65049b shaped-texture: Draw pipeline relative to alloc
By implementing ClutterContent, it is expected that
MetaShapedTexture can draw on any actor. However,
right now this is not possible, since it assumes
that the drawing coordinates and sizes of the actor
are synchronized with its own reported width and
height.

It mistakenly draws, for example, when setting an
actor's content to it. There is no way to trigger
this wrong behavior right now, but it will become
a problem in the future where we can collect the
paint nodes of MetaShapedTexture as part of other
ClutterContent implementations.

Use the allocation box passed by the actor to draw
the pipelines of MetaShapedTexture.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/409
2019-08-23 13:23:07 +00:00
Georges Basile Stavracas Neto
d3f30d9ece wayland/actor-surface: Set geometry scale in surface actor
Now that MetaShapedTexture is a ClutterContent implemetation that
is aware of its own buffer scale, it is possible to simplify the
event translation routines.

Set the geometry scale in MetaSurfaceActor, and stop adjusting the
surface scale when translating points. Also remove the now obsoleted
meta_wayland_actor_surface_calculate_scale() function.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/409
2019-08-23 13:23:07 +00:00
Georges Basile Stavracas Neto
75cffd0ec4 shaped-texture: Implement ClutterContent
MetaWindowActor is the compositor-side representative of a
MetaWindow. Specifically it represents the geometry of the
window under Clutter scene graph. MetaWindowActors are backed
by MetaSurfaceActors, that represent the windowing system's
surfaces themselves. Naturally, these surfaces have textures
with the pixel content of the clients associated with them.
These textures are represented by MetaShapedTexture.

MetaShapedTextures are currently implemented as ClutterActor
subclasses that override the paint function to paint the
textures it holds.

Conceptually, however, Clutter has an abstraction layer for
contents of actors: ClutterContent. Which MetaShapedTexture
fits nicely, in fact.

Make MetaShapedTexture a ClutterContent implementation. This
forces a few changes in the stack:

 * MetaShapedTexture now handles buffer scale.

 * We now paint into ClutterPaintNode instead of the direct
   framebuffer.

 * Various pieces of Wayland code now use MetaSurfaceActor
   instead of MetaShapedTexture.

 * MetaSurfaceActorWayland doesn't override size negotiation
   vfuncs anymore

https://gitlab.gnome.org/GNOME/mutter/merge_requests/409
2019-08-23 13:23:07 +00:00
Olivier Fourdan
13deb22223 wayland/xdg-output: Add xdg-output v3 support
xdg-output v3 marks `xdg_output.done` as deprecated, avoid sending that
event for clients using xdg-output v3.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/704
2019-08-21 15:47:14 +00:00
Olivier Fourdan
eac227a203 xwayland: Add local user to xhost
With the addition of xauth support (commit a8984a81c), Xwayland would
rely only on the provided cookies for authentication.

As a result, running an Xclient from another VT (hence without the
XAUTHORITY environment variable set) would result in an access denied.

The same on X11 is granted because the local user is automatically
granted access to Xserver by the startup scripts.

Add the local user to xhost at startup on Xwayland so that the user can
still run a client by setting the DISPLAY as long as it's the same user
on the same host.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/735
2019-08-19 17:14:40 +02:00
Olivier Fourdan
bc166aa6b4 xwayland: Use given X11 display for DnD setup
Use the provided X11 display instead of poking into GDK to get the X11
display.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/735
2019-08-19 17:14:40 +02:00
Olivier Fourdan
5fa8b24b2b xwayland: pass the X11 display
Pass the X11 display to `meta_xwayland_complete_init()` so that it can
be used without poking into GDK.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/735
2019-08-19 17:14:40 +02:00
Jonas Ådahl
0db38c4999 compositor: Let MetaDisplay choose the correct compositor type
A base type shouldn't know about sub types, so let MetaDisplay make
the correct choice of what type of MetaCompositor it should create. No
other semantical changes introduced.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/727
2019-08-19 08:44:58 +00:00
Jonas Ådahl
8ee00cee60 compositor/x11: Move stage input region setting to MetaX11Display
It doesn't use anything specific to MetaCompositor, and
MetaCompositorX11 isn't exposed, so move it to MetaX11Display.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/727
2019-08-19 08:44:58 +00:00
Jonas Ådahl
984aad4b86 compositor: Move out X11 compositing code into sub type
Introduce MetaCompositorX11, dealing with being a X11 compositor, and
MetaCompositorServer, being a compositor while also being the display
server itself, e.g. a Wayland display server.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/727
2019-08-19 08:44:58 +00:00
Jonas Ådahl
9af90bf9c1 compositor: Fix indentation mistake
https://gitlab.gnome.org/GNOME/mutter/merge_requests/727
2019-08-19 08:44:58 +00:00
Jonas Ådahl
12ea2fcb51 compositor: Make type derivable
This is so that we can split it up properly into X11 compositor and
display server compositor sub types.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/727
2019-08-19 08:44:58 +00:00
Jonas Ådahl
55cd110c63 compositor: Use meta_window_actor_from_window() throughout
Instead of explicitly using meta_compositor_get_window_private() and
casting it to MetaWindowActor * each time.

With minor bonus style cleanups.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/727
2019-08-19 08:44:58 +00:00
Olivier Fourdan
f37a172dc7 events: No UI frame button press events for Wayland
When double clicking to un-maximize an X11 window under Wayland, there
is a race between X11 and Wayland protocols and the X11 XConfigureWindow
may be processed by Xwayland before the button press event is forwarded
via the Wayland protocol.

As a result, the second click may reach another X11 window placed right
underneath in the X11 stack.

Make sure we do not forward the button press event to Wayland if it was
handled by the frame UI.

https://gitlab.gnome.org/GNOME/mutter/issues/88
2019-08-19 09:16:04 +02:00
Olivier Fourdan
ad62a659eb window: Move UI frame event handler to a separate function
In order to tell whether an event has been handled by the frame UI, move
the UI frame handler to a specific helper function.

https://gitlab.gnome.org/GNOME/mutter/issues/88
2019-08-19 09:16:04 +02:00
Albert Vaca Cintora
4d8190972d cursor-renderer/native: Fix compilation warning
Previous initialization triggered Wmissing-braces in Clang.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/731
2019-08-16 14:54:48 +02:00
Hans de Goede
f3660dc60e kms: Deal with GPUs being unplugged
Add meta-kms and meta-monitor-manager-kms listener for the udev
device-removed signal and on this signal update the device state /
re-enumerate the monitors, so that the monitors properly get updated
to disconnected state on GPU removal.

We really should also have meta-backend-native remove the GPU itself
from our list of GPU objects. But that is more involved, see:
https://gitlab.gnome.org/GNOME/mutter/issues/710

This commit at least gets us to a point where we properly update the
list of monitors when a GPU gets unplugged; and where we no longer
crash the first time the user changes the monitor configuration after
a GPU was unplugged.

Specifically before this commit we would hit the first g_error () in
meta_renderer_native_create_view () as soon as some monitor
(re)configuration is done after a GPU was unplugged.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
2019-08-15 20:38:28 +00:00
Hans de Goede
0eb355e29d kms: Fix drm_connector mem-leak in meta_kms_connector_update_state
https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
2019-08-15 20:38:28 +00:00
Hans de Goede
3ccb7cf4b2 kms: drmModeGetConnector may fail
drmModeGetConnector may fail and return NULL, this may happen when
a connector is removed underneath us (which can happen with e.g.
DP MST or GPU hot unplug).

Deal with this by skipping the connector when enumerating and by
assuming it is disconnected when checking its connection state.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
2019-08-15 20:38:28 +00:00
Hans de Goede
578ff22464 kms: drmModeGetCrtc may fail
drmModeGetCrtc may fail and return NULL. This will trigger when
meta_kms_crtc_update_state gets called from meta_kms_update_states_sync
after a GPU has been unplugged leading to a NULL pointer deref causing
a crash.

This commit fixes this by checking for NULL and clearing the current_state
when NULL is returned.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
2019-08-15 20:38:28 +00:00
Hans de Goede
73db35c53c kms: Fix meta_kms_crtc_read_state gamma table memory leak
Before this commit meta_kms_crtc_read_state was overwriting the
entire MetaKmsCrtcState struct stored in crtc->current_state including
the gamma (sub)struct.

This effectively zero-s the gamma struct each time before calling
read_gamma_state, setting the pointers where the previous gamma values
were stored to NULL without freeing the memory. Luckily this zero-ing
also sets gamma.size to 0, causing read_gamma_state to re-alloc the
arrays on each meta_kms_crtc_update_state call. But this does mean that
were leaking the old gamma arrays on each meta_kms_crtc_update_state call.

This commit fixes this by making meta_kms_crtc_read_state only overwrite
the other values in the MetaKmsCrtcState struct and leaving the gamma
sub-struct alone, this will make read_gamma_state correctly re-use the
gamma tables if the gamma table size is unchanged; or re-alloc them
(freeing the old ones) if the size has changed, fixing the memory leak.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
2019-08-15 20:38:28 +00:00
Hans de Goede
76445bcb97 kms: Remove unused fields from MetaKmsCrtcState struct
https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
2019-08-15 20:38:28 +00:00
Hans de Goede
6792903c4f udev: Add device-removed signal
Add a device-removed signal which gets emitted when a GPU is removed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
2019-08-15 20:38:28 +00:00
Hans de Goede
17c217848d udev: Fix wrong closure function usage for the "device-added" signal
The "device-added" signal should use g_cclosure_marshal_VOID__OBJECT not
g_cclosure_marshal_VOID__VOID.

Instead of fixing this manually, simply replace the closure function for
both signals with NULL, glib will then automatically set the correct
va_marshaller.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/713
2019-08-15 20:38:28 +00:00
Carlos Garnacho
a0bdf44c2d core: Do not crash on untimely stack queries for X11 windows
Some meta_later operations may happen across XWayland being shutdown,
that trigger MetaStackTracker queries for X11 XIDs. This crashes as
the MetaX11Display is already NULL.

Return a NULL window in that case, as in "unknown stack ID".

https://gitlab.gnome.org/GNOME/mutter/merge_requests/728
2019-08-15 15:11:01 +02:00
Carlos Garnacho
3259c7e150 wayland: Start up the grace Xwayland period right after starting Xwayland
There may be cases where a X11 client does not spawn any X11 windows (eg.
simple clients like xinput --list, or xlsclients), in this case the Xwayland
server would remain running until X11 windows happen to come and go in the
future.

Firing the shutdown timeout on restart caters for this, and would be undone
if the client maps X11 windows.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/728
2019-08-15 15:09:49 +02:00
Carlos Garnacho
e9e28baab7 wayland: Create XAuthority file once
Where the prepare_auth_file() call is, it does create a new one on every
respawn of Xwayland. This is not benefitial, as the XAUTHORITY envvar is
already fixed in the session.

Only create the XAuthority file once, and reuse it on future Xwayland
respawns.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/728
2019-08-15 15:09:38 +02:00
Jonas Ådahl
d20f6c7969 compositor: Use g_clear_signal_handler to disconnect signal handlers
This also exposed wrong types used for the signal handler ids.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/385
2019-08-14 15:42:03 +00:00
Marco Trevisan (Treviño)
93c7d571af display: Destroy compositor using g_clear_pointer
https://gitlab.gnome.org/GNOME/mutter/merge_requests/385
2019-08-14 15:42:03 +00:00
Marco Trevisan (Treviño)
d526283ab9 compositor: Make it a GObject
This means we can later use GObject features like signals, subclassing
etc.

Bump glib_req version as per g_clear_handle_id usage.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/385
2019-08-14 15:42:03 +00:00
Hans de Goede
782056adab wayland/data-device: Use correct selection type to get mime types
When primary_offer_receive checks if the requested mime_type is supported,
it should check against the list of mime-types supported by the
primary-selection, instead of the list for the clipboard.

This fixes primary selection copy paste from X11 apps to Wayland apps
not working.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/702
2019-08-14 12:00:10 +02:00
Jonas Ådahl
0521706617 monitor: Always advertise modes similar to the preferred mode
Even if the preferred mode ends up being too small according to the area
size filter, it should still be advertised as it's still preferred.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/725

https://gitlab.gnome.org/GNOME/mutter/merge_requests/722
2019-08-13 14:38:16 +00:00
Jonas Ådahl
989a281b5f monitor: Check mode resolution area when determining advertisability
Explicitly checking the dimensions of a mode to determine whether it
should be advertised or not fails for portrait style modes. Avoid this
by checking the area instead.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/722
2019-08-13 14:38:16 +00:00
Jonas Ådahl
18838bcefc monitor: Fix style issue
https://gitlab.gnome.org/GNOME/mutter/merge_requests/722
2019-08-13 14:38:16 +00:00
Carlos Garnacho
08c6b801d2 core: Exit early on keybindings if this is a wayland compositor
Fixes a thinko in commit 79b5ece2. It is meant to bail out early
on issuing X11 passive grabs if the compositor is a wayland one,
but this condition was inverted.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/721
2019-08-09 11:36:45 +02:00
Carlos Garnacho
80c8a287ee wayland: Check the xwayland shutdown policy before listening for x11 windows
We only listen for those so we know there's no more X11 clients that we
should keep the Xwayland server alive for. Check first that we really did
request Xwayland to be handled on demand for this, otherwise the check is
superfluous, even harmful.

https://gitlab.gnome.org/GNOME/mutter/issues/719
2019-08-07 18:34:10 +02:00
Carlos Garnacho
141373f0ba wayland: Implement on-demand start of Xwayland
The Xwayland manager now has 4 distinct phases:
- Init and shutdown (Happening together with the compositor itself)
- Start and stop

In these last 2 phases, handle orderly initialization and shutdown
of Xwayland. On initialization We will simply find out what is a
proper display name, and set up the envvar and socket so that clients
think there is a X server.

Whenever we detect data on this socket, we enter the start phase
that will launch Xwayland, and plunge the socket directly to it.
In this phase we now also set up the MetaX11Display.

The stop phase is pretty much the opposite, we will shutdown the
MetaX11Display and all related data, terminate the Xwayland
process, and restore the listening sockets. This phase happens
on a timeout whenever the last known X11 MetaWindow is gone. If no
new X clients come back in this timeout, the X server will be
eventually terminated.

The shutdown phase happens on compositor shutdown and is completely
uninteresting. Some bits there moved into the stop phase as might
happen over and over.

This is all controlled by META_DISPLAY_POLICY_ON_DEMAND and
the "autostart-xwayland" experimental setting.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
0c5866a9e1 core: Avoid queueing a stack operation on the frame when the X11 is closing
When rushing to unmanage X11 windows after the X11 connection is closed/ing,
this would succeed at creating a stack operation for no longer known windows.
Simply avoid to queue a stack operation if we know it's meaningless.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
879f5f0dbb x11: Add "closing" flag to MetaX11Display
So code not directly in dispose() can know to avoid certain things
when the X11 display is about to close.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
123b40105d x11: Shuffle x11-stack destruction in MetaX11Display dispose
Unmanaging the windows may trigger stack operations that we later try
to synchronize despite being in dispose() stage. This may trigger
MetaStackTracker warnings when trying to apply those operations.

Switching destruction order (First dispose the X11 stack representation,
then unmanage windows) won't trigger further stack changes on X11 windows
after having signaled MetaDisplay::x11-display-closing.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
7ef32f747b wayland: Add setting/api to check the policy to set up the X11 display
This replaces meta_should_autostart_x11_display(). The "on-demand" policy
is not honored yet.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
e8949292c1 wayland: Refactor code setting up the display socket
So it may be reused when we need to open those again.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
f5a2694eba wayland: Add tracking of X11 windows
This is unused ATM, but will be used to check whether it is safe to
shut Xwayland down.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
319f7f5b63 compositor: Add explicit API call to redirect X11 windows
This is not useful yet, but will be when Xwayland may restart

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
9a10b8ff94 wayland: Disconnect signal when the display closes
It would be potentially left dangling if the display were closed, and
reconnected again when restarting the server.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
8b62f4884d wayland: Rename xwayland init/shutdown functions
The start/stop verbs will be reused later when we can start and
stop the X server. Rename these functions to init/shutdown, and
init_xserver() to start_xserver().

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
500a692e3b core: Manage only X11 windows when (re)starting
What "restart" means is somewhat different between x11 and wayland
sessions. A X11 compositor may restart itself, thus having to manage
again all the client windows that were running. A wayland compositor
cannot restart itself, but might restart X11, in which case there's
possibly a number of wayland clients, plus some x11 app that is
being started.

For the latter case, the assert will break, so just make it
conditional. Also rename the function so it's more clear that it
only affects X11 windows.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
d3d1ff1aae x11: Do not queue stack operation for guard window
In the case mutter is a x11 compositor, it doesn't matter much
since the stack tracker will go away soon. In the case this is a
wayland compositor with mandatory Xwayland, it matters even less
since the session would be shutting down in those paths.

But if this a wayland compositor that can start Xwayland on demand,
this is even harmful, as the MetaStackTracker should be cleared of
x11 windows at this moment, and we actually did right before dispose
on ::x11-display-closing.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
ca51cd8488 core: Prepare MetaStackTracker for X11 display being closed
If the display is closed prematurely, go through all windows that
look X11-y and remove them for future calculations. This is not
strictly needed as Xwayland should shut down orderly (thus no client
windows be there), but doesn't hurt to prepare in advance for the
cases where it might not be the case.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
9109fa0eb8 x11: Add meta_x11_get_display_name() function
Instead of poking the DISPLAY envvar at places.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
79b5ece241 core: Ensure passive key grabs are only set up on X11
We don't strictly need it for wayland compositors, yet there are
paths where we try to trigger those passive grabs there. Just
skip those on the high level code (where "is it x11" decisions
are taken) like we do with passive button grabs.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
cda9579034 core: propagate the effective on-all-workspaces setting to transient window
Commit 09bab98b1e tried to avoid several workspace changes while in
window construction, but it missed a case:

If we have a window on a secondary monitor with no workspaces enabled
(so it implicitly gets on_all_workspaces = TRUE without requesting it)
and trigger the creation of a second window that has the first as
transient-for, it would first try to set the first workspace than the
transient-for window and then fallback to all/current workspace.

After that commit we only try to set the same workspace than the
transient-for window, but it gets none as neither is on a single workspace,
nor did really request to be on all workspaces.

Fixes crashes when opening transient X11 dialogs in the secondary monitor.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/714
2019-08-05 18:19:01 +00:00
Florian Müllner
56a5c5e4d1 cleanup: Stop using g_get_current_time ()
It has been deprecated because it isn't Y2k38 ready, so replace it
with g_get_real_time () which is.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/708
2019-08-03 16:12:32 +00:00
Ray Strode
b95d7e8276 iconcache: Support 16bit icons
Mutter current crashes if an application sets a 16-bit color depth
icon in its window manager hints.

This commit fixes the crash.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/710
2019-08-01 16:52:10 -04:00
Niels De Graef
5b98cc7a3a cursor-tracker: Document cursor-moved signal
It's a bit easier to track what's going on in a signal if you document
it (otherwise you have to check where it was emitted in the code).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/697
2019-07-31 09:34:17 +00:00
Niels De Graef
4de892b02a cursor-tracker: Don't use g_cclosure_marshal_VOID__VOID
Similar to gtk commit f507a790, this ensures that the valist variant of
the marshaller is used. From that commit's message:

```
If we set c_marshaller manually, then g_signal_newv() will not setup a
va_marshaller for us. However, if we provide c_marshaller as NULL, it will
setup both the c_marshaller (to g_cclosure_marshal_VOID__VOID) and
va_marshaller (to g_cclosure_marshal_VOID__VOIDv) for us.
```

https://gitlab.gnome.org/GNOME/mutter/merge_requests/697
2019-07-31 09:34:17 +00:00
Niels De Graef
efe6c13d93 cursor-tracker: Use our own marshal for cursor-moved
By putting `NULL` as the C marshaller in `g_signal_new`, you
automatically get `g_cclosure_marshaller_generic`, which will try to
process its arguments and return value with the help of libffi and
GValue.

Using `glib-genmarshal` and valist_marshallers, we can prevent this so
that we need less instructions for each signal emission.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/697
2019-07-31 09:34:17 +00:00
Carlos Garnacho
aae9f3a3e6 window-actor: Fix rectangle coordinates in culling
The cull methods expect regions with 0,0 in the actor top-left corner,
whereas meta_window_get_frame_rect() returns a rectangle in workarea
coordinates.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/707
2019-07-31 00:27:33 +02:00
Carlos Garnacho
f501fdcc56 window-actor: Remove negation in function name
Double negations are the spawn of the devil, and is_non_opaque() is
used like that to find out if it's opaque most often, change the
function name to see the glass half full.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/698
2019-07-30 23:17:14 +02:00
Carlos Garnacho
90a5582a73 background-actor: Clip obscured background areas
The MetaBackgroundActor was ignoring the unobscured area altogether,
and just painted according to the clip area. Check the unobscured
area too, as it might well be covered by client windows.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/698
2019-07-30 23:17:14 +02:00
Carlos Garnacho
ac7aa11417 window-actor: Cull out areas covered by opaque windows
Wayland clients do this through the opaque region in the surface
actor. However X11 clients were considered fully transparent for
culling purposes, which may result in mutter painting other bits
of the background or other windows that will be painted over in
reality.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/698
2019-07-30 23:17:14 +02:00
Carlos Garnacho
cc5968109b window-actor: Fix check to clip beneath the window
We want to clip it away if 1) The window is fully opaque or
2) If it's translucent but has a frame (as explained in the comment
above). The code didn't quite match and we were only applying it on
case #2.

Case #1 is far more common, and saves us from pushing some drawing
that we know will be covered in the end.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/698
2019-07-30 23:08:51 +02:00
Carlos Garnacho
0f6ab787ac window-actor: Check frame bounds region before use
It may be NULL when the window goes unmanaged. This was unnoticed
as we barely enter the clip_shadow_under_window() check.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/698
2019-07-30 23:08:42 +02:00
Carlos Garnacho
2812338b7a shadow-factory: Optimize shadows entirely if clip region is empty
If the clip region is empty, we don't need to check the 9 slices
separately, nothing will be painted anyway.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/698
2019-07-30 23:08:30 +02:00
Carlos Garnacho
09bab98b1e core: Avoid consecutive workspace changes in window construction
We first set the workspace to the transient-for parent's, and then
try to set on the current workspace. If both happen, we double the
work on adding/removing it from the workspace, and everything that
happens in result.

Should reduce some activity while typing on the Epiphany address
bar, as the animation results in a number of xdg_popup being created
and destroyed to handle the animation.

https://gitlab.gnome.org/GNOME/mutter/issues/556
2019-07-24 21:06:50 +02:00
Carlos Garnacho
aee8bfce3f core: Only notify on MetaWindow::user-time on actual changes
If the timestamp is the same, it doesn't make sense to update and we
don't do so. So it doesn't make sense to notify on the property either.

https://gitlab.gnome.org/GNOME/mutter/issues/556
2019-07-24 13:55:53 +02:00
Mark Blakeney
e9cc220c8e x11: Remove benign warning for older X clients
The default configuration of libinput-gestures utility invokes wmctrl to
switch between desktops. It uses wmctrl because this works on both Xorg
and Wayland (via XWayland). Unfortunately, this generates the following
warning message every time, in both Xorg and Wayland desktops:

"Received a NET_CURRENT_DESKTOP message from a broken (outdated) client
who sent a 0 timestamp"

The desktop switch still works fine. The tiny code change here removes
this specific warning because, as the prefacing code comment originally
said and still says, older clients can validly pass a 0 time value so
why complain about that?

I also refactored the "if (workspace)" code slightly to avoid the double
test of the workspace value.

This is submitted for MR
https://gitlab.gnome.org/GNOME/mutter/merge_requests/671.
2019-07-22 07:31:41 +00:00
Jonas Ådahl
61e51cdef6 dma-buf: Mark DMA-BUF textures as paint-only
Reading pixels directly from a texture imported from a DMA-BUF EGLImage
may result compressed textures to be transferred into non-compressed
texture. This may have side effects causing it to be rendered
incorrectly in subsequent paints.

Avoid this by passing the no-get-data flag to the texture creator
function, eventually causing mutter to use an intermediate offscreen
framebuffer when reading pixels from such textures.

https://bugs.freedesktop.org/show_bug.cgi?id=111140
https://gitlab.freedesktop.org/xorg/xserver/issues/545

https://gitlab.gnome.org/GNOME/mutter/merge_requests/687
2019-07-18 14:09:22 +00:00
Jonas Ådahl
7868ab761f cogl/texture: Add EGLImage texture import flags
The flags are 'none', and 'no-get-data' meaning get_data() is not
supported.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/687
2019-07-18 14:09:22 +00:00
Olivier Fourdan
ac5d9ec558 keybindings: Do not grab the locate-pointer key if unnecessary
On X11, mutter needs to keep a grab on the locate-pointer key to be able
to trigger the functionality time the corresponding key combo is
pressed.

However, doing so may have side effects on other X11 clients that would
want to have a grab on the same key.

Make sure we only actually grab the key combo for "locate-pointer" only
when the feature is actually enabled, so that having the locate pointer
feature turned off (the default) would not cause side effects on other
X11 clients that might want to use the same key for their own use.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/647
2019-07-18 13:10:32 +00:00
Olivier Fourdan
9c8ff5dbe8 keybindings: Mark "locate-pointer" key as "no-auto-grab"
Mark the keybinding for locate-pointer as "no-auto-grab" so we don't
automatically redo the grab.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/685
2019-07-18 13:10:32 +00:00
Olivier Fourdan
7738316dff keybindings: Mark the "overlay" key as "no-auto-grab"
Mark the keybinding for overlay as "no-auto-grab" to skip it in
`change_binding_keygrabs()` so we don't automatically redo the grab.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/685
2019-07-18 13:10:32 +00:00
Olivier Fourdan
1c3d8defb5 keybindings: Add "no-auto-grab" type
Some special modifiers (typically "Control_L" used for locate-pointer in
mutter/gnome-shell or "Super_L" for overlay) must be handled separately
from the rest of the key bindings.

Add a new flag `META_KEY_BINDING_NO_AUTO_GRAB` so we can tell when
dealing with that special keybinding which should not be grabbed
automatically like the rest of the keybindings, and skip those when
changing the grabs of all keybindings.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/685
2019-07-18 13:10:32 +00:00
Olivier Fourdan
b2ae03c428 keybindings: Fix indentation
Small cleanup of indentation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/685
2019-07-18 13:10:32 +00:00
Olivier Fourdan
456698c814 keybindings: Remove unneeded forward declaration
The functions `grab_key_bindings()` and `ungrab_key_bindings()` are not
used before their actual definition, there is no need to have a forward
declaration for those.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/685
2019-07-18 13:10:32 +00:00
Florian Müllner
4259cfd4c6 cleanup: Don't use G_TYPE_INSTANCE_GET_PRIVATE()
It has been deprecated in favor of the get_instance_private() function
generated by the G_ADD_PRIVATE() macro.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/689
2019-07-18 11:01:09 +02:00
Florian Müllner
4fdefb5b2e cleanup: Don't use g_memmove()
Glib stopped providing any fallback implementations on systems without
memmove() all the way back in 2013. Since then, the symbol is a simple
macro around memmove(); use that function directly now that glib added
a deprecation warning.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/689
2019-07-18 11:01:09 +02:00
Marco Trevisan (Treviño)
5ca0ef078d window-x11: Focus a window in the active workspace as take-focus fallback
Starting with commit 2db94e2e we try to focus a fallback default focus window
if no take-focus window candidate gets the input focus when we request it and
we limit the focus candidates to the current window's workspace.

However, if the window is unmanaging, the workspace might be unset, and we could
end up in deferencing a NULL pointer causing a crash.

So, in case the window's workspace is unset, just use the currently active
workspace for the display.

Closes https://gitlab.gnome.org/GNOME/mutter/issues/687

https://gitlab.gnome.org/GNOME/mutter/merge_requests/688
2019-07-18 10:09:45 +02:00
Daniel van Vugt
a5265365dd background: Reload when GPU memory is invalidated
Fixes corrupt background wallpaper when resuming from suspend on the
Nvidia driver.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/1084

https://gitlab.gnome.org/GNOME/mutter/merge_requests/600
2019-07-16 16:24:41 +08:00
Robert Mader
62f576e15b events: Use new API to get MetaWindow from ClutterActor
The new API supports Wayland subsurfaces and is probably better placed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/604
2019-07-13 15:32:19 +02:00
Robert Mader
73bc3c4426 window-actor: Add API to get a MetaWindowActor from a ClutterActor
Make it so it returns the closest ancestry MetaWindowActor if it
is a MetaSurfaceActor.
We need this for Wayland subsurfaces, so we can support actions like
Meta+Drag on them.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/604
2019-07-13 15:32:01 +02:00
Robert Mader
57772e5850 workspace-manager: Fix a documentation warning
Pure comment should not start with two stars. Fixes a GIR creation warning
introduced in 8038eaa99f.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/683
2019-07-12 22:01:27 +02:00
Carlos Garnacho
7c8baf8ed9 compositor: Drop meta_get_overlay_window()
This is no longer necessary outside of mutter, nor used internally.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/680
2019-07-11 10:56:53 +02:00
Carlos Garnacho
0e3c062406 dnd: Use composite_overlay_window directly
Saves us from using MetaCompositor API, at a point where it might not
be initialized yet. Use the same window directly, since we already
have it handy.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/672
2019-07-11 10:56:47 +02:00
Jonas Dreßler
4bc7425332 wayland/pointer: Remove duplicate include
https://gitlab.gnome.org/GNOME/mutter/merge_requests/448
2019-07-10 12:39:06 +00:00
Jonas Dreßler
a2a8f0cdaa wayland/pointer: Set focus to NULL when the cursor is hidden
This is important when using a touchscreen or stylus instead of a mouse
or touchpad. If the cursor only gets hidden and the focus stays the
same, the window will still send hover events to the UI element under
the cursor causing unexpected distractions while interacting with the
touchscreen.

Fix this by emitting a visibility-changed signal from the cursor tracker
which then triggers a focus surface sync and always set the focus
surface to NULL when it's synced while the cursor is hidden.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/448
2019-07-10 12:39:06 +00:00
Jonas Dreßler
faa7b2d4e5 cursor-tracker: Add API to get whether the pointer is visible
Allow checking whether the pointer is visible without accessing the
trackers internal is_showing property. While we don't need this just yet
for reading the visibility inside meta-wayland-pointer, it's useful when
implementing the logic to remove Clutter's focus when the cursor goes
hidden later.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/448
2019-07-10 12:39:06 +00:00
Pekka Paalanen
a95644dbdc renderer/native: Debug for primary copy mode
COPY_MODE_PRIMARY has two paths, automatically chosen. For debugging purposes,
e.g. why is my DisplayLink screen slowing down the whole desktop, it will be
useful to know which copy path is taken. Debug prints are added to both when
the primary GPU copy succeeds the first time and when it fails the first time.

This is not the full truth, because theoretically the success/failure could
change every frame, but we don't want to spam the logs (even in debug mode)
every frame. In practise, it should be rare for the success or failure to ever
change. Hence, saying what happened on the first time is enough. This does
indicate if it ever changes even once, too, so we know if that unexpected thing
happens.

The debug prints are per secondary GPU since there could be several.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
720f363241 renderer/native: Add tracing for 2nd GPU copies
These traces allow seeing how long the copy operations stall in libmutter, and
which copy operations actually get used.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
3794df608c renderer/native: Use primary GPU to copy
When the preferred path META_SHARED_FRAMEBUFFER_COPY_MODE_SECONDARY_GPU cannot
be used, as is the case for e.g. DisplayLink devices which do not actually have
a GPU, try to use the primary GPU for the copying before falling back to
read-pixels which is a CPU copy.

When the primary GPU copy works, it should be a significant performance win
over the CPU copy by avoiding stalling libmutter for the duration.

This also renames META_SHARED_FRAMEBUFFER_COPY_MODE_* because the new names are
more accurate. While the secondary GPU copy is always a GPU copy, the primary
copy might be either a CPU or a GPU copy.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
2c893beff1 renderer/native: Add meta_dumb_buffer_ensure_dmabuf_fd
Follow-up work will use this in an attempt to use the primary GPU to
copy into secondary GPU dumb buffers.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
a3c425ad89 wayland/dma-buf: Use meta_egl_create_dmabuf_image
Use the new helper instead of open-coding practically the same.

No behavioral changes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
1d144486d1 wayland/dma-buf: Fix offset, stride types
These parameters are uint32_t in the Wayland protocol so make them uint32_t
here as well.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Pekka Paalanen
9cd3b07472 egl: Introduce meta_egl_create_dmabuf_image
This bit of code was more or less duplicated in meta-renderer-native-gles3.c
and meta-wayland-dma-buf.c. Start consolidating the two implementations by
moving the *-gles3.c function into meta-egl.c and generalizing it so it could
also accommodate the meta-wayland-dma-buf.c usage.

The workaround in the *-gles3.c implementation is moved to the caller. It is
the caller's responsibility to check for the existence of the appropriate EGL
extensions.

Commit 6f59e4858e worked around the lack of
EGL_EXT_image_dma_buf_import_modifiers with the assumption that if the modifier
is linear, there is no need to pass it into EGL. The problem is that not
passing a modifier explicitly to EGL invokes implementation-defined behaviour,
so we should not have that workaround in meta-egl.c.

This patch intends to be pure refactoring, no behavioral changes. The one
change is the addition of g_assert to catch overwriting arbitrary memory.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/615
2019-07-10 08:15:02 +00:00
Carlos Garnacho
78560b8426 core: Use source device on ::accelerator-activated
Using the master device, as we did, won't yield the expected result when
looking up the device node (it comes NULL as this is a virtual device).
Use the slave device, as the g-s-d machinery essentially expects.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/678
2019-07-08 16:30:16 +02:00
Carlos Garnacho
dd8c8e82f2 core: Emit ::accelerator-activated with a ClutterInputDevice argument
The device ID is kind of pointless on Wayland, so it might be better to
stick to something that works for both backends. Passing the device here
allows the higher layers to pick.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/676
2019-07-08 10:31:11 +00:00
Marco Trevisan (Treviño)
62f4e0501f stack: Style and introspection doc fixes
https://gitlab.gnome.org/GNOME/mutter/merge_requests/669
2019-07-08 11:46:52 +02:00