1
0
Fork 0
Commit graph

8992 commits

Author SHA1 Message Date
Carlos Garnacho
38bbd9593b backends/x11: Implement ClutterSeat::touch-mode for the X11 backend
This only checks touchscreen availability as we have no access to
tablet-mode switch events as we do on the native backend.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1242

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1278
2020-05-29 12:39:59 +00:00
Jonas Ådahl
066bc5986d wayland: Drive frame callbacks from stage updates
Don't tie frame callbacks to actor painting, as it may end up in
situations where we miss sending frame callbacks when we should have. An
example of this is when a surface is partially off screen, and then
reports damage that is fully off screen. When this happen, we are likely
not to repaint anything, thus we won't send any frame callbacks even
though it's "suitable" for rendering again, as the surface is not on a
separate workspace or fully obscured.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/817
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1152

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:46:57 +02:00
Jonas Ådahl
e8b09df8d2 wayland/compositor: Pass backend when constructing
This is so that it can be retrieved later without going via the global
singleton.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:35:01 +02:00
Jonas Ådahl
1571f8078a Reshuffle Wayland initailization
Move Wayland support (i.e. the MetaWaylandCompositor object) made to be
part of the backend. This is due to the fact that it is needed by the
backend initialization, e.g. the Wayland EGLDisplay server support.

The backend is changed to be more involved in Wayland and clutter
initialization, so that the parts needed for clutter initialization
happens before clutter itself initialization happens, and the rest
happens after. This simplifies the setup a bit, as clutter and Wayland
init now happens as part of the backend initialization.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:35:00 +02:00
Jonas Ådahl
510cbef15a surface-actor: Move out some X11-ism to X11 subclass
On X11 we don't update the texture in certain circumstances, such as if
the surface is a fullscreen unredirect, or doesn't have a Pixmap. On
Wayland we only want to avoid updating the texture if there is no
texture, but as this is handled implicitly by MetashapedTexture, we
don't need to try to emulate the X11-y conditions in the generic layer
and instead just have the implementations handle update processing
themself.

This doesn't have any functional changes, but removes a vfunc from
MetaSurfaceActorClass.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:35:00 +02:00
Jonas Ådahl
9d3e4fd402 clutter/stage-cogl: Use buffer age when view monitor is rotated
We failed to use the buffer age when monitors were rotated, as when they
are, we first composite to an offscreen framebuffer, then later again to
the onscreen. The buffer age checking happened on the offscreen, and an
offscreen being single buffered, they can't possible support buffer
ages.

Instead, move the buffer age check to check the actual onscreen
framebuffer. The offscreen to onscreen painting is still always full
frame, but that will be fixed in a later commit.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
03c65b93e6 region-utils: Make transform util const correct
The input should be const, as it will not be altered.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
346cadeddb renderer/native: Only enable shadowfbs if we can blit
There is no point in enabling shadow buffers if we can't as that'd be
even slower than not having them at all.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:28 +00:00
Jonas Ådahl
f4d9953b9c renderer-native: Move shadow fb construction to the stage view
The stage view will need a more involved approach to shadow buffers, in
order to implement things such double buffered shadow buffers and damage
detection.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:27 +00:00
Jonas Ådahl
6db94a0b77 clutter/stage-view: Add name property
Will be used for logging to identify what view a log entry concerns. For
the native and nested backend this is the name of the output the CRTC is
assigned to drive; for X11 it's just "X11 screen", and for the legacy
"X11 screen" emulation mode of the nested backend it's called "legacy
nested".

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:27 +00:00
Jonas Ådahl
9bf6faf639 output: Add name getter
This will return the name of the connector, e.g. DP-2.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:27 +00:00
Jonas Ådahl
4434a17d08 cogl/dma-buf-handle: Pass more metadata to handle constructor
Could be useful would one want to mmap the dmabuf and deal with its
content manually in CPU space.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1237
2020-05-26 13:54:27 +00:00
Jonas Dreßler
c65f63b647 wayland/actor-surface: Don't notify geometry-changed on mapped changes
There's no reason to notify the surface that its geometry changed when
the visibility of the actor changes. This is only needed to update the
outputs of the surface, so do that directly instead.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1235
2020-05-26 14:54:57 +02:00
Jonas Dreßler
79d981aac9 wayland/actor-surface: Factor in mapped clones in mapped check
We started listening to notify::mapped with commit
5eb5f72434 in order to emit
wl_surface.leave events consistently when a surface gets hidden. This
caused a problem with the ClutterClones used in the overview, since
those temporarily map and unmap the windows for painting, spamming
wl_surface.leave and enter events to all surfaces.

We can easily fix that by also treating mapped clones as mapped, which
means the surface should also be on a wl_output when the overview is
shown.

Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/1141

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1235
2020-05-26 14:54:57 +02:00
Jonas Dreßler
2791f5b466 clutter/actor: Make has_mapped_clones() factor in parent actors
All existing users of clutter_actor_has_mapped_clones() actually want to
know whether the actor is being cloned by a visible clone, it doesn't
matter to them if that clone is attached to an actor somewhere else in
the tree or to the actor itself.

So make clutter_actor_has_mapped_clones() a bit more convenient to use
and also check the clones of the parent-actors in that function.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1235
2020-05-26 14:54:57 +02:00
Jonas Dreßler
e68bb27df2 wayland/actor-surface: Don't listen to notify::position signal
We started listening to "notify::position" on surface actors with commit
08e4cb54. This commit was done to fix a regression from commit cf1edff9,
which forgot to handle some cases like the actual WindowActor and not
the SurfaceActor (which is a child of the WindowActor) moving (that was
fixed by listening to MetaWindows "position-changed" signal). Also that
commit introduced meta_wayland_surface_update_outputs_recursively(),
which updates the outputs of all (sub-)surfaces in case any position
changed and made sure subsurfaces also get their outputs updated in case
the parent actor moved.

Connecting to the "notify::position" signal, which the above commit also
did is now superflous though because position changes will queue a
relayout and the actors allocation will change during the next
allocation cycle, notifying the "allocation" property which we also
listen to.

So save some resources and stop listening to that signal.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1235
2020-05-26 14:52:15 +02:00
Jonas Ådahl
0fbda366e8 native: Return an error if no drm devices are found
Without this, we'll end up segfaulting when trying to log the
non-existing error.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1217
2020-05-22 20:25:06 +00:00
Florian Müllner
106d332c71 backend/xcursor: Support a "blank" cursor type
We don't have enough Xlib code in mutter ...

Joking aside, it can be useful to make the cursor invisible
without hiding it, for example for replacing the actual cursor
with an actor in gnome-shell; the real cursor should still
update the focus surface in that case, and not sneak into
screenshots or -casts.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1244
2020-05-22 14:10:50 +00:00
Jonas Ådahl
c8e12ead08 screen-cast-src: Notify about the stream being closed after dispatch
We're iterating inside the PipeWire loop when detecting PipeWire errors,
and shouldn't destroy the PipeWire objects mid-iteration. Avoid this by
first disabling the stream src (effectively stopping the recording),
then notifying about it being closed in an idle callback. The
notification eventually makes the rest of the screen cast code clean up
the objects, including the src and the associated PipeWire objects, but
will do so outside the PipeWire loop iteration.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1251

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1251
2020-05-22 00:15:48 +00:00
Jonas Ådahl
8a541c08fb stage-x11: Move view management to renderer
In the native backend, the MetaRenderer manages the view by creating one
per CRTC, but until now the MetaStageX11 managed the view for the X11
backend. This caused some issues as it meant meta_renderer_get_views()
not returning anything, and that the view of the X11 screen not being a
MetaRendererView, while in the other backends, all views are.

Fix this by moving the view management responsibility to
MetaRendererX11Cm, and have MetaStageX11 only operate on it via
meta_renderer_x11_cm_*() API. The MetaRendererX11Cm takes care of making
sure the view is always added to the list in the renderer, and turning
X11 screen sizes into "layouts" etc.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1251
2020-05-22 00:15:48 +00:00
Jonas Ådahl
dfed5f6a11 stage-x11: Clean up include macros
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1251
2020-05-22 00:15:48 +00:00
Jonas Ådahl
96dd794fd1 screen-cast-stream-src: Don't throttle if max framerate is 1/0
The max framerate 1/0 means variable without any particular max, so
don't throttle if that was set.

Not doing this would end up with a floating point exception.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1251
2020-05-22 00:15:48 +00:00
Jonas Ådahl
73a436362a renderer: Change 'set_legacy_view()' to 'add_view()'
"Legacy" is a misleading name, it's just how the native backend and the
X11 backend behaves differently. Instead rename it to 'add_view()' and
add the sanity check to the caller.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1251
2020-05-22 00:15:48 +00:00
Jonas Ådahl
7343b8d817 wayland/dma-buf: Make gbm_bo import function better named
It imports a DMA buffer as a gbm_bo, but only if it can be used to scan
it out, so name it import_scanout_gbm_bo().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1261
2020-05-21 23:59:56 +00:00
Jonas Ådahl
dbf47b652e wayland/dma-buf: Handle failing to import scanout DMA buffer
A DMA buffer might not be able to scanout, and in that case the import
with GBM_BO_USE_SCANOUT will fail. Handle that by failing to scanout,
effectively falling back to compositing.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1261
2020-05-21 23:59:56 +00:00
Jonas Dreßler
b97a6e62a3 window: Add a note about the trustworthiness of the client PID
Since PIDs are inherently insecure because they are reused after a
certain amount of processes was started, it's possible the client PID
was spoofed by the client.

So make sure users of the meta_window_get_pid() API are aware of those
issues and add a note to the documentation that the PID can not be
totally trusted.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
Jonas Dreßler
4fac1a4862 window: Cache the client PID
Since the PID of a window can't change as long as the window exists, we
can safely cache it after we got a valid PID once, so do that by adding
a new `window->client_pid` private property.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
Jonas Dreßler
70ba844c3c window: Return pid_t in meta_window_get_pid()
Just as with the last commit, pid_t is compatible with all platforms and
we should use that everywhere, so also make meta_window_get_pid() return
a pid_t.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
Jonas Dreßler
bc0b9f7628 window: Use pid_t for get_client_pid() vfunc
It makes sense to use pid_t when getting the PID since that will work on
all platforms and architectures.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
Jonas Dreßler
c971d6ea1f window: Remove support for _NET_WM_PID
We have the client pid API that works on both Wayland and X11 nowadays,
so the _NET_WM_PID property is no longer needed, remove it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
Jonas Dreßler
dac09a8e23 window: Use client PID for meta_window_get_pid()
The shell uses the PID of windows to map them to apps or to find out
which window/app triggered a dialog. It currently fails to do that in
some situations on Wayland, because meta_window_get_pid() only returns a
valid PID for x11 clients.

So use the client PID instead of the X11-exclusive _NET_WM_PID property
to find out the PID of the process that started the window. We can do
that by simply renaming the already existing
meta_window_get_client_pid() API to meta_window_get_pid() and moving
the old API providing the _NET_WM_PID to meta_window_get_netwm_pid().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
Florian Müllner
a1be7cdbd7 tests/clutter: Don't test BoxLayout's child properties
They are about to become ex-properties.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1265
2020-05-21 15:49:31 +02:00
Florian Müllner
c14ba5937f clutter/tests: Stop using deprecated BoxLayout API
... so that we can remove it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1265
2020-05-21 15:49:31 +02:00
Jonas Dreßler
3c29bf7491 clutter: Remove allocation flags
Since there are now no more allocation flags, we can remove
ClutterAllocationFlags from Clutter.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:31 +00:00
Jonas Dreßler
0a986fc885 clutter/tests: Remove usage of ABSOLUTE_ORIGIN_CHANGED flag
We're going to remove this allocation flag, so stop using in the
interactive test-layout test.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1245
2020-05-20 12:50:31 +00:00
Carlos Garnacho
c8837a8de5 backends: Make uniform checks on remote desktop input dbus methods
They all checked that the remote session service talked with the
correct peer, and some of them did check that there is an associated
screencast session.

Add a new check for the session being started (as it's state is
decoupled with screencast session availability) and move all checks
to a function that is called from all input-oriented DBus methods.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1254

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1258
2020-05-20 10:19:24 +00:00
Carlos Garnacho
283cccbe9f backends: Ensure remote desktop dbus interface state
Ensure that it does receive Start and Stop orderly, and error out
otherwise.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1258
2020-05-20 10:19:24 +00:00
Daniel van Vugt
1d5f9b6917 backend-x11: Reintroduce XInitThreads
It was removed in 3.34 as part of 6ed5d2e2. And we thought that was the
only thread that might exist and use X11. But the top gnome-shell crasher
in 3.36 seems to suggest otherwise.

We don't know what or where the offending thread is, but since:

 1. We used XInitThreads for years already prior to 3.34; and

 2. Extensions or any change to mutter/gnome-shell could conceivably use
    threads to make X calls, directly or indirectly,

it's probably a good idea to reintroduce XInitThreads. The failing assertion
in libx11 is also accompanied by a strong hint:

```
fprintf(stderr, "[xcb] Most likely this is a multi-threaded client " \
                "and XInitThreads has not been called\n");
```

https://bugs.launchpad.net/bugs/1877075

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1252

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1256
2020-05-15 15:30:09 +08:00
Robert Mader
3c068ef135 wayland/surface: Simplify state cleanup after merge
Instead of manually freeing things, use the existing helper function.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1232
2020-05-14 00:34:49 +02:00
Carlos Garnacho
2becb3dd29 wayland: Add support for wayland-protocols primary selection protocol
This protocol was added some time ago. Supporting it fell through the
cracks. Add new data device/source/offer implementations for it,
interoperation between primary selection protocols (and X11 primary
selection for that matter) comes for free.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/943

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1255
2020-05-13 18:27:46 +02:00
Carlos Garnacho
55f5177fe0 build: Build scaffolding for primary-selection wayland protocol
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1255
2020-05-13 18:18:18 +02:00
Carlos Garnacho
037b68ab8e wayland: Rename gtk primary protocol files to "legacy"
We want to make room for the wayland-protocols primary selection
protocol. Rename our private protocol as "legacy".

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1255
2020-05-13 18:18:14 +02:00
Carlos Garnacho
b45d5ef3f5 wayland: Send primary offer to all data devices from the same client
Make the data device track the keyboard focus, and use that list to
forward the primary selection to all data devices from the same
client.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1253
2020-05-13 14:44:55 +00:00
Carlos Garnacho
7e4e371466 wayland: Send clipboard offers to all data devices from the same client
Make the data device track the keyboard focus, and use that list to
forward the clipboard selection to all data devices from the same
client.

This is however not the case of DnD data offers, as the semantics
of multiple in-flight offers is unclear.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1250

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1253
2020-05-13 14:44:55 +00:00
Robert Mader
819f9afa31 shaped-texture: Fix typo in documentation
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1252
2020-05-13 12:12:01 +02:00
Daniel van Vugt
7a0bc5af7f background: Limit mipmap levels to avoid loss of visible detail
When the wallpaper image is larger than the monitor resolution we already
use mipmapping to scale it down smoothly in hardware. We use
`GL_TEXTURE_MIN_FILTER` = `GL_LINEAR_MIPMAP_LINEAR` for the highest quality
scaling that GL can do. However that option is designed for 3D use cases
where the mipmap level is changing over time or space.

Since our wallpaper is not changing distance from us we can improve the
rendering quality even more than `GL_LINEAR_MIPMAP_LINEAR`. To do this we
now set `GL_TEXTURE_MAX_LEVEL` (if available) to limit the mipmap level or
blurriness level to the lowest resolution (highest level) that is still
equal to or higher than the monitor itself. This way we get the benefits
of mipmapping (downscaling in hardware) *and* retain the maximum possible
sharpness for the monitor resolution -- something that
`GL_LINEAR_MIPMAP_LINEAR` alone doesn't do.

Example:

  Monitor is 1920x1080
  Wallpaper photo is 4000x3000
  Mipmaps stored on the GPU are 4000x3000, 2000x1500, 1000x750, ...

  Before: You would see an average of the 2000x1500 and 1000x750 images.
  After:  You will now only see the 2000x1500 image, linearly sampled.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1003
2020-05-13 09:37:31 +00:00
Jonas Dreßler
a51807fc1e tests: Move monitor test functions into common utils
It's very useful to have common functions for easily creating a monitor
test setup for all kinds of tests, so move create_monitor_test_setup()
and check_monitor_configuration() and all the structs those are using to
monitor-test-utils.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1243
2020-05-13 08:38:40 +00:00
Jonas Dreßler
3c35a78769 tests/monitor-store-unit-tests: Rename some structs
We're going to move some structs from monitor-unit-tests.c to
monitor-test-utils.h and some names are currently clashing with the
struct names here, so rename those to be specific to the
MonitorStoreUnitTests.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1243
2020-05-13 08:38:40 +00:00
Jonas Dreßler
ae7cb7a3bf tests/monitor-unit-tests: Check test state outside of common function
check_monitor_test_clients_state() is a function that's only meant to be
used in the monitor-unit-tests, and since we're going to move the
functions for creating MonitorTestSetups into a common file, this
function is going to be in the way of that. So move the checking of the
test client state outside of check_monitor_test_clients_state().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1243
2020-05-13 08:38:39 +00:00
Jonas Dreßler
531b0ab300 tests/monitor-unit-tests: Use TestCaseExpect for checking configuration
Similar to the last commit, allow checking configurations without
passing the whole MonitorTestCase, but instead only the
MonitorTestCaseExpect object.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1243
2020-05-13 08:38:39 +00:00
Jonas Dreßler
7cc604b9e5 tests/monitor-unit-tests: Use TestCaseSetup for building TestSetup
We're going to move the functions for building MonitorTestSetups to the
common monitor-test-utils.c file.

To make building test setups a bit more straightforward in case no
TestCaseExpect is wanted, change create_monitor_test_setup() to take a
MonitorTestCaseSetup instead of a MonitorTestCase as an argument.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1243
2020-05-13 08:38:39 +00:00
Jonas Dreßler
f3a65c9b32 tests/monitor-test-utils: Remove unused function definition
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1243
2020-05-13 08:38:39 +00:00
Robert Mader
dec97a6541 tests/monitor-transform: Also test invert()
Commit e06daa58c3 changed the tested values to use corresponding valid
enum values instead of negative ones. Unfortunately that made one value
become a duplicate of an existing one and also in part defeated the original
intention of checking the implementation of
`meta_output_crtc_to_logical_transform`.

Use `meta_monitor_transform_invert` to fix both shortcomings.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1242
2020-05-13 08:19:42 +00:00
Niels De Graef
cfa2d1abf7 shaped-texture: Add a few explanatory comments
One of the important classes in Mutter's handling of client textures is
the `MetaShapedTexture`. This commit adds a few gtk-doc comments which
explain its purpose, with special attention to the viewport methods.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1210
2020-05-13 07:57:58 +00:00
Jonas Dreßler
d9fb6b5ca2 wayland/surface: Connect to "output-destroyed" in surface_entered_output
Since we're now connecting to one more signal of MetaWaylandOutput, keep
signal connections in one place and move connecting the
"output-destroyed" signal to surface_entered_output() and disconnecting
it to surface_left_output().

This also allows us to use the "outputs_to_destroy_notify_id" as a
simple set and rename it to "outputs".

While at it, also use g_hash_table_destroy() instead of
g_hash_table_unref() since destroy is more clear than unref and does the
same thing in this case.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1230
2020-05-11 18:06:58 +00:00
Jonas Dreßler
696b534570 wayland/surface: Send enter event when a client binds to wl_output late
When hotplugging a new monitor, we recreate all the MetaWaylandOutputs
and need to emit leave events to the surfaces for the old wl_outputs and
enter events for the newly created ones.

There's a race condition though: We might update the monitors a surface
is on (and thus emit enter/leave events for the wl_outputs) before the
Wayland client is registered with the new wl_output (ie. the
bind_output() callback of MetaWaylandOutput was called), which means we
don't send an enter event to the client in surface_entered_output().
Since MetaWaylandSurface now has the MetaWaylandOutput in its outputs
hashtable, it thinks the client has been notified and won't send any
more enter events.

To fix that, make MetaWaylandOutput emit a new signal "output-bound"
when a client bound to the output and make all surfaces which are on
that output listen to the signal. In the signal handler compare the
newly added client to the client the surface belongs to, and if it's the
same one, send an enter event to that client.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1230
2020-05-11 18:06:58 +00:00
Jonas Dreßler
38db4a5a65 wayland/wl-output: Emit "output-destroyed" signal earlier
The "output-destroyed" signal is used for notifying MetaWaylandSurfaces
that an output they are shown just got invalid (for example because a
monitor hotplug happened).

While we delay the destroying of outputs by 10 seconds since commit
1923db97 because of a race-condition, it doesn't make sense to wait 10
seconds until we let surfaces know that an output was destroyed.

So move the emission of the "output-destroyed" signal to
make_output_inert(), which is called before we start the 10 seconds
delay.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1230
2020-05-11 18:06:58 +00:00
Akatsuki
6f62c5b575 core/place: Use work area when centering new window.
use the workarea instead of the logical monitor

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/964
2020-05-09 09:47:42 +00:00
Ting-Wei Lan
d823a54b5d monitor-transform: Don't call abs on non-negative enum
It causes Clang to show a lot of warnings during compilation because it
thinks the abs call is useless.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1234
2020-05-09 01:02:22 +02:00
Robert Mader
e06daa58c3 tests/monitor-transform: Test only valid enums
This test was introduces assuming we'd do interger math outside
of `meta-monitor-transform`. We later agreed to not do that and require
valid enums, but forgot to remove the corresponding test case.

Test the corresponding valid enums instead of negative ones.

See https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1064

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1234
2020-05-09 01:02:22 +02:00
Corentin Noël
bd28581471 monitor-manager: Remove "supports-mirroring" from D-Bus desciption file
This is unused since commit 0a6034ef3a

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1134
2020-05-08 06:50:16 +00:00
Jonas Ådahl
82470cd40d tests/stacking: Add test checking the initial size
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:25 +00:00
Jonas Ådahl
b4972f573c tests/stacking: Add test for checking restored positions
Going maximized -> unmaximized should restore the previous position. The
same for untiling, or going from tiled, to maximized, to floating.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:25 +00:00
Jonas Ådahl
c97c409c50 tests/test-runner: Add 'move' and 'assert_position'
Make it possible for tests to move the windows, and check their
positions.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:25 +00:00
Jonas Ådahl
989e2ccc46 tests/restore-size: Also test that untiling restores correctly
Tiling, then untiling should restore to the size prior to tiling.

Tiling, maximizing, then unmaximizing should also restore to the size
prior to tiling.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:25 +00:00
Jonas Ådahl
e09e62d585 tests/test-runner: Add tile and untile commands
This allows test cases to tile windows to the right or left, and untile,
just as the keyboard shortcuts does.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Jonas Ådahl
033f0d11bf window: Set fall-back tile monitor if not set
When tiling, we want to set the tile monitor. To not have to do this
from the call site, make meta_window_tile() fall back to the current
monitor if nothing set it prior to the call.

This will make it more convenient for test cases to test tiling
behavior.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Jonas Ådahl
668eb318c7 window: Add meta_window_untile()
It does the same as the untile keyboard shortcut does, i.e. handles
going back to saved maximized state. It's split out to be able to be
tested by the stacking tests.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Jonas Ådahl
449cbe153b tests/stacking: Test some maximize fullscreen interaction
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Jonas Ådahl
9b8e5a05f5 tests/test-client: Add 'fullscreen' and 'unfullscreen' commands
This needs some hand holding when calculating the "full" size of the
window, as the titlebar isn't actually shown.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Jonas Ådahl
d14c8cf9a4 tests/stacking: Check that unmaximize to new size works
A client that set a new fallback size while being maximized should not
restore to the one prior to being maximized.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Jonas Ådahl
4571de5772 tests/stacking: Add test to verify we unmaximize correctly
The test tests that (for both X11 and Wayland) that:

 * The client unmaximizes after mapping maximized to a predictable size
 * That the client unmaximizes to the same size after toggling maximize

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Jonas Ådahl
62f449d7d5 tests/test-runner: Add a 'wait_reconfigure' command
This makes sure that a client has properly responded to a configure
event it itself triggered. In practice, this is just two 'wait'
commands, with a 'dispatch' in between, which is needed because a single
one does not reliably include the two way round trip happening when e.g.
responding to a unmaximize configure event triggered by a unmaximize
request.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Jonas Ådahl
476ef76de6 tests/test-runner: Add 'assert_size' command
The 'assert_size' command checks that the size of the window, both
client side and compositor side, corresponds to an expected size set by
the test case.

The size comparison can only be done when the window is using 'csd', in
order for both the client and server to have the same amount of
understanding of the title bar. For ssd, the client cannot know how
large the title bar, thus cannot verify the full window size.

Sizes can be specified to mean the size of the monitor divided by a
number. This is that one can make sure a window is maximized or
fullscreened correctly.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Jonas Ådahl
48de81b63e tests/test-client: Remove shadow from X11 test client CSS style
Gtk is quite buggy and "fluid" in how it handles the shadow margins for
windows under X11. The "size" of the window fluctuate between including and
excluding a shadow margin in a way that causes issues, as there are no
atomic update of any state going on.

In order to avoid running into those particular issues now, lets get rid
of shadows so the margins are always zero, when the client is using the
X11 backend.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Jonas Ådahl
2ee3d5392b tests/test-client: Make 'resize' client command include the titlebar
To get some kind of consistency between what 'resize' means for the
compositor and the client, make the size correspond to the "frame rect"
of the window, i.e. the window geometry in the Wayland case, and the
window size including the titlebar in the X11 case.

This is so that the window size later can be reliably compared both in
the compositor and in the client using the same expected dimensions.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Jonas Ådahl
0f2a33cc9c tests/test-client: Add line breaks to warning messages
When toying with the test client to try to reproduce issues (e.g.
writing commands on stdin to create and manipulate windows), when you
write a command incorrectly you'll get a warning printed to standard
out. The problem, however, is that it doesn't include a line break in
the end, meaning when you type the correct command, it won't be on a new
line.

Fix this minor annoyance by adding line breaks to all warning messages.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Jonas Ådahl
2ce622f057 tests/test-runner: Plumb "resize" command
The test client could already understand the resize command, but they
could not be added to metatests as the command was not properly plumbed
via the test runner. Establish the plumbing for the resize command so
that resize tests can be added.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Jonas Ådahl
76083d76af tests/test-client: Add commands to maximize/unmaximize
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Jonas Ådahl
322b51cded clutter: Remove ClutterAnimation
This removes ClutterAnimation and related tests. ClutterAnimation has
been deprecated for a long time, and replacements exist and are used by
e.g. GNOME Shell since a while back.

This also disables a few relatively unrelated interactive tests, as they
rely on ClutterAnimation to implement some animations they use to
illustrate what they actually test.

As interactive tests currently are more or less untestable due to any
interaction with them crashing, as well as they in practice means
rewriting the tests using non-deprecated animation APIs, they are not
ported right now. To actually port the interactive tests, it needs to be
possible to fist interact with them.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
Jonas Ådahl
b46bc98d44 tests/clutter/conform: Remove left-over ClutterAnimator scripts
ClutterAnimator is long gone; remove some leftover test scripts.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
Jonas Ådahl
e3c0fcf7d5 tests/clutter: Add back redhand_alpha.png and light0.png
They were removed long long ago, but are still used, so add them back to
get the relevant tests usable again.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
Jonas Ådahl
73cb96ddb9 clutter: Remove 'ClutterAlpha'
It was some kind of deprecated interpolation mechanism used in
ClutterAnimation. We're not using it, and have non-deprecated
replacement functionality, so lets drop it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
Jonas Ådahl
a55a286b15 clutter: Remove deprecated 'ClutterState'
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1192
2020-05-07 20:04:07 +00:00
Ting-Wei Lan
18e7b814f2 tests/wayland: Don't test file sealing on the fallback case
When memfd_create isn't used, the file isn't sealed. Therefore, we
should skip test_readonly_seals on the fallback case. This fixes
compilation error on FreeBSD 12, which does not support memfd_create.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1229
2020-05-07 19:39:13 +00:00
Carlos Garnacho
e073076119 backends/native: Unset the correct button codes when a virtual device is destroyed
We were iterating through evcodes, but using API that expects Clutter button
numbers. Instead of transforming those to Clutter numbers to have those translated
back, use the inner seat API that already takes evcodes.

Fixes stuck buttons keys after a virtual device is destroyed while those are
pressed.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1239
2020-05-07 17:01:05 +00:00
Olivier Fourdan
5d58156134 wayland/keyboard: Chain finalize up to the parent class
Finalize the parent class of the Wayland keyboard object.

Suggested-by: Marco Trevisan (Treviño) <mail@3v1n0.net>
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1238
2020-05-07 10:27:32 +00:00
Sergey Zigachev
5201d77b0b keybindings: Use current monitor for move-to-center
Move to center uses all monitors for calculating work area.

