1
0
Fork 0
Commit graph

9768 commits

Author SHA1 Message Date
Ray Strode
c1f5e57f2b keymap-x11: Don't update key types when adding key to keymap
meta_keymap_x11_replace_keycode currently reports to the X server
that the key types data is changed when adding a key to the keymap.

It's not changed. The number of key types is the same, and none of
them are modified.

This has two bad side effects:

1) It sends all of the key types data into the request
2) It hits a bug in the X server leading to the request getting
rejected entirely.  See:

https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/761

Furthmore, the changed structure used to report to the X server
that the key types data is changed doesn't actually need to modified
at all in the function.  It's already prepped by libX11 with the
correct state for the changes mutter is doing when
XkbChangeTypesOfKey is called.

This commit addresses the above two problems by just removing the
lines causing the issues.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2039>
2021-10-06 14:16:39 +00:00
Sebastian Keller
2740f1d2d2 keymap/x11: Stop searching through reserved keycodes explicitly
Keys in the reserved keycode list are always added for the first group.
Before the previous commit such keycodes were not found unless that was
the current group. But now that we can also find matching keycodes that
are not directly in the current group, this is not necessary anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1955>
2021-10-06 13:38:18 +00:00
Sebastian Keller
795418a5db keymap/x11: Consider the out of range group action
Some keys, such as enter or backspace are only bound to a single group,
even if multiple groups are configured. Because the code was previously
only looking for keysyms in the same group as the current one, no
matching keycodes for these would be found if the current group is not
the first group. This was causing those keys to not work on the X11 OSK.

To fix this use the correct action to convert an out of range group for
that key according to its group_info field.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1955>
2021-10-06 13:38:18 +00:00
Sebastian Keller
bb24e4ac9e keymap/x11: Check for the group earlier when finding keycode from keyval
This effectively changes meta_keymap_x11_get_entries_for_keyval() to
meta_keymap_x11_get_entry_for_keyval() and moves the check if the
keycode maps to the keyval in the current group there. This simplifies
the code a bit and will allow a followup fix.

As a side effect this now also causes the reserved kecodes to be
searched, if no keycodes were found, rather than just when only ones
matching the wrong groups.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1955>
2021-10-06 13:38:18 +00:00
Jonas Ådahl
9179d4a4b1 kms/impl-device/atomic: Add virtio_gpu to deny list
virtio_gpu is used in virtual machine environments, meaning they need
accurate cursor hotspots, which currently needs non-atomic mode setting.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=2009304
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2040>
2021-10-05 13:55:06 +00:00
Robert Mader
e42196b00a wayland/actor-surface: Restore stage update for unmapped actors
The extra stage update we schedule in `apply_state()` is mainly
needed in two situations:
 - a partial update happened only in obscurred or off-screen parts
   of a surface
 - a surface requests frame callbacks without having done damage,
   notably the (in)famous Firefox vsync implementation.

Commit 0330ce1f15 limited the update to cases when the actor
was mapped, breaking it for Firefox in the overview.

Remove the mapped check again and get the stage from the backend,
restoring previous behaviour.

Fixes 0330ce1f15
Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1957

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2034>
2021-10-04 11:13:04 +02:00
Dor Askayo
98d5aa159e xwayland: Fix condition for queuing a window to META_QUEUE_CALC_SHOWING
This logic was changed by accident in df642eb15. The change caused every
Xwayland window to be queued to META_QUEUE_CALC_SHOWING on every surface
commit. As a result, X11 window management events, including _NET_WM_STATE,
were dispatched at clients on every single frame.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2032>
2021-10-02 00:12:34 +03:00
Bastien Nocera
c789b6be38 backend: Reset idletime when unplugging the power cable
Avoid having laptops suspend or lock as soon as the power cable is
unplugged as the timeout for those actions when on battery are smaller
than the timeouts when on AC.

- laptop is plugged in, and hasn't been used for X minutes
- laptop is unplugged
- the gnome-settings-daemon power plugin sets up its timeouts for
  inactivity for the "on battery" case
- those X minutes of inactivity are still counting, and are above
  the level of one of the timeouts (say, suspend or lock screen),
  mutter fires the timeouts
- gsd-power activates the action associated with the timeout

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1953
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2029>
2021-09-30 17:45:39 +02:00
Bastien Nocera
14b6c8780d backend: Refactor "lid-is-closed" handling code
We'll need to handle another property in the same place, so refactor the
code to allow falling-through to handle another property.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2029>
2021-09-30 17:45:22 +02:00
Sebastian Keller
e38db1237d window: Don't change workspaces of unmanaged windows
If the ancestor a window is transient for has already been unmanaged
when the window is activated via meta_window_activate_full while its
transient_for property still points to that ancestor, this will cause
the already unmanaged ancestor to get added to the windows workspace.
This is after the ancestor had its workspace set to NULL when it was
unmanaged, causing this to look like an actual workspace change. Once
the window has been added to the workspace, it will never be removed
again, because the it has already been unmanaged. This confuses things
like the shell window tracker and leads to phantom windows being
considered present for apps that are not even running anymore.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4184
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2003>
2021-09-29 09:34:30 +00:00
Robert Mader
8bf87a7e73 shaped-texture: Remove mask texture handling from get_image()
It has been broken for a long time now, not handling shadows of
SSD clients well. Instead, just use the offscreen code paths.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1996>
2021-09-22 13:07:44 +00:00
Jonas Ådahl
1031de5605 tests/dbus-runner: Make sure to tear-down even on test failure
When a test failed, an exception would be raised. This meant that the
mocked service would stay alive, and the test case being run eventually
failing due to a timeout, not the failure itself.

Fix this by catching the exception during the test, ensuring that we
tear down properly, then re-raise the same exception again after having
teared down.

This avoids the dead lock, while still printing the appropriate error
message.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2008>
2021-09-22 12:37:23 +00:00
Jonas Ådahl
fca9010963 mutter: Add signal handlers
With the introduction of MetaContext, the responsibility for handling
signals was changed to the application (e.g. GNOME Shell) using
libmutter. What wasn't fixed was making the stand-alone mutter do the
equivalent as well. This commit fixes this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2007>
2021-09-22 11:38:17 +00:00
José Expósito
36b5719a3b backends/x11: Fix middle button emulation settings
Update the name of the property used to toggle middle click emulation to
"libinput Middle Emulation Enabled".

Fix: <#1881>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2000>
2021-09-20 17:39:15 +00:00
Erfan Abdi
922878acc6 wayland/dma-buf: Add support for BGR_8888 formats
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1999>
2021-09-20 17:07:54 +00:00
Daniel van Vugt
b6857e59b2 shaped-texture: Fix whitespace/indentation warnings
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1992>
2021-09-20 16:07:59 +00:00
Marco Trevisan (Treviño)
ef0f708404 monitor-manager: Use connect_object to connect to settings signals
We were disconnecting from the wrong object, so instead of adjusting it
we can simply use "new" utility functions instead.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
16e335eb24 backends/native: Remove unused includes
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
3d689989ea kms/connector: Use utility function to get the property ID
We already have one for this, so use it instead of repeating the same

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
cbfb59b828 backends/native: Ignore udev events while we're paused
When the native backend is paused we still process the udev events
even though this isn't needed and may just cause unneeded events to be
triggered afterwards.

Since we'll resume with full changes on such event, we can just block
the signal hander when paused and restore it afterwards.

As per this we can cleanup also a bit the device adding signal handling
given that now we don't have to disconnect/reconnect it again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
9cb35e2c80 backends/kms: Always perform full changes on KMS resume
Resume happens after we may have received various events that we've
ignored, so at this point we need to just emit an hotplug event like if
everything changed so that user settings may be re-applied.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
dd0ad3bfb1 kms/impl-device: Only update crtc/connector whose ID has changed
On hotplug events we may get informations about what CRTC or connector
changed a property (and the property itself), so in such case let's just
ignore the changes to the non-affected CRTCs/connectors, and let's read
only the affected one

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
91ed95ab6f kms: Only update a device state if it contains the changed crtc/connector
On hotplug events we may receive a "CRTC" or "CONNECTOR" property that
indicates which crtc/connector property ID has changed.

In such case, instead of update data for all the devices, only update the
device containing the relative connector.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
3d3668a389 kms/device: Add functions to find connector and crtc in devices
Hotplug events may contain CRTC or CONNECTOR ids to notify a property
change to just one owner, so we need to find its parent device.

Also we may want to update properties directly without having to go through
all the devices, so expose a simple way to find them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
ea00c96044 udev: Pass the device as parameter on hotplug events
This will allow to find the related MetaKmsDevice that is emitting the
hotplug event

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
49501c28f2 kms: Return a more specific change if there are no devices
In case we have no devices, after a KMS update (both because they've
all have been removed or because there were none), we may need to behave
differently compared to the case in which nothing changed, so add a more
specific KMS update change type

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
9ce3abad28 monitor-manager-native: Do not reload all the monitors on gamma-only change
If only gamma changed on drm CRTC's we don't have to rebuild the whole
monitors, nor to inform the backed about, the only consumer could be the
DBus API, and so we still emit a signal, but nothing else is needed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Marco Trevisan (Treviño)
a8d11161b6 kms: Only emit resources-changed signal if we recorded a change
Since we cache already all the KMS parameters we care about let's check at
each device update if anything has really changed and only in such case
emit a resources-changed signal.

In this way we can also filter out the DRM parameters that when changed
don't require a full monitors rebuild.

Examples are the gamma settings or the privacy screen parameters, that
emits an udev "hotplug" event when changed, but we want to register those
only when we handle the changed property.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1964>
2021-09-20 15:37:59 +00:00
Christian Rauch
d2eec866ed wayland: Allow to maximize windows by client regardless of constraints
A client request for maximizing itself should always be handled by mutter
by emitting a configure event with the native maximized resolution,
regardless of the client's own set limits. This also aligns the behavior by
allowing fixed-sized windows to go into fullscreen or maximized state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1997>
2021-09-20 15:09:17 +00:00
Robert Mader
3192b0239a wayland-dma-buf: Add support for DRM_FORMAT_XBGR2101010
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1810>
2021-09-20 14:39:20 +00:00
Robert Mader
9ededb9b34 wayland-dma-buf: Use alpha-less pixel formats where appropriate
The XRGB/XBGR pixel formats do not set the cogl alpha bit. This
allows for example `MetaShapedTexture` to use the fast opaque
path for rendering and `MetaCullable` to detect whether a
`MetaSurfaceActor` is opaque.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1810>
2021-09-20 14:39:20 +00:00
Michel Dänzer
3059d3ffc8 cursor-renderer: Remove meta_cursor_renderer_is_overlay_visible
Not used anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1914>
2021-09-20 14:00:08 +00:00
Michel Dänzer
6c818cd8d5 screen-cast/monitor-src: Use clutter_stage_paint_to_buffer
It works correctly with scanouts, in contrast to
clutter_stage_capture_into. Inspired by
meta_screen_cast_area_stream_src_record_to_buffer.

maybe_paint_cursor_sprite is now unused and thus removed.

v2:
* clutter_stage_paint_to_buffer requires switching to recording from an
  idle callback as well. (Jonas Ådahl)
v3:
* Set human readable name for idle source. (Ivan Molodetskikh)

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1940
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1914>
2021-09-20 14:00:08 +00:00
Michel Dänzer
10d1de2bdf screen-cast/monitor-src: Always set before-paint watch
We weren't setting it for META_SCREEN_CAST_CURSOR_MODE_EMBEDDED, so
that case didn't work correctly with scanouts.