This can lead to an unexpected behaviour on some monitor
configurations resulting in current window being split between
monitors. We should move window to the center of the active display.

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1073
2020-05-06 16:03:45 +05:00
Christian Rauch
aedf692e0c backends: move 'input_device' to HAVE_LIBWACOM scope
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1231
2020-05-03 23:35:03 +01:00
Jonas Ådahl
9e41f687a0 remote-access-controller: Make it build with -Dremote_desktop=false
It'll be all no-ops, which is fine, since there is nothing to
inhibit/uninhibit.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1223
2020-04-28 22:00:11 +02:00
Olivier Fourdan
61356caa06 keybindings: Mask out the reserved modifiers mask
When switching layouts, special modifiers bits may be be set for
internal use by Xkb.

As we now ignore a set of modifiers when processing the special
modifiers keys, we ought to also mask out those reserved modifiers
otherwise we would discard the [Super] key after switching layouts
in X11.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1144
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1219
2020-04-27 15:51:47 +00:00
Jonas Ådahl
4300f1f91d remote-access-controller: Allow inhibiting remote access
Inhibiting remote access means any current remote access session is
terminated, and no new ones can be created, until remote access is
uninhibited. The inhibitation is ref counted, meaning there can be more
than one inhibitor.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1212
2020-04-27 14:31:06 +00:00
Laurent Bigonville
d26dc4ae44 compositor: Only include meta-window-actor-wayland.h when building with wayland
https://gitlab.gnome.org/GNOME/mutter/-/issues/1074
2020-04-27 13:28:28 +00:00
Olivier Fourdan
bd45a00fa3 window-actor/x11: Cache the frame bounds
When resizing an X11 window with client side decorations, the shadow is
clipped by the frame bounds so that we don't need to paint the shadow
under the opaque areas covered by the window and its frame.

When the X11 client uses the EMWH synchronization mechanism (like all
gtk-3 based clients), the actual window may not be updated so that the
actual window and it frame may be behind the expected window frame
bounds, which gives the impression of de-synchronized shadows.

To avoid the issue, keep a copy of the frame bounds as a cache and only
update it when the client is not frozen so that the clipping occurs on
the actual content.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1178
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1214
2020-04-27 13:04:38 +02:00
Florian Müllner
43e12dab7b backend: Remove support for META_DUMMY_MONITORS variable
Forcing a dummy monitor manager is unexpected and has been broken
since commit 315a6f43d.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1213
2020-04-23 21:31:46 +02:00
Jonas Ådahl
c4535fdf85 screen-cast: Add RecordArea for screen cast arbitrary area
It takes coordinates in stage coordinate space, and will result in
a screen cast stream consisting of that area, but scaled up by the scale
factor of the view that overlaps with the area and has the highest scale
factor.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1207
2020-04-23 14:45:53 +00:00
Jonas Ådahl
d2c3272eb7 clutter/paint-context: Add 'no-cursors' paint flag
Will be used by the stage to not paint the overlays. We skip all
overlays since overlays are only ever used for pointer cursors when the
hardware cursors cannot or should not be used.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1207
2020-04-23 14:45:53 +00:00
Jonas Ådahl
90c4b6492f stage: Only invoke paint phase callbacks when painting views
These phase callbacks are not intended to be inovked when something
secondary is painting the stage, such as a screen cast stream, or
similar. Thus, only invoke the callbacks when there is a view associated
with the paint context, which will not be the case for offscreen
painting.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1207
2020-04-23 14:45:53 +00:00
Jonas Ådahl
e849667be6 screen-cast-stream-src: Add getter for stride
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1207
2020-04-23 14:45:53 +00:00
Jonas Ådahl
424016d66c stage: Pass paint context in phase callbacks
If there is a paint context available (i.e. for the phases that are
during the actual stage paint), pass it along the callbacks, so that
the callback implementations can change their operation depending on the
paint context state.

This also means we can get the current view from the paint context,
instead of the temporarily used field in the instance struct.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1207
2020-04-23 14:45:53 +00:00
Jonas Ådahl
a4f55d4986 clutter/paint-context: Allow passing redraw clip to offscreen paint context
So that we can mark the redraw clip of the part of the stage we're
painting.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1207
2020-04-23 14:45:53 +00:00
Jonas Ådahl
1b33a5a3a7 clutter/paint-context: Add paint flag
A paint flag affects a paint operation in ways defined by the flags.
Currently no flags are defined, so no semantical changes are defined
yet. Eventually a flag aiming to avoid painting of cursors is going to
be added, so that screen cast streams can decide whether to include a
cursor or not.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1207
2020-04-23 14:45:53 +00:00
Pekka Paalanen
36111270aa kms-impl/simple: Fix page_flip_data ref leak on fallback
If drmModePageFlip() or custom_page_flip_func fails, process_page_flip() was
forgetting to undo the ref taken for that call. This would leak page_flip_data.

The reference counting works like this:
- when created, ref count is 1
- when calling drmModePageFlip, ref count is increased to 2
- new: if flip failed, ref count is decreased back to 1
- if calling schedule_retry_page_flip(), it takes a ref internally
- if calling mode_set_fallback(), it takes a ref internally
- all return FALSE paths have an explicit unref
- return TRUE path has an explicit unref

This issue was found by code inspection and while debugging an unrelated issue
with debug prints sprinkled around. I am not aware of any end-user visible
issues being fixed by this, as the leak is small and probably very rare.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1209
2020-04-23 16:30:22 +03:00
Pekka Paalanen
6e0cfd3e55 kms: Make GSource ready by default
When testing a laptop with intel and DisplayLink devices, attempting to set the
DL output as the only active output resulted in GNOME/Wayland freezing. The
main event loop was running fine, but nothing on screen would get updated once
the DL output become the only one. This patch fixes that issue.

DisplayLink USB 3 devices use an out-of-tree kernel DRM driver called EVDI.
EVDI can sometimes fail drmModePageFlip(). For me, the flip fails reliably when
hotplugging the DL dock and when changing display configuration to DL only.
Mutter has a workaround for failing flips, it just calls drmModeSetCrtc() and
that succeeds.

What does not work reliably in the fallback path is Mutter keeping track of the
pageflip. Since drmModePageFlip() failed, there will not be a pageflip event
coming and instead Mutter queues a callback in its stead. When you have more
than one output, some other output repainting will attempt to swap buffers and
calls wait_for_pending_flips() which has the side-effect of dispatching any
queued flip callbacks. With multiple outputs, you don't get stuck (unless they
all fail the exact same way at the same time?). When you have only one output,
it cannot proceed to repaint and buffer swap because the pageflip is not marked
complete yet. Nothing dispatches the flip callback, leading to the freeze.

The flip callback is intended to be an idle callback, implemented with a
GSource. It is supposed to be called as soon as execution returns to the main
event loop. The setup of the GSource is incomplete, so it will never dispatch.

Fix the GSource setup by setting its ready-time to be always in the past. That
gets it dispatched on the next cycle of the main event loop. This is now the
default behavior for all sources created by meta_kms_add_source_in_impl().
Sources that need a delay continue to do that by overriding the ready-time
explicitly.

An alternative solution could have been to implement GSource prepare and check
callbacks returning TRUE. However, since meta_kms_add_source_in_impl() is used
by flip retry code as well, and that code needs a delay through the ready-time,
I was afraid I might break the flip retry code. Hence I decided to use
ready-time instead.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1209
2020-04-23 16:30:17 +03:00
Carlos Garnacho
5671f0a284 x11: Allow X11 clients to clear the selection
According to the XSetSelectionOwner libX11 documentation:

  [...] If the owner window it has specified in the request is later
  destroyed, the owner of the selection automatically reverts to None,
  but the last-change time is not affected.

This is indeed visible through the selection_timestamp field in
XFixesSelectionNotify events.

Use this to check whether the selection time is recent-ish (thus
likely coming from an explicit XSetSelectionOwner request) and honor
the client intent by setting a "NULL" owner. If the selection time
is too old, it's definitely an indication of the owner client being
closed, the scenario where we do want the clipboard manager to take
over.

This fixes two usecases:
- X11 LibreOffice / WPS clear the selection each time before copying
  its own content. Mutter's clipboard manager would see each of those
  as a hint to take over, competing with the client over selection
  ownership. This would simply no longer happen
- Password managers may want to clear the selection, which would be
  frustrated by our clipboard manager.

There's a slight window of opportunity for the heuristics to fail
though, if a X11 client sets the selection and closes within 50ms, we
would miss the clipboard manager taking over.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1206
2020-04-21 21:32:53 +00:00
Carlos Garnacho
a7e63bea6c x11: Generalize x11 selection owner checks
Shuffle things so the x11 selection can check the current owner directly,
instead of its type.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1206
2020-04-21 21:32:53 +00:00
Carlos Garnacho
94b3c334e5 x11: Clear X11 selection source after unsetting owner
The X11 selection source was being preserved after unsetting its
ownership. This is no leak as it would be eventually replaced by
another source, or destroyed on finalize. But it's pointless to
keep it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1206
2020-04-21 21:32:53 +00:00
Jonas Dreßler
efb0addb62 tests/wayland: Add a test for meta-anonymous-file
Test the two modes of MetaAnonymousFile, MAPMODE_SHARED and
MAPMODE_PRIVATE and make sure they don't leak data to other FDs when
writing to an FD provided by `meta_anonymous_file_get_fd` even though
the data of both FDs is residing in the same chunk of memory.

We do all the reading tests using mmap instead of read() since using
read() on shared FDs is going to move the read cursor of the fd. That
means using read() once on the shared FD returned by
meta_anonymous_file_get_fd() in MAPMODE_PRIVATE breaks every subsequent
read() call.

Also test the fallback code of MetaAnonymousFile in case `memfd_create`
isn't used for the same issues.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1012
2020-04-21 17:52:08 +02:00
Jonas Dreßler
988da215c8 wayland/keyboard: Use MetaAnonymousFile to share keymap files
Since protocol version 7 clients must use MAP_PRIVATE to map the keymap
fd, that means we can use memfd_create() to create the fd by using
meta_anonymous_file_open_fd() with META_ANONYMOUS_FILE_MAPMODE_PRIVATE,
for older versions we use META_ANONYMOUS_FILE_MAPMODE_SHARED to be
compatibile with MAP_SHARED.

Pretty much all of this code was written for Weston by Sebastian Wick,
see https://gitlab.freedesktop.org/wayland/weston/merge_requests/240.

Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/1734

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1012
2020-04-21 17:52:08 +02:00
Jonas Dreßler
551a57ed7f Add read-only anonymous file abstraction MetaAnonymousFile
Add MetaAnonymousFile, an abstraction around anonymous read-only files.
Files can be created by calling meta_anonymous_file_new(), passing the
data of the file. Subsequent calls to meta_anonymous_file_open_fd()
return a fd that's ready to be sent over the socket.

When mapmode is META_ANONYMOUS_FILE_MAPMODE_PRIVATE the fd is only
guaranteed to be mmap-able readonly with MAP_PRIVATE but does not
require duplicating the file for each resource when memfd_create is
available. META_ANONYMOUS_FILE_MAPMODE_SHARED may be used when the
client must be able to map the file with MAP_SHARED but it also means
that the file has to be duplicated even when memfd_create is available.

Pretty much all of this code was written for weston by Sebastian Wick,
see https://gitlab.freedesktop.org/wayland/weston/merge_requests/240.

Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1012
2020-04-21 17:52:08 +02:00
Carlos Garnacho
b7366b5b53 wayland: Drop unused struct variable
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1193
2020-04-17 00:51:00 +02:00
Carlos Garnacho
5e8d8b9ade wayland: Move the primary data device manager to its own file
Instead of having everything clumped at MetaWaylandDataManager,
split the primary selection to its own struct. This manager is
handled separately from wl_data_device_manager and other selection
managers, so they would be able to interoperate between them, even.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1193
2020-04-17 00:50:57 +02:00
Carlos Garnacho
4726f3d5d3 wayland: Move primary data offers to their own file
Following the MetaWaylandDataOffer split.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1193
2020-04-17 00:46:23 +02:00
Carlos Garnacho
91ef7515de wayland: Move MetaWaylandDataOffer to its own file
This is still an openly defined struct, as we will need accessed
by "subclasses". Same principle applies than with the
MetaWaylandDataSource refactor, this is not meant to introduce
functional changes, so just go with it.

On the bright side, the interactions are now clearer, so it could
be made saner in the future.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1193
2020-04-17 00:46:23 +02:00
Carlos Garnacho
317f6c0910 wayland: Move MetaWaylandDataSourcePrimary to its own file
Following the MetaWaylandDataSource split, this goes next.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1193
2020-04-17 00:46:23 +02:00
Carlos Garnacho
6a3d521466 wayland: Split MetaWaylandDataSource into a separate file
The split wasn't 100% clean, and some extra private API had to be
added for it (but well, looking at the API, it's already evident
there's a cleanup/streamlining task due). This is meant to be a
refactor with no functional changes, so just go with it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1193
2020-04-17 00:46:21 +02:00
Carlos Garnacho
1363246d44 wayland: Rely on MetaSelection::owner-changed for .selection event emission
We already have a signal callback that translates selection ownership changes to
data_device/primary .selection events. Given both will be run when a data source
is being replaced, and this event emission being deleted is kinda short sighted
in that in only knows about Wayland, rely entirely on MetaSelection::owner-changed
emission.

Fixes spurious .selection(null) events being sent when a compositor-local source
takes over the selection without the focus changing (eg. screenshot to clipboard).

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1160

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1204
2020-04-16 22:25:00 +00:00
Carlos Garnacho
0b6560fac4 wayland: Do not cancel old data source when setting new selection
This is taken care already by the MetaSelection machinery, by
deactivating the previous selection source when setting a new one.
That works across X11 and internal selection sources. This
only works when replacing one wayland source with another, and
actually results in doubly .cancelled events due to the other
paths.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1177

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1203
2020-04-16 19:27:51 +00:00
Carlos Garnacho
d4c3870286 wayland: Shuffle wl_data_source.cancelled version checks on DnD
We are meant to send a .cancelled event after the drop is performed
in certain situations, but only for version>3 clients. Since this is
all version 3 business, only set the drop_performed flag for v3
clients. This drops the need to perform version checks at the time
of cancelling (which is present for other usecases in v1).

Fixes emission of wl_data_source.cancelled for v1 clients.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1177

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1203
2020-04-16 19:27:51 +00:00
Carlos Garnacho
4bdf9a1e70 core: Cater for reading selection in chunks
For the cases where we read a fixed size from the selection (eg. imposing
limits for the clipboard manager), g_input_stream_read_bytes_async() might
not read up to this given size if the other side is spoonfeeding it content.

Cater for multiple read/write cycles here, until (maximum) transfer size is
reached.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
1909977a67 x11: Do not trust there is task in error paths
Flushing the X11 selection output stream may happen synchronously or
implicitly, in which case there is not a task to complete. Check there
is actually a task before returning errors. We additionally set the
pipe_error flag, so future operations will fail with an error, albeit
with a more generic message.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
655a783891 x11: Don't stall on write_async()
If a write_async() comes up while we are flushing on the background,
the task will be queued, but not deemed a reason on itself to keep
flushing (and finish the task) after a property delete event.

To fix this, do not ever queue up write_async tasks (this leaves
priv->pending_task only used for flush(), so the "flush to end"
behavior in the background is consistent). We only start a
background flush if there's reasons to do it, but the tasks are
immediately finished.

All data will still be ensured to be transfered on flush/close,
this makes the caller in this situation still able to reach to it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
a4596becc4 x11: Fix iterative INCR property checks
It does not make sense to check for the stream not being closed,
this might happen multiple times during the lifetime of the stream
for a single transfer. We want to notify the INCR transfer just
once.

Check for the explicit conditions that we want, that the remaining
data is bigger than we can transfer at once, and that we are not
yet within the INCR transfer.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
7015bb3efd x11: Don't exceed transfer size in INCR chunks
The stream automatically flushes after data size exceeds the
size we deem for INCR chunks, but we still try to copy it all.
Actually limit the data we copy, and leave the rest for future
INCR chunks.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
d2c762cc66 x11: Don't invariably queue a pending delete request
We don't need doing this roundtrip for non-INCR transfers.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
04d429b743 x11: Finish INCR transfers properly
INCR transfers are mandated to finish with a final 0-size XChangeProperty
roundtrip after the final data chunk. Actually honor this and ensure we
iterate just once more for this.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
0b21dcfe08 x11: Wait till data is flushed before notifying on the pending task
It does not make sense to notify flushes mid-transfer. We should wait
till the data is actually finished before notifying on the pending
task.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
7c939d78c2 x11: Only send SelectionNotify on first INCR chunk
This should only be sent if the selection can be sent at once, or
if we are right about to notify on the first chunk of an INCR
transfer.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
8a2b82897d x11: Ensure flush() Flushes all output stream data
This seemed to work under the assumption that a flush() call can
only result in one INCR roundtrip. This is evidently not true, so
we should hold things off until all pending data is actually flushed.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
e95c365cf0 x11: Unset pending flush flag right before notifying on task
Together with some other state. We can do this altogether on task
notification, instead of lost somewhere in this function flow.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
a32cb7133b x11: Intern INCR atom
We want to use it, despite it not existing previously.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
967966cdee x11: Flag flushes despite having less than the element size
If say we want 32bit data, but have 2 bytes stored, we would simply
ignore flush requests. Allow (and don't clear) the needs_flush flag
if we have less than the element size accumulated.

Instead handle this in can_flush(), so it's triggered whenever we
have enough data to fill 1 element, or if the stream is closing
(seems a broken situation, but triggered by the caller).

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Carlos Garnacho
06d67b6abf x11: XMaxRequestSize returns 4-byte units
XMaxRequestSize/XMaxExtendedRequestSize are documented to return
the maximum size in 4-byte units, whereas we are comparing this
to byte lenghts. We can afford 4x the data here.

Since I don't know the payload size of the XChangeProperty request,
be generous and allot 400 bytes for it, we have some to spare.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Marco Trevisan (Treviño)
f15ce01e2b monitor-unit-tests: Ensure configuration is preserved in laptop with closed lid
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1200
2020-04-16 15:14:03 +00:00
Marco Trevisan (Treviño)
e48516679c monitor-config-manager: Fallback to closed laptop lid configuration
When closing the lid of a laptop, we reconfigure all the monitors in order
to update the CRTCs and (if enabled) the global UI scaling factor.

To do this, we try first to reuse the current configuration for the usable
monitors, but if we have only monitor enabled and this one is on the laptop
lid we just end up creating a new configuration where the primary monitor is
the laptop one (as per find_primary_monitor() in MetaMonitorConfigManager),
but ignoring the user parameters.

In case the user selected a different resolution / scaling compared to the
default one, while the laptop lid is closed we might change the monitors
layout, causing applications to rescale or reposition.

To avoid this, when creating the monitors configuration from the current
current state, in case we have only one monitor available and that one is
the laptop panel, let's just reuse this configuration.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1200
2020-04-16 15:14:03 +00:00
Jonas Ådahl
65a6c4c361 compositor: Add support for direct scanout of Wayland surfaces
Try to bypass compositing if there is a fullscreen toplevel window with
a buffer compatible with the primary plane of the monitor it is
fullscreen on. Only non-mirrored is currently supported; as well as
fullscreened on a single monitor. It should be possible to extend with
more cases, but this starts small.

It does this by introducing a new MetaCompositor sub type
MetaCompositorNative specific to the native backend, which derives from
MetaCompositorServer, containing functionality only relevant for when
running on top of the native backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
b51c468c0f later: Listen to MetaCompositor signal instead of clutter
We need to coordinate with MetaCompositor during pre-paint so that we
have control over whether MetaLater callbacks happen first, or the
MetaCompositor pre-paint logic.

In order to do so, make MetaLater listen to a new signal "pre-paint" on
MetaCompositor, that is called MetaCompositors own pre-paint handling.

This fixes an issue where the top window actor was calculated after the
MetaCompositor pre-paint handling, meaning the top actor being painted
was out-of-date.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
2e7d02f1ce later: Make MetaCompositor the owner of the MetaLaters state
Since the order of destruction during MetaDisplay tear down is a bit
unordered, there are pieces that try to destruct its compositing
dependent pieces (i.e. queued MetaLater callbacks) after MetaCompositor
has been cleaned up, meaning we need to put some slightly awkward NULL
checks to avoid crashing.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
dc4fe780f7 display: Initialize MetaCompositor in two steps
MetaCompositor is the place in mutter that manages the higher level
state of compositing, such as handling what happens before and after
paint. In order for other units that depend on having a compositor
instance active, but should be initialized before the X11 implementation
of MetaCompositor registers as a X11 compositing manager, split the
initialization of compositing into two steps:

 1) Instantiate the object - only construct the instance, making it
    possible for users to start listening to signals etc
 2) Manage - this e.g. establishes the compositor as the X11 compositing
    manager and similar things.

This will enable us to put compositing dependent scattered global
variables into a MetaCompositor owned object.

For now, compositor management is internally done by calling a new
`meta_compositor_do_manage()`, as right now we can't change the API of
`meta_compositor_manage()` as it is public. For the next version, manual
management of compositing will removed from the public API, and only
managed internally.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
d682cdb078 util: Move MetaLater to its own file
While at it, fix some style inconsistencies, for now use a single
singleton struct instead of multiple static variables, and
other non-functional cleanups. Semantically, there is no changes
introduced.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
ff7a42b8bc wayland: Add API to acquire a CoglScanout from a surface
This will check whether the current backing buffer is compatible with
the primary plane of the passed CoglOnscreen. Since this will extend the
time before a buffer is released, the MetaWaylandBufferRef is swapped
and orphaned if a new buffer is committed before the previous one was
released. It'll eventually be released, usually by the next page flip
callback.

Currently implemented for EGLImage and DMA-BUF buffer types.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
4b1805c306 wayland/dma-buf: Handle getting dma-buf from detached buffer handle
We might still have a MetaWaylandBuffer for a wl_buffer that was
destroyed. Handle trying to fetch the MetaWaylandDmaBufBuffer from such
a buffer gracefully.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
03c00e4944 wayland/dma-buf: Minor style fix
Indentation was off.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
cb05b16414 wayland/dma-buf: Don't advertise modifier support by default
Advertising support for modifiers means we will most likely not not be
able to scan out client buffers directly, meaning it just as likely that
we won't be able to scan out even fullscreen windows without atomic KMS.

When we have atomic support, we should advertise support for modifiers
if atomic is used to drive the CRTCs, as we by then can check whether we
can scan out directly, place in an overlay plane, etc.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
b9fe9c736a onscreen/native: Add API to check whether buffer is scanout compatible
While this is fairly incomplete, as to check things fully we need to use
TEST_ONLY in atomic to try out a complete assignment on the device, but
this works well enough for legacy non-modifier cases.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
3dd8861fbf renderer/native: Add API to get primary GPU
Will be used when acquiring scanouts from Wayland buffers.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
3da8c1bfdc cogl/onscreen: Add API to scanout a buffer directly
Instead of always swapping buffers and flipping the back buffer, make it
possible to scan out a provided buffer directly without swapping any EGL
buffers.

A buffer is passed as an object implementing the empty CoglScanout
interface. It is only possible to do this in the native backend; and the
interface is implemented by MetaDrmBufferGbm. When directly scanned out,
instead of calling gbm_surface_lock_front_buffer() to get the gbm_bo and
fbid, get it directly from the MetaDrmBufferGbm, and use that to create
the page flip KMS update.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:15 +02:00
Jonas Ådahl
f8ee974628 wayland/buffer-ref: Add helpers for use count tracking
https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 14:08:19 +02:00
Jonas Ådahl
f36120757f wayland: Make MetaWaylandBufferRef reference counted
So that we can have a more dynamic ownership.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 14:08:19 +02:00
Jonas Ådahl
5dad87cfb9 surface-actor-x11: Move window related unredirect logic to MetaWindowX11
Better to have the relevant object figure out whether it is a good
position to be unredirectable other than the actor, which should be
responsible for being composited.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 14:08:19 +02:00
Jonas Ådahl
0f8f607e4c window/x11: Use G_DECLARE_DERIVABLE_TYPE()
This removes the MetaWindowX11::priv pointer. It is replaced with a
meta_window_x11_get_private() helper function, and another method to get
the client rect without going through MetaWindowX11Private.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 14:08:19 +02:00
Jonas Ådahl
282aada13a drm-buffer/gbm: Support both surface and standalone buffers
Surface buffers are created with meta_drm_buffer_new_acquire(), taking a
gbm_surface acquiring the gbm itself, and meta_drm_buffer_new_take()
that takes over ownership of a passed gbm_bo.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 14:08:19 +02:00
Jonas Ådahl
47002bf0cd wayland/surface: Put buffer reference on heap
Currently a buffer use count always reaches zero before it is replaced.
This is due to the fact that at the point a new buffer is attached, the
last potential user releases it (the stage) since the currently
displayed frame has a composited copy of the buffer.

This may however change, if a buffer is scanned out directly, meaning it
should not be released until the page flip callback is invoked.

Prepare for this by making the buffer reference a heap allocated struct,
enabling us to keep a pointer to it longer than the buffer is attached.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 10:43:34 +02:00
Jonas Ådahl
3d47c7edc1 cursor-renderer-native: Take CRTC transform into account
The CRTC level transform (not necessarily the hw transform) must be
taken into account when calculating the position of the CRTC in the
stage coordinate space, when placing the hw cursor, otherwise we'll
place the cursor as if the monitor was not rotated.

This wasn't a problem in the past, as with rotation, we always used the
OpenGL cursor, so the issue newer showed.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1199
2020-04-15 15:29:55 +00:00
Jonas Ådahl
bc350f37f5 renderer-native: Use CRTC layout in stage view
The port to per CRTC views was incomplete; we still used the logical
monitor layout as the stage view layout, while still using one view per
CRTC.