Suggested by Georges Basile Stavracas Neto.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1914>
2021-09-20 14:00:08 +00:00
Corentin Noël
f140d01df2 context: Add some missing introspection data
Allows to use option groups/entries from the introspection.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1976>
2021-09-16 07:23:24 +00:00
Olivier Fourdan
20bb8bf502 wayland: Avoid a race in wl_seat capabilities
The way wl_seat capabilities work, by notifying clients of capabilities
changes, and clients consequently requesting the relevant interface
objects (pointer, keyboard, touch) is inherently racy.

On quick VT changes for example, capabilities on the seat will be added
and removed, and by the time the client receives the capability change
notification and requests the relevant keyboard, pointer or touch,
another VT switch might have occurred and the wl_pointer, wl_keyboard or
wl_touch already destroyed, leading to a protocol error which kills the
client.

To avoid this, create the objects when requested regardless of the
capabilities.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1797
Related: https://bugzilla.gnome.org/show_bug.cgi?id=790932
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/77>
2021-09-16 06:52:20 +00:00
Dor Askayo
70f2eb7bfa x11: Initialize g_autofree with NULL
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1990>
2021-09-04 20:00:23 +00:00
Dor Askayo
264b5b825f xwayland: Initialize g_autofree with NULL
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1990>
2021-09-04 20:00:23 +00:00
Robert Mader
2239e7ad29 shaped-texture: Remove get_image_via_offscreen()
It duplicates functionality in `meta_window_actor_get_image()`, its
only user. Instead, make `should_get_via_offscreen()` public and
use it in the former.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1893>
2021-09-04 09:17:44 +00:00
Robert Mader
b1c8510a95 window-actor: Add paint_to_content() function
Analogous to `get_image()` this returns a `ClutterContent` for a
given `MetaWindowActor`. This can be used to implement window
effects without a roundtrip from GPU to CPU memory.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1893>
2021-09-04 09:17:44 +00:00
Robert Mader
6bbb216f07 window-actor: Factor out framebuffer creation of get_image()
So we can reuse the code in the following commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1893>
2021-09-04 09:17:44 +00:00
Marco Trevisan (Treviño)
a4223007e2 tests: Run a localed mock implementation on tests
As per this we can just warn if its proxy initialization fails.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:01 +02:00
Marco Trevisan (Treviño)
b3c5ca12a5 monitor-manager: Remove persistent_timeout on dispose
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:01 +02:00
Marco Trevisan (Treviño)
4fe7569567 orientation-manager: Use an idle to apply monitor orientation changes
In X11 when we switch to another tty all the the signals are blocked (as
the display fd is not replying back to polling, causing the main loop to
stop), and they are all handled once we switch back to the tty.

This is not a problem for most of external events, but in case of
accelerometer changes, once we reactivate a mutter session we'll get
them all together, causing lots of monitor reconfigurations leading to
black screen for some seconds and most of the times to a wrong
configuration being applied.

To avoid this, batch all these events using an idle to only apply the
last one we got in a loop.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1217
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:01 +02:00
Marco Trevisan (Treviño)
d5f397977e monitor-unit-tests: Add tests with dynamic orientation changes
Verify monitors disposition when we have rotation changes coming from
MetaOrientationManager, using our mock dbus implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:01 +02:00
Marco Trevisan (Treviño)
d0a9dfefc8 monitor-transform: Add function to compute from orientation
We have two places in the code where we compute the monitor
transformation from the device orientation, avoid duplicating this
code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:01 +02:00
Marco Trevisan (Treviño)
bf54a16f92 tests: Add MetaOrientationManager tests via SensorsProxy mock
Create a test system bus and use it to run all the tests, add a mock
SensorsProxy (via dbusmock template) server that implements the
net.hadess.SensorProxy interface.

To make testing easier, the service is created on request of a proxy for
it, whose lifetime controls the mock service lifetime as well.
This is done using a further mock service that is used to manage the
others, using python-dbusmock to simplify the handling.

Add basic tests for the orientation manager.

As per the usage dbusmock, we're now launching all the tests under such
wrapper, so that local dbus environment won't ever considered, and
there's no risk that it may affect the tests results both locally and in
CI.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:04:00 +02:00
Marco Trevisan (Treviño)
f1228c4a51 orientation-manager: Expose the number of valid orientations
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
617e1b30e2 monitor-config-manager: Rename builtin monitor lookup utility function
It's only meant to find the builtin monitor configuration, for any
rotation, so no need to specify that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
c326313370 monitor-config-manager: Find builtin configuration even when inactive
When creating the configuration for the builtin monitor we try to get
the panel configuration for the builtin panel, but we don't proceed if
that monitor is currently inactive.

This is fine when adjusting an active configuration to the current
device rotation, but it isn't correct when we want to create a new
configuration based on another where the monitor is configured but not
yet enabled.

So, only find the panel configuration without looking the current state
but ensuring that the passed configuration will enable it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
f803c0ee0a monitor-manager: Add config relationships and use it for orientation events
When we get an orientation event we don't care about keeping track of the
configuration changes, but actually we can consider the new configuration
just a variant of the previous one, adapted to floating device hardware
events, so we only want to apply it if possible, but we don't want to keep
a record of it for reverting capabilities.

Doing that would in fact, break the ability of reverting back to an actual
temporary or persistent configuration.
For example when device orientation events happen while we're waiting for
an user resolution change confirmation, we would save our new rotated
configuration in the history, making then impossible to revert back to
the original persistent one.

So in such case, don't keep track of those configurations in the history,
but only keep track of the last one as current, checking whether the
new current is child or sibling of the previously one.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1221
Related to: https://gitlab.gnome.org/GNOME/mutter/-/issues/646

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
db68a2a91c monitor-unit-tests: Add tests to verify config manager history
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
d773aaf7a9 monitor-manager: Apply built-in monitor orientation to previous configurations
When we reuse a monitor configuration (from the storage or previously
used), we need to make sure that the built-in monitor rotation matches
with the current sensors status.

So, instead of trying to apply a previously used or stored configuration
with a wrong orientation and fix it later, if orientation is managed by
sensor, try to create another configuration based on the previous one that
uses the current built-in monitor orientation and use it.

Related to: https://gitlab.gnome.org/GNOME/mutter/-/issues/646

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/592
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/646
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/954
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
dbf5e38f03 monitor-config-manager: Ignore orientation if it is not managed
When creating a configuration taking orientation into account we're using
the sensors orientation even if this is currently not used (for example
when an accelerator is available, but there's no touch screen).

This would cause to have a different behavior when configuration is
created and when we're loading a known configuration on startup.

So always honor whether the monitor's orientation is managed or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
2289f56112 monitor-manager: Don't apply unneeded orientation changes
There's no need to ensure monitor orientation changes if the wanted
orientation is matching the current one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
e976137d97 monitor-manager: Only manage orientation if we have a built in panel
All the auto-rotation code is expecting to have a built-in panel, but we
still monitor accelerometer changes if we don't have one (uncommon, but
possible).

Thus manage the panel orientation in such case and update it on monitors
changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Marco Trevisan (Treviño)
f78e21c45a monitor-manager: Remove some trailing spaces in orientation code
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1233>
2021-09-04 10:01:29 +02:00
Carlos Garnacho
405ec8edc2 wayland: Forward button press / touch down to Wayland text-input impls
These are ClutterInputFocus subclasses, so this will trigger reset of
the input method. As the .done event is possibly deferred in the
zwp_text_input_v3 implementation, ensure the changes caused by the
reset are flushed immediately, before the button press is forwarded
to the client by MetaWaylandPointer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1940>
2021-09-03 22:05:46 +00:00
Piotr Lopatka
b328c8cc8b onscreen/native: Pass damage rectangles when page flipping
This commit passes damage rectangles metadata to the (KMS) primary
plane.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1879>
2021-09-03 21:37:56 +01:00
Piotr Lopatka
af0460d0ce kms: Allow passing framebuffer damage metadata
This commit adds support to atomic KMS backend for optional plane property
prop_fb_damage_clips. Some drivers (e.g. EVDI) take advantage of this
property and process only updated regions of the screen instead of
processing the full frame. This can save system resources.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1879>
2021-09-03 21:10:35 +01:00
Nishal Kulkarni
7555688d8d display: Set xattr on focus window cgroup dir
Added a function `meta_window_set_inactive_since` it sets
xattr on the cgroup directory for the given MetaWindow.

Resource management daemons can then monitor these changes on xattr
and make allocation decisions accordingly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1960>
2021-09-02 21:54:30 +00:00
Nishal Kulkarni
c2efe25597 window: Add cgroup management to MetaWindow
Currently the only way to get cgroup for a MetaWindow is to get it's
PID and perform a bunch of file accesses and string manipulations.
This is especially not feasible if we want to get the cgroup every
time a MetaWindow has gained or lost focus.

A solution to this is to cache the GFile for a cgroup path.
The creation and access of this GFile is handled by
`meta_window_get_unit_cgroup` function.

`meta_window_unit_cgroup_equal` is a utility function which allows
us to compare whether two MetaWindows belong to the same cgroup.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1960>
2021-09-02 21:54:30 +00:00
Nishal Kulkarni
4a0c86ea4c meson: Add optional libsystemd dependency
To utilize the API provided by libsystemd it would be better to
create a separate HAVE_LIBSYSTEMD configuration option instead of
having to rely on HAVE_NATIVE_BACKEND.

For now this will be utilized for getting the control group of a
MetaWindow.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1960>
2021-09-02 21:54:30 +00:00
Robert Mader
5ffd77c36b tests/wayland: Test reattaching subsurface after parent was destroyed
and the subsurface was not previously detached from it using
`wl_subsurface_destroy()`.

Without 'window-actor/wayland: Remove subsurface actors on dispose' this
test would fail.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1958>
2021-09-02 21:14:18 +00:00
Robert Mader
dd416dd3e2 window-actor/wayland: Remove subsurface actors on dispose
Destroying the window actor also destroys all its children. Subsurfaces
however may get reused. If the client did not unparent them before
the window actor got destroyed, they will be left without actor
which results in a crash.

Unparent all actors of subsurfaces on dispose to avoid that.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1958>
2021-09-02 21:14:18 +00:00
Robert Mader
f41696b0fc wayland/subsurface: Handle node unlinking on parent destroyed
It concerns subsurface state and the subsurface already listenes
for the parent to get destroyed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1958>
2021-09-02 21:14:18 +00:00
Robert Mader
2a2f9300d0 wayland/subsurface: Check for parent actor before unparenting
No need to assume the actor still has a parent. This silences warnings
in normal builds and prevents a crash in fully optimized ones.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1958>
2021-09-02 21:14:18 +00:00
Florian Müllner
d17e9adc73 context: Add (hidden) --unsafe-mode option
When running gnome-shell, it is possible to toggle unsafe-mode in
looking glass. We'll eventually start using the property in mutter
as well, so to make stand-alone debugging easier, also expose it
as a hidden command line option.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3943

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1983>
2021-09-02 16:58:46 +00:00
Florian Müllner
c62e86cb23 context: Add :unsafe-mode property
We are going to restrict several sensitive D-Bus APIs to a set
of allowed callers (like Settings or portal implementations).

Add an :unsafe-mode property to the context to allow turning off
those restrictions temporarily, in order to not get in the way
of development/debugging.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3943

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1983>
2021-09-02 16:58:46 +00:00
Ray Strode
2cb617e9e0 backend: Clean up renderer after clutter backend
commit c4a73e7950 added
code to cleanup the renderer when the meta backend is
disposed. Unfortunately, this introduced a crash when
the window manager is replaced.