This worked fine for most cases, e.g. regular monitors, tiled or
non-tiled, transformed or non-transformed. Where it broke, however, was
when a monitor consists of multiple CRTCs. We already have the layout a
CRTC corresponds to on the stage kept with the CRTC metadata, so use
this directly.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1170

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1199`
2020-04-15 15:29:55 +00:00
Jonas Ådahl
b55e2e1df9 tests/monitor-unit-tests: Test non-hw-transform rotated tiled monitors
Should affect the assigned transform, but not the layout, as that is the
layout on the stage, not the coordinates in any buffer.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1199
2020-04-15 15:29:55 +00:00
Jonas Ådahl
43baf643d4 monitor-config-manager: Only use crtc transform for assignment
The CRTC level transform (i.e. not necessarily the one set on the
hardware) is what is relevant for calculating the layout the CRTC will
have on the stage, so only use the one that can be handled by the
hardware for the CRTC assignment.

This makes the CRTC layout valid for tiled monitors.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1199
2020-04-15 15:29:55 +00:00
Jonas Ådahl
21b8ae10b8 monitor: Fix tile coordinate calculation
Previously the tile coordinate was used to offset a CRTC scanout
coordinate within a larger framebuffer. Since 3.36 we're always
scanning out from (0, 0) as we always have one framebuffer per CRTC; we
instead use the tile coordinate to calculate the coordinate the tile has
in the stage view. Adapt calculation to fulfil this promise instead of
the old one.

This also corrects the tiled custom monitor test case.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1199
2020-04-15 15:29:55 +00:00
Thomas Hindoe Paaboel Andersen
d0ef660ff6 clutter: fix memleak in test error path
If clutter_init fails then we will not free state.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1195
2020-04-12 21:40:20 +00:00
Marco Trevisan (Treviño)
506e06589b test-utils: Only initialize client when we're returning it
test_client_new might return early if conditions are not met, leaving some
allocated data around without freeing it.

Since we're not using the client before, there's no need to initialize it early
and just initialize it when it's going to be returned.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1195
2020-04-12 21:40:20 +00:00
Marco Trevisan (Treviño)
1d75d5aa2f group: Free group if returning early
If we get an error when fetching the window attributes, the group isn't ever
free'd, so use an autopointer instead, releasing the stolen one.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1195
2020-04-12 21:40:20 +00:00
Phillip Wood
3e967d731a input-settings: fix device list iteration
Dereference the loop variable rather than the original list head. This
fixes a regression introduced in 4413b86a3 ("backends: Replace
ClutterDeviceManager usage in favor of ClutterSeat", 2019-10-04) which
broke button scrolling with trackballs.

Closes:https://gitlab.gnome.org/GNOME/mutter/-/issues/1120
2020-04-11 18:59:14 +01:00
Carlos Garnacho
167fd07e01 x11: Forward current selection state when initializing X11 selections
Most visible with xwayland-on-demand, at the time of setting things up
for X11 selections, we don't forward the current state. This makes the
first started X11 app oblivious to eg. the current clipboard.

Syncing selections up at the time of initializing the X11 selection
stuff ensures that doesn't happen.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1186
2020-04-09 21:30:05 +00:00
Carlos Garnacho
fbd6366edd core: Add private function to get the current selection owner
This is a bit untidy to expose, however may be necessary internally.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1186
2020-04-09 21:30:05 +00:00
Jonas Dreßler
eb6e1f694a clutter: Remove drag and drop actions
We aren't using those actions in the shell or anywhere in Mutter, our
DnD support is implemented on the shell side.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/789
2020-04-08 20:21:31 +00:00
Olivier Fourdan
5b30a52bbd wayland: preserve xkb_state on VT switch
On VT switch, the devices are removed, which means for Wayland disabling
the keyboard.

When the keyboard is disabled, the associated `xkb_state` is freed and
recreated whenever the keyboard is re-enabled when switching back to the
compositor VT.

That means the `xkb_state` for Wayland is lost whereas the same for
clutter is kept, which causes to a discrepancy with locked modifiers on
VT switch.

To avoid that issue, preserve the XKB info only to dispose it when the
keyboard is eventually finalized.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/344
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1185
2020-04-08 13:16:25 +00:00
Carlos Garnacho
a5294ce55f cogl: Remove CoglPath and the tesselator
This was barely used, and doesn't represent the way we want to
do 2D rendering.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1126
2020-04-08 11:38:48 +02:00
Carlos Garnacho
ba3417667f wayland/xdnd: Add error traps around Xdnd* IPC
Make all of them spew criticals, except for XdndLeave as it's feasible
to expect the window we are sending the event to did disappear in the
way (eg. if the window is destroyed while the DnD operation is ongoing
and the pointer is over the window).

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2590

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1184
2020-04-07 18:08:03 +00:00
Jonas Troeger
50fa002a19 backends/native: Translate coordinates of absolute motion events
The motion events of tablets for example need to be mapped on the
selected screen area if the input device is configured to use only a
part of the active logical monitor.
To achieve this behavior each motion event is transformed using the
transformation matrix set for the input device.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1118
2020-04-07 17:50:11 +00:00
Carlos Garnacho
f0718c7d95 backends/x11: Fix access to WacomDevice
At some point we crossed the streams... In a short timespan we had
1f00aba92c merged, pushing WacomDevice to a common parent object,
and dcaa45fc0c implementing device grouping for X11.

The latter did not rely on the former, and just happened to
merge/compile without issues, but would promptly trigger a crash
whenever the API would be used.

Drop all traces of the WacomDevice internal to MetaInputDeviceX11.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1183
2020-04-07 17:36:13 +00:00
Jonas Ådahl
8df3b21a51 window: Check aliveness a bit less aggressively
Currently we check whether a window is alive everytime it's focused.
This means that an application that doesn't respond to the check-alive
event during startup always showing the "application froze" dialog,
without the user ever trying to interact with it.

An example where this tends to to happen is with games, and for this
particular scenario, it's purely an annoyance, as I never tried to
interact with the game window in the first place, so I don't care that
it's not responding - it's loading.

To avoid these unnecessary particular "app-is-frozen" popups, remove the
alive check from the focus function, and instead move it back to the
"meta_window_activate_full()" call. To also trigger it slightly more
often, also add it to the path that triggers the window focus when a
user actively clicks on the window.

This means that we currently check whether a window is alive on:

  * Any time the window is activated. This means e.g. alt-tab or
    selecting the window in the overview.
  * The user clicks on the window.

Note that the second only works for an already focused window on
Wayland, as on X11, we don't refocus it. This particular case isn't
changed with this commit, as we didn't call meta_window_focus() to begin
with here.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1182
2020-04-07 10:46:01 +02:00
Jonas Ådahl
6f0e5b0b56 clutter/stage: Remove 'accept-focus' property
Also unused, only valid on X11. Meant for applications. Lets drop it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1175
2020-04-06 14:08:26 +00:00
Jonas Ådahl
fe27a6ea3b clutter/stage: Remove hide/show cursor API
This removes it from the stage window API too. It's managed by the
mutter backends, so we don't need the stage window to do it as well.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1175
2020-04-06 14:08:25 +00:00
Jonas Ådahl
1301770dcb clutter/stage: Remove 'alpha' property
Was unused except for in a test, lets remove it. Half transparent
monitors will probably have to be dealt with some other way anyway.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1175
2020-04-06 14:08:25 +00:00
Jonas Ådahl
a6f94696e2 window-actor: Set viewport when blitting to screencast fb
This fixes an issue where a non-maximized screen casted window would be
stretched to fill the whole screen cast stream, instead of just the crop
that corresponds to the current window size.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1174
2020-04-03 16:14:02 +00:00
Christian Rauch
a8f6cada88 x11: fix compilation if 'libwacom=false'
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1168
2020-04-01 15:23:43 +01:00
Georges Basile Stavracas Neto
7f488e3e1d tests/actor-pick: Allocate actor before picking
Picking now only happens on allocated actors, but the
callback in the actor-pick test is not waiting for the
stage to run an allocation cycle. Ideally, we'd wait
for this cycle, but for now, forcing an allocation works
as well.

Allocate the overlay actor in the actor-pick test.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1169
2020-03-31 19:10:55 -03:00
Georges Basile Stavracas Neto
059d2144b2 tests/actor-pick: Remove tabs
They're evil.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1169
2020-03-31 19:10:10 -03:00
Robert Mader
09a6031c69 window-actor: Force full actor geometry sync when mapping
Normally we bail out in `sync_actor_geometry()`. The comment there
states:
```
Normally we want freezing a window to also freeze its position; this allows
windows to atomically move and resize together, either under app control,
or because the user is resizing from the left/top. But on initial placement
we need to assign a position, since immediately after the window
is shown, the map effect will go into effect and prevent further geometry
updates.
```

The signal for the initial sync originates in `MetaWindow` though and predates
`xdg_toplevel_set_maximized`, which again calls `meta_window_force_placement`,
triggering the signal too early. As a result, Wayland clients that start up
maximized have a wrong map animation, starting in the top-left corner.

In order to fix this without changing big parts of the geometry logic and risking
regressions, force the initial sync again before mapping.

Solution suggested by Jonas Ådahl.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1164
2020-03-30 15:59:48 +00:00
Robert Mader
dbe919ef92 wayland/surface: Check for surface role in meta_wayland_surface_get_window()
The function can get called without valid surface role, e.g. from
`zwp_xwayland_keyboard_grab_manager_grab()`.

Debugged by @piegamesde

Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/1147
2020-03-30 16:08:13 +02:00
Christian Rauch
2907ee93cc wayland/pointer-constraints: Fix typo
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1163
2020-03-29 19:48:33 +01:00
Carlos Garnacho
bb5ea0580f wayland: Translate delete-surrounding properly to protocols
IBusInputContext/ClutterInputFocus/GtkIMContext all go for offset+len
for their ::delete-surrounding signals, with offset being a signed int
(neg. to delete towards left of selection, pos. to delete towards right
of selection) and len being an unsigned int from the offset (and
presumably, skipping the current selection).

The text-input protocols however pass in this event two unsigned integers,
one being the length of text to delete towards the left of the selection,
and another the length of text to delete towards the right of the selection.

To translate properly these semantics, positive offsets shouldn't account
for before_length, and negative offset+len shouldn't account for after_length.
The offset/length approach may of course represent deletions that are
detached from the current cursor/selection, we simply delete the whole range
from the cursor/selection positions then.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/517
2020-03-29 11:37:27 +00:00
Takao Fujiwara
2cfdbbd730 clutter: Enable negative offsets in delete surrounding text
The input method can assign a negative value to
clutter_input_method_delete_surrounding() to move the cursor to the left.
But Wayland protocol accepts positive values in delete_surrounding() and
GTK converts the values to the negative ones in
text_input_delete_surrounding_text_apply().

https://gitlab.gnome.org/GNOME/mutter/issues/539
2020-03-29 11:37:27 +00:00
Jonas Dreßler
9f31e7252c backends/native: Release virtual buttons on dispose instead of finalize
GObject recommends to break references to other objects on dispose
instead of finalize, also we want to release the pressed virtual buttons
as early as possible if we know the object is getting destroyed.

So release the pressed buttons and unref our virtual
MetaInputDeviceNative when the dispose vfunc is called, which also
allows us to release the buttons immediately from javascript instead of
waiting for the garbage collector by calling run_dispose() on the
object.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1157
2020-03-28 16:55:59 +00:00
Georges Basile Stavracas Neto
fed5f4d9aa window-actor: Inhibit culling when blitting to screencast
This allows us to screencast any window continuously, even
without it being visible. Because it's still being painted,
clients continue to receive frame callbacks, and people
are happy again.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129
2020-03-27 23:29:58 +00:00
Georges Basile Stavracas Neto
f6700f19a7 window-stream-src: Finish framebuffer after blitting
Just like what's done for monitor screencasting. Unfortunately, there's
no mechanism to share fences with PipeWire clients yet, which forces
us to guarantee that a frame is completed after blitting.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129
2020-03-27 23:29:58 +00:00
Georges Basile Stavracas Neto
ea34915df3 window-stream-src: Implement cursor blitting
A regression compared to the old code, we're not drawing the cursor
when on EMBEDDED mode.

Blit the cursor to the screencast framebuffer when on EMBEDDED mode.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129
2020-03-27 23:29:58 +00:00
Georges Basile Stavracas Neto
37742c5cde window-stream-src: Ensure initial frame is recorded
MetaScreenCastWindowStreamSrc connects to the "damaged" signal of
MetaWindowActor. This signal is not exactly tied to the paint cycle
of the stage, and a damage may take quite a while to arrive when
a client doesn't want to draw anything. For that reason, the window
screencast can start empty, waiting for a damage to arrive.

Ensure at least one frame is recorded when enabling the window stream.

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129
2020-03-27 23:29:57 +00:00
Georges Basile Stavracas Neto
cdd27d0e53 window-actor: Clip before translate when blitting
cogl_framebuffer_push_rectangle_clip() acts on the current modelview
matrix. That means the result of clipping then translating will be
different of the result of translating then clipping.

What we want for window screencasting is the former, not the latter.
Move the translation code (and associated) to after clipping.

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129
2020-03-27 23:29:57 +00:00
Georges Basile Stavracas Neto
82778f72a4 window-actor: Shuffle some lines around
Move the CoglColor assignment right above the cogl_framebuffer_clear() call,
and let these wonderful partners together to delight us with an easier to
read code.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1129
2020-03-27 23:29:57 +00:00
Hans de Goede
da600b8400 cursor-renderer-native: Take panel-orientation into account for sprite transform
When calculating the transform we should apply to the cursor sprite
before uploading it to the cursor plane, we must also take into
account non upright mounted LCD panels.

Otherwise the cursor ends up 90 degrees rotated on devices where the
LCD panel is mounted 90 degrees rotated in its enclosure.

This commit fixes this by calling meta_monitor_logical_to_crtc_transform
in get_common_crtc_sprite_transform_for_logical_monitors to adjust the
transform for each Monitor in the LogicalMonitor.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1123

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1153
2020-03-27 15:10:35 +00:00
Robert Mader
6aa546145f core: Demote tiff and bmp image formats in the clipboard manager
Support for them appears to be way less common than e.g. png, which is
currently the preferred format from Firefox, Chromium, Libreoffice and others.
Adopt to that fact.

As a side effect, this works around a bug observed when copying images in
Firefox on Wayland.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1141
2020-03-27 14:37:29 +00:00
Jonas Ådahl
ac01e69a67 window-wayland: Don't use grab op for some other window when resizing
When resizing a window interactively, we'll set a grab operation and a
grab window, among other things. If we're resizing (including setting
initial size, i.e. mapping) another window, that didn't change position,
don't use the gravity of the grab operation when resizing our own
window.

This fixes an issue with jumpy popup position when moving a previously
mapped gtk popover.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/999
2020-03-26 17:44:09 +01:00
Jonas Ådahl
a68e6972a2 cursor-renderer-native: Set cursor hotspot metadata on plane assignment
This triggers the paths in the legacy KMS backend to use
drmModeSetCursor2(), making virtual machines using "seamless mouse mode"
behave correctly again.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1136
2020-03-26 16:18:28 +00:00
Jonas Ådahl
55cf1c1496 kms/plane-assignment: Add API to set cursor hotspot metadata
The transactional KMS API has been modelled after atomic KMS. Atomic KMS
currently doesn't support forwarding cursor hotspot metadata, thus it
was left out of the transactional KMS API having the user set the simply
create a plane assigment with the cursor sprite assigned to a cursor
plane using regular coordinates.

This, however, proved to be inadequate for virtual machines using
"seamless mouse mode" where they rely on the cursor position to
correspond to the actual cursor position of the virtual machine, not the
cursor plane. In effect, this caused cursor positions to look "shifted".

Fix this by adding back the hotspot metadata, right now as a optional
field to the plane assignment. In the legacy KMS implementation, this is
translated into drmModeSetCursor2() just as before, while still falling
back to drmModeSetCursor() with the plane coordinates, if either there
was no hotspot set, or if drmModeSetCursor2() failed.

Eventually, the atomic KMS API will learn about hotspots, but when
adding our own atomic KMS backend to the transacitonal KMS API, we must
until then still fall back to legacy KMS for virtual machines.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1136
2020-03-26 16:18:28 +00:00
Jonas Ådahl
343de21af5 monitor-transform: Add API to transform point
Transforms a point in a rectangle with the origin (0, 0). To be used to
transform cursor hotspots within a cursor sprite.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1136
2020-03-26 16:18:28 +00:00
Jonas Ådahl
3c157242fa cursor-sprite: Add API to get dimension
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1136
2020-03-26 16:18:28 +00:00
Jonas Ådahl
32c99513c8 clutter/actor: Inherit cloned painting when calculating resource scale
When calculating the resource scale of a clone source, we might end up
in situations where we fail to do so, even though we're in a paint. A
real world example when this may happen if this happens:

 * A client creates a toplevel window
 * A client creates a modal dialog for said toplevel window
 * Said client commits a buffer to the modal before the toplevel

If GNOME Shell is in overview mode, the window group is hidden, and the
toplevel window actor is hidden. When the clone tries to paint, it fails
to calculate the resource scale, as the parent of the parent (window
group) is not currently mapped. It would have succeeded if only the
clone source was unmapped, as it deals with the unmapped actor painting
by setting intermediate state while painting, but this does not work
when the *parent* of the source is unmapped as well.

Fix this by inheriting the unmapped clone paint even when calculating
the resource scale.

This also adds a test case that mimics the sequence of events otherwise
triggered by a client. We can't add a Wayland client to test this, where
we actually crash is in the offscreen redirect effect used by the window
dimming feature in GNOME Shell.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/808

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1147
2020-03-26 11:42:23 +01:00
Jonas Ådahl
40c345d6f3 cursor-sprite-xcursor: Emulate Wayland hotspot limitations
For HiDPI pointer cursors backed by Wayland surfaces, the hotspot must
be placed using integers on the logical pixel grid. In practice what
this means is that if the client loads a cursor sprite with the buffer
scale 2, and it's hotspot is not dividable by 2, it will be rounded
down to an integer that can. E.g. a wl_surface with buffer scale 2 and a
cursor image with hotspot coordinate (7, 7) will have the coordinate
(3.5, 3.5) in surface coordinate space, and will in practice be rounded
down to (3, 3) as the hotspot position in wl_pointer only takes
integers.

To not potentially shift by 1 pixel on HiDPI monitors when switching
between wl_surface backend cursor sprites and built-in ones, make the
built in one emulate the restrictions put up by the Wayland protocol.

This also initializes the theme scale of the xcursor sprite instances to
1, as they may not have been set prior to being used, it'll only happen
in response to "prepare-at" signals being emitted prior to rendering.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1107
2020-03-26 08:47:37 +00:00
Jonas Ådahl
8beef8ccd0 shaped-texture: Fix use-nearest check when viewports are scaled
We checked that the content size was appropriately painted in the stage,
but didn't take into account that the size of the sampled texture
region, meaning that when stage views were scaled, we'd think that we
would draw a texture scaled, as e.g. a 200x200 sized texture with buffer
scale 2 would have the size 100x100. When stage views were not scaled,
we'd apply a geometry scale meaning it'd end up as 200x200 anyway, thus
pass the check, but when stage views are scaled, it'd still be painted
as a 100x100 shaped texture on the stage, thus failing the
are-we-unscaled test.

Fix this by comparing the transformed paint size with the sampled size,
instead of the paint size again, when checking whether we are being
painted scaled or not. For example, when stage views are scaled, our
200x200 buffer with buffer scale 2, thus content size 100x100 will
transform to a 200x200 paint command, thus passing the test. For
non-scaled stage views, our 200x200 buffer with buffer scale 2 thus
content size 100x100 will also transform into a 200x200 paint command,
and will also pass the check, as the texture sample region is still
200x200.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1124
2020-03-26 08:32:46 +00:00
Jonas Ådahl
62d0dd907b clutter-utils: Fix a couple of coding style issues
Multiple assignments on the same line were split up, so was a super long
line.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1124
2020-03-26 08:32:46 +00:00
Jonas Ådahl
0462208d4e crtc-xrandr: Respect configured RANDR panning
A user may have configured an output to be panning, e.g. using xrandr
--output <output> --mode <mode> --panning <size>. Respect this by making
the logical monitor use the panning size, instead of the mode. This
makes e.g. makes the background cover the whole panning size, and panels
etc will cover the whole top of the panned area, instead of just the top
left part covering the monitor if having panned to (0, 0).

No support is added to configuring panning, i.e. a panned monitor
configuration cannot be stored in monitors.xml.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1085
2020-03-26 09:24:25 +01:00
Jonas Ådahl
238e41d493 cogl: Install cogl-trace.h and include from cogl.h
This is so that cogl-trace.h can start using things from cogl-macros.h,
and so that it doesn't leak cogl-config.h into the world, while exposing
it to e.g. gnome-shell so that it can make use of it as well. There is
no practical reason why we shouldn't just include cogl-trace.h via
cogl.h as we do with everything else.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1059
2020-03-26 09:05:38 +01:00
Carlos Garnacho
8699482475 backends: Check both input settings and mapper for tablet monitors
The upper layers (OSDs basically) want to know the monitor that a
tablet is currently assigned to, not the monitor just as configured
through settings.

This broke proper OSD positioning for display-attached tablets since
commit 87858a4e01, as the MetaInputMapper kicks in precisely when
there is no configured monitor for the given device.

Consulting both about the assigned output will make OSDs pop up
again in the right place.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/971
2020-03-25 19:09:32 +00:00
Carlos Garnacho
dcaa45fc0c backends/x11: Implement is_grouped for X11
If the devices have a wacom description, compare those. Otherwise,
look up the devices' VID:PID, if they match they should also be
grouped.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/971
2020-03-25 19:09:32 +00:00
Carlos Garnacho
3c4f5ddcb4 core: Let pad mode switch events always go through MetaInputSettings
We used to inhibit all pad actions while the OSD is shown, but one we
would actually want to handle are mode switches while the OSD is open.
So it has an opportunity to catch up to the mode switch.

This lets MetaInputSettings reflect the mode switch (eg. when querying
action labels), so the OSD has an opportunity to update the current
actions.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/975
2020-03-25 19:56:09 +01:00
Florian Müllner
d4c070da88 window: Really propagate effective on-all-workspaces setting to transients
Commit cda9579034 fixed a corner case when setting the initial workspace
state of transient windows, but it still missed a case:

should_be_on_all_workspaces() returns whether the window should be on all
workspaces according to its properties/placement, but it doesn't take
transient relations into account.

That means in case of nested transients, we can still fail the assert:

 1. on-all-workspaces toplevel
 2. should_be_on_all_workspaces() is TRUE for the first transient's parent,
    as the window from (1) has on_all_workspaces_requested == TRUE
 3. should_be_on_all_workspaces() is FALSE for the second transient's
    parent, as the window from (2) is only on-all-workspace because
    of its parent

We can fix this by either using the state from the root ancestor
instead of the direct transient parent, or by using the parent's
on_all_workspaces_state.

The latter is simpler, so go with that.

https://gitlab.gnome.org/GNOME/mutter/issues/1083
2020-03-24 18:15:33 +00:00
Carlos Garnacho
d052f9c070 backends: Drop internal WacomDevice in MetaInputSettings
Use the one from MetaInputDevice instead. Since we no longer try
to ask for WacomDevices that weren't first retrieved:

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1109
2020-03-24 18:07:31 +00:00
Carlos Garnacho
3b88af94e3 backends/x11: Drop internal WacomDevice lookups
Just use the ones from MetaInputDevice.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1109
2020-03-24 18:07:31 +00:00
Carlos Garnacho
1f00aba92c backends: Add MetaInputDevice derivable class
This class sits between ClutterInputDevice and the backend implementations,
it will be the despositary of features we need across both backends, but
don't need to offer through Clutter's API.

As a first thing to have there, add a getter for a WacomDevice. This is
something scattered across and somewhat inconsistent (eg. different places
of the code create wacom devices for different device types). Just make it
here for all devices, so users can pick.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1109
2020-03-24 18:07:31 +00:00
Carlos Garnacho
ec1195e3ff backends: Fix configuration changes to tap[-and-drag]
Most people just see a harmless warning when applying this setting to
all touchpads (which this patch fixes). But tap[-and-drag] is supposed
to remain enabled for display-less Wacom tablets, despite configuration
changes.

Fix this by using the mapping function, so the setting is forced on for
wacom devices. This happens on a per-device basis, so the warning is
gone too.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1145
2020-03-24 17:05:12 +00:00
Carlos Garnacho
18b661cc93 backends: Add mapping function arg to settings_set_bool_setting()
This will be useful to actually determine on a per-device basis the
setting being applied, while still doing changes on a per-device-type
basis.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1145
2020-03-24 17:05:12 +00:00
Carlos Garnacho
8592a8591b wayland: Handle NULL preedit text
The preedit text may be NULL (eg. when unsetting it). This started
causing crashes since commit db9b60cc63, duh.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1132
2020-03-24 16:07:44 +00:00
Peter Hutterer
7fa7c2aeb7 backends: use the enum name instead of a literal 0
No functional change.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1144
2020-03-24 15:46:43 +10:00
Robert Mader
41130b08eb surface-actor: Add culling offset for geometry scale
This fixes a case that was overlooked in
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1036 - when we
have a geometry scale > 1 and Wayland subsurfaces that have an offset
to their parent surface (which is often the case when the toplevel surface
includes decoration/shadows etc.), we have to add extra offset to their
opaque regions so they match their 'visible' location.

This is necessary as `meta_cullable_cull_out_children` moves the coordinate
system during culling, but does not know about geometry scale.

Also, remove the redundant check for `window_actor` - we only hit this code
path if a `window_actor` culls out its children.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1108
2020-03-23 20:28:59 +01:00
Robert Mader
1d20045247 surface-actor: Fix memory leak
When we create a new region for an opaque texture we need to free it.
While on it, simplify the check slightly.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1108
2020-03-23 18:10:28 +00:00
Carlos Garnacho
c131a9b7fa backends/x11: Observe multiple pad mode switch buttons in a group
Some tablets like the Cintiq 24HDT have several mode switch buttons
per group. Those are meant to jump straight to a given mode, however
we just handle cycling across modes (as most other tablets have a
single mode switch button per group).

So spice up the mode switch handling so we handle multiple mode
switch buttons, assigning each of them a mode. If the device only
has one mode switch button, we do the old-fashioned cycling.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/970
2020-03-20 21:30:30 +01:00
Carlos Garnacho
2ecbf6d746 x11: Handle windowing errors while writing selection INCR data
This error was just logged but not raised. Do as the code comment said
and raise a pipe error at that moment, and for subsequent operations
on the output stream (although none besides close() should be expected
after propagating the error properly).

Related: https://gitlab.gnome.org/GNOME/mutter/issues/1065
2020-03-20 16:14:07 +01:00
Jonas Ådahl
0a6034ef3a monitor-manager: Remove 'mirror' capability
With per-CRTC views, there is nothing stopping NVIDA EGLStream based
rendering to not support monitor mirroring, so lets remove that
restriction.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1098
2020-03-18 00:46:20 +00:00
Jonas Ådahl
c9a5b2b22f kms-impl-simple: Handle lack of cached mode set in flip fallback
When a page flip fails with a certain error code, we've treated this as
a hint that page flipping is broken and we should try to use mode
setting instead.

On some drivers, it seems that this error is also reported when there
was no mode set, which means we'll have no cached mode set to use in the
fallback. The lack of prior mode set tends to happen when we hit a race
when the DRM objects change before we have the time to process a hotplug
event.

Handle the lack a missing mode set in the flip fallback path, with the
assumption that we'll get a hotplug event that'll fix things up for us
eventually.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/917
2020-03-18 00:33:03 +00:00
Carlos Garnacho
db9b60cc63 wayland: Represent preedit string cursor offset in bytes
Both IBus and ClutterInputFocus work in character offsets for the cursor
position in the preedit string. However the zwp_text_input protocol does
define the preedit string cursor offset to be in bytes.

Fixes client bugs in representing the caret within the preedit string,
as we were clearly giving the wrong offset.

Fixes: https://gitlab.gnome.org/GNOME/gtk/issues/2517

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1132
2020-03-17 22:15:52 +00:00
Jonas Ådahl
fa74da0039 wayland/window: Ignore state changes for popups
We send configure events for state changes e.g. for `appears-focused`,
etc. What we don't want to do is to do this for popup windows, as in
Wayland don't care about this state.

When the focus mode was configured to "sloppy focus" we'd get
`appears-focused` state changes for the popup window only by moving the
mouse cursor around, and while a popup may care about focus, it does not
care about related appearance, as there is no such state in xdg_popup.

What these state changes instead resulted in was absolute window
configuration events, intended for toplevel (xdg_toplevel) windows. In
the end this caused the popup to be positioned aginst at (0, 0) of the
parent window, as the assumptions when the configuration of the popup
was acknowledged is that it had received a relative position window
configuration.

Fix this by simply ignoring any state changes of the window if it is a
popup, meaning we won't send any configuration events intended for
toplevels for state changes. Currently we don't have any way to know
this other than checking whether it has a placement rule. Cleaning up
MetaWindow creation is left to be dealt with another day.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1122
2020-03-17 21:59:02 +00:00
Robert Mader
4133b73632 cursor-renderer/native: Skip hw cursor upload if we can't use it
If the CRTCs the cursor is visible on do not share a common scale
and transform, we can't use the cursor hardware plane as we only have one.
We therefore fall back to software / gl cursor.

The check for that currently happens after we tried to upload the cursor image
to the hardware plane though.
This is made worse by the fact that in the scaling step, where we scale the
cursor image to the desired size, until now we expected a valid common scale -
otherwise scaling the image by an uninitialized float.

Make sure we bail out early during the scale/upload step if we don't have common
scales and transforms - to avoid that bug and save some unnecessary work.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1125
2020-03-16 21:51:30 +01:00
Daniel van Vugt
074f4974dd input-settings: Specify middle-click-emulation key
Which exists, unlike `emulate-middle`.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1124
2020-03-16 15:09:00 +08:00
Andrew Gaul
0700f3749f input-settings/x11: Fix typo in has_udev_property
https://gitlab.gnome.org/GNOME/mutter/merge_requests/256
2020-03-15 13:04:32 +09:00
Andrew Gaul
0487e6f11f input-settings: Wire up middle-emulation
This allows emulating middle click via simultaneous left and right
click.  Fixes #238.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/256
2020-03-15 13:04:32 +09:00
Carlos Garnacho
23da6c2426 keybindings: Check the special modifiers specifically
Make sure it is only the special modifier (hardcoded to 1 currently)
which is being pressed (not counting locked modifiers) before notifying
that the special modifier is pressed, as we are interested in it being
pressed alone and not in combination with other modifier keys.

This helps in two ways:
- Pressing alt, then ctrl, then releasing both won't trigger the locate
  pointer action.
- Pressing alt, then ctrl, then down/up to switch workspace won't interpret
  the last up/down keypress as an additional key on top of the special ctrl
  modifier, thus won't be forwarded down to the focused client in the last
  second.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1014
2020-03-13 21:37:32 +01:00
Carlos Garnacho
67dd0b4fec keybindings: Avoid double calls to process_event() on the same event
If you first press a key that triggers the "special modifier key" paths
(ctrl, super), and then press another key that doesn't match (yet?) any
keybindings (eg. ctrl+alt, super+x), the second key press goes twice
through process_event(), once in the processing of this so far special
combination and another while we let the event through.

In order to keep things consistent, handle it differently depending on
whether we are a wayland compositor or not. For X11, consider the event
handled after the call to process_event() in process_special_modifier_key().
For Wayland, as XIAllowEvents is not the mechanism that allows clients see
the key event, we can just fall through the regular paths, without this
special handling.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1014
2020-03-13 21:22:28 +01:00
Jonas Ådahl
5319949a45 kms-impl-device: Clean up state if drm resources disappear
It may happen that drmModeGetResources() starts returning NULL. Handle
this gracefully by removing all connectors, CRTCs and planes making the
device in practice defunct.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1121
2020-03-12 13:08:46 +00:00
Alynx Zhou
aba0b9ef64 keybindings: Move common window grab code out of X-only if statement
`3c8d4171` moved some common codes into X11-only code blocks by mistake,
and it prevents keyboard window resize/move mode under Wayland because
those variables are unset. This commit fixed it via moving such common
codes out of X11-only code blocks.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/997
2020-03-12 08:42:04 +00:00
Jonas Ådahl
512bb7d1cd wayland: Don't crash when trying to fullscreen on inert wl_output
There is a race where an output can be used as a fullscreen target, but
it has already been removed due to a hotplug. Handle this gracefully by
ignoring said output in such situations.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1120
2020-03-11 14:37:09 +00:00
Jonas Ådahl
d2a12ee0fa crtc-xrandr: Compare right coordinate when checking assignment
Compare x with x, and y with y, not y with x.

Fixes an issue where only changing the scale doesn't actually apply the
new scale.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1119
2020-03-11 13:02:50 +00:00
Jonas Ådahl
531a195cf1 monitor-config-manager: Respect layout mode when calculating CRTC layout
The scale used when calculating the CRTC layout should only come from
the logical monitor scale if the layout mode of the corresponding
configuration is 'logical'.

This fixes an issue where the X11 screen size accidentally got set to a
size scaled down by the configured global UI scale.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/1107
Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/1109

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1118
2020-03-11 12:55:03 +00:00
Sebastian Keller
509e9ca5a0 xwayland: Fix mime type atom list leak on DnD with more than 3 types
Found using the clang static analyzer

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1117
2020-03-11 03:21:36 +01:00
Olivier Fourdan
0743381573 window/x11: Rename meta_window_x11_buffer_rect_to_frame_rect
To keep consistent and avoid confusion, rename the function:
    `meta_window_x11_buffer_rect_to_frame_rect()`
to:
    `meta_window_x11_surface_rect_to_frame_rect()`

As this function doesn't deal with the `window->buffer_rect` at all.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1091
2020-03-10 14:52:26 +01:00
Olivier Fourdan
267f712068 window-actor/x11: Use the new MetaShapedTexture API
The code in `build_and_scan_frame_mask` predates the introduction of the
`MetaShapedTexture` API to get the texture width hand height.

Use the new `meta_shaped_texture_get_width/height` API instead of using
the CoGL paint texture.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1091
2020-03-10 14:52:26 +01:00
Olivier Fourdan
0b102afb53 xwayland: Update regions on texture updates
For X11 clients running on Wayland, the actual texture is set by
Xwayland.

The shape, input and opaque regions, however are driven by X11
properties meaning that those may come at a different time than the
actual update of the content.

This results in black areas being visible at times on resize with
Xwayland clients.

To make sure we update all the regions at the same time the buffer is
updated, update the shape, input and opaque regions when the texture is
committed from when the Xwayland surface state is synchronized.

That fixes the remaining black areas being sometimes visible when
resizing client-side decorations windows on Xwayland.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1007
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1091
2020-03-10 14:52:26 +01:00
Olivier Fourdan
304a103659 window-actor: Add API to update regions
For X11 clients running on Xwayland, the opaque, input and shape regions
are processed from different properties and may occur at a different
time, before the actual buffer is eventually committed by Xwayland.

Add a new API `update_regions` to window actor to trigger the update of
those regions when needed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1091
2020-03-10 14:52:26 +01:00
Olivier Fourdan
2d09e95934 window-actor/x11: Compute client area from surface size
Commit 7dbb4bc3 cached the client area when the client was frozen.

This is not sufficient though, because the buffer size might still be
lagging waiting for the buffer from Xwayland to be committed.

So instead of caching the client size from the expected size, deduce the
client area rectangle from the surface size, like we did for the frame
bounds in commit 1ce933e2.

This partly reverts commit 7dbb4bc3 - "window-actor/x11: Cache the
client area"

https://gitlab.gnome.org/GNOME/mutter/issues/1007
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1091
2020-03-10 14:52:26 +01:00
Olivier Fourdan
be11525b28 window/x11: Add function to convert the surface to client area
Add a convenient function to get the client area rectangle from a given
surface rectangle.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1091
2020-03-10 14:52:26 +01:00
Robert Mader
adc38f902a window-actor/X11: Update shape, input and opaque region in order
As they depend on each other to be correct, we should set all of them
in the correct order. As we do already have a function for that, use it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1091
2020-03-10 14:52:26 +01:00
Pekka Paalanen
8abdf16a39 cursor-renderer/native: Handle GPU hotplug
Listen for GPU hotplug events to initialize their cursor support.

This fixes one reason for why DisplayLink devices may not be using a hardware
cursor. Particularly, when a DisplayLink device is hotplugged for the first
time such that EVDI creates a new DRM device node after gnome-shell has already
started, we used to forget to initialize the cursor support.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1097
2020-03-10 08:26:17 +00:00
Pekka Paalanen
4cc29cfb61 cursor-renderer/native: Refactor init to per-gpu
Extract the code to initialize a single GPU cursor support into its own
function. The new function will be used by GPU hotplug in the future.

This is a pure refactoring without any behavioral changes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1097
2020-03-10 08:26:17 +00:00
Olivier Fourdan
50ff30bf2b xwayland: Log actual error message if available
If X11 initialization fails, print the actual error message if the error
is set, to help with debugging.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1102
2020-03-09 17:49:51 +00:00
Jonas Ådahl
26e1e495a0 screen-cast-stream-src: Don't leak GSource
For every stream src, we created and attached a GSource. Upon stream
src destruction, we g_source_destroy():ed the GSource. What
g_source_destroy() does, hawever, is not really "destroy" it but only
detaches it from the main context removing the reference the context had
added for it via g_source_attach(). This caused the GSource to leak,
although in a detached state, as the reference taken on creation was
still held.

Fix this by also removing our own reference to it when finalizing.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1106
2020-03-09 17:31:23 +00:00
Jonas Ådahl
480e7d44be screen-cast-stream-src: Don't complain when we can't dequeue buffer
PipeWire will be unable to dequeue a buffer if all are already busy.
This can happen for valid reasons, e.g. the stream consumer not being
fast enough, so don't complain in the journal if it happens.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1115
2020-03-09 17:46:54 +01:00
Jonas Ådahl
6e966e47f2 cursor-renderer-native: Handle lack of cursor planes gracefully
While we will always have cursor planes, as we'll currently create fake
ones when real ones are missing (See #1058), eventually we will run into
situations where we can't create fake ones, for example for atomic KMS
drivers that don't advertise any cursor planes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1079
2020-03-07 21:40:50 +00:00
Jonas Ådahl
227eea1e31 kms-impl-simple: Add fake cursor planes if no real ones
Non-atomic drivers may support drmModeSetCursor() even if no cursor
plane is advertised. To deal with this, add a fake cursor plane for
every CRTC when using MetaKmsImplSimple. This will eventually be
translated to drmModeSetCursor() calls without any explicit cursor plane
usage.

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1079
2020-03-07 21:40:50 +00:00
Jonas Ådahl
6cd0aa429f window: Force placement for first placement rule
If we don't force the placement, we enter the constrain machinery with
the position (0, 0), meaning we always get the "current work area" setup
to correspond to whatever logical monitor was at that position.

Avoid this by doing the same as "meta_window_force_placement()" and set
"window->calc_placement" to TRUE while move-resizing, causing the
move-resize to first calculate the initial position.

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

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1110
2020-03-06 17:28:09 +01:00
Jonas Ådahl
f97804f4f4 wayland/xdg-shell: Add support for explicit popup repositioning
This commit completes the implementation of `xdg_wm_base` version 3,
which introduces support for synchronized implicit and explicit popup
repositioning.

Explicit repositioning works by the client providing a new
`xdg_positioner` object via a new request `xdg_popup.reposition`. If the
repositioning is done in combination with the parent itself being
reconfigured, the to be committed state of the parent is provided by the
client via the `xdg_positioner` object, using
`xdg_positioner.set__parent_configure`.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
5c37f5104e wayland/xdg-shell: Add support implicit popup moving
This sets the `is_reactive` flag on the window placement rules, causing
the popups to be reconfigured as they are affected by environmental
changes, such as the parent moving in a way making the popup partially
offscreen.

As with synchronization, the implementation is dormant, as the
version of the advertised global isn't bumped yet, as the new protocol
version is not yet fully implemented.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
d08a8de265 window: Implement asynchronous popup moving
This commits adds support on the MetaWindow and constraints engine side
for asynchronously repositioning a window with a placement rule, either
due to environmental changes (e.g. parent moved) or explicitly done so
via `meta_window_update_placement_rule()`.

This is so far unused, as placement rules where this functionality is
triggered are not yet constructed by the xdg-shell implementation, and
no users of `meta_window_update_placement_rule()` exists yet.

To summarize, it works by making it possible to produce placement rules
with the parent rectangle a window should be placed against, while
creating a pending configuration that is not applied until acknowledged
by the client using the xdg-shell configure/ack_configure mechanisms.

An "temporary" constrain result is added to deal with situations
where the client window *must* move immediately even though it has not yet
acknowledged a new configuration that was sent. This happens for example
when the parent window is moved, causing the popup window to change its
relative position e.g. because it ended up partially off-screen. In this
situation, the temporary position corresponds to the result of the
movement of the parent, while the pending (asynchronously configured)
position is the relative one given the new constraining result.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
6c82feb1b8 wayland/window-configuration: Track resize flags and gravity too
Will later be used to determine in what way a pending configuration will
resize.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
0dac91cffc Add MetaGravity and replace X11 equivalent with it
MetaGravity is an enum, where the values match the X11 macros used for
gravity, with the exception that `ForgetGravity` was renamed
`META_GRAVITY_NONE` to have less of a obscure name.

The motivation for this is to rely less on libX11 data types and macros
in generic code.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
ff381d1d52 constraints: Pass constrained relative coordinates to window impl
A placement rule placed window positions itself relative to its parent,
thus converting between relative coordinates to absolute coordinates,
then back to relative coordinates implies unwanted restrictions for
example when the absolute coordinate should not be calculated againts
the current parent window position.

Deal with this by keeping track of the relative position all the way
from the constraining engine to the move-resize window implementation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
05e9d6ab9e window: Put placement related fields in a anynomous struct
To organize things a bit better, put the fields related to the placement
rule state in its own anonymous struct inside MetaWindow. While at it,
rename the somewhat oddly named variable that in practice means the
current relative window position.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
d22f947bf5 wayland/window: Pass popup configuration using relative coordinates
After popup placement rules have gone through the constraints engine has
ended up resulting in an actual move, pass the window configuration down
the path using relative coordinates, as that is what the next layer
(xdg-shell implementation) actually cares about.

In the future, this will also be helpful when the configured position is
not against the current state of the parent.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
9b97e5ed58 place: Make placement rule processing provide relative coordinates
A placement rule is always about placing a window relative to its
parent. In order to eventually place it against predicted future parent
positions, make the placement rule processing output relative
coordinates, having the caller deal with turning them into absolute.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
7f9fac2ba2 window/wayland: Don't inhibit finishing moves if any window is resized
meta_window_wayland_finish_move_resize() inhibited window moves to be
finished if there was a resize grab active at the time, in order to
handle window resizing. Change this to only affect the grabbed window
itself, so that e.g. a popup can be positioned according to a pending
configuration while there is an active resize grab.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Carlos Garnacho
64eaf70279 xwayland: Allow setting up maintenance processes
This is made a signal, so the upper layers (read: gnome-shell) may
decide what services to spawn. The signal argument contains a task
that will resume MetaX11Display startup after it is returned upon.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/945
2020-02-29 20:41:26 +00:00
Carlos Garnacho
e3149e6021 wayland: Pass private X connection on GNOME_SETUP_DISPLAY
This envvar will be picked up by the services spawned together with Xwayland
startup, and used instead of the regular DISPLAY meant for regular clients.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/945
2020-02-29 20:41:26 +00:00
Carlos Garnacho
166a464515 wayland: Set up initialization X11 socket
This is used by GDK and the X11 bits, but may also be used for
other initialization services we might need to run along with
Xwayland initialization.

However, as the -initfd argument in Xwayland is a fairly new
feature, add some meson build-time checks so that the feature
is handled transparently while allowing to explicitly set/unset
it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/945
2020-02-29 20:41:26 +00:00
Carlos Garnacho
38e58b837b core: Use DISPLAY envvar to forward in the launch context
The meta_x11_get_display_name() will return our private connection, which
is not what we want to transfer to clients being launched.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/945
2020-02-29 20:41:26 +00:00
Robert Mader
39a8c047d1 background-actor: Do not copy empty clip/unobscured regions
Clip and unobscured regions stricly shrink during culling. If they
are already empty, simply reference the empty region to reduce allocations.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1082
2020-02-29 19:44:01 +00:00
Robert Mader
c979cd95aa surface-actor: Do not copy empty clip/unobscured regions
Clip and unobscured regions stricly shrink during culling. If they
are already empty, simply reference the empty region to reduce allocations.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1082
2020-02-29 19:44:01 +00:00
Robert Mader
6831f2edb4 window-actor/x11: Disable culling on window actor level
This shape region culling was wrongly implemented in f5a28aa9, as it
does not take frame offsets into account, and is also redundant, as
we already set the opaque region of the underlying surface accordingly.

The other parts were implemented in ac7aa114, the reason given in
the commit message:
```
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.
```

is wrong though - culling on X11 actors works just fine and did only
not work in Wayland sessions because of a bug that got fixed in
19814497.

In conclusion the whole part appears to be redundand and some testing
done suggests the same. Drop it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1082
2020-02-29 19:44:01 +00:00
Robert Mader
372d73e275 surface-actor: Cull out surfaces without alpha channel
If a opaque region is explicitly set we should not consider the surface
opaque, as that implies e.g. a shape region is set.

If no opque region is set but the texture does not have an alpha channel,
we can savely cull it out.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1082
2020-02-29 19:44:01 +00:00
Robert Mader
0ada90024f wayland/actor-surface: Check for MetaXwaylandSurface instead of window type
The previous check would not ignore subsurfaces. Use the chance to directly
check for the surface role instead - it's much cleaner.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1082
2020-02-29 19:44:01 +00:00
worldofpeace
8a6673bb55 build: ensure absolute path to sysprof dbus interface dir
We want sysprof's exact datadir for compatability with
platforms where software is installed into their own
individual immutable prefix's. Such that, mutter's prefix will
never equate to sysprof's. This depends on a MR in sysprof [0]
which adds datadir to its pkgconfig files, as these files will always
have the proper path we want.

This adds version a constraint on sysprof_dep, as datadir was added to
the .pc in this version.

[0]: https://gitlab.gnome.org/GNOME/sysprof/merge_requests/19

https://gitlab.gnome.org/GNOME/mutter/merge_requests/957
2020-02-29 13:17:40 +01:00
Jonas Ådahl
390fd7ddcf cursor-renderer-native: Fix hw cursor for non-square sprites
wl_shm_buffer_get_width() was used where wl_shm_buffer_get_height()
should have used, resulting in only square cursors working. Make
rectangular cursors work again.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1099
2020-02-28 21:49:58 +00:00
Carlos Garnacho
4b513a31ae compositor: Shuffle x11 compositing bits in MetaCompositor
Given that on Wayland we are pretty much guaranteed to finish MetaX11Display
setup after the MetaCompositor is enabled, we may drop the
meta_compositor_manage() x11 initialization bits, and move them into the
MetaX11Compositor subclass where it's actually needed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
2020-02-28 20:20:35 +00:00
Carlos Garnacho
25c9e66c73 xwayland: Do not block on Xwayland initialization
We artificially made Xwayland initialization synchronous, as we used
to rely on MetaX11Display and other bits during meta_display_open().
With support for Xwayland on demand and --no-x11, this is certainly
not the case.

So drop the main loop surrounding Xwayland initialization, and turn
it into an async operation called from meta_display_init_x11(). This
function is turned then into the high-level entry point that will
get you from no X server to having a MetaX11Display.

The role of meta_init() in Xwayland initialization is thus reduced
to setting up the sockets. Notably no processes are spawned from here,
deferring that till there is a MetaDisplay to poke.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
2020-02-28 20:20:35 +00:00
Carlos Garnacho
649911b6b3 core: Make meta_display_init_x11() an async function
This ATM completes the task right away, but we will want to do
further things here that are asynchronous in nature, so prepare
for this operation being async.

Since the X11 backend doesn't really need this, make it go on
the fast lane and open the MetaX11Display right away, the case
of mandatory Xwayland on a wayland session is now handled
separately.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
2020-02-28 20:20:35 +00:00
Carlos Garnacho
8c332a4704 tests: Set fatal log handler on clutter tests
With Xwayland initialization going async, these errors will seep
into the parts controlled by g_test*(), resulting in the harmless
errors about DBus names not acquired turned fatal.

Set an error log handler, and specifically ignore those.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
2020-02-28 20:20:35 +00:00
Carlos Garnacho
21994bb00d tests: Ensure MetaX11Display is initialized before running tests
It might not be available right on initialization time if X11 is started
asynchronously. As this is a requirement for our tests, ensure it is there
before proceeding with the test.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
2020-02-28 20:20:35 +00:00
Carlos Garnacho
87a06c63ad x11: Set up the compositing manager selection on meta_display_init_x11()
This used to be set on meta_compositor_manage(), but only if there is a
MetaX11Display. Given meta_display_init_x11() is Wayland only, and we can
always assume compositing to be enabled, just have it invariably set after
the X server is up.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
2020-02-28 20:20:35 +00:00
Georges Basile Stavracas Neto
09026e5f0e monitor-stream-src: Use cogl_framebuffer_finish()
Even though cogl_framebuffer_flush() was supposed to be enough,
it ends up creating streams with odd visual glitches that look
very much like unfinished frames.

Switch back to cogl_framebuffer_finish(), which is admittedly
an overkill, but it's what works for now. There is anedoctal
evidence showing it doesn't incur in worse performance.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 15:52:19 -03:00
Georges Basile Stavracas Neto
1f190a7cfe screen-cast-stream-src: Remove unused parameter
The 'data' parameter is not used in maybe_record_cursor(), so remove
it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 15:52:19 -03:00
Georges Basile Stavracas Neto
86168b945c window-stream-source: Draw into DMA buffer image
Much like monitor streaming, implement window streaming by
making the window actor draw itself with a paint context
that used the passed framebuffer.

Now that all MetaScreenCastStreamSrc subclasses implement
blit_to_framebuffer, remove the conditional check from
meta_screen_cast_stream_src_blit_to_framebuffer().

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 15:52:19 -03:00
Georges Basile Stavracas Neto
680a54aff6 monitor-stream-src: Implement blitting view framebuffers
Add the vfunc override that actually consume the new Cogl API. Every
view that fits into the logical monitor is rendered.

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 15:52:03 -03:00
Georges Basile Stavracas Neto
548073ec27 screen-cast-stream-src: Support DMA buffer sharing
Implement PipeWire's add_buffer and remove buffer, try and export
a DMA buffer first and, on failure, fallback to memfd.

When DMA buffers are successfully created and shared, blit the
framebuffer contents when drawing instead of downloading the pixels.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 15:29:03 -03:00
Georges Basile Stavracas Neto
d366fb335d renderer-native: Implement DMA buffer creation
Create a new gbm_bo using the same given geometry, and export the new
bo's DMA buffer fd. The new bo lives as long as necessary to be used,
and reused, by PipeWire.

Unfortunately, PipeWire doesn't support modifiers properly, so use the
linear format for now. For now, a hardcoded format of DRM_FORMAT_XRGB8888
is set, so we don't need to negotiate the format with PipeWire early.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 15:29:02 -03:00
Georges Basile Stavracas Neto
7fbb47b2bb renderer-native: Move DMA buffer creation to an auxiliary function
This will be reused by the DMA buffer exporting function.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1086
2020-02-28 15:28:22 -03:00
Robert Mader
969ad54feb cursor-renderer/native: Remove unnecessary endian check
Both cases have the same content.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/526
2020-02-28 10:22:11 +00:00
Robert Mader
987ce5bec0 cursor-renderer/native: Implement scaled/transformed hardware cursors
If the cursor sprite does not match the scale factor or transformation
of the monintor, we currently fall back to a software cursor, causing
redraws of the shell. This commit implements scaling and transforming
of the cursor sprite, so we can use it with hardware planes, too.

This commit does the following steps:

1. Make sure we reupload the cursor image if the cursor is over
a logical monitor not matching the scale or transform from the previous
update.
2. Before upload to the hardware plane, scale and transform the cursor
image if possible and necessary.
3. Make sure we always use the hardware cursor if possible (only fall
back to software/OGL cursor if it is visible on multiple logical monitors
with differet scales/transforms).
4. Transform or scale the cursor coordinates if necessary.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/526
2020-02-28 10:22:11 +00:00
Robert Mader
d600cd9aee monitor-transform: Add generic function to get relative transform
It takes transforms A and B and returns the transform to get from
A to B.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/526
2020-02-28 10:22:11 +00:00
Robert Mader
1fc7935858 backends/cursor: Add API to set and get the texture buffer transform
In Wayland clients can commit transformed surfaces, so the compositor
can directly use them on hardware planes. We already support that
for other surfaces, this is the first step to also support it on
cursor sprites.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/526
2020-02-28 10:22:11 +00:00
Jonas Ådahl
01aaced129 crtc: Don't leak MetaCrtcConfig
We never freed it except when CRTC disabled during runtime.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1095
2020-02-27 20:35:07 +00:00
Jonas Ådahl
ff59b5d041 monitor: Move logical <-> CRTC transform helpers to MetaOutput
So that we avoid leaking the internal guts of MetaOutput into
MetaMonitor, while also making it possible to use it without a
MetaMonitor at hand.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1064
2020-02-27 09:47:22 +01:00
Jonas Ådahl
92f0eb9d14 monitor: Use transform helper when dealing with panel orientation
Replace the open coded monitor transform math with the new helper.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1064
2020-02-27 09:47:08 +01:00
Jonas Ådahl
e6913d1471 monitor-transform: Add meta_monitor_transform_transform() helper
Intended to replace various manual monitor transform enum math here and
there. Tests added as well, to test some hand picked transforms.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1064
2020-02-27 09:07:25 +01:00
Carlos Garnacho
88bb24f66e backends/native: Shuffle udev client initialization in MetaSeatNative
This may be used indirectly before creation as we dispatch libinput events
right after creation (to let input devices be known), so those device
additions would trigger the touch-mode checks.

Creating it in advance results in checks being correctly performed, although
redundantly.

Spotted by Bastien Nocera.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1067
2020-02-26 18:32:05 +00:00
Arun Raghavan
6e7316ef11 build: Use dbus interface dir from pkg-config
Using 'datadir' breaks prefixed builds (as we look for interface files
in the prefix we are going to install to).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1094
2020-02-26 15:37:00 +00:00
Jonas Ådahl
9fa56176fd monitor-manager-xrandr: Don't try to disable disabled CRTC
When applying a configuration to XRANDR, we first disable CRTCs that
happen to extend outside of the to-be X11 screen size. While doing so,
we fail to actually check whether the CRTC is active or not, meaning
we'll try to query the content of the CRTC configuration even though it
has none, leading to a NULL pointer dereference.

Fix this by simply ignoring non-configured CRTCs.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1093
2020-02-26 16:14:04 +01:00
Jonas Ådahl
fe1ccea1e1 clutter: Pass redraw clip via paint context
Instead of users fetching it via `clutter_stage_get_redraw_clip()`, pass
it via the paint context. This is helpful as it is only valid during a
paint, making it more obvious that it needs to be handled differently
when there is no redraw clip (i.e. we're painting off-screen).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 19:18:54 +01:00
Jonas Ådahl
c483b52d24 clutter/stage: Pass redraw clip instead of extents when painting view
That's the struct we have ready, the callee can just call
cairo_region_get_extents() if it only cares about the extents rectangle.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 19:18:54 +01:00
Jonas Ådahl
2d6665950c crtc: Move logical monitor pointer to MetaMonitor
Since the last code fetching the logical monitor state directly from the
CRTC has been removed, we can move the logical monitor pointer to a more
natural place.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
1c98f01a65 renderer-native: Draw stage separately per CRTC
Prior to this commit the stage was drawn separately for each logical
monitor. This allowed to draw different parts of the stage with
different transformations, e.g. with a different viewport to implement
HiDPI support.

Go even further and have one view per CRTC. This causes the stage to
e.g. draw two mirrored monitors twice, instead of using the same
framebuffer on both. This enables us to do two things: one is to support
tiled monitors and monitor mirroring using the EGLStreams backend; the
other is that it'll enable us to tie rendering directly to the CRTC it
will render for. It is also a requirement for rendering being affected
by CRTC state, such as gamma.

It'll be possible to still inhibit re-drawing of the same content
twice, but it should be implemented differently, so that it will still
be possible to implement features requiring the CRTC split.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
e3f30371aa renderer-native: Fix a couple of style misses
Removed stray newline, and fixed an incorrect indentation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
1a14c4d3c9 renderer-x11-nested: Remove stray newline
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
fe42d56db3 crtc: Move configured state to separate struct
To make it more reliable to distinguish between values that are read
from the backend implementation (which is likely to be irrelevant for
anything but the backend implementation), split out those values (e.g.
layout).

This changes the meaning of what was MetaCrtc::rect, to a
MetaCrtcConfig::layout which is the layout the CRTC has in the global
coordinate space.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
a11f9bd513 boxes: Add 'round' rounding strategy
It just calls roundf(), and is intended to be used when the graphene
rectangle is approximately integer aligned.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
7f6cafa847 logical-monitor: Pass monitor in the for each CRTC helper callback
Will be used in later commits.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
1b67f49f7f monitor: Move logical to CRTC transform helper to MetaOutput
So that it can be used on a per output basis in the future.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Dreßler
b98ebe60b2 clutter/x11: Stop tracking stage changes on crossing events
On x11 we emulate pointer events from touch events as long as there's
only one touchpoint on screen, this obviously leads to x11 sending us
crossing events triggered by the emulated pointer. Now if we get a leave
event and set the stage of the ClutterInputDevice to NULL, new touch
events will be discarded by clutters backend because the core pointer
doesn't have a stage associated. This means Mutter completely loses
state of a touchpoint as soon as it crosses a shell actor.

An easy reproducer for this issue is to start the four-finger-workspace
gesture above a window and to move the pointer emulating touch outside
of the window, this will freeze the gesture as the gesture no longer
receives touch events.

To fix this, stop tracking stage changes on crossing events and simply
leave the ClutterInputDevice stage as-is. In our case there is only one
stage anyway and that won't change in the future.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/423
2020-02-24 10:54:56 +00:00
Jonas Dreßler
ad8ba69423 wayland/pointer: Use g_signal_connect_swapped for one signal
Remove the rather useless callback function that's currently used for
handling the "visibility-changed" signal and instead connect to the
signal using `g_signal_connect_swapped()`.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1077
2020-02-24 09:52:06 +00:00
Jonas Dreßler
bf24b816c2 wayland/pointer: Add support for the new ClutterSeat inhibit-unfocus API
The last commit added a new API to ClutterSeat to inhibit setting the
focus-surface of the MetaWaylandPointer to NULL, let's do that.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1077
2020-02-24 09:52:06 +00:00
Jonas Ådahl
2da27720ca display: Make check-alive timeout configureable
The check-alive feature is there for the user to be able to terminate
frozen applications more easily. However, sometimes applications are
implemented in a way where they fail to be reply to ping requests in a
timely manner, resulting in that, to the compositor, they are
indistinguishable from clients that have frozen indefinitely.

When using an application that has these issues, the GUI showed in
response to the failure to respond to ping requests can become annoying,
as it disrupts the visual presentation of the application.

To allow users to work-around these issues, add a setting allowing them
to configure the timeout waited until an application is considered
frozen, or disabling the check completely.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1080
2020-02-23 17:28:57 +00:00
Olivier Fourdan
f9326cfa3d wayland/data-device: Fix crash with offer from X11 client
If a data offer comes from an X11 client, the Wayland resource would be
NULL, causing a crash in `data_offer_choose_action()` trying to get the
resource version.

So instead of doing the version check in `data_offer_choose_action()`,
do it early when creating the data source.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1057
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1073
2020-02-23 16:36:16 +00:00
Olivier Fourdan
963108a9a6 wayland/data-device: Check resource version on cancel
For clarity, check the resource version needs the "cancelled" message in
the actual vmethod rather than from the caller function.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1073
2020-02-23 16:36:15 +00:00
Olivier Fourdan
b8355a6686 xwayland: Not all xwayland surface have a window
`meta_xwayland_surface_get_relative_coordinates()` may cause a crash if
the Xwayland surface has no window associated.

That can be observed when using drag and drop from an X11 window to a
Wayland native window:

```
    at src/core/window.c:4503
    at src/wayland/meta-xwayland-surface.c:200
    at src/wayland/meta-wayland-surface.c:1517
    at src/wayland/meta-wayland-pointer.c:1048
    at src/wayland/meta-wayland-pointer.c:840
    at src/wayland/meta-wayland-pointer.c:865
    at src/wayland/meta-wayland-pointer.c:954
    at src/wayland/meta-wayland-pointer.c:456
    at src/wayland/meta-wayland-pointer.c:993
    at src/wayland/meta-wayland-data-device.c:1004
    at src/wayland/meta-wayland-data-device.c:1278
    at src/wayland/meta-xwayland-dnd.c:326