This is because cleaning up the renderer involves talking
to the X server over a display connection that's closed
two lines higher as part of the clutter_backend_destroy
call.

This commit fixes the crash by swapping their order.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1965>
2021-08-31 16:41:11 +00:00
Jonas Ådahl
ef8c428ef9 background-image: Properly clear the failed to be filled texture pointer
Otherwise we'll unref and effectively free it, eventually resulting in
use after free, causing wierd issues like crashes and infinite
recursions.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1989726
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1979>
2021-08-31 08:25:32 +00:00
Jonas Ådahl
04994ebddf background-image: Use autoptrs for errors when loading image
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1979>
2021-08-31 08:25:32 +00:00
Florian Müllner
41d1a8407e keybindings: Remove 'panel-run-dialog' handler
There is very little point in sending an X11 client message to
gnome-panel in case gnome-shell isn't handling the binding. We
can just as well do nothing, so do exactly that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1886>
2021-08-30 21:43:34 +00:00
Florian Müllner
b5ba216163 keybindings: Remove support for 'panel-main-menu' binding
Nothing uses it anymore, and probably nobody expects mutter to
send an X11 client message to gnome-panel in that case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1886>
2021-08-30 21:43:34 +00:00
Robert Mader
021c1dd7fa surface-actor: Remove get_image() function
It is unused and removing it allows us some further cleanups.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1978>
2021-08-28 13:59:52 +02:00
Robert Mader
9f8242658e surface-actor: Remove some unused and useless functions
These functions only added some extra redirections.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1978>
2021-08-28 13:58:48 +02:00
Robert Mader
eede3d1836 wayland/actor-surface: Remove some needles redirections
We already interact with the `MetaShapedTexture` directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1978>
2021-08-28 13:58:48 +02:00
Daniel van Vugt
cd355b5d74 onscreen/native: Remove a tab character
To resolve CI warnings.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1972>
2021-08-24 16:44:44 +08:00
Florian Müllner
6288763671 build: Stop using source_root()/build_root()
They were deprecated in meson 0.56.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1957>
2021-08-22 17:32:12 +00:00
Jonas Ådahl
ea46ebea99 tests/stage-view: Added test for incorrect frame clock scheduling
The test attempts to reproduce gnome-shell#4486, and is fixed by
"window-actor/x11: Don't cache the frame-drawn frame clock".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1947>
2021-08-22 17:06:53 +00:00
Jonas Ådahl
d2186f6f1a window-actor/x11: Don't cache the frame-drawn frame clock
We fetch a frame clock that we schedule update on when queuing
_NET_WM_FRAME_DRAWN events. In some situations this frame clock is the
one from the stage, and if there are multiple hotplugs in a row, we
failed to update it as there were no stage views changes on the window
actor itself. As an actor updates the stage views list on layout, When a
queue_frame_drawn() call was done (typically from an X11 event) after a
second hotplug, it'd attempt to schedule an update on the frame clock
from the previous hotplug, as it didn't get notified about any
stage-views changes since for itself there was none.

Fix this by not caching the frame clock at all and just fetch it every
time.

In the majority of cases, this fetching means iterating over a very
short list (most often a single entry, rarely more), so it's very
unlikely to be of any relevance. The only situations where it might be a
heavier operation is the short time between a hotplug and a layout, as
it will attempt to traverse up to the stage to find a clock, but that's
likely only a few levels, so even that is unlikely to be an issue.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4486
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1947>
2021-08-22 17:06:53 +00:00
Jonas Ådahl
c8fb98a0a7 wayland/output: Fly-by coding style fix
Change 'GList *iter' to 'GList *l' in a few places.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1712>
2021-08-22 16:40:42 +00:00
Jonas Ådahl
bf7c34507d wayland/output: Make each wl_output correspond to one monitor
This is more in line with the protocol, and allows us to remove some
awkward code that tries to "combine" different metadata from different
monitors into one, which sometimes meant picking an arbitrary "main"
monitor, or "and" metadata together to find a common ground.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1712>
2021-08-22 16:40:42 +00:00
Jonas Ådahl
4615da2122 monitor: Add hash function
Will be used to keep a monitor spec as a hash table key.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1712>
2021-08-22 16:40:42 +00:00
Jonas Ådahl
fcbeae5f60 wayland/output: Move struct to C file
Avoids leaking implementation details outside.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1712>
2021-08-22 16:40:42 +00:00
Jonas Ådahl
2b59b85d85 wayland: Fetch wl_output logical monitor via helper
Will be useful when wl_output gets tied to a MetaMonitor, instead of a
MetaLogicalMonitor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1712>
2021-08-22 16:40:42 +00:00
Jonas Ådahl
99531f9d4b wayland/surface: Get wl_output resource list via helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1712>
2021-08-22 16:40:42 +00:00
Ivan Molodetskikh
f6bf1ceb92 cursor-tracker: Add meta_cursor_tracker_get_scale ()
Used in the screenshot UI (and arguably should be used in the existing
gnome-shell screenshot drawing code).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1967>
2021-08-22 15:02:38 +00:00
Alexander Mikhaylenko
ed391eb06b window: Make default focus window on each workspace appear focused
Makes workspace transitions in gnome-shell look more seamless, since
both outgoing and incoming workspace have focused windows.

This is only done for click focus mode, since it's not known which
window would be focused for the other modes.

Track the state and recompute it when it changes, to avoid redrawing
the windows needlessly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/850>
2021-08-12 21:41:40 +05:00
Alexander Mikhaylenko
7afefbbb61 workspace: Add meta_workspace_get_default_focus_window()
Each workspace has a window that will be focused when switching to that
workspace. Add a function to retrieve that window.

This is only relevant for click-to-focus focus mode, since with the two
other modes no window will be focused upon switching, and will only gain
focus when hovered.

This will be used in the next commit to make this window appear focused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/850>
2021-08-12 21:39:05 +05:00
Alexander Mikhaylenko
448ffaefc5 stack: Check workspace in get_default_focus_window()
Check against the window argument, instead of active workspace.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/850>
2021-08-12 21:39:05 +05:00
Jonas Ådahl
26e06845e3 plugins/default: Switch to g_spawn_check_wait_status()
The old one is deprecated and equivalent.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1941>
2021-08-12 13:11:31 +00:00
Jonas Ådahl
23bebf3385 xwayland-grab-keyboard: Switch to g_pattern_spec_match_string()
The g_pattern_match_string() variant is deprecated, switch to the
properly namespaced one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1941>
2021-08-12 13:11:31 +00:00
Robert Mader
a96caf6def wayland-dma-buf: Fix 'kms-modifiers' experimental setting
The setting was ignored in favor of whatever the backend
returned.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1953>
2021-08-06 10:28:13 +00:00
Robert Mader
287c715df6 shaped-texture: Do not apply y-inverts to shape masks
This was introduced by accident in commit 1467b6b02a

y-inverted textures in combination with shape masks appear to
be only commonly used with EGLstreams. However, as we draw the
shape mask ourselves, we don't want to apply the y-invert to it
as testified by the left over `cogl_pipeline_set_layer_matrix()`.

Note that we still allow to apply viemports and buffer transforms,
as the Xwayland mode setting emulation may use it (in fact only
the former, but it probably does not hurt to leave the later as well).

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1937>
2021-08-04 15:08:12 +00:00
Florian Müllner
111055acdd wayland/gtk-shell: Add titlebar_gesture request
This allows client to delegate titlebar gestures to the compositor,
which allows for better consistency with server-side decorations,
and a wider range of actions (including lower-on-middle-click).

The protocol addition is based on a suggestion from Carlos Garnacho
and Jonas Ådahl.

https://gitlab.gnome.org/GNOME/mutter/-/issues/602

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1944>
2021-08-04 14:41:43 +00:00
Florian Müllner
eed1db4379 window: Add meta_window_lower_with_transients()
The only thing x11-specific about the existing code is that it is only
used to implement titlebar actions on server-side decorations.

We are about to bring that functionality to wayland, so move the code
into MetaWayland.

https://gitlab.gnome.org/GNOME/mutter/-/issues/602

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1944>
2021-08-04 14:41:43 +00:00
Marco Trevisan (Treviño)
3baf750e42 monitor-test-utils: Add debug friendly statements during tests
Monitor configuration check tests can be very complex and in case of
failures we can't easily catch where a failure happened without entering
in debug mode, something that isn't always an option in CI or external
builders.

So add more debug statements in configuration check functions and use
macros to ensure that we print the caller function and location on more
complex check functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
37e154c832 monitor-config-manager: Use match rule to check laptop panel visibility
Use the MONITOR_MATCH_VISIBLE match rule instead of doing the same check when
initializing the list of disabled monitor specs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
e59da5ad83 monitor-conifig-manager: Generate primary monitor config with others
Primary monitor is just the same of the other monitors, but it has a
primary monitor flag. Since the computation of the scaling isn't
dependent anymore on the computed configuration we can now generate the
primary monitor config together with the others.

However, we've to ensure that the primary monitor is the first of the
configs list in order to properly compute the positioning.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
e8b84441a4 monitor-config-manager: Computer monitor scale in caller
Compute the monitor scaling in a separated function using the primary
monitor (not its config) and pass it to the creation function instead.

This will allow removing the special logic for the primary monitor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
aeea2882e5 monitor-config-manager: Use monitor match filters to create config
Factorize the creation of a configuration inside one function that looks for
the primary monitor and the other monitors using the matching rules and
dispose them according to the chosen policy (checking if the result is valid
when using the suggested positioning).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
3dbec4d709 monitor-config-manager: Define cleanup functions for structs
Monitor configuration structures can be used inside containers such as GList
and in order to have smart cleanups we need to define the relative free function

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
4574f2d9af monitor-config-manager: Use single filter function to build configs
Add a find_monitors function that allows to search for monitors that match
the MonitorMatchRule filter and use this to look for the primary monitor and
the other monitors that need to match the requested filter in order to be
configured.

Having just one function doing this kind of checks reduces the possibility
of unexpected results.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
32d7c5fbfb monitor: Only assign suggested positions to valid pointers
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
ab48b6b933 monitor-unit-tests: Check suggested configuration has adjacent outputs
Verify that the suggested monitor configuration contains only adjacent monitors,
and that if this is not the case we fallback to the linear configuration.

This can happen in case of multi-DPI setup, so add a test checking this too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
be9e6dcc4f monitor-config-manager: Reject a suggested config with gaps
It could happen that monitors suggest to use coordinates that don't take
in consideration the scaling applied to one monitor, and such the
generated configuration is not valid because not all the monitors are
adjacent.

So enforce this check before accepting a suggested configuration as it
is.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
58c2f423f7 boxes: Add function to check if rectangle is adjacent to region
We may need to check if rectangles region has adjacent neighbors and
so if there are no gaps in between monitors.