```

Check if the xwayland surface has an associated MetaWindow prior to get
its buffer rect.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1073
2020-02-23 16:36:15 +00:00
Christian Hergert
4c421959dc clutter: fix hole in ClutterPaintNode
Fixing the missalignment takes the structure from 80 bytes down to 72.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1081
2020-02-21 22:36:31 +00:00
Sebastian Keller
aedcfcd010 sound-player: Fix invalid write after playback is cancelled early
The cancellable of a request might already be cancelled by the time
the cancelled_cb is connected resulting in finish_cb being called via
ca_context_cancel before g_cancellable_connect returns. In this case
the request that is written to has already been freed.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/1060
2020-02-21 16:06:18 +00:00
Jonas Dreßler
41d72e86e0 backends/native: Also check touch-mode on object initialization
On a Surface Pro 2017, touch-mode is currently only detected correctly
after detaching and attaching the Type Cover (detachable keyboard) once,
it seems that `has_external_keyboard` is only set to the correct value
after MetaSeatNative is initialized.

So fix that and call `update_touch_mode()` once again when the object is
initialized and the `has_external_keyboard` and `has_touchscreen`
properties have been finally updated.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1075
2020-02-21 15:24:58 +00:00
Daniel van Vugt
282b09c17e clutter/actor: Add CLUTTER_OFFSCREEN_REDIRECT_ON_IDLE
Which offscreens actor rendering only in cases where it hasn't changed for
2 frames or more. This avoids the performance penalty of offscreening an
actor whose content is trying to animate at full frame rate. It will
switch automatically.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1069
2020-02-21 18:07:46 +08:00
Wim Taymans
c5d2fc856a screen-cast: Update to PipeWire 0.3 API
Update to 0.3 API

[jadahl: update Dockerfile to include new enough pipewire]

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1062
2020-02-20 18:45:31 +01:00
Robert Mader
f5a28aa9e4 window-actor: Make culling of opaque windows X11 only
It is only useful for clients that do not set an opaque region but
still can be detected as being opaque. This is helpful for X11 clients
as opaque regions only got introduced around 2012 and only as part of EWMH
and are thus not used in many cases.
On Wayland however opaque regions have been part of the core protocol from the
beginnig and we can assume they are used more commonly.

As the current implementation in `MetaWindowActor` does not handle Wayland
subsurfaces well, instead of adding more complexity just move it to
`MetaWindowActorX11`.

While on it, take the shape region into account that is set when clients
use the X Nonrectangular Window Shape Extension Protocol, so we have exact
culling with those clients.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1058
2020-02-20 15:57:51 +00:00
Jonas Ådahl
a209a14898 renderer-native: Use hardware acceleration check in generic layer
No need to duplicate it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/838
2020-02-20 10:40:42 +00:00
Jonas Ådahl
3e6a55aff0 renderer: Add API to check whether renderer is hardware accelerated
Also expose an introspected variant via the MetaBackend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/838
2020-02-20 10:40:42 +00:00
Jonas Ådahl
704fea6323 renderer-native: Move 'backend' field to MetaRenderer
So that it can be used by the generic MetaRenderer class, as well as
other sub types, as well.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/838
2020-02-20 10:40:42 +00:00
Jonas Ådahl
8c1e6ebde0 remote-access-handle: Expose disable-animations property
Set to TRUE if a screen cast session asked for animations to be
disabled.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/838
2020-02-20 10:40:42 +00:00
Jonas Ådahl
81512ad0dc screen-cast-session: Add 'disable-animations' property
Allow screen casters (e.g. VNC remote desktop services) to ask for
animations to be inhibited, in order to lower the number of frames sent
over the network.

Currently only sets a field on the screen cast session object. Later
it'll be exposed via the remote access handle and via D-Bus by
gnome-shell.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/838
2020-02-20 10:40:42 +00:00
Jonas Ådahl
44ae38599f wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.

With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.

Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Ådahl
df642eb150 wayland: Move calc-showing window logic to roles having windows
https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Ådahl
722ae2b77a wayland/surface: Let roles set DND functions
The DND functions are role specific, with Xwayland surface being the
special one. Let the roles set it instead of having per role like logic
in MetaWaylandSurface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Ådahl
54194e67e3 wayland/surface: Move relative coordinate calculating to roles
The role determines how a relative coordinate is calculated. More
specifically, using clutters API to transform coordinates is only
accurate right after a clutter layout pass but this function is used
e.g. to deliver pointer motion events which can happen at any time. This
isn't a problem for Wayland clients since they don't control their
position, but X clients do and we'd be sending outdated coordinates if a
client is moving a window in response to motion events.

This was already done already, but now move the Xwayland specific logic
to the Xwayland surface role, keeping the generic transformation logic
in the generic actor surface role.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Ådahl
c0c74484bc wayland: Don't access MetaWaylandSurface::window directly
It'll be moved to the role owning it, accessed via a helper function
implemented by the role. Currently it still just fetches the field in
MetaWaylandSurface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Ådahl
5149e1e43a wayland: Move tree updating to the shell surface role
The shell surface role is the one where subsurfaces may exist, and it
has direct relation to the MetaWindowActorWayland which currently has
the subsurface stacking logic.

Instead of directly finding the window actor when dealing with
subsurfaces, notify the parent surface that the subsurface state
changed, so that it can outsource the application of this information to
the role. For subsurface roles, this simply means forward upward to the
parent; for shell surface roles, this means regenerate the surface actor
layering.

This allows us to move away from accessing the window directly from the
surface, which in turn allows us to change the ownership structure of
windows.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Ådahl
ac2c870177 surface-actor: Remove get_window() API and vfunc
It was unused.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Ådahl
f21595687f xwayland: Move out surface role related logic
Does some needed naming cleanup while at it, to be more similar to other
role types.

In short, MetaWaylandSurfaceRoleXwayland was changed to
MetaXwaylandSurface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Dreßler
e51279dcf0 display: Only send one ping to a window at a time
If a window already is being pinged, it doesn't make sense to send more
pings to the window, instead we should just wait for that answer or
timeout until we send a new one.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/891
2020-02-19 21:20:29 +00:00
Jonas Dreßler
9b58033375 display: Make sure ping serials are never reused
Using a timestamp twice in a row (e.g. when activating two windows in
response to the same event or due to other bugs) will break the window
detection and show a close dialog on the wrong window. This is a grave
error that should never happen, so check every timestamp before sending
the ping for uniqueness and if the timestamp was already used and its
ping is still pending, log a warning message and don't send the ping.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/891
2020-02-19 21:20:29 +00:00
Jonas Dreßler
0bf9727a31 display: Fix intendation of an argument and add details to a warning
https://gitlab.gnome.org/GNOME/mutter/merge_requests/891
2020-02-19 21:20:29 +00:00
Jonas Dreßler
d053ccfb18 window: Check window responsiveness on every window focus
Increase the number of checks whether a window is still responsive and
ping windows on every call to `meta_window_focus()` instead of
`meta_window_activate_full()`. This ensures the window is also pinged in
case normal interaction like clicks on the window happen and a close
dialog will eventually get shown.

Related https://gitlab.gnome.org/GNOME/mutter/issues/395

https://gitlab.gnome.org/GNOME/mutter/merge_requests/891
2020-02-19 21:20:29 +00:00
Jonas Dreßler
7cc02cf24e backends/native: Replace tabs with spaces
Replace the few remaining places where tabs are used for indentation
with spaces.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1065
2020-02-19 18:28:29 +00:00
Jonas Dreßler
e07478f8bc virtual-input-device/native: Fix warning message
We want to log the evdev keycode here, not the Clutter one.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1065
2020-02-19 18:28:29 +00:00
Jonas Dreßler
efe1bc2e59 util: Add INPUT debug topic
Allow debugging input issues more easily by adding an INPUT debug topic.
Currently there are only debug messages for the native backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1065
2020-02-19 18:28:29 +00:00
Sebastian Keller
b45b03b063 surface-actor-x11: Avoid flicker when (un)redirecting windows
Currently when a window is requested to be unredirected, the
corresponding pixmap and texture can get cleared before the window has
been unredirected by the X server. This can result in the windows behind
showing through which causes a short flicker after showing an OSD or
notification when a fullscreen application is running.
Fix this by ensuring the texture is only cleared after the window has
been unredirected by the server.

Similarly when the window is being redirected again, the pixmap of the
window can only be requested after the redirection has been completed by
the server. This currently can happen in a different frame than the next
redraw of the actor resulting in an empty texture until the next redraw.
Fix this by queuing a redraw immediately after redirecting.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/997
2020-02-18 22:49:01 +00:00
Jonas Ådahl
c06fae4741 window-actor: Don't show actor until meta_window_actor_show()
By default clutter will show an actor as it is added to a parent. This
means that after we create the window actor, when it's added to the
window group, we implicitly show it. What we really want is to not show
it until the window is supposed to be shown, which happens when
meta_window_actor_show() is called, as showing prior to that, could
cause issues.

Avoid the implicit show by setting the "show-on-set-parent" property on
the window actor to `FALSE` on window actor construction.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1066
2020-02-18 23:04:49 +01:00
Olivier Fourdan
76e0d7293d window-actor/x11: Update opaque region
Now that the opaque region is not reset by the Wayland actor surface, we
need to update the opaque region just like we do for input region.

That fixes a regression with client-side decoration X11 windows running
in Xwayland.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1060
Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1043
2020-02-17 23:37:18 +00:00
Jonas Ådahl
0e0afa240e settings: Improve logging of enabled experimental features
We didn't log what we enabled, just g_info():ed what failed to be
enabled. Change this to g_warning() what failed to be enabled, and
g_message() on what was enabled, so that both will be visible in the
logs.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1061
2020-02-17 17:08:21 +00:00
Robert Mader
aceadfe305 cullable: Check if effects are disabled
Currently we skip culling actors if they have any effects set. But
effects can be disabled, in which case we don't need to do that.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1052
2020-02-14 01:17:42 +01:00
Carlos Garnacho
1ecfdb1748 backends: Drop meta_idle_monitor_get_for_device()
As far as public API is concerned, there's only one idletime monitor
from now on.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1039
2020-02-12 22:07:55 +00:00
Carlos Garnacho
f7646af810 core: Do not update idle times for slave devices
Those go nowhere, so just avoid doing this.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1039
2020-02-12 22:07:55 +00:00
Carlos Garnacho
586723eb44 backends: Drop per-device idle monitors
We preserve the core one, which represents the union of all input
devices. It might make sense to make this per-seat in the future,
but certainly the per-device granularity is unused (at last!) and
useless.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1039
2020-02-12 22:07:55 +00:00
Adam Jackson
5c704e3f81 cogl: Remove no-op cogl_shader_compile and cogl_shader_get_info_log
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1024
2020-02-12 21:55:44 +00:00
Robert Mader
1981449776 wayland/actor-surface: Do not set opaque region for XWayland clients
XWayland clients get their opaque region set from their window, not the
surface. Doing both resulted in the surface constantly overwriting the
opaque region - effectively disabling culling of XWayland clients.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1049
2020-02-12 01:52:38 +01:00
Olivier Fourdan
98d7a542b0 wayland: Advertise MetaMonitor as wl_output
With the logical size of outputs being handled by xdg-output, we don't
need to "lie" to Wayland clients anymore about the output size, so
advertise the real mode size as wl_output regardless of the scale, as it
should be (and like other Wayland compositors do).

https://bugzilla.gnome.org/show_bug.cgi?id=787363
https://gitlab.gnome.org/GNOME/mutter/merge_requests/994
2020-02-11 18:56:13 +00:00
Jonas Ådahl
438f75e6b3 cursor-renderer-native: Get cursor size from MetaKmsDevice
It now provides this information, so don't get it ourself.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
f3cdc9906c kms/device: Handle tracking capabilities
Devices have capabilities that other parts need to know about. Instead
of having them probe using drmMode* API, outsource this to
MetaKmsDevice. Currently the only capability tracked is HW cursor size.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
ae00f5653e cursor-renderer-native: Port to transactional KMS api
Turns the cursor setting and movement into cursor plane assignment
primitives. In the current simple implementation, this in turn
translates into legacy drmModeSetCursor() and drmModeMoveCursor() calls.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
7c3172a0af kms/impl-simple: Add cursor plane processing
A cursor plane can now be assigned, and for the simple KMS
implementation, it'll translate into drmModeSetCursor() and
drmModeMoveCursor() calls.

When assignments failed, the cursor planes that failed to be assigned
are communicated via the feedback object.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
73dcb9fa22 kms: Make update processing return direct feedback
The current API as all synchronous, so they can be made to return
feedback immediately. This will be needed for the cursor renderer which
needs to know whether it should fall back to OpenGL cursor rendering.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
3ace2b9a28 kms/update: Move auto-cleanup declaration to the bottom
It relies on visible function declarations, so move it to the bottom so
we can add more auto-cleanup declarations same without them being spread
out.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
01bab81727 kms/update: Add flags to plane assignment
Currently unused, but will used to let the implementation know when it
can avoid setting the plane content (i.e. not call drmModeSetCursor()).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
c1fc46e3db kms/device: Fix indentation mistake
https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
4abec2f8e7 kms: Assert that callbacks are outside of the impl context
https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
ee854ed7ab kms: Fix function name
meta_kms_update_process_..() makes it sound like it's a MetaKmsUpdate
function called update_..() but in fact it's a MetaKms function that
calls the corresponding process-update impl function. Clear up this
naming confusion.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
ec9d7145c8 kms: Return gpointer from impl tasks
Currently only used to return either TRUE or FALSE to communicate
success or failure. Will be used to return feedback objects.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
3a8c545b32 kms/device: Add getter for finding cursor planes
Works the same as the getter for the primary planes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:32:07 +01:00
Jonas Ådahl
6c1e9b51f9 kms-impl-simple: Add helper to process update entries
This avoids some loop iteration boiler plate.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:27:46 +01:00
Jonas Ådahl
851024f730 kms/update: Add unassign_plane() API
Meant to disable a plane.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:27:46 +01:00
Jonas Ådahl
b23fc99655 kms/plane: Move _new() function to private header
Code outside of the MetaKms namespace is not expected to create plane
objects, so move it to a private header. More things will be added to
this header later.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/930
2020-02-11 18:27:46 +01:00
Olivier Fourdan
0f58c98386 screen-cast-window: Use buffer bounds in place of frame bounds
The frame bounds as returned by `meta_window_actor_get_frame_bounds()`
would be used as cropping values when streaming a window content.

But, as its name implies, it returns the actual frame bounds, whereas we
may want to include the whole buffer, to include client side shadows for
example.

Rename the `get_frame_bounds()` API to `get_buffer_bounds()` (which was
previously partly removed with commit 11bd84789) and return the actual
buffer bounds to use as the cropping area when streaming a window.

Fixes: 931934511 - "Implement MetaScreenCastWindow interface"
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1022
Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1018
2020-02-11 12:59:57 +00:00
Olivier Fourdan
ebc07871eb shaped-texture: Add get_width()/get_height() API
Add an API to retrieve the content size of a shaped texture.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1022
2020-02-11 12:59:57 +00:00
Olivier Fourdan
840c50b00d window-actor: Ensure clipping in capture_into()
The clip bounds passed in `meta_window_actor_capture_into()` represent
the actual allocated buffer size where the window actor image will be
eventually copied.

As such, it is completely agnostic to the scaling factors that might
affect the different surface actors which compose the window actor.

So instead of trying to compute the scale factor by which the given
clipping bounds need to be adjusted, simply clip the resulting image
based on the given bounds to make sure we never overflow the destination
buffer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1022
2020-02-11 12:59:57 +00:00
Carlos Garnacho
e76ff8530b backends/native: Override the right property name
Fixup to https://gitlab.gnome.org/GNOME/mutter/merge_requests/1044,
clearly it's not enough to compile check after "just a minor rename".
2020-02-11 12:02:04 +01:00
Carlos Garnacho
c273f74025 backends: Implement ClutterSeat::touch-mode on MetaSeatNative
This taps on:
1) Touchscreen availability
2) Availability of external keyboards
3) Tablet mode switch, if existent

So we get this property enabled whenever it makes sense to show touch
focused features (eg. the OSK).

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1044
2020-02-10 22:04:53 +00:00
Sergio Costas
5b1620475e Fix incorrect 'is' in gen_default_modes
During compilation, gen_default_modes.py shows two warnings that
say that a comparison is using 'is' instead of '=='.

This patch fixes this bug.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/985
2020-02-10 20:35:05 +01:00
Olivier Fourdan
934a829a57 wayland/subsurface: Keep subsurface actors reactive
The actors of Wayland subsurfaces are set to be reactive on creation,
when receiving the `wl_subcompositor.get_subsurface` request.

However, if a client creates several subsurfaces and then creates the
xdg_toplevel object after, the previous subsurface actors are reset.

As a result, Clutter picking will skip and ignore those actors in
`clutter_actor_should_pick_paint()` because they aren't marked as
reactive anymore.

An example of such a client being affected by this issue is SCTK, the
Rust library implementing client side decorations for Wayland used
internally by winit and alacritty.

Move the `set_reactive()` call from `get_subsurface()` to the subsurface
`sync_actor_subsurface_state()` vfunc to make sure those remain reactive
even after `xdg_surface.get_toplevel` is invoked.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1024
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1040
2020-02-10 08:51:41 +00:00
Robert Mader
264f68858a surface-actor: Implement meta_cullable_is_untransformed interface
Its `cull_out()` method was already implemented with geometry scale
in mind. Add a corresponding `is_untransformed()` method so culling
succeeds with geometry scale > 1.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1036
2020-02-08 19:20:41 +01:00
Robert Mader
56ce25360c cullable: Factor out untransformed check into a vfunc
Some cullable implementation may have extra information about their
expected size. The main example here are surface actors which can be scaled
by geometry scale.

Add an API to overwrite the default size / untransformed check for such cases.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1036
2020-02-08 19:20:41 +01:00
Robert Mader
d8b7905662 surface-actor: Scale unobscured and clip region by geometry scale
The local copy of the clip- and unobscured region are used to optimize
painting. To get correct results when the actor is scaled, thus "grows",
the corresponding regions have to "shrink", i.e. get scaled down.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1036
2020-02-07 19:22:15 +01:00
Robert Mader
ae1768bf4f wayland/actor-surface: Do not use geometry scale to constrain regions
The regions and the surface size are all in surface coordinates, thus
don't use the geometry scale, otherwise we might not clip scaled actors
enough.

See also https://gitlab.gnome.org/GNOME/mutter/merge_requests/148

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1036
2020-02-07 18:05:49 +01:00
Robert Mader
cbef49fd74 shaped-texture: Remove unused meta-cullable header
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1036
2020-02-07 18:05:49 +01:00
Hans de Goede
bcbb44fdea monitor-config-manager: honor accelerometer value changes when there is more than 1 monitor
Modify create_for_builtin_display_rotation to lookup the
MetaLogicalMonitorConfig for the panel in the logical_monitor_configs
list instead of only working when there is only 1 monitor.

The goal of this change is to honor accelerometer value changes when there is
more than 1 monitor.

Note, since create_for_builtin_display_rotation is also used for handling the
"rotate-monitor" hotkey and this commit modifies the common path of
create_for_builtin_display_rotation this means that we will now also honor
"rotate-monitor" hotkey keypresses when there is more than 1 monitor and
update the builtin display rotation instead of ignoring "rotate-monitor"
hotkey keypresses when there is more than 1 monitor. If this is deemed
undesirable this is easy to fix, but I believe that doing things this way
is more consistent.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/959
2020-02-07 13:55:39 +01:00
Hans de Goede
0d185b21fd monitor-config-manager: Add clone_logical_monitor_config_list helper
Add a clone_logical_monitor_config_list helper function for making a deep
copy of MetaLogicalMonitorConfig lists.

This is a preparation patch for honoring accelerometer value changes when
there is more than 1 monitor.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/959
2020-02-07 13:50:51 +01:00
Hans de Goede
e4d5cb72ee monitor-config-manager: Take device orientation into account for new configs
When creating a new config because of a monitor being (un)plugged or
because of super+p being pressed, honor the orientation reported by
the accelerometer for the internal panel.

Before this commit we would always configure the internal panel with
a normal / upright transform when e.g. an external monitor gets plugged
in even if another transform was in use before plugging in the external
monitor. This is inconsistent and causes problems for several use-cases.
This commit fixes this by querying the accelerometer when creating a new
config for an internal panel.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/707
Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/924

https://gitlab.gnome.org/GNOME/mutter/merge_requests/959
2020-02-07 13:46:45 +01:00
Hans de Goede
c37e2523ac orientation-manager: Do not change current orientation when locked
Bail out of sync_state() immediately if the orientation is locked, before
calling read_iio_prox() which updates the curr_orientation value.

There are 2 reasons for this change:

1. Currently meta-monitor-config-manager.c always assumes normal / upright
orientation when generating a new config. This means that e.g. when an
external monitor gets plugged in the builtin panel's transform will be reset
to normal / upright even if the device is not in an upright orientation.

To fix this meta-monitor-config-manager.c needs to call
meta_orientation_manager_get_orientation() to get the current orientation
when generating a new config. Without this change locking the orientation
would stop the emitting of "orientation-changed" signals but we would
still update the curr_orientation value. So when a new config needs to
be generated the latest orientation would be used, effectively ignoring
the "orientation-lock" setting, not updating curr_orientation when
locked fixes this.

2. This ensures we properly emit an an "orientation-changed" signal when
the orientation has changed between when it was locked and it was
unlocked. Before this change if the user locked the orientation, changed it
and then unlocked it, no signal would be raised as we would already have
updated the curr_orientation value turning the sync_state() call in
orientation_lock_changed() into a no-op.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/959
2020-02-07 13:46:45 +01:00
Daniel van Vugt
06dae3a8cc wayland-pointer: Bail unconditionally if without native backend
Using `-Dnative_backend=false` caused build failure due to a missing
(implicit) definition of `META_IS_BACKEND_X11`. But if we define it
properly then that just leaves some of the function's locals uninitialized
and it will never work anyway. Just return unconditionally if there's no
native backend to initialize the variables.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1025
2020-02-05 18:09:34 +08:00
Daniel van Vugt
76240e24f7 background: Scale monitor_area after texture creation
Scaling the `monitor_area` before texture creation was just wasting
megabytes of memory on resolution that the monitor can't display. This
was also hurting runtime performance.

Example:

  Monitor is natively 1920x1080 and scale set to 3.

  Before: The monitor texture allocated was 5760x3250x4 = 74.6 MB
  After:  The monitor texture allocated is  1920x1080x4 =  8.3 MB

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1004
2020-02-04 19:48:01 +00:00
Olivier Fourdan
9b0392e988 backends/native: Emit signals for virtual devices
When creating a virtual device for the native backend, no "device-added"
is emitted.

Similarly, no "device-removed" signal is emitted either when the virtual
device is disposed.

However, the backend plugs into the "device-added" signal to set the
monitor device. Without the "device-added" signal being emitted, the
monitor associated with a virtual device remains NULL.

That later will cause a crash in `meta_idle_monitor_reset_idlettime()`
called from `handle_idletime_for_event()` when processing events from a
virtual device because the device monitor is NULL.

Make sure to emit the "device-added" signal when creating a virtual
device, and the "device-removed" when the virtual device is disposed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1037
2020-02-04 18:26:52 +01:00
Florian Müllner
aa0aa89a1e window: Ignore requests to be placed on non-existent workspaces
When an X11 window requests an initial workspace, we currently trust
it that the workspace actually exists. However dynamic workspaces
make this easy to get wrong for applications: They make it likely
for the number of workspaces to change between application starts,
and if the app blindly applies its saved state on startup, it will
trigger an assertion.

Make sure that we pass valid parameters to set_workspace_state(),
and simply let the workspace assignment fall through to the default
handling otherwise.

https://gitlab.gnome.org/GNOME/mutter/issues/1029
2020-02-04 00:07:54 +00:00
Robert Mader
b91d66bf98 core: Extend list of image formats to be stored in the clipboard manager
These types are probably common enough to support.

See also:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1034
2020-02-03 16:51:15 +01:00
Carlos Garnacho
832c0fb0ea core: Define specific image formats to be stored in the clipboard manager
And order those preferences in order of lossiness (jpeg < png < bmp). This
avoids us from prefering other formats that are not useful or widely
recognized.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/939
2020-02-03 13:19:00 +00:00
Carlos Garnacho
2fbbf657d5 core: Demote image formats' priority from preservation in clipboard manager
Most usually, applications either expose clipboard content either as text
or as images, so the prioritization here is pointless. However there's some
outliers like LibreOffice Calc which exports content as both image and text
formats (besides other internal ones).

In that mixed case, we probably prefer to keep text formats, rather than
image based ones.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/919
2020-02-03 13:19:00 +00:00
Sebastian Keller
81de2c2913 backends/x11: Fix use after free on device removal
The devices_by_id hash table is responsible for managing the reference
to the devices. In remove_device however, for non-core devices there are
additional calls to dispose/unref, after the last reference has
already been dropped by the hash table.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1032
2020-02-01 15:35:49 +00:00
Carlos Garnacho
ffad55c66f wayland: Handle dragging from/dropping to v1 data device users
Interoperation between wl_data_device_manager v1 and v3 got broken
at some point. Ensure that we resort to the "copy" action if either
the drop site or the drag source are from a client that requested v1.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/965
2020-02-01 15:14:52 +00:00
Sebastian Keller
98040e67a2 core: Fix task leak in meta_selection_source_memory_read_async
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
e7928ce6ee selection: Fix task leak in error case of source_read_cb
Fixes the last part of https://gitlab.gnome.org/GNOME/mutter/issues/1006
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
b41094ef5f x11-selection: Unref owners and cancellables on shutdown
Selection owners are set using g_set_object in source_new_cb, but that
reference is never removed on shutdown.

Similarly the cancellables created in handle_xfixes_selection_notify are
never freed on shutdown.

Fixes parts of https://gitlab.gnome.org/GNOME/mutter/issues/1006
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
d699c80ac2 display: Unref selection on shutdown
Otherwise it will be leaked and the dispose method added in the previous
commit would never be run.

Fixes parts of https://gitlab.gnome.org/GNOME/mutter/issues/1006
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
35316a034f selection: Unref selection owners on dispose
Selection owners are set using g_set_object, which adds a reference to
the owner, which then never was removed on shutdown.

Fixes parts of https://gitlab.gnome.org/GNOME/mutter/issues/1006
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
c05019e232 x11-selection: Don't store copies of strings that are not being used
MetaX11SelectionOutputStream was storing copies of strings only to use
them in init and then free them in finalize. This was also causing a
small leak, because one of these strings was not freed. Instead of doing
that just don't create these unnecessary copies in the first place.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
861e5caf8c x11-selection: Plug potential GInputStream leak
The stream was not freed in the error case. I have never observed this
one in practice though.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
8e6821bc65 x11-selection: Plug MetaSelectionSourceX11 leak
meta_selection_source_x11_new_finish() transfers the ownership of the
selection source, but source_new_cb() was not freeing it.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/998
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
05301d280c clipboard-manager: Plug mimetypes list leak
Fixes https://gitlab.gnome.org/GNOME/mutter/issues/1005
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Robert Mader
15b46a6f88 wayland/data-device: Small style fixes
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1031
2020-01-31 12:13:02 +01:00
Robert Mader
c27fc3537b wayland/data-device: Guard against a potential crash
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1031
2020-01-31 12:13:02 +01:00
Robert Mader
6cc748cce9 wayland/data-device: Cancel drag source when the drag finished unsuccessfully
When a drag was performed but did not finish successfully, e.g. because no
mimetype was accepted, we need to send the source cancel event so clients
know they can destroy the drag source (since version 3).

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1031
2020-01-31 12:13:02 +01:00
Sebastian Keller
afd645193a backends/native: Use proper method for getting core idle monitor
e9fbbd5853 changed meta_backend_get_idle_monitor() to use
ClutterInputDevice pointers instead of device IDs, but did not adjust
the call in meta_backend_native_resume() which was still using 0 to get
the core idle monitor resulting in a NULL pointer dereference.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1029
2020-01-30 22:19:49 +00:00
Carlos Garnacho
5723bd8ec7 backends: Use latest pointer position if no pointer constrain exists
The meta_seat_native_constrain_pointer() function receives the current
pointer position, and the new pointer position as in/out parameters.
We were however calculating the new coordinates based on the last pointer
position if there was no pointer constrain in place.

Fortunately to us, this didn't use to happen often/ever, as a pointer
constrain function is set on MetaBackend initialization. This behavior
did also exist previously in MetaDeviceManagerNative.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1028
2020-01-30 18:57:18 +01:00
Carlos Garnacho
1e9682b417 backends: Move warp_pointer() to ClutterSeat
The onscreen pointer sprite is a per-seat element, so it makes sense
to move pointer warping over there too.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:12:58 +01:00
Carlos Garnacho
9da275cf73 backends: Set pointer constrain/relative motion hooks before backend init
The backend being initialized triggers a pointer warp (and motion event)
where we want to observe the callbacks put in place. So ensure we set
up the hooks before that could happen.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:12:58 +01:00
Carlos Garnacho
f1d4d687f3 backends: Drop get_relative_motion_deltas() vfunc
Just go ATM through backend checks, and looking up directly the
native event data, pretty much like the rest of the places do that...
Eventually would be nice to have this information in ClutterEvent,
but let's not have it clutter the MetaBackend class.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:11:37 +01:00
Carlos Garnacho
e9fbbd5853 backends: Do not use device IDs on idle monitors
Device IDs are somewhat x11 specific, seems better to avoid those
on public API. We can rely everywhere on ClutterInputDevice, so use
it instead.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:11:23 +01:00
Carlos Garnacho
d3160d095d clutter: Drop ClutterDeviceManager
This is mostly replaced by ClutterSeat, which offers a per-seat instead
of a global device abstraction.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:11:23 +01:00
Carlos Garnacho
873449d0f9 tests: Replace ClutterDeviceManager usage in favor of ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:11:23 +01:00
Carlos Garnacho
4413b86a30 backends: Replace ClutterDeviceManager usage in favor of ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:11:23 +01:00
Carlos Garnacho
f55d4f33af backends: Make meta_backend_update_last_device() take a clutter device
Instead of a pretty x11 specific device ID. This also updates the argument
of the ::last-device-changed signal to be a ClutterInputDevice.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:34 +01:00
Carlos Garnacho
4761c4ee1c backends: Move native keymap manipulation functions to MetaSeatNative
Since the ClutterKeymap is obtained through the ClutterSeat, it makes
sense to have these manipulation functions in the ClutterSeat impl.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:34 +01:00
Carlos Garnacho
7644ddeddc core: Replace ClutterDeviceManager usage in favor of ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:34 +01:00
Carlos Garnacho
6dfd2ffcef wayland: Replace ClutterDeviceManager usage in favor of ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:34 +01:00
Carlos Garnacho
835f12043e clutter: Drop select_stage_events() device manager vfunc
This is specific to X11, so handle it within the X11 backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:34 +01:00
Carlos Garnacho
7afbc01fe8 clutter: Move motion compression handling to ClutterSeat
Another responsibility taken away from ClutterDeviceManager

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:31 +01:00
Carlos Garnacho
1c689b83f9 clutter: Move virtual device management to ClutterSeat
A11y in general may be considered a per-seat feature.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:14 +01:00
Carlos Garnacho
8d0527f674 clutter: Move pointer a11y from ClutterDeviceManager to ClutterSeat
A11y in general may be considered a per-seat feature.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:01:53 +01:00
Carlos Garnacho
bc7ba8c875 clutter: Move keyboard a11y from ClutterDeviceManager to ClutterSeat
A11y in general may be considered a per-seat feature.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:01:50 +01:00
Carlos Garnacho
34ce39f8dc clutter: Move platform event data management to ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 17:59:47 +01:00
Carlos Garnacho
9be4f98c73 clutter: Move keymap from ClutterBackend to ClutterSeat
Keymaps are a per-seat feature, so move it there.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 17:59:47 +01:00
Carlos Garnacho
1fc021c3c6 clutter: Move bell_notify() from ClutterBackend to ClutterSeat
Bells can be considered to be a per-seat feature, so move it there.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 17:59:46 +01:00
Carlos Garnacho
9aba37f70f clutter: Move keymap direction from ClutterBackend to ClutterKeymap
This makes more sense to have in the ClutterKeymap, since we have it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 17:59:46 +01:00
Carlos Garnacho
5bb3d86884 native: Implement ClutterSeat
We had the MetaSeatNative struct around, so use it as the base of
this Clutter object. A few responsibilities were drawn from
ClutterDeviceManager.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 17:59:41 +01:00
Carlos Garnacho
1611979fa8 x11: Implement ClutterSeat
The ClutterDeviceManager signaling becomes implemented on top of this.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 16:28:51 +01:00
Carlos Garnacho
88fb003cdc x11: Drop subscription for input event from floating devices
This is unlikely to happen, and unlikely to be right (eg. we don't translate
input event coordinates, since those are not in display coordinate space, we
don't offer any feedback for those either).

This can simply be dropped, we listen to XIAllMasterDevices, which suffices
for what we want to do.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 16:28:51 +01:00
Olivier Fourdan
a382698acc wayland: Update input device before repick
When a Wayland window is mapped or unmapped, the Wayland compositor is
expected to send the coorespoindign `wl_pointer` enter/leave events to
the affected clients.

To do so, mutter calls `meta_wayland_compositor_repick()` which
eventually calls `meta_wayland_pointer_repick()` and
`repick_for_event()`.

If pointer input device has not been updated yet, the old clutter actor
is picked and no enter/leave event is emitted.

Make sure we update the pointer input device prior to do the repick to
get the actual `ClutterActor` under the pointer.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1016
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1026
2020-01-30 09:37:58 +01:00
Olivier Fourdan
5618e41cea window: Remove Wayland code from meta_window_show()
As we now call `meta_wayland_compositor_repick()` when the effects are
complete for Wayland surfaces, we can safely remove the Wayland specific
code to do the same from `meta_window_show()`.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1026
2020-01-30 09:37:58 +01:00
Olivier Fourdan
f97930eaf5 wayland/surface: Repick when effects are complete
When mapping/unmapping windows, an animation may be played which can
change the actual actor size and location, hence defeating picking if
done too early.

Make sure we repick when the affects are completed, once the actor is
sized and placed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1026
2020-01-30 09:37:58 +01:00
Alberts Muktupāvels
5e07478843 x11-display: add support for _GTK_WORKAREAS_Dn
In addition to existing _NET_WORKAREA property set also new
_GTK_WORKAREAS_Dn property where n is desktop number (between 0
and _NET_NUMBER_OF_DESKTOPS - 1).

https://mail.gnome.org/archives/wm-spec-list/2018-December/msg00000.html
https://gitlab.freedesktop.org/xdg/xdg-specs/merge_requests/22

https://gitlab.gnome.org/GNOME/mutter/merge_requests/370
2020-01-29 11:08:21 +00:00
Olivier Fourdan
1ce933e281 window-actor/x11: Get frame rect from the buffer size
When building the frame mask, the current reported frame size may not
match when is actually on screen if the buffer has not been updated
yet.

So instead of getting the frame size from the meta window, deduce it
from the texture size.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1009
2020-01-29 10:44:50 +00:00
Olivier Fourdan
1000ebe203 window/x11: Add function to convert the buffer to frame rect
Add a convenient function to get the frame rectangle from a given
buffer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1009
2020-01-29 10:44:50 +00:00
Olivier Fourdan
c0321c7b21 frame: Pass the frame area for get_mask()
Currently, `meta_frame_get_mask()` and `meta_ui_frame_get_mask()` will
return the frame mask applied to the current frame size, by querying the
frame themselves.

To be able to get the frame mask at an arbitrary size, change the API to
take a rectangle representing the size at which the frame mask should be
rendered.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1009
2020-01-29 10:44:50 +00:00
Olivier Fourdan
7dbb4bc3f5 window-actor/x11: Cache the client area
With Xwayland, the shape region is recomputed and reapplied even when
the actor is frozen to prevent the black shadows effect.

However, while recomputing the shape region, the current client size is
taken into account, rather than the size when the client was frozen,
which is ahead of the actual client size using the NET_WM_SYNC protocol.

Keep the current client area and to reuse them when the X11 window actor
is frozen for rebuilding the client mask texture.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1009
2020-01-29 10:44:50 +00:00
Corentin Noël
9d390ee49f meta: Add missing display.h to meta-workspace-manager.h
This is required because MetaDisplayCorner is only defined in display.h

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1025
2020-01-29 11:30:24 +01:00
Carlos Garnacho
403466c0db wayland: Implement dnd cancel on pressing Esc key
When this key is pressed the DnD operation should be cancelled,
and the "pop DnD icon back" animation to happen.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1020
2020-01-28 14:05:35 +00:00
Carlos Garnacho
30bf588a38 wayland: Do not check current offer on DnD button release
This check was added on commit 48639ac5 as a means to disregard
DnD drops where the offer would disappear beforehand. However since
that commit was all about wl_data_device_manager version < 3,
forgetting about the selected mimetype seems a behavior more inline
with those versions.

Since no current drop is something expected on X11 drop sites, fixes
DnD over those, while keeping the original bug fixed.

Found by Robert Mader (https://gitlab.gnome.org/GNOME/mutter/issues/974#note_688144)

https://gitlab.gnome.org/GNOME/mutter/issues/974
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1005
2020-01-27 14:07:47 +00:00
Carlos Garnacho
090a6ad409 xwayland: Set XDND source-side actions as per XDND
In XDND, we just get a hint on XdndPosition about what's the action
chosen by the user. Make the data source actions the full set on
XdndEnter (as we can't know better), and pass the hint in XdndPosition
as the user chosen action as it should be.

Makes Wayland drop sites aware of the user action as per XDND with X11
drag sources, and still makes modifiers during DnD work.

https://gitlab.gnome.org/GNOME/mutter/issues/974
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1005
2020-01-27 14:07:47 +00:00
Carlos Garnacho
a6c195b05c x11: Map x11 (UTF8_)STRING requests to text/plain mimetypes
Make the x11 selection proxy map UTF8_STRING and STRING to proper
mimetypes, as the selection source (wayland or memory) might not
offer those for backwards compatibility.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/1355
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1005
2020-01-27 14:07:47 +00:00
Carlos Garnacho
c1df48befd wayland: Preserve XdndTypeList for future callers
This Xdnd property is owned by the drag source, we shouldn't delete
it when reading/proxying it to Wayland clients.

Closes: https://gitlab.gnome.org/GNOME/gtk/issues/2347
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1005
2020-01-27 14:07:47 +00:00
Sebastian Keller
abc58f7b9d kms: Fix drmModeEncoder leak
The result of drmModeGetEncoder() needs to be free'd by the caller.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1020
2020-01-24 21:10:11 +00:00
Sebastian Keller
66fe6d85d0 backends/crtc: Fix leak of MetaCrtcMode name string
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1020
2020-01-24 21:10:11 +00:00
Sebastian Keller
a63e80ec64 wayland: Avoid GVariant leak in set_gnome_env
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1020
2020-01-24 21:10:11 +00:00
Sebastian Keller
9feda1c58b kms/crtc: Fix gamma state leak
The gamma value pointers of the current_state are overwritten by the
calls to memdup causing a small leak. while the leak itself is small, it
can be triggered quite often from things like night light.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1020
2020-01-24 21:10:11 +00:00
Sebastian Keller
51733ca499 window/wayland: Plug window configuration leak
The acked configuration is removed from the pending configuration list
by acquire_acked_configuration(), but finish_move_resize() does not free
the data after applying the configuration.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1020
2020-01-24 21:10:11 +00:00
Sebastian Keller
f0c92646eb wayland/surface: Plug leak in meta_wayland_surface_assign_role
The underlying data of the names array is not used anymore after this,
so it should be freed as well.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1020
2020-01-24 21:10:11 +00:00
Sebastian Keller
f447a053bb renderer: Chain up parent class finalize
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1016
2020-01-22 20:56:34 +01:00
Adam Jackson
545fcb3dbf renderer-native: Fix memory leak in secondary GPU update
Leaking a texture object and a framebuffer object every time you update
the secondary GPU is perhaps not the best plan.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1011
2020-01-21 14:39:01 +00:00
Sebastian Keller
b30a29f830 shaped-texture: Plug region leak
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1002
2020-01-16 20:57:20 +00:00
Pekka Paalanen
b6c824dd16 renderer/native: Import primary buffer to 2nd GPU
Where possible, try to export the buffer rendered by the primary GPU as a
dmabuf and import it to the secondary GPU and turn it into a DRM FB for
scanout. If this works, we get a zero-copy path to secondary GPU outputs.

This is especially useful on virtual drivers like EVDI (used for DisplayLink
devices) which are not picky at all about what kind of FBs they can handle.

The zero-copy path is prioritised after the secondary GPU copy path, which
should avoid regressions for existing working systems. Attempting zero-copy
would have the risk of being less performant than doing the copy on the
secondary GPU. This does not affect the DisplayLink use case, because there is
no GPU in a DisplayLink device.

The zero-copy path is prioritised before the primary GPU and CPU copy paths. It
will be tried on the first frame of an output and the copy path is executed
too. If zero-copy fails, the result from the copy path will take over on that
frame. Furthermore, zero-copy will not be attemped again on that output. If
zero-copy succeeds, the copy path is de-initialized.

Zero-copy is assumed to be always preferable over the primary GPU and CPU copy
paths. Whether this is universally true remains to be seen.

This patch has one unhandled failure mode: if zero-copy path first succeeds and
then fails later, there is no fallback and the output is left frozen or black.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/810
2020-01-16 20:19:29 +00:00
Pekka Paalanen
03ac7b1821 backend/native: Share drmModeAddFB code
With all the three paths this is quite a handful of code, and it was mostly
duplicated in two places. A follow-up patch would need to introduce a third
copy of it. Therefore move the code into a helper function.

There are two behavioral changes:

- The format error now prints the string code as well, because it is easy to
  read.

- The g_debug() in init_dumb_fb() is removed. Did not seem useful.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/810
2020-01-16 20:19:29 +00:00
Pekka Paalanen
f409dddb54 renderer/native: Extract secondary_gpu_release_dumb
There will be another place where I need to release the dumb buffers but not
destroy the whole secondary_gpu_state, so extract this bit of code into a
helper.

The checks of fb_id are dropped as redundant with the check already in in
release_dumb_fb ().

https://gitlab.gnome.org/GNOME/mutter/merge_requests/810
2020-01-16 20:19:29 +00:00
Pekka Paalanen
fe76e6a228 renderer/native: Reset all fields of MetaDumbBuffer
release_dumb_fb () checks 'map' to see if anything needs freeing. Other places
are checking fb_id instead. The checks maybe redundant, but let's reset all
fields here while at it, so that all the checks work as expected.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/810
2020-01-16 20:19:29 +00:00
Pekka Paalanen
40408150f0 renderer/native: Absorb free_next_secondary_bo
The function is trivial and only used once, so fold it into the caller.

Makes the code more readable by removing a little bit of boilerplate.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/810
2020-01-16 20:19:29 +00:00
Pekka Paalanen
fea6abb4f0 renderer/native: Copy mode irrelevant for bo freeing
Simplify the bo freeing functions by not checking what the copy mode is. This
matches what swap_secondary_drm_fb () already does. g_clear_object () is safe
to call even if the value is already NULL.

The copy mode does not change mid-operation. If it did, this change would
ensure we still clean up everything. So this is more future-proof too.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/810
2020-01-16 20:19:29 +00:00
Pekka Paalanen
94992ffff6 renderer/native: META_DRM_BUFFER is not NULL-safe
I could not find this in GObject documentation, but I hear the cast macro is
not safe to call with NULL.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/810
2020-01-16 20:19:29 +00:00
Pekka Paalanen
d7c9042c78 renderer/native: state consistency in copy_shared_framebuffer_gpu
To mirror what happens in meta_onscreen_native_swap_buffers_with_damage(), warn
here too if next_fb is not NULL. This makes it clear to the reader of what the
expectations are inside this function.

Ensuring next_fb is NULL as the first thing in the function will make all error
paths equal: no longer some failures reset next_fb while others don't. Removing
such special cases should reduce surprises.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/810
2020-01-16 20:19:29 +00:00
Jonas Ådahl
ce3409b2b7 kms-impl-simple: Handle mode set race conditions gracefully
If we end up trying to do a mode set on a DRM state that has already
changed behind our back without us yet having seen the hotplug event we
may fail with `EINVAL`. Since the renderer layer doesn't handle mode set
failure, it'll still try to page flip later on, which will then also
fail. When failing, it'll try to look up the cached mode set in order to
retry the mode set later on, as is needed to handle other error
conditions. However, if the mode set prior to the page flip failed, we
won't cache the mode set, and the page flip error handling code will get
confused.

Instead of asserting that a page flip always has a valid cached mode set
ready to look up, handle it being missing more gracefully by failing to
mode set. It is expected that things will correct themself as there
should be a hotplug event waiting around the the corner, to reconfigure
the monitor configuration setting new modes.

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1007
2020-01-16 14:50:34 +00:00
Jonas Ådahl
7733f88168 kms-impl-simple: Include mode name in error message
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1007
2020-01-16 14:50:34 +00:00
Olivier Fourdan
c0038f6dac window-actor/x11: Update shape even when frozen
On Xwayland, freezing actor updates on sync requests means the
server-side frame and shadows repaint will be frozen as well, which
causes the shadow to show black at times when resizing X11 clients
which support NET_WM_SYNC.

Using freeze/thaw commits prevents the content from changing, yet the
shape window still needs to be updated when frozen otherwise the
difference in shape induced by the on-going resize operation will show
as well, even if the toplevel window has its commits frozen.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
Closes: https://bugzilla.gnome.org/show_bug.cgi?id=767212
Closes: https://gitlab.gnome.org/GNOME/mutter/issues/858
2020-01-16 09:22:25 +01:00
Olivier Fourdan
4d5a86327a window/x11: Add always_update_shape() vfunc
To address the black shadows that sometimes show during resize with
Xwayland, we need to update the window shape regardless of the frozen
status of the window actor.

However, plain Xorg does not need this, as resized windows do not clear
to black, so add a new vfunc to window/x11 to indicate whether or not
the backing windowing system (either plain X11 or Xwayland) would
require the shape to be always updated.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Olivier Fourdan
d7a7af1ff2 window-actor/x11: Freeze/thaw commits on actor freeze/thaw
When using Xwayland, if the damage get posted before the X11 window
manager/compositor has finished repainting the actors, the intermediate
state will show.

Make sure to hint Xwayland as to when it can post pending damages and
commit the Wayland buffer using the `freeze_commits()/thaw_commits()`
API, based on window actor freeze/thaw.

See-also: https://gitlab.gnome.org/GNOME/mutter/merge_requests/855
See-also: https://gitlab.freedesktop.org/xorg/xserver/merge_requests/316

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Olivier Fourdan
aa017383ac window-actor: Add set_frozen vfunc
Currently, the window actor freeze/thaw implementation sets the frozen
state of the surface actor using `meta_surface_actor_set_frozen()`.

If we want to expand that behavior to also freeze/thaw commits for X11
windows running on Xwayland, we need to have a specific vfunc to abstract
that in the window actor specific implementation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Olivier Fourdan
c3c54e8ce6 surface-actor: Add meta_surface_actor_is_frozen()
Change the internal `is_frozen()` API to be available publicly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Olivier Fourdan
53fce8e988 frames: Freeze Xwayland commits until repainted
To make sure the frame is painted before the commits are thawed, freeze
the commits when invalidating the GDK window, only to thaw to it after
the actual frame draw is performed or the frame is destroyed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Olivier Fourdan
4ae9953607 window/x11: Freeze commits on resize
Make sure we freeze commits before resizing the window as this will
clear the frame to black.

Set the "thaw on paint" flag so that the post paint for window actor X11
can then thaw the freeze initiated prior to the resize and keep the
freeze/thaw balanced.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Olivier Fourdan
10796e6726 window/x11: Add flag to thaw commits after resize
To be able to thaw commits following a resize that might have frozen
commits, to keep freezes and thaws even, we need a way to tell whether
a repaint should also thaw commits.

Add a flag to `MetaWindowX11` and the appropriate functions to set and
query it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Olivier Fourdan
845157c111 window/x11: Add freeze_commits()/thaw_commits()
Xwayland may post damages for an X11 window as soon as the frame
callback is triggered, while the X11 window manager/compositor has not
yet finished updating the windows.

If Xwayland becomes compliant enough to not permit updates after the
buffer has been committed (see [1]), then the partial redraw of the X11
window at the time it was posted will show on screen.

To avoid that issue, the X11 window manager can use the X11 property
`_XWAYLAND_ALLOW_COMMITS` to control when Xwayland should be allowed to
post the pending damages.

Add `freeze_commits()` and `thaw_commits()` methods to `MetaWindowX11`
which are a no-op on plain X11, but sets `_XWAYLAND_ALLOW_COMMITS` on
the toplevel X11 windows running on Xwayland.

[1] https://gitlab.freedesktop.org/xorg/xserver/merge_requests/316
See-also: https://gitlab.gnome.org/GNOME/mutter/merge_requests/855

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Ray Strode
bac188b568 window: Always disarm XSYNC watchdog when X client responds
At the moment we only disarm the watchdog timer set up for SYNC counter
requests if we're in the middle of a resize operation.

It's possible that the resize operation finished prematurely by the user
letting go of the mouse before the client responded.  If that happens, when the
client finally updates mutter will erroneously still have the watchdog timer
engaged from before until it times out, leading to resizes for the next second
or so to not get processed, and the client to get blacklisted from future sync
requests.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/942
2020-01-16 09:22:25 +01:00
Jonas Ådahl
6d15231f10 wayland/actor-surface: Always consider unmapped actors not on output
This avoids using bogus geometric values from an unmapped actor to
determine whether an actor is on a logical monitor or not. This would
happen when committing to a subsurface of a yet to be mapped toplevel.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:22 +00:00
Jonas Ådahl
3e90070b88 tests/wayland: Test subsurface commits after parent was reset
Without 'wayland/surface-actor: Reset and sync subsurface state when
resetting' this test would fail.

This also adds a simple framework for testing lower level Wayland
semantics.

In contrast to the test-client and test-driver framework, which uses
gtk and tests mostly window management related things, this framework is
aimed to run Wayland clients made to test a particular protocol flow,
thus will likely consist of manual lower level Wayland mechanics.

A private protocol is added in order to help out clients do things they
cannot do by themself. The protocol currently only consists of a request
meant to be used for getting a callback when the actor of a given
surface is eventually destroyed. This is different from the wl_surface
being destroyed due to window destroy animations taking an arbitrary
amount of time. It'll be used by the first test added in the next
commit.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:22 +00:00
Jonas Ådahl
f0df07cba3 wayland/surface: Move shaped-texture synchronization to actor surface
As with most other state that ends up being pushed to the actor and the
associated shaped texture, also push the texture and the corresponding
metadata from the actor surface. This fixes an issue when a toplevel
surface was reset, where before the subsurface content was not properly
re-initialized, as content state synchronization only happened on
commit, not when asked to synchronize.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:22 +00:00
Jonas Ådahl
fe7bece31e wayland/surface-actor: Reset and sync subsurface state when resetting
A actor surface may be reset by an xdg_toplevel if a NULL buffer is
attached. This should reset the actor state of the toplevel to an empty
state, while unmapping the previous actor. Subsurfaces, however, should
stay intact, including their relationship to the toplevel. They should
also not be yanked away from the actor of the actor surface prior to it
resetting, so that a window-destroy animation can include the subsurface
actor.

This fixes a potential crash when a subsurface tries to commit to its
wl_surface after the destroy animation of the toplevel has finished, as
the actor would at that point have been destroyed and cleared from the
actor surface struct, causing a segmentation fault.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:22 +00:00
Jonas Ådahl
3969285e5c shaped-texture: Make setting the same texture a no-op
Will be helpful when pushing state to the shaped texture, letting the
one pushing not have to care about checking if anything changed.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:22 +00:00
Jonas Ådahl
60ebf19c9e shaped-texture: Minor clean up
Use cogl_clear_object(), add reference to texture when setting, and
remove redundant runtime type check.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:22 +00:00
Jonas Ådahl
fcfe90aa9f wayland: Replace manual GNode subsurface iteration with macro
Similar to wl_list_foreach(), add
META_WAYLAND_SURFACE_FOREACH_SUBSURFACE() that iterates over all the
subsurfaces of a surface, without the caller needing to care about
implementation details, such as leaf nodes vs non-leaf nodes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:21 +00:00
Jonas Ådahl
76ee026caa wayland/egl-stream: Cache texture snippet
While it's not very relevant now, as we would rarely create it anyway
since the buffer nor texture never changes for a surface, it will be in
the future, as the actor state (including its content,
MetaShapedTexture) will be synchronized by the MetaWaylandActorSurface
at a later point in time, and not by MetaWaylandSurface, at state
application time.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/961
2020-01-10 16:01:21 +00:00
Jonas Ådahl
6e5ac0b585 Use G_GNUC_FALLTHROUGH instead of comments
Get the same task done in a bit more C:y way.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/998
2020-01-09 17:58:29 +01:00
Jonas Dreßler
c4fa30ac7d backends/native: Fix relative motion calculation if monitor isn't found
The method `relative_motion_across_outputs` is used to adjust the
distance/delta of a mouse movement across multiple monitors to take the
different scale factors of those monitors into account. This works by
getting the adjacent monitors that the movement-line/vector intersects
with and adjusting the final position (or end point of the
movement-line) by multiplying the parts of the line spanning across
different monitors with the scale factors of those monitors.

In the end of this calculation, we always want to set the new end
coordinates of the relative motion to the new end coordinates of the
adjusted movement-line. We currently only do that if all adjacent
monitors the line is crossing actually exist, because only then we end
up inside the "We reached the dest logical monitor" else-block and set
`x` and `y` to the correct values. Fix that and make sure the returned
values are also correct in case an adjacent monitor doesn't exist by
adding separate `target_x` and `target_y` variables which we update during
each pass of the while loop so we're always prepared for the while loop
exiting before the destination monitor was found.

Thanks to Axel Kittenberger for reporting the initial bug and tracking
the issue down to `relative_motion_across_outputs`.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/774
2020-01-07 20:18:46 +00:00
Sebastian Keller
802309caf9 x11-selection: Plug MetaX11SelectionOutputStream leak
https://gitlab.gnome.org/GNOME/mutter/merge_requests/991
2020-01-06 19:54:00 +00:00
Sebastian Keller
468b09c01e theme: Plug GdkPixbuf leak
https://gitlab.gnome.org/GNOME/mutter/merge_requests/991
2020-01-06 19:54:00 +00:00
Sebastian Keller
c13ea4f48d theme: Plug GtkIconInfo leak
https://gitlab.gnome.org/GNOME/mutter/merge_requests/991
2020-01-06 19:54:00 +00:00
Carlos Garnacho
1e7285b2bb backends: Always enable tap-to-click/drag on opaque Wacom tablets
Touch-wise, those are essentially giant touchpads, but have no buttons
associated to the "touchpad" device (There may be pad buttons, but
those are not mouse buttons).

Without tap-to-click/drag, touch in those devices is somewhat useless
out of the box. Have them always enable these features, despite the
setting.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/968
2020-01-06 13:52:55 +00:00
Robert Mader
a8cb84c711 window-actor: Also cull out clip_region
From `meta_cullable_cull_out`:
```
Actors that may have fully opaque parts should also subtract out a region
that is fully opaque from @unobscured_region and @clip_region.
```

As we do no check for the intersection of these two elsewhere in the code,
let's substract from the clip region, too.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/985
2020-01-06 13:38:23 +00:00
Pascal Nowack
e89cea8e5a screen-cast: Fix window recording on HiDPI
Using the same scale for the window as the
logical monitor only works correctly when having
the experimental 'scale-monitor-framebuffer'
feature enabled.
Without this experimental feature, the stream
will contain a black screen, where the actual
window only takes a small part of it.

Therefore, use a scale of 1 for the non-
experimental case.

Patch is based on commit 3fa6a92cc5.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/976
2019-12-18 18:41:44 +01:00
Yariv Barkan
67d9995280 backends/native: Get the correct value for pinch dy
Fix a typo - use the correct libinput api.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/974
2019-12-13 21:57:33 +02:00
Jonas Ådahl
4fccc903b5 xwayland: Don't queue frame callbacks when role assigned
'xwayland: Do not queue frame callbacks unconditionally' changed the
frame callback behavior of Xwayland surfaces so that they behave the
same way as other actor surfaces (e.g. xdg-shell ones), except for the
case when they are initially assigned.

Remove this special casing as well including the now incorrect comment,
so that the Xwayland surfaces behave the same as the others in this
regard also when assigning.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/964
2019-12-10 09:15:49 +00:00
Jonas Ådahl
132fbf49d7 wayland: Let MetaWaylandXdgPopup dismiss incorrectly placed popups
It's a xdg_popup detail, and not until the actual position is finalized
is the actual correctness known.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
d02c124e1d wayland/surface-role: Rename commit() vfunc apply_state()
The vfunc is not called when a surface commits its state, but when the
state is applied. Make this clearer by changing the name to
"apply_state" (and "pre_apply_state").

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
554644f9e0 wayland: Rework asynchronous window configuration
This changes how asynchronous window configuration works. Prior to this
commit, it worked by MetaWindowWayland remembering the last
configuration it sent, then when the Wayland client got back to it, it
tried to figure out whether it was a acknowledgment of the configuration
or not, and finish the move. This failed if the client had acknowledged
a configuration older than the last one sent, and it had hacks to
somewhat deal with wl_shell's lack of configuration serial numbers.

This commits scraps that and makes the MetaWindowWayland take ownership
of sent configurations, including generating serial numbers. The
wl_shell implementation is changed to emulate serial numbers (assuming
each commit acknowledges the last sent configure event). Each
configuration sent to the client is kept around until the client one. At
this point, the position used for that particular configuration is used
when applying the acknowledged state, meaning cases where we have
already sent a new configuration when the client acknowledges a previous
one, we'll still use the correct position for the window.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
cc444d4991 window/wayland: Use G_DECLARE_FINAL_TYPE
https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
4bf5b7d78d window: Don't constrain an acked window geometry
In Wayland, window configuration is asynchronous. Window geometry is
constrained, the constrained geometry is sent to the client, and the
client will adapt its surface and acknowledge the configuration. When
acknowledged, we shouldn't reconstrain again, as that may invalidate the
constraint calculated for the configured size.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
cb91f44ba4 wayland/wl-shell: Use input region as window geometry if set
Historically, wl_shell clients used to pretend the input region was
equivalent to the window geometry, so for "correctness" lets do that
here too. This makes wl_shell clients with drop shadow behave marginally
better than before.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
f7e256e9a1 wayland/surface: Make cached subsurface state generic
This moves the cached subsurface surface state into the generic
MetaWaylandSurface namespace. Eventually it'll be used by other surface
roles which as well aim to implement synhcronization.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
bbec8abb68 wayland/surface: Rename MetaWaylandPendingState to MetaWaylandSurfaceState
The name didn't communicate it was about surface state, and it somewhat
confusingly had the name "pending" in it, which could be confused with
the fact that while it's used to collect pending state, it's also used
to cache previously committed pending state.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
d60d671fec wayland: Use helper to access pending state from the outside
With the eventual aim of exposing the internals of MetaWaylandSurface
outside of meta-wayland-surface.c, make users of the pending state use a
helper to fetch it. While at it, rename the struct field to something
more descriptive.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
8dc730e5ca wayland/surface: Move subsurface synchronization logic to role
It's an implementation detail of subsurfaces when to cache state
and when not to, so move that logic to the subsurface role
implementation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
0cf98c5641 wayland/surface: Emit signal before applying state
Will be used to invalidate depending state that should be updated as
part of a surface state being applied.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
4bacb3621b window/wayland: Make .._wayland_move_resize() name more explanatory
The intention of meta_window_wayland_move_resize() is to finish a
move-resize requested previously, e.g. by a state change, or a
interactive resize. Make the function name carry this intention, by
renaming it to meta_window_wayland_finish_move_resize().

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
aef865afc4 wayland/xdg-shell: Scope variable better
A window geometry rectangle was declared in the wrong scope. Both
xdg-shell and legacy xdg-shell had the same issue.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Tim Crawford
d70ddc65ea backends/native: Fix double free of error
error is an autoptr, so must not be explicitly freed.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/1852
Fixes: 5c500ad402 ("backend: Move GPU ownership from the monitor manager to the backend")

https://gitlab.gnome.org/GNOME/mutter/merge_requests/960
2019-12-06 11:33:26 -07:00
Pekka Paalanen
832a522cce kms-impl/simple: Fix meta_set_fallback_feedback_idle
Presumably this function is supposed to be like
meta_kms_impl_simple_handle_page_flip_callback() but the condition in the
if-statement is inverted. Fix the inversion to make these two functions look
alike.

This is part 2 of 2 fixing a complete desktop freeze when drmModePageFlip()
fails with EINVAL and the fallback to drmModeSetCrtc() succeeds but the success
is not registered correctly as completed "flip". The freeze occurs under
wait_for_pending_flips() which calls down into meta_kms_impl_device_dispatch()
which ends up poll()'ing the DRM fd even though drmModeSetCrtc() will not
produce a DRM event, hence the poll() never returns. The freeze was observed
when hotplugging a DisplayLink dock for the first time on Ubuntu 19.10.

This patch makes meta_set_fallback_feedback_idle() actually end up calling into
notify_view_crtc_presented() which decrements
secondary_gpu_state->pending_flips so that wait_for_pending_flips() can finish.

CC stable: gnome-3-34

https://gitlab.gnome.org/GNOME/mutter/merge_requests/953
2019-12-06 15:55:35 +00:00
Pekka Paalanen
79491df2b8 kms: Process impl idle callbacks before pre dispatch flush
mode_set_fallback() schedules a call to mode_set_fallback_feedback_idle(), but
it is possible for Mutter to repaint before the idle callbacks are dispatched.
If that happens, mode_set_fallback_feedback_idle() does not get called before
Mutter enters wait_for_pending_flips(), leading to a deadlock.

Add the needed interfaces so that meta_kms_device_dispatch_sync() can flush all
the implementation idle callbacks before it checks if any "events" are
available. This prevents the deadlock by ensuring
mode_set_fallback_feedback_idle() does get called before potentially waiting
for actual DRM events.

Presumably this call would not be needed if the implementation was running in
its own thread, since it would eventually dispatch its idle callbacks before
going to sleep polling on the DRM fd. This call might even be unnecessary
overhead in that case, synchronizing with the implementation thread needlessly.
But the thread does not exist yet, so this is needed for now.

This is part 1 of 2 fixing a complete desktop freeze when drmModePageFlip()
fails with EINVAL and the fallback to drmModeSetCrtc() succeeds but the success
is not registered correctly as completed "flip". The freeze occurs under
wait_for_pending_flips() which calls down into meta_kms_impl_device_dispatch()
which ends up poll()'ing the DRM fd even though drmModeSetCrtc() will not
produce a DRM event, hence the poll() never returns. The freeze was observed
when hotplugging a DisplayLink dock for the first time on Ubuntu 19.10.

CC stable: gnome-3-34

https://gitlab.gnome.org/GNOME/mutter/merge_requests/953
2019-12-06 15:55:35 +00:00
Christian Rauch
9f50b2cef2 startup: Fix build with 'startup_notification=false'
https://gitlab.gnome.org/GNOME/mutter/merge_requests/958
2019-12-05 01:27:14 +00:00
Robert Mader
96e1883361 xwayland: Do not queue frame callbacks unconditionally
The removed comment is not longer true: XWayland schedules its VSYNC
from frame callbacks nowadays. Only sending callbacks when the surface
actor is unobscured makes XWayland throttle its VSYNC to 1/sec,
reducing repaints in many cases.

Follow up of https://gitlab.gnome.org/GNOME/mutter/merge_requests/918

https://gitlab.gnome.org/GNOME/mutter/merge_requests/956
2019-12-04 18:59:24 +01:00
Jonas Ådahl
4ede6ea8c5 cogl: Remove the framebuffer and source stacks
They have been deprecated for a long time, and all their uses in clutter
and mutter has been removed. This also removes some no longer needed
legacy state tracking, as they were only ever excercised in certain
circumstances when there was sources (pipelines or materials) on the now
removed source stack.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
3f65837e0d clutter, core: Stop using the Cogl framebuffer stack
The Cogl framebuffer stack is going away; replace all its uses by the
framebuffer stack carried by the paint context.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
549f60fe49 texture-tower: Don't use implicit framebuffer stack Cogl API
Replace it with the non-deprecated counterparts.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
26147afb08 shadow-factory: Don't set implicit Cogl material
We only draw with non-deprecated API already, so there is no reason to
set the source material.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
6f30cf0004 tests/clutter/cogl-tex-polygon: Port to CoglPrimitive
Instead of using cogl_polygon(), which uses deprecated API, implement
polygon drawing using the CoglPrimitive API family. While the test might
have been used to explicitly test cogl_polygon() it could still be
useful to test the non-deprecated way of rendering polygons.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
8c7ec44681 tests/clutter: Port to using non-implicit framebuffer Cogl API
Port tests to use API such as cogl_framebuffer_push_matrix() instead of
cogl_push_matrix() all over the Clutter tests, with one exception:
cogl_polygon(). It'll be ported over in a separate commit, as it is less
straight forward.

Implicitly set CoglMaterial properties are changed to explicitly created
and destructed CoglPipelines with the equivalent properties set.
cogl_push|pop_framebuffer() is replaced by explicitly passing the right
framebuffer, but tests still rely on cogl_get_draw_framebuffer() to get
the target framebuffer.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
f11170fecb clutter/paint-node: Have caller of .._get_framebuffer() handle fallback
clutter_paint_node_get_framebuffer() fell back on
cogl_get_draw_framebuffer() when the root node didn't have a custom
get_framebuffer vfunc. As this relies on deprecated implicit Cogl stack
API, it needs to go away, so handle this in the caller that knows more
about the context.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
cb9d6b79ef clutter: Introduce pick contexts
Just as with painting, add a pick context that carries pick related
temporary state when doing actor picking. It is currently unused, and
will at least at first still carry around a framebuffer to deal track
view transforms etc.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
3f2a6f58eb tests/clutter: Remove unneeded gitignore files
We're using meson, so everything built ends up in the build directory.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
98c0fe934b cogl: Remove CoglVertexBuffer
It was deprecated, relied on deprecated API (implicit framebuffers,
mateiarls etc), and was unused. Lets remove it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Jonas Ådahl
49c8d42317 clutter: Introduce paint contexts
When painting, actors rely on semi global state tracked by the state to
get various things needed for painting, such as the current draw
framebuffer. Having state hidden in such ways can be very deceiving as
it's hard to follow changes spread out, and adding more and more state
that should be tracked during a paint gets annoying as they will not
change in isolation but one by one in their own places. To do this
better, introduce a paint context that is passed along in paint calls
that contains the necessary state needed during painting.

The paint context implements a framebuffer stack just as Cogl works,
which is currently needed for offscreen rendering used by clutter.

The same context is passed around for paint nodes, contents and effects
as well.

In this commit, the context is only introduced, but not used. It aims to
replace the Cogl framebuffer stack, and will allow actors to know what
view it is currently painted on.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/935
2019-12-03 19:02:14 +00:00
Niels De Graef
5c986060f0 wayland: Add documentation to wayland_shell_init
Especially preventing the confusion that it might only initalize the
wl_shell interface.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/871
2019-12-03 14:43:43 +01:00
Niels De Graef
404e713227 wayland: Add documentation to the WaylandBuffer object
https://gitlab.gnome.org/GNOME/mutter/merge_requests/871
2019-12-03 14:43:43 +01:00
Niels De Graef
542bad60ba wayland: Add documentation for dma-buf namespace
It's not always clear how the dma-buf functions work (e.g. where memory
is allocated) without actually going in-depth in the code. This just
adds a few commments to more quickly gain understanding.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/871
2019-12-03 14:43:43 +01:00
Carlos Garnacho
6f4c7d66a4 x11: Check wacom button flags to determine whether button is mode switch
Checking the leds is not really accurate, since some devices have mode
switch buttons without leds. Check in the button flags whether they are
mode switch buttons for any of ring/ring2/strip/strip2, and return the
appropriate group.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/952
2019-11-29 18:10:14 +00:00
Florian Müllner
c843102eec stack: Delegate layer calculation to a window vfunc
While most of the code to compute a window's layer isn't explicitly
windowing backend specific, it is in practice: On wayland there are
no DESKTOP windows(*), docks(*) or groups.

Reflect that by introducing a calculate_layer() vfunc that computes
(and sets) a window's layer.

(*) they shall burn in hell, amen!

https://gitlab.gnome.org/GNOME/mutter/merge_requests/949
2019-11-29 15:14:38 +01:00
Florian Müllner
b753213f9b window: Add get_default_layer() helper
Most of the layer computation that the stack does actually depends
on the windowing backend, so we will move it to a vfunc.

However before we do that, split out the bit that will be shared.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/949
2019-11-29 15:14:38 +01:00
Florian Müllner
599d8e3287 stack: Move HAS_TRANSIENT_TYPE macro to window-private
We'll soon need it elsewhere, so move it to a shared location.
While at it, convert it to a function.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/949
2019-11-29 15:14:38 +01:00
Florian Müllner
1c89fce30e stack: Allow promoting transient windows to their parent's layer
When a window that should be stacked above another one is placed in a lower
layer than the other window, we currently allow promoting it to the higher
layer when it has a "transient type". We should do the same when the window
is an actual transient of the other window.

This is particularly relevant for wayland windows, where types play a
much smaller role: Transient windows like non-modal dialogs (and since
commit 666bef7a, popup windows as well) currently end up underneath their
always-on-top parent.

https://gitlab.gnome.org/GNOME/mutter/issues/587
2019-11-28 21:10:47 +01:00
Robert Mader
0247d35e5a shaped-texture: Do not invalidate content on set_cogl_texture()
This was wrongly introduced in 75cffd0ec4. As the comment above explains, we
only want to queue redraws in response to surface/buffer damage.

This triggered a full redraw when using DMA buffers on Wayland as we currently
create a new texture on every buffer_attach(), breaking partial invalidation.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/947
2019-11-26 21:35:50 +01:00
Marco Trevisan (Treviño)
427670cc63 device-manager-x11: Ignore events if no source device is set
There might be some inconsistent event for which we don't have a known
source device.

In the current state we don't handle them and we could crash when getting
the current device tool.

So, add an utility function that retrieves the source device for an event
that warns if no device is found, and use this for Motion, Key and Button
events.

In case we don't have a valid source in such case, just return early instead
of trying to generate invalid clutter events.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/823
2019-11-23 01:38:16 +00:00
Jonas Ådahl
4af4b79123 window: Assert we have an up to date monitor after they changed
Add an assert that we don't have a MetaWindow::monitor pointer that
points to an old MetaLogicalMonitor. After this, and the other
monitors-changed callbacks have been called, the old MetaLogicalMonitor
will be destoryed, thus if we didn't update the pointer here, we'll
point to freed memory, and will eventually crash later on.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/929
2019-11-23 00:58:19 +00:00
Corentin Noël
5582d7b3be background: set_file accepts NULL files
https://gitlab.gnome.org/GNOME/mutter/merge_requests/941
2019-11-22 22:13:35 +00:00
Corentin Noël
4cccba5cac workspace-manager: get_workspace_by_index can return NULL
https://gitlab.gnome.org/GNOME/mutter/merge_requests/941
2019-11-22 22:13:35 +00:00
Carlos Garnacho
e44bd2edb4 compositor: Use redraw clip region to cull out children
This will avoid repainting too much of the background if the
bounding box turned out to be too large.

https://bugzilla.gnome.org/show_bug.cgi?id=782344
2019-11-22 21:07:05 +00:00
Robert Mader
8e172aeecb cleanup: Use g_clear_handle_id() for g_source_remove()
It makes sure we do not forget to zero the id and lets us avoid
zero checks before. We use it for all new code, lets clean up the
existing code base.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/947
2019-11-22 01:27:40 +01:00
Robert Mader
92375c75f8 cleanup: Use g_clear_signal_handler() where possible
This is inspired by 98892391d7 where the usage of
`g_signal_handler_disconnect()` without resetting the corresponding
handler id later resulted in a bug. Using `g_clear_signal_handler()`
makes sure we avoid similar bugs and is almost always the better
alternative. We use it for new code, let's clean up the old code to
also use it.

A further benefit is that it can get called even if the passed id is
0, allowing us to remove a lot of now unnessecary checks, and the fact
that `g_clear_signal_handler()` checks for the right type size, forcing us
to clean up all places where we used `guint` instead of `gulong`.

No functional changes intended here and all changes should be trivial,
thus bundled in one big commit.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/940
2019-11-21 15:02:27 +00:00
Carlos Garnacho
e5af790acb wayland: Move "ownership" of the DnD selection source to the data device
On wl_data_source destruction we used to indirectly unset the DnD selection
owner via the wl_resource destructor triggering the destruction of the
MetaWaylandDataSource, which would be caught through the weak ref set by
the MetaWaylandDragGrab.

This works as long as the grab is held, however we have a window between
the button being released and the drop site replying with
wl_data_offer.finish that the MetaWaylandDataSource is alive, but its
destruction wouldn't result in the call chain above to unsetting the DnD
source.

In other selection sources, we let the MetaWaylandDataDevice hold the
"ownership" of the MetaWaylandDataSource, and its weak ref functions unset
the respective MetaSelection owners. Do the same here, so the
MetaWaylandDataSource destruction is listened for all its lifetime.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/591
2019-11-20 12:07:51 +01:00
Carlos Garnacho
48639ac5da wayland: Do not cancel data source on offer destruction
This is wrong for both clipboard and DnD, as the selection source
will still be able to focus another surface, and churn another
wl_offer.

We should just detach the data offer from the data source in this
case, and let the source live on. However, we should still check
that there is a source and an offer to finish DnD, do that when
handling the drop operation instead.

https://gitlab.gnome.org/GNOME/mutter/issues/591
2019-11-20 12:07:51 +01:00
Carlos Garnacho
e7b2f9603e wayland: Avoid redundant cancel() call
This is unnecessary as we are unsetting the DnD selection owner,
and will result in the related data source being cancelled already.

https://gitlab.gnome.org/GNOME/mutter/issues/591
2019-11-20 12:07:51 +01:00
Carlos Garnacho
46b3811e22 wayland: Drop unused wl_signal structs
Those were used to signal clipboard ownership around, but that got
replaced by MetaSelection and friends. These signals are no longer
listened on, so can be safely removed.

https://gitlab.gnome.org/GNOME/mutter/issues/591
2019-11-20 12:07:51 +01:00
Adam Jackson
7adaaab2d6 clutter: Remove deprecated ClutterTableLayout
https://gitlab.gnome.org/GNOME/mutter/merge_requests/921
2019-11-19 21:50:27 +00:00
Jonas Ådahl
244f55df28 tests/clutter: Remove tests testing or relying on ClutterTexture
ClutterTexture is going to be removed, so remove interactive tests that
stand in the way for that. Some test texture features, while some makes
heavy use of ClutterTexture to implement their testing. Remove these
tests to prepare for the removal of ClutterTexture.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/932
2019-11-13 13:56:08 +00:00
Jonas Ådahl
f7ad7e6c0f tests/clutter/touch-events: Use ClutterCanvas to draw touch
Change the interactive touch events test case to use ClutterCanvas to
draw touch points instead of using ClutterCairoTexture.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/932
2019-11-13 13:56:08 +00:00
Jonas Ådahl
e0ebc4de60 tests/clutter/easing: Use ClutterCanvas
Remove the usage of ClutterCairoTexture and use a ClutterCanvas content
instead.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/932
2019-11-13 13:56:08 +00:00
Jonas Ådahl
14bb104ef0 tests/clutter: Replace ClutterTexture from image with custom helper
ClutterTexture is deprecated, lets remove the trivial usage with a
simple gdk-pixbuf using constructor putting pixel contents into a
ClutterImage then putting said image in a plain ClutterActor.

Tested partially, as the interactive tests cannot be properly run at the
moment.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/932
2019-11-13 13:56:08 +00:00
Jonas Ådahl
f3b9fc8159 tests/clutter/interactive: Init backend and mutter context
As was with the tests run via meson test, for the interactive tests we
too need to configure the mutter backend and initialize things in order
to be able to run any tests.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/932
2019-11-13 13:56:08 +00:00
Hans de Goede
8907a29912 cursor-renderer/native: Fix cursor drawing in combination with panel_orientation_transform
Properly take the panel_orientation_transform into account in
update_monitor_crtc_cursor. This fixes us sometimes drawing the cursor
on two monitors at the same time as we did not properly swap the crtc
width/height when a panel_orientation_transform is active.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/927
2019-11-13 10:54:37 +01:00
Hans de Goede
a5f986259f output-kms: Fix "panel orientation" kms-prop being ignored on native outputs
Actually store the panel_orientation_transform in the meta_output, so
that it gets honored by the core code.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/927
2019-11-13 10:53:50 +01:00
Jonas Ådahl
7193938d27 compositor: Guard against untimely calls
It seems that sometimes these functions are called by Javascript in
GNOME Shell during tear down. This causes segfaults and crash reports,
but without any backtraces other than the entry and exit points into
gjs.

In order to get more useful information about where these calls come
from, validate the input passed gracefully, by complaining in the log
and returning NULL values.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/926
2019-11-11 13:09:20 +00:00
Hans de Goede
5afec87b96 input-settings/x11: Add missing clutter_x11_trap_x_errors around XIGetProperty
Add missing clutter_x11_[un]trap_x_errors around the XIGetProperty call
in meta-input-settings-x11.c's get_property helper function.

This fixes mutter crashing with the following error if the XInput device
goes away at an unconvenient time:

 X Error of failed request:  XI_BadDevice (invalid Device parameter)
   Major opcode of failed request:  131 (XInputExtension)
   Minor opcode of failed request:  59 ()
   Device id in failed request: 0x200011
   Serial number of failed request:  454
   Current serial number in output stream:  454

https://gitlab.gnome.org/GNOME/mutter/merge_requests/928
2019-11-10 19:45:08 +01:00
Robert Mader
a4f51da184 plugin-manager: Kill window effects on destroy
We do so for all other window effects already. Why this was left out
is unknown (9b3a0d1ad8), but we will need it for a fix in GS.

Related: https://gitlab.gnome.org/GNOME/mutter/issues/655

https://gitlab.gnome.org/GNOME/mutter/merge_requests/924
2019-11-08 22:18:09 +00:00
Florian Müllner
0545b93232 plugins/default: Handle skipped animations
We currently assume that the actor_animate() helper function returns
a timeline. However Clutter may skip implicit animations and simple
set properties directly, for example when the actor is hidden.

The returned timeline will be NULL in that case, and we abort when
using it as instance parameter to g_signal_connect().

Fix this by only setting up a completed handler when we are actually
animating, and complete the effect directly otherwise.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/925
2019-11-08 22:49:31 +01:00
Marco Trevisan (Treviño)
6944839ab6 window-props: Read WM_TRANSIENT_FOR for override-redirect windows
As per the Extended Window Manager Hints standard version 1.3 [1] an
override-redirect window can set a transient-for window per compositing and
app-matching purposes.

So just read the WM_TRASIENT_FOR property also for such windows, adapting
the error in case they are transient for another O-R window and adding a
test to check such case.

[1] https://standards.freedesktop.org/wm-spec/wm-spec-latest.html#idm140200472512128

https://gitlab.gnome.org/GNOME/mutter/merge_requests/920
2019-11-07 18:43:16 +00:00
Xiang Fan
4a76f66a54 wayland/surface: Don't double scale when getting absolute coordinates
The actor is already in surface coordinate space, so we should not scale
with the buffer scale to transform surface coordinates to stage
coordinates.

This bug causes input method using wayland text-input protocol to
receive wrong cursor location. Reproduced in ibus (when candidate
window is open) with scaling factor other than 1.

This commit also fixes pointer confinement.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/915
2019-11-07 16:20:13 +00:00
Marco Trevisan (Treviño)
bacbbbd628 window-props: Don't set override redirect windows as top-level parent
Java applications might use override-redirect windows as parent windows for
top-level windows, although this is not following the standard [1].

In such case, the first non-override-redirect child window that is created
was marked as being on_all_workspaces since the call to
should_be_on_all_workspaces() returns TRUE for its parent, and this even
though the on_all_workspaces_requested bit is unset.
When a further child of this window was added, it was set as not having a
workspace and not being on_all_workspaces, since the call to
should_be_on_all_workspaces() for its parent would return FALSE (unless if
it is in a different monitor, and the multiple-monitors workspaces are
disabled).

Since per commit 09bab98b we don't recompute the workspace if the
on_all_workspaces bit is unset, we could end up in a case where a window can
be nor in all the workspaces or in a specific workspace.

So let's just ignore the transient_for bit for a window if that points to an
override-redirect, using the x11 root window instead.

Add a stacking test to verify this scenario (was failing before of this
commit).

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/885
https://gitlab.gnome.org/GNOME/mutter/merge_requests/895

[1] https://standards.freedesktop.org/wm-spec/wm-spec-latest.html#idm140200472512128
2019-11-07 16:04:19 +00:00
Marco Trevisan (Treviño)
c85fb107c0 window-props: Don't look for parent multiple times
Once we set the transient_for, we look for parent MetaWindow, so instead
of overwriting this value for loops check, just use another function
and avoid to look for the xwindow again when setting the MetaWindow parent.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/895
2019-11-07 16:04:19 +00:00
Marco Trevisan (Treviño)
13f10e36e4 window: Assert we only set a NULL workspace when unmanaging
There might be cases in which a window might be marked as both not in all
workspaces and with NULL workspace.

So to avoid this to happen, let's just assert early instead of doing this at
later point where the context might not be clear.

Related to https://gitlab.gnome.org/GNOME/mutter/issues/885

https://gitlab.gnome.org/GNOME/mutter/merge_requests/895
2019-11-07 16:04:19 +00:00
Marco Trevisan (Treviño)
2644e54c51 window: Warn if O-R window workspace state is used
Override-redirect windows have no workspace by default, and can't be parent
of a top-level window, so we must check that the parent window is not an
O-R one when setting the workspace state.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/895
2019-11-07 16:04:19 +00:00
Jonas Ådahl
0e5a5df5fe wayland/actor-surface: Always store away frame callbacks on commit
We're expected by MetaWaylandSurface to always pick the frame callbacks
out from the pending state when committing (applying) so that no frame
callbacks are unaccounted for. We failed to do this if our actor for
some reason (e.g. associated window was unmanaged) was destroyed. To
handle this situation better, store away the frame callbacks until we
some later point in time need to pass them on forward.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/893
2019-11-07 12:56:58 +00:00
Marco Trevisan (Treviño)
ffa0a24848 x11-display: Get next serial just before using it
We ask XLib the next request serial number before performing other actions
triggered by meta_x11_display_set_input_focus_internal() that doesn't use
the request serial anyways. So, just request it before updating the focus
window as that's the operation that needs it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/909
2019-11-06 17:32:29 +00:00
Marco Trevisan (Treviño)
efe5bed5b4 x11-display: Don't unset the X11 focused window after setting one
When using DesktopIcons extension and clicking in an icon, gnome-shell
starts an infinite loop caused by the first focus change that may trigger
on X11 a focus in/out event that leads to stage activation/deactivation
which never ends.

This happens because as part of meta_x11_display_set_input_focus_xwindow()
to focus the X11 stage window, we unset the display focus, but this also
causes to request the X11 display to unset the focus since we convolute by
calling meta_x11_display_set_input_focus() with no window, that leads to
focusing the no_focus_window and then a focus-in / focus-out dance that the
shell amplifies in order to give back the focus to the stage.

In order to fix this, mimic what meta_display_set_input_focus() does, but
without updating the X11 display, and so without implicitly calling
meta_x11_display_set_input_focus(), stopping the said convolution and
properly focusing the requested xwindow.
Also ensure that we're not doing this when using an older timestamp, since
this check isn't performed anymore.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/896
Fixes https://gitlab.gnome.org/GNOME/mutter/issues/899

https://gitlab.gnome.org/GNOME/mutter/merge_requests/909
2019-11-06 17:32:29 +00:00
Carlos Garnacho
e865fcc460 wayland: Check focus surface client in wl_data_device.set_selection()
Similar to our handling in set_primary(), ignore set_selection() requests
that come from unfocused clients.

https://gitlab.gnome.org/GNOME/mutter/issues/878
2019-11-06 15:59:16 +01:00
Carlos Garnacho
16eb461054 wayland: Clean up meta_wayland_data_device_set_primary()
This function is already checking for the focus surface client
matching the requestor. The type check was slightly bogus though
as it'd be an screwup in our code, make it an assert instead.

Also, move the check for the client having the focus into the
upper call, so this and wl_data_device.set_selection code can
get more in line.

https://gitlab.gnome.org/GNOME/mutter/issues/878
2019-11-06 15:59:16 +01:00
Carlos Garnacho
c11ef6ef07 wayland: Flatten data source object hierarchy
We have an abstract MetaWaylandDataSource and 2 subclasses for
clipboard/primary data sources. Since the abstraction provided
by the additional sublevel is arguable, push the wl_resource
field up, and leave us with just 2 objects to think about, all
of them containing a wl_resource.

https://gitlab.gnome.org/GNOME/mutter/issues/878
2019-11-06 15:59:16 +01:00
Thomas Hindoe Paaboel Andersen
95eda361c1 wayland: use correct enum type for tablet pad
Fixes a compile warning.  The two enums are identical, so no
functional change intended.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/863
2019-11-05 13:07:47 +00:00
Jonas Ådahl
662c76c4fc tests/monitor-unit-tests: Add another tiling window hot plug test
Checks that we handle hot plugs of a untiled window, that was previously
tiled.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:36:25 +01:00
Jonas Ådahl
ff799a1abe window: Reset tile monitor number when untiling
Otherwise we'll end up trying to access the out of date state later.

Fixes the following test failure backtrace:

    #0  _g_log_abort ()
    #1  g_logv ()
    #2  g_log ()
    #3  meta_monitor_manager_get_logical_monitor_from_number ()
    #4  meta_window_get_work_area_for_monitor ()
    #5  meta_window_get_tile_area ()
    #6  constrain_maximization ()
    #7  do_all_constraints ()
    #8  meta_window_constrain ()
    #9  meta_window_move_resize_internal ()
    #10 meta_window_tile ()

https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:36:25 +01:00
Jonas Ådahl
155b7bf569 tests/monitor-unit-tests: Add window tiling hot plug test
This test that we handle hot plugs correctly together with tiled
windows.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:36:25 +01:00
Jonas Ådahl
47155ed524 tests/runner: Move window shown synchronization to helper
https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:35:00 +01:00
Jonas Ådahl
db91439bb0 tests/monitor-unit-tests: Move test client sanity check into helper
https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:35:00 +01:00
Jonas Ådahl
77aad0869f window: Always update tile monitor number on hot plug
Otherwise we'll end up crashing if we had two connected monitors,
unplugged both, then replugged in a single one.

Avoids the following error:

    #0  _g_log_abort ()
    #1  g_logv ()
    #2  g_log ()
    #3  meta_monitor_manager_get_logical_monitor_from_number ()
    #4  meta_window_get_work_area_for_monitor ()
    #5  meta_window_get_tile_area ()
    #6  constrain_maximization ()
    #7  do_all_constraints ()
    #8  meta_window_constrain ()
    #9  meta_window_move_resize_internal ()
    #10 meta_window_move_resize_frame ()
    #11 meta_window_move_resize_now ()
    #12 idle_move_resize ()
    #13 call_idle_later ()

https://bugzilla.redhat.com/show_bug.cgi?id=1767703

https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:35:00 +01:00
Jonas Ådahl
dc1a28c42a plugins/default: Clean up tile preview when closing display
On finalize, the preview actor will have been destroyed behind our back;
avoid that by cleaning up before it's too late.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:35:00 +01:00
Jonas Ådahl
955b27637c plugin/default: Init quark before using
Cut lines in pieces, and remove useless "optimizations" while at it

https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:35:00 +01:00
Jonas Ådahl
1f5b403524 display: Add 'closing' signal
Emitted when the MetaDisplay is closing. Meant for clean up that depends
on things that will be torn down during closing.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:35:00 +01:00
Robert Mader
5e87d67e5f surface-actor-wayland: Do not send frame callbacks if the actor is obscured
`meta_surface_actor_is_obscured` implies that the actor got successfully culled
out and nothing of it will get painted. This includes that there are no clones,
no effects etc. In this cases we don't want to send frame callbacks, thus avoiding
unnecessary client work.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/918
2019-11-04 16:06:37 +01:00
Olivier Fourdan
60800d2313 renderer-native: Separate offscreen and shadowfb
Create the intermediate shadow framebuffer for use exclusively when a
shadowfb is required.

Keep the previous offscreen framebuffer is as an intermediate
framebuffer for transformations only.

This way, we can apply transformations between in-memory framebuffers
prior to blit the result to screen, and achieve acceptable performance
even with software rendering on discrete GPU.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/877
2019-11-04 10:44:42 +01:00
Carlos Garnacho
2202c0d02e tests: Explicitly set a background color for offscreen actor tests
Those change opacity and read pixels, relying on an implicit stage color.
We won't do that anymore.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/911
2019-11-01 15:02:09 +00:00
Hans de Goede
dbb95cbe5f window-xwayland: Add Xwayland fullscreen games workaround
This is a workaround for X11 games which use randr to change the resolution
in combination with NET_WM_STATE_FULLSCREEN when going fullscreen.

Newer versions of Xwayland support the randr part of this by supporting randr
resolution change emulation in combination with using WPviewport to scale the
app's window (at the emulated resolution) to fill the entire monitor.

Apps using randr in combination with NET_WM_STATE_FULLSCREEN expect the
fullscreen window to have the size of the emulated randr resolution since
when running on regular Xorg the resolution will actually be changed and
after that going fullscreen through NET_WM_STATE_FULLSCREEN will size
the window to be equal to the new resolution.

We need to emulate this behavior for these games to work correctly.

Xwayland's emulated resolution is a per X11 client setting and Xwayland
will set a special _XWAYLAND_RANDR_EMU_MONITOR_RECTS property on the
toplevel windows of a client (and only those of that client), which has
changed the (emulated) resolution through a randr call.

This commit checks for that property and if it is set adjusts the fullscreen
monitor rect for this window to match the emulated resolution.

Here is a step-by-step of such an app going fullscreen:
1. App changes monitor resolution with randr.
2. Xwayland sets the _XWAYLAND_RANDR_EMU_MONITOR_RECTS property on all the
   apps current and future windows. This property contains the origin of the
   monitor for which the emulated resolution is set and the emulated
   resolution.
3. App sets _NET_WM_FULLSCREEN.
4. We check the property and adjust the app's fullscreen size to match
   the emulated resolution.
5. Xwayland sees a Window at monitor origin fully covering the emulated
   monitor resolution. Xwayland sets a viewport making the emulated
   resolution sized window cover the full actual monitor resolution.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/739
2019-11-01 14:14:21 +01:00
Hans de Goede
ae238d1d4d window: Add adjust_fullscreen_monitor_rect virtual method
Add an adjust_fullscreen_monitor_rect virtual method to MetaWindowClass
and call this from setup_constraint_info() if the window is fullscreen.

This allows MetaWindowClass to adjust the monitor-rectangle used to size
the window when going fullscreen, which will be used in further commits
for a workaround related to fullscreen games under Xwayland.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/739
2019-11-01 14:12:17 +01:00
Christian Hergert
6051712919 profiler: track changes in GLib and Sysprof
This tracks the changes to gdbus-codegen in terms of how GUnixFDList is
done to use the UnixFD annotation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/908
2019-10-30 16:07:36 -07:00
Carlos Garnacho
f2b3dd318f wayland: Check stylus serials on meta_wayland_seat_can_popup()
This allows xdg_popup.grab() to work with styli. Without this check
we would bail out and emit xdg_popup.popup_done, leaving stylus users
unable to interact with popup menus, comboboxes, etc...

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/886
2019-10-28 19:10:01 +00:00
Jonas Ådahl
942883577e x11: Limit touch replay pointer events to when replaying
When a touch sequence was rejected, the emulated pointer events would be
replayed with old timestamps. This caused issues with grabs as they
would be ignored due to being too old. This was mitigated by making sure
device event timestamps never travelled back in time by tampering with
any event that had a timestamp seemingly in the past.

This failed when the most recent timestamp that had been received were
much older than the timestamp of the new event. This could for example
happen when a session was left not interacted with for 40+ days or so;
when interacted with again, as any new timestamp would according to
XSERVER_TIME_IS_BEFORE() still be in the past compared to the "most
recent" one. The effect is that we'd always use the `latest_evtime` for
all new device events without ever updating it.

The end result of this was that passive grabs would become active when
interacted with, but would then newer be released, as the timestamps to
XIAllowEvents() would out of date, resulting in the desktop effectively
freezing, as the Shell would have an active pointer grab.

To avoid the situation where we get stuck with an old `latest_evtime`
timestamp, limit the tampering with device event timestamp to 1) only
pointer events, and 2) only during the replay sequence. The second part
is implemented by sending an asynchronous message via the X server after
rejecting a touch sequence, only potentially tampering with the device
event timestamps until the reply. This should avoid the stuck timestamp
as in those situations, we'll always have a relatively up to date
`latest_evtime` meaning XSERVER_TIME_IS_BEFORE() will not get confused.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/886
2019-10-28 18:40:44 +00:00
Jonas Ådahl
23fa59b77c display: Move finishing of touch sequence to the backend
We need to manipulate an X11 grab when a touch sequence ends; move that
logic to where it belongs - in the X11 backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/886
2019-10-28 18:40:43 +00:00
Georges Basile Stavracas Neto
563e7139b6 Allow changing Clutter debug flags at runtime
This way, we can simply pop up the Looking Glass and run:

 >>> Meta.add_clutter_debug_flags(Clutter.DebugFlag.PICK, 0, 0)

And measure specific actions or events on GNOME Shell.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/862
2019-10-25 19:12:34 +00:00
Adam Jackson
a60457c2d8 clutter: Remove behaviours
https://gitlab.gnome.org/GNOME/mutter/merge_requests/879
2019-10-22 19:01:17 +00:00
Adam Jackson
33d1bae03f clutter: Remove deprecated/clutter-behaviour-scale.c
https://gitlab.gnome.org/GNOME/mutter/merge_requests/879
2019-10-22 19:01:17 +00:00
Adam Jackson
096d78479b clutter: Remove tests/interactive/test-texture-quality.c
This is the last consumer of clutter_behaviour_depth_*, and is testing
clutter_texture_set_filter_quality which is also deprecated.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/879
2019-10-22 19:01:17 +00:00
Adam Jackson
68fca552d7 clutter: Remove unused deprecated/clutter-behaviour-opacity.c
https://gitlab.gnome.org/GNOME/mutter/merge_requests/879
2019-10-22 19:01:17 +00:00
Adam Jackson
18e0a8f7bf clutter: Remove stray references to ClutterBehaviour{Path,Rotate}
These were removed back in cc077023 and df3d2389.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/879
2019-10-22 19:01:17 +00:00
Carlos Garnacho
71c3f4af31 x11: Update X11 focus before updating MetaDisplay focus
In a similar vein to commit 8fd55fef85. This notably failed when setting
the focus on the stage (eg. to redirect key events to Clutter actors).
Deeper in MetaDisplay focus updating machinery, it would check
meta_stage_is_focused() which would still return FALSE at the time it's
called.

This would not typically have side effects, but our "App does not respond"
dialogs see the focus change under their feet, so they try to bring
themselves to focus again. This results in a feedback loop.

Changing the order results in later checks on the X11 POV of the focus
being correct, so focus is not mistakenly stolen from the close dialog,
and it actually succeeds in keeping the key focus.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/1607

https://gitlab.gnome.org/GNOME/mutter/merge_requests/876
2019-10-22 14:51:36 +02:00
Adam Jackson
bd1630a12c cogl: Remove unused CoglFeatureFlags
https://gitlab.gnome.org/GNOME/mutter/merge_requests/866
2019-10-21 21:43:08 +00:00
Adam Jackson
cf107c89b8 cogl: Remove always-set COGL_FEATURE_OFFSCREEN
https://gitlab.gnome.org/GNOME/mutter/merge_requests/866
2019-10-21 21:43:08 +00:00
Carlos Garnacho
40e6aa7d94 compositor: Plug cairo_region_t leak
The MetaBackgroundActor uses a region to find out the areas that need
repainting, but forgot to free it, oops.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/873
2019-10-21 19:01:37 +02:00
Carlos Garnacho
668be1f4bd backends: Plug MetaKmsPageFlipData leak
If the page flip is postponed, keep a ref to it, but still unref it
on the page flip callback anyways. Fix suggested by Jonas Ådahl.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/873
2019-10-21 19:01:35 +02:00
Jan Alexander Steffens (heftig)
a444a4c5f5 EGL: Include EGL/eglmesaext.h
The eglext.h shipped by libglvnd does not include the Mesa extensions,
unlike the header shipped in Mesa.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/876
2019-10-21 14:04:30 +00:00
Georges Basile Stavracas Neto
179d5ba6a6 clutter: Split pick and paint
Add the corresponding clutter_actor_pick() and
clutter_actor_continue_pick() as public APIs,
and use them in pick overrides and ClutterEffect.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/865
2019-10-21 13:49:26 +00:00
Robert Mader
98892391d7 wayland/surface: Reset buffer_destroy_handler_id
Syncronized subsurfaces that call into `merge_pending_state` might
otherwise not create new destroy handlers, ending up with a invalid
handler ids, throwing errors and leaking.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/868
2019-10-21 12:54:36 +00:00
Carlos Garnacho
45a8806e65 x11: Iterate over selections in a safer manner for event handling
It might be the case that handling an event induces the stream to
trigger completion, hence removing itself from the list. In that
case we would operate on the no longer valid list element to fetch
the next one.

Keep a pointer to the next element beforehand, so we can tiptoe
over streams that did remove themselves.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/869
2019-10-21 13:19:48 +02:00
Carlos Garnacho
e1fa0734a9 x11: Detach selection streams on dispose
The streams were only detached from MetaX11Display (and its event handling)
on completion. This is too much to expect, and those might be in some
circumstances replaced while operating.

Make those streams detach themselves on dispose(), so we don't trip into
freed memory later on when trying to dispatch unrelated X11 selection events.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/869
2019-10-21 11:47:40 +02:00
Cosimo Cecchi
8665084df1 monitor-manager: check for underscan setting validity upfront
Instead of doing a roundtrip to the X server before setting it, rely on
the previous value fetched before the configuration was sent over DBus.
This matches the argument check we already do elsewhere, and will allow
us to more easily add an additional condition to determine if underscan
is supported.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/673
2019-10-16 14:34:14 +00:00
Daniel van Vugt
e82a657cd9 clutter/actor: Remove color from the pick virtual function
It's unused since commit 14c706e51.

**ABI break**

https://gitlab.gnome.org/GNOME/mutter/merge_requests/851
2019-10-16 12:01:16 +00:00
Georges Basile Stavracas Neto
bdf5e3f357 Replace ClutterGeometry by graphene_rect_t
The last of the replacements. It is fine for now
to replace ClutterGeometry's integers by floats.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:14 +00:00
Georges Basile Stavracas Neto
94682e69aa Replace ClutterRect by graphene_rect_t
https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:14 +00:00
Georges Basile Stavracas Neto
160cc9182d Replace ClutterPoint by graphene_point_t
Remove the tests for ClutterPoint since it's
corresponding code moved to private ClutterStage
methods.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:14 +00:00
Georges Basile Stavracas Neto
a5d0cfe8fb Replace ClutterVertex by graphene_point3d_t
Pretty direct and straightforward port. This requires a
GNOME Shell counterpart. In addition to that, include a
progress function.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:13 +00:00
Georges Basile Stavracas Neto
959a418cc3 Replace CoglEuler by graphene_euler_t
As the first step into removing Cogl types that are covered by
Graphene, remove CoglEuler and replace it by graphene_euler_t.

This is a mostly straightforward replacement, except that the
naming conventions changed a bit. Cogl uses "heading" for the
Y axis, "pitch" for the X axis, and "roll" for the Z axis, and
graphene uses the axis themselves. That means the 1st and 2nd
arguments need to be swapped.

Also adapt the matrix stack to store a graphene_euler_t in the
rotation node -- that simplifies the code a bit as well.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:13 +00:00
Georges Basile Stavracas Neto
3ecae81809 clutter/tests: Rename variable
Graphene uses C99 and includes stdbool.h, which adds a
new 'bool' type. Clutter has an a11y test that names a
variable as 'bool' too, and they do not play well together.

Rename this variable to boolean.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:13 +00:00
Georges Basile Stavracas Neto
b1a1d4e13d Remove fog support
Fog is explicitly deprecated in favour of CoglSnippet API,
and in nowhere we are using this deprecated feature, which
means we can simply drop it without any sort of replacement.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/458
2019-10-16 11:38:13 +00:00
Jonas Ådahl
f7315c9a36 window-actor: Move shapes, shadows and unredirection to X11 sub types
Move out updating of various shapes (input, opaque, shape) indirectly
from X11 to the corresponding X11 sub types of MetaWindowActor and
MetaSurfaceActor.

Also move fullscreen window unredirection code with it. We want to
effectively do something similar for MetaCompositorServer, but it will
work differently enough not to share too much logic.

While it would have been nice to move things piece by piece, things were
too intertwined to make it feasible.

This has the side effect fixing accidentally and arbitrarily adding
server side shadow to Wayland surfaces.

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/734
2019-10-16 13:16:55 +02:00
Jonas Ådahl
9ac52f0340 compositor/x11: Move unredirect logic to helper
It makes it clearer what is required for unredirecting a window.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/734
2019-10-16 13:05:40 +02:00
Jonas Ådahl
f059466337 window-actor/x11: Use g_clear_signal_handler()
Also fixes type of handler ID.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/734
2019-10-16 13:05:40 +02:00
Jonas Ådahl
dcd0f4322a shaped-texture: Add API to check opaqueness
It is opaque if the texture has no alpha channel, or if the opaque
region covers the whole content.

Internally uses a function that checks whether there is an alpha
channel. This API will be exposed at a later time as well.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/734
2019-10-16 13:05:40 +02:00
Niels De Graef
8e204e036a cogl: Add a notion of pixel format planes
As we will start adding support for more pixel formats, we will need to
define a notion of planes. This commit doesn't make any functional
change, but starts adding the idea of pixel formats and how they (at
this point only theoretically) can have multple planes.

Since a lot of code in Mutter assumes we only get to deal with single
plane pixel formats, this commit also adds assertions and if-checks to
make sure we don't accidentally try something that doesn't make sense.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/858
2019-10-15 16:35:16 +00:00
Carlos Garnacho
97010ac64d meta: Move private defines to a private header
These defines are unused outside of mutter, and actually not
desirable to export. Move them to a private header.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/859
2019-10-15 11:03:56 +00:00
Marco Trevisan (Treviño)
2773e8adf8 clutter/actor: Remove deprecated internal child support
Clutter had support for internal children in its early revisions, but they
were deprecated for long time (commit f41061b8df, more than 7 years ago) and
no one is using them in both clutter and in gnome-shell.

So remove any alternative code path that uses internal children.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/816
2019-10-15 08:51:45 +00:00
Jonas Ådahl
e17d70a592 x11/window-controls: Pass around MetaX11Display directly
Instead of passing around an X11 Display pointer that is retrieved from
the default Gdk backend, then finding the MetaX11Display from said X11
Display, pass the MetaX11Display directly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/854
2019-10-15 07:17:29 +00:00
Jonas Ådahl
da213febdc core/core: Rename and move to x11/meta-x11-window-control
The functionality core/core.c and core/core.h provides are helpers for
the window decorations. This was not possible to derive from the name
itself, thus rename it and put it in the right place.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/854
2019-10-15 07:17:29 +00:00
Jonas Ådahl
7c2e926c44 core/core: Remove meta_retheme_all() helper
All it did was get the MetaDisplay and call a function on it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/854
2019-10-15 07:17:29 +00:00
Jonas Ådahl
c474ad6a53 Stop including core.h where it's not used
It provides glue for window frame controls and internal window
management, and that is only relevant for a couple of places in src/ui/.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/854
2019-10-15 07:17:29 +00:00
Jonas Ådahl
877ecc1bb4 core/core: Remove unused function
https://gitlab.gnome.org/GNOME/mutter/merge_requests/854
2019-10-15 07:17:29 +00:00
Niels De Graef
0d0286d59e cogl: Remove COGL_INVALID_HANDLE
Just use `NULL`, which is the normal C convention

https://gitlab.gnome.org/GNOME/mutter/merge_requests/451
2019-10-14 17:05:28 +00:00
Niels De Graef
23f77a1b63 cogl: Remove cogl_handle_ref/unref
This is for all intents and purposes the same as
`cogl_object_ref/unref`, but still refers to handles rather than
objects (while we're trying to get rid of the former) so it's a bit of
unnecessary redundant API.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/451
2019-10-14 17:05:28 +00:00
Robert Mader
317ce05a27 window-actor: Add a missing NULL-check
We shouldn't crash on a NULL-clip.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/856
2019-10-14 18:23:32 +02:00
Robert Mader
a8155a0471 meta: Add META namespace to macros
To silence warnings during GIR generation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/822
2019-10-14 10:14:11 +00:00
Niels De Graef
5e7fa20f06 wayland-egl-stream: Add log message on sucessful dlopen
Right now, there is no feedback message that tells you whether the
nvidia-egl-wayland module was succesfully loaded.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/853
2019-10-14 10:53:38 +02:00
Niels De Graef
3a688988e0 dbus-session-watcher: Chain up to parent finalize()
https://gitlab.gnome.org/GNOME/mutter/merge_requests/847
2019-10-14 09:09:01 +02:00
Carlos Garnacho
5c1be2233d x11: Map mimetypes back to selection atoms
This may be seen as the missing half of
https://gitlab.gnome.org/GNOME/mutter/merge_requests/842. Now that we
translate some atoms to better known mimetypes, we should also translate
those mimetypes to the underlying atoms if we might have added them.

Fixes c&p from certain X11 clients.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/854
2019-10-12 19:18:19 +02:00
Carlos Garnacho
e1751ad9ee wayland: Figure out better the right selection source for a wl_data_offer
We were just looking at DnD actions which might still be unset at that
point. Instead of doing these heuristics, store the selection type on
the data offer.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/845
2019-10-12 01:19:48 +02:00
Carlos Garnacho
84cc89e19a wayland: Set dummy selection source on .set_selection(null)
Requesting a selection with a NULL data source means "unset the clipboard",
but internally we use an unset clipboard as the indication that the
clipboard manager should take over.

Moreover, this unset request may go unheard if the current owner is someone
else than the MetaWaylandDataDevice.

Instead, set a dummy data source with no mimetypes nor data, this both
prevents the clipboard manager from taking over and ensures the selection
is replaced with it.

The MetaSelectionSourceMemory was also added some checks to allow for this
dummy mode.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/793
2019-10-11 23:04:01 +02:00
Carlos Garnacho
ea4665bf51 wayland: Simplify MetaSelectionSourceWayland
Instead of taking resource and send/cancel funcs, take a
MetaWaylandDataSource, which exposes all the vfuncs to do the same on the
internal resource.

This has the added side effect that only MetaWaylandDataSource has a
pointer to the wl_resource, which may be unset untimely.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/842
2019-10-11 23:04:01 +02:00
Carlos Garnacho
227d272049 wayland: Check resource before emitting cancelled event
If a data source is destroyed we first unset the resource, and then try to
unref the related selection source. At this point the only event that might
be emitted by the internal selection machinery is .cancelled, so make sure
we avoid it on destroyed sources.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/842
2019-10-11 23:01:44 +02:00
Carlos Garnacho
e53db92a7b wayland: Emit wl/primary offer after changing selection
We are still poking the mimetypes from the previous selection when creating
the new offer. This may come out wrong between changes of the copied
mimetypes.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/789
2019-10-11 23:00:12 +02:00
Carlos Garnacho
dd2b1278a0 wayland: Chain up to the right finalize on MetaWaylandDataSourceWayland
This function was using the wrong parent class pointer, so it was mistakenly
skipping over MetaWaylandDataSource::finalize.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/848
2019-10-11 23:00:12 +02:00
Carlos Garnacho
f2e2fcf758 wayland: Drop field from MetaWaylandDataSourcePrimary
This is a subclass of MetaWaylandDataSourceWayland, so there's no need
for a duplicate wl_resource field. Make sure to reuse the parent struct
one.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/848
2019-10-11 23:00:12 +02:00
Carlos Garnacho
dfd44ff971 wayland: Plug MetaSelectionSourceWayland leaks
There was a dangling ref left on all of them, oops.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/848
2019-10-11 23:00:12 +02:00
Jonas Ådahl
69a0c1dc80 main: Warn instead of error in meta_test_init()
Otherwise we'll get the warning

../src/core/main.c: In function 'meta_test_init':
../src/core/main.c:755:1: error: function might be candidate for attribute 'noreturn' [-Werror=suggest-attribute=noreturn]
  755 | meta_test_init (void)
      | ^~~~~~~~~~~~~~

when building without Wayland.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/837
2019-10-10 22:51:00 +00:00
Jonas Ådahl
1b4709794e kms/crtc: Read gamma state when prediction failed
If we did a mode set, the gamma may have been changed by the kernel, and
if we didn't also update the gamma in the same transaction, we have no
way to predict the current gamma ramp state. In this case, read the
gamma state directly from KMS.

This should be relatively harmless regarding the race conditions the
state prediction was meant to solve, as the worst case is we get none or
out of date gamma ramps; and since this is for when gamma ramps are not
updated at mode setting time, we'd get intermediate gamma state to begin
with, so it's not worse than what we currently do anyway.

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/840
2019-10-10 14:46:32 +00:00
Jonas Ådahl
1cc249fe18 kms: Always predict state after processing update
Not only mode sets have state that should be predicted; changing gamma
currently happens with its own update, so we missed predicting that.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/840
2019-10-10 14:46:32 +00:00
Marco Trevisan (Treviño)
446bd04b6c clutter-backend-x11: Don't push keymap events to clutter
Xkb events should be handled by clutter backend but they are not translated
into an actual clutter event. However we're now handling them and also trying
to push an empty event to clutter queue, causing a critical error.

So in such case, just handle the native event but don't push the non-populated
clutter-event to the queue.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/750
https://gitlab.gnome.org/GNOME/mutter/merge_requests/764
2019-10-10 13:00:02 +00:00
Marco Trevisan (Treviño)
9234fcb624 event-x11: Use CLUTTER prefix for X11 filter docs
As per commit ad72fa46b clutter_x11_handle_event was renamed into
meta_x11_handle_event but the return type didn't change.

So, keep the doc-string to match the actual possible return values.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/764
2019-10-10 13:00:02 +00:00
Carlos Garnacho
59a697f773 x11: Translate well known selection atoms to mimetypes
Some antediluvian x11 clients only bother to set atoms like
UTF8_STRING/STRING/TEXT/... and no matching mimetypes. Cover for them
and add the well known mimetypes if they are missing.

Reported at https://bugzilla.redhat.com/show_bug.cgi?id=1758873

https://gitlab.gnome.org/GNOME/mutter/merge_requests/842
2019-10-10 12:13:46 +00:00
Jonas Ådahl
d49d10b14f wayland/actor-surface: Queue redraw for frame callback
A frame callback without damage is still expected to be responded to.
Implement this by simply queuing damage if there are any frame callbacks
requested and there is no damage yet. If there already is damage,
we'll be queued already, but with more correct damage. Without we simply
need to make sure we flush the callbacks if any area of surface is not
occluded.

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/839
2019-10-10 10:01:05 +00:00
Jonas Ådahl
4c15d32b55 wayland/surface: Some minor coding style clean up
Some very long lines that were split up.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/839
2019-10-10 10:01:05 +00:00
Tim Klocke
81ee8886ce backends: Update inhibited state for the monitor and respect that state
The inhibited state of the monitor was after the initializiation never
updated. meta_idle_monitor_reset_idletime didn't respect the inhibited
state, so it set timeouts if it shouldn't have.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/573
2019-10-09 09:53:32 +00:00
Carlos Garnacho
d9597d2148 wayland: Ensure to forward numlock state to clients
This makes sure the numlock key lock state is forwarded to the wl_keyboard
internal state, notably on startup and after keymap changes.

https://gitlab.gnome.org/GNOME/mutter/issues/769
2019-10-07 22:28:45 +00:00
Carlos Garnacho
fc3831c797 backends: Fix thinko
We are meant to pass a flagset there, not a boolean. Fixes state querying
to the ClutterKeymap in the native backend.

https://gitlab.gnome.org/GNOME/mutter/issues/769
2019-10-07 22:28:45 +00:00
Carlos Garnacho
ce86f90efb Revert "backends/x11: Do not reload keymap on new keyboard notifications"
This reverts commit b01edc22f3.

It breaks keybindings on certain physical keyboard layouts.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/822
2019-10-07 22:15:02 +00:00
Jonas Ådahl
b5f50028f2 wayland: Untie MetaWindowXwayland lifetime from the wl_surface
For the most part, a MetaWindow is expected to live roughly as long as
the associated wl_surface, give or take asynchronous API discrepancies.

The exception to this rule is handling of reparenting when decorating or
undecorating a window, when a MetaWindow on X11 is made to survive the
unmap/map cycle. The fact that this didn't hold on Wayland caused
various issues, such as a feedback loop where the X11 window kept being
remapped. By making the MetaWindow lifetime for Xwayland windows being
the same as they are on plain X11, we remove the different semantics
here, which seem to lower the risk of hitting the race condition causing
the feedback loop mentioned above.

What this commit do is separate MetaWindow lifetime handling between
native Wayland windows and Xwayland windows. Wayland windows are handled
just as they were, i.e. unmanaged together as part of the wl_surface
destruction; while during the Xwayland wl_surface destruction, the
MetaWindow <-> MetaWaylandSurface association is simply broken.

Related: https://gitlab.freedesktop.org/xorg/xserver/issues/740
Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/762

https://gitlab.gnome.org/GNOME/mutter/merge_requests/774
2019-10-07 20:25:20 +00:00
Jonas Ådahl
fb6e2743ec plugins/default: Hold reference on timelines while stopping
We get implicit, thus auto-removed, transitions, then manage them
manually by stopping them and emitting "completed" signals. This doesn't
work since they are removed and freed when stopped. To be able to emit
the "completed" signal, hold a reference while stopping, so that we
still can emit the signal as before.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/828
2019-10-07 18:33:28 +00:00
Carlos Garnacho
107e521553 wayland: Unset pointer constraint in the backend before dropping the grab
Dropping the grab has the side effect that the pointer will be re-picked,
and it might find another surface with a pointer constraint. If that were
the case, the focus change would try to add the pointer constraint before
the now old focus surface released its own.

Just invert these operations, so the constraint is unset before the repick
that might enable another pointer constraint.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/779
2019-10-07 19:37:13 +02:00
Carlos Garnacho
7735a919d1 wayland: Check pointer visibility on post-grab focus changes
Just like sync_focus_surface() does, we shouldn't set a focus surface while
the pointer is hidden, so the illusion that there is none remains.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/779
2019-10-07 19:37:13 +02:00
Carlos Garnacho
9f617ae43d wayland: Warn if a surface is being set while the pointer is invisible
This is an unexpected condition, better not to fall in it without further
indications.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/779
2019-10-07 19:30:09 +02:00
Jonas Ådahl
104bdde746 kms: Predict state changes when processing update
We can't just update the state of the connector and CRTC from KMS since
it might contain too new updates, e.g. from a from a future hot plug. In
order to not add ad-hoc hot plug detection everywhere, predict the state
changes by looking inside the MetaKmsUpdate object, and let the hot-plug
state changes happen after the actual hot-plug event.

This fixes issues where connectors were discovered as disconnected while
doing a mode-set, meaning assumptions about the connectedness of
monitors elsewhere were broken until the hot plug event was processed.

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/826
2019-10-07 14:59:18 +00:00
Jonas Ådahl
2a990cc140 kms/update: Add helper to turn fixed point rect into int rect
Currently unused, but will in the following commit.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/826
2019-10-07 14:59:18 +00:00
Jonas Ådahl
3e41568074 kms/update: Add helper to get primary plane assignment
Replaces a private static function, with no functional changes made to
it.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/826
2019-10-07 14:59:18 +00:00