This can be done by checking if each monitor is adjacent to any other in
the same region.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Marco Trevisan (Treviño)
d3602e9fef monitor-unit-tests: Add test for overlapping monitor config
Verify that when we've monitors with overlapping preferred configuration, we
fallback to the default linear configuration.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Carlos Garnacho
36299494dd x11: Add COGL_HAS_TRACING checks around tracing code
This code sneaked unconditionally, even though we can disable
tracing code with -Dprofiler=false. Add some COGL_HAS_TRACING
checks so that this code is also optionally built.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1951>
2021-08-02 17:15:33 +02:00
Carlos Garnacho
a42c470efd compositor: Add COGL_HAS_TRACING checks around tracing code
This code sneaked unconditionally, even though we can disable
tracing code with -Dprofiler=false. Add some COGL_HAS_TRACING
checks so that this code is also optionally built.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1951>
2021-08-02 17:15:23 +02:00
Jonas Ådahl
ffb88bffc5 x11/window: Add tracing for X11 synchronization events
Add tracing and data gathering for processing related to
_NET_WM_FRAME_DRAWN and _NET_WM_FRAME_TIMINGS, used by some X11 clients
for synchronized rendering.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:37:12 +02:00
Jonas Ådahl
d956f63d67 x11/events: Trace X11 event handling
Traces the type of event, and how much time was spent processing it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:16:48 +02:00
Jonas Ådahl
6c7765439f x11/events: Fly-by coding style cleanup
A large else block didn't have {}, so added them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:16:48 +02:00
Jonas Ådahl
72704f787c x11/events: Clean up event name getting
Preparation for adding a generic "get event name" getter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1700>
2021-07-29 15:16:48 +02:00
Pascal Nowack
537e2dfafe core/selection: Cancel selection transfer requests after a timeout
When a selection owner advertises a mime type, but does not provide the
content upon a request for the mime type content, the requesting side
might wait indefinitely on the content.
To avoid this situation, add a timeout source, which will cancel the
selection transfer request after a certain timeout (15 seconds) passed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1874>
2021-07-28 15:26:04 +00:00
Pascal Nowack
20db6af4e6 remote-desktop: Check pipe fd before assuming existing read() operation
Currently, if g-r-d closes the read end of the pipe for a
SelectionRead() operation, due to realizing that the application, that
should provide the mime type content, does not provide any content,
mutter won't notice that and still assumes that the read() operation
on the pipe in g-r-d is still happening, as mutter never writes to the
pipe in that situation and therefore cannot realize that the pipe is
already closed.
The effect of this is, that if g-r-d aborts a read() operation and
requests a new read() operation via SelectionRead(), mutter will deny
the request since it assumes that the previous read() operation is
still ongoing.

Fix this behaviour by also checking the pipe fd in mutter before
denying a SelectionRead() request.

https://gitlab.gnome.org/GNOME/gnome-remote-desktop/-/issues/60

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1874>
2021-07-28 15:26:04 +00:00
Daniel van Vugt
9e6a3f537b background-content: Shrink and optimize the rounded-clip shader
The main benefit being it now fits within the hardware limits for the
i915 Mesa driver, and runs on the GPU instead of software fallback.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4251,
       https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4425

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1860>
2021-07-26 16:17:46 +08:00
Marco Trevisan (Treviño)
3e1e2cb91f monitor: Do not overlap when checking for applicable scaling values
With some resolutions (such as 4096x2160) we may compute duplicated
scale factors because we used a too wide threshold to check for an
applicable value.

In fact, while when we're at the first and last values it's fine to
search applicable values up to SCALE_FACTORS_STEP, on intermediate ones
we should stop in the middle of it, or we're end up overlapping the
previous scaling value domain.

In the said example in fact we were returning 2.666667 both when
looking to a scaling value close to 2.75 and 3.00 as the upper bound of
2.75 (3.0) was overlapping with the lower bound of 3.0 (2.75).
With the current code, the lower and upper bounds will be instead 2.875.

Adapt test to this, and this allows to also ensure that we're always
returning a sorted and unique list of scales (which is useful as also
g-c-c can ensure that this is true).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1878>
2021-07-22 16:19:15 +02:00
Marco Trevisan (Treviño)
c86a1e00c0 monitor-unit-tests: Check integer scaling values are matching expectations
A per previous commit we can now ensure that all the scaling values
when using non-fractional scaling have the value we expect.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1878>
2021-07-22 16:06:10 +02:00
Marco Trevisan (Treviño)
98f3f96978 monitor: Never return fractional scale values when NO_FRAC is used
We introduced META_MONITOR_SCALES_CONSTRAINT_NO_FRAC to get global scale
values however, this didn't work properly for some resolutions.

In fact it may happen that for some resolutions (such as 3200x1800) that
we did not compute some odd scaling levels (such as 3.0) but instead
its closest fractional value that allowed to get an integer resolution
(2.98507452 in this case).

Now this is something relevant when using fractional scaling because we
want to ensure that the returned value, when multiplied to the scaled
sizes, will produce an integer resolution, but it's not in global scale
mode where we don't use a scaled framebuffer.

So, take a short path when using no fractional mode and just return all
the applicable values without waste iterations on fractional values.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1878>
2021-07-22 16:06:08 +02:00
Marco Trevisan (Treviño)
f6e2059a65 monitor: Replace some useless goto with clearer returns
There was no point to use goto in place of normal returns here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1878>
2021-07-22 15:54:03 +02:00
Marco Trevisan (Treviño)
b088dbd90b monitor-unit-tests: Add tests to verify the computed scaling values
Scaling values computation code served us well in the past years but
it's quite delicate and it has some issues in edge cases, so add a test
that verifies that the computed scaling values for all the most common
resolutions (and some that may be common in future) are what we expect
to be.

This may also serve us in future when we'd define a better algorithm to
compute the preferred scale, but this not the day.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1878>
2021-07-22 15:50:44 +02:00
Marco Trevisan (Treviño)
4ca5a97ea8 monitor-manager: Only derive global scales supported by all monitors
When deriving the global scale from current monitor, we were just checking the
supported value by the primary monitor, without considering weather the current
scale was supported by other monitors.

Resolve this by checking if the picked global scale is valid for all active
monitors, and if it's not the case, use a fallback strategy by just picking the
maximum scale level supported by every head.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
2021-07-22 15:38:04 +02:00
Marco Trevisan (Treviño)
1ab79c79a5 monitor-manager: Derive configured global scale using common value
When deriving the global scale from config, we need to ensure that the value
is matching all the monitor configurations.

If not, we should fallback to the normal scale value.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
2021-07-22 15:38:04 +02:00
Marco Trevisan (Treviño)
7c87c1c24f monitor-manager: Check if all monitor scales are matching in global mode
When global scaling is set we need to ensure that all the requested scale
configurations are matching, otherwise we'd end up in a mixed setup that
we don't support in this scenario.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
2021-07-22 15:38:04 +02:00
Marco Trevisan (Treviño)
1ac63fcd77 monitor-manager-xrandr: Use monitor to calculate scaling
In Xrandr we were caching the available scaling modes that were computed just
for the current mode, for each monitor, while we can actually reuse the
default implementation, by just passing the proper scaling constraint.

In monitor we need then to properly filter these values, by only accepting
integer scaling factors that would allow to have a minimal logical monitor
size.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
2021-07-22 15:38:02 +02:00
Marco Trevisan (Treviño)
67eb60c19a monitor-manager: Pass the Logical mode when computing the monitor scale
In order to compute proper default scaling value we need to know if the
fractional scaling is enabled or not and thus if we're using a logical
mode or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/336>
2021-07-22 13:14:01 +02:00
Florian Müllner
ff14ed5ad9 compositor: Update outdated URL
The file was moved a while ago. Update the link to the new location,
and specify a particular tag instead of master to make sure this
doesn't happen again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1930>
2021-07-18 23:14:16 +02:00
Carlos Garnacho
414302fa82 backends: Promote g_debug() MetaStageImpl message to meta_topic()
We now have a META_DEBUG_BACKEND topic that can suit this bag of
assorted debug messages. Assign it to these, instead of plain
G_MESSAGES_DEBUG=mutter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:12:01 +02:00
Carlos Garnacho
dc6d3cead2 backends: Shuffle ClutterBackendX11 code into MetaClutterBackendX11
We have a Clutter implementation of the X11, just to subclass it in
our backends. Move the implementation entirely to src/backends/x11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
e77e88894b backends: Excise MetaStageView to its own file
It was implemented together with MetaStageImpl, move it to a separate
file.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
d5c3c80dfe backends: Rename ClutterStage[View]Cogl API and types
Rename to MetaStageImpl and MetaStageView, so they are in line with
the rest of the backend code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
8f839b2f9c clutter: Move ClutterStageCogl[View] code to src/backends
This is now MetaStageImpl in backend code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
0ac257212e core: Add private utility function to get Clutter debug flags
This will be used to fetch the debug flags from backend code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
5785d8cde0 backends/native: Remove unused array definition
This array is a relic from the input code belonging to Clutter,
and is nowadays unused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Jonas Ådahl
a2937a47bb onscreen/native: Change some g_debug() meta_topic()
g_debug() is inconvenient to use; change to meta_topic() with the 'kms'
topic. This makes it possible to enable valuable debug output at
runtime.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
2021-07-16 18:17:04 +02:00
Jonas Ådahl
d057762cdb device-pool: Add debug logging
Enabled by enabling the 'backend' debug topic.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
2021-07-16 18:17:04 +02:00
Jonas Ådahl
4b6631338e util: Add 'backend' debug topic
Meant for backend things that are not large enough to warrant their own
topic.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
2021-07-16 18:17:04 +02:00
Jonas Ådahl
b65555a958 renderer/native: Include error message in log entries
We had a GError handed to us, where we logged a warning, but didn't log
the message from the error. Do that so it becomes easier to find out
what might have failed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
2021-07-16 18:10:56 +02:00
Jonas Ådahl
58f053d437 drm-buffer/dumb: Return TRUE when init succeeded
Returning FALSE means it failed, but we returned FALSE even when it
succeeded, meaning it would never succeed.

Fixes: 10c4bc6e3f
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1880
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1888
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1932>
2021-07-16 17:18:55 +02:00
Jonas Ådahl
8a4aa92a54 context: Move the signal handling and dir management to user
Signals and changing current directory is a process global action, thus
isn't that suitable for a library. Thus, move that responsibility to
gnome-shell.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 13:40:34 +02:00
Jonas Ådahl
9cda0bd719 tests: Make common test code a shared library
This will require some symbol exporting, but the benefit is that have
better control of what external test cases can do in terms of creating
more testing specific contexts.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 13:40:34 +02:00
Jonas Ådahl
d8107027ef tests/test-utils: Move test client path ensure helper to private header
It's only used from the test context, and the main test utils header
file will be used to export helper functionality, so move it out,
preparing for that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:42:40 +02:00
Jonas Ådahl
724a7eee74 tests: Move 'wait-for-X11-display' helper to MetaContextTest
Gets rid of a un-prefixed helper function relying on a global singleton.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:42:40 +02:00
Jonas Ådahl
e8742be568 tests/test-utils: Remove unused init function
This is now dealt with by MetaContextTest.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:42:40 +02:00
Jonas Ådahl
3d5a2b2ffb context/test: Make type derivable
This makes it possible to declare the type in an installed header (so
that e.g. META_CONTEXT_TEST(context) works), but without having to
expose the MetaContextClass struct.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:42:40 +02:00
Jonas Ådahl
acb0a44224 tests: Prefix test plugin name getter with meta_
It'll be used via the new shared library, so prefix it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:42:40 +02:00
Jonas Ådahl
9f1f3139b8 tests/utils: Prefix AsyncWaiter with Meta
This too will be used by test cases via a shared library.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:42:40 +02:00
Jonas Ådahl
4a6e22311a tests/utils: Prefix TestClient with Meta
Soon we'll expose it via a libmutter-test library.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:42:40 +02:00