1
0
Fork 0
Commit graph

2339 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
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
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
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
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
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)
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
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
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
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
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
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
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)
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
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
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)
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)
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
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
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
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
ff0afb186a context: Move 'replace-current-wm' tracking to the context
This move yet another scattered global static variable into the
context's control.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
0330ce1f15 context: Make the context own MetaWaylandCompositor
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
4be9bc9db4 stage/x11: Terminate using MetaContext instead of meta_quit()
Done for the nested backend when clicking the close button.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
7d116bee0f main: Move MetaX11DisplayPolicy to a new meta-private-enums.h
As with the compositor type enum, also have the X11 display policy enum,
as it's also effectively part of the context configuration. But as with
the compositor type, move it to a header file for enums only, and since
this is a private one, create a private variant meta-enums.h.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:36 +02:00
Jonas Ådahl
b1c643eeaa context: Make the context owner of the backend
There is still the `_backend` singleton still, as there are still the
`meta_get_backend()` that needs to work for now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
23b79f33fa launcher: Remove open/close restricted file API
It has since some time been replaced with MetaDevicePool, and isn't used
by anything anymore, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1929>
2021-07-13 12:19:14 +00:00
Ivan Molodetskikh
1116b14f38 backends/native: Get rendering and swap timings during scanout
Scanout doesn't go through the usual path of compositing and doing
eglSwapBuffers, therefore it doesn't hit the timestamp query placed in
that path. Instead, get the timings by binding the scanout buffer to an
FBO and doing a timestamp query on the FBO.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
5a0d3ed4dd backends/native: Remove unneeded NULL check
There seems to be no way to construct this type with an invalid bo.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
8c258d1de1 cogl: Add CPU swap time and GPU rendering query to CoglFrameInfo
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
d10567ea3e clutter: Add vblank duration to ClutterStageView
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
2d939754b1 crtc-mode-info: Add vblank duration field
Only populated for KMS backed modes, as that's where it's relevant.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Ivan Molodetskikh
e40ff9d8b7 backends/native: Add meta_calculate_drm_mode_vblank_duration_us()
Computes the vblank duration from mode timings.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1762>
2021-07-13 08:09:42 +00:00
Daniel van Vugt
9f492a0ee0 kms: Add fixed point formatting to MUTTER_DEBUG=kms printing
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1923>
2021-07-13 15:29:14 +08:00
Daniel van Vugt
b59c5386b9 kms: Add a trivial meta_fixed_16_to_double conversion function
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1923>
2021-07-13 15:26:43 +08:00
Daniel van Vugt
ea75ea0b73 kms: Add an internal MetaKmsPropType to distinguish fixed point values
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1923>
2021-07-13 15:26:43 +08:00
Daniel van Vugt
d996319cf9 kms: Add a missing g_set_error on error
So the GError is not left NULL and then dereferenced.

Fix provided by Jonas Ådahl <jadahl@gmail.com>

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1878
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1925>
2021-07-09 16:26:11 +08:00
Jonas Ådahl
ce5a5789bb native: Release output device files that are unused
In order to make it possible to e.g. unload an unused DRM device, we
need to make sure that we don't keep the file descriptor open if we
don't need it; otherwise we block anyone from unloading the
corresponding module.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:10:30 +02:00
Jonas Ådahl
3c47661b78 egl: Add eglBindAPI helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
173d895d53 kms: Remove now unused API to get file descriptor
The last user switched to using MetaDeviceFile, so time to clean up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
10c4bc6e3f drm-buffer: Create from MetaDeviceFile instead of MetaKmsDevice
The DRM buffers aren't really tied to mode setting, so they shouldn't
need to have an associated mode setting device. Now that we have a
device file level object that can fill this role, port over
MetaDrmBuffer and friends away from MetaKmsDevice to MetaDeviceFile.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
6613463f58 renderer/native: Decouple device file from MetaKmsDevice
Keep a private MetaDeviceFile instance for the GPU's managed by the
renderer. This is a step towards decoupling rendering from mode setting,
as well as on-demand holding of device file descriptors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
e567cb972d renderer/native: Get 'uses-monotonic' state from MetaKmsDevice
It's better suited to be handled by the MetaKmsDevice abstraction.

This eliminates the last caller of drmGetCaps() from outside
MetaKmsImplDevice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
86c4369f41 renderer/native: Look up prefers-shadow cap via MetaKmsDevice
This eliminates the second last user of drmGetCap() from outside of
MetaKmsImplDevice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
93f9c99cc5 kms/impl-device: Set universal plane client cap when opening file
This means it will be set again if the file is reopened.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
5502f956f5 device-file: Add tags
Tags are meant to make it possible for a device file opener to tag a
file if it has affected the state the file descriptor is in; e.g. if it
has enabled a DRM capability.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
ceff2a93ca renderer/native: Create dummy offscreens if onscreens fail to allocate
This is less dramatic than aborting, and could in theory be a temporary
issue, so handle it by rendering into an offscreen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:26 +02:00
Jonas Ådahl
db1d35c53d kms/mode: Recreate blob id each mode set
This simplifies the blob management and isn't that less efficient that
it matters.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
3c9ab768ec launcher: Remove now unused file management API
The open/close helpers for (maybe) restricted files has been replaced
with MetaDevicePool, so lets remove that functionality from here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
7ce266628e seat-impl: Open/close files via device pool
This replaces going through MetaLauncher to open/close restricted files.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
f6f9c093ba clutter/seat: Remove backend pointer
It was unused, and having a pointer to the MetaBackend in subtypes is
more useful, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
b4cf839e87 device-pool: Add way to open files read-only
Will be used by libinput's tablet device led device files.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
a845a07a92 device-pool: Handle interrupted open()
Handle open() failing due to being interrupted by trying again until it
either succeeds, or fails due to some other error. This was an error
handling path taken when opening sysfs files; do the same here to not
potentially regress once we open sysfs files with the device pool.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
3d882b6410 device-pool: Only fetch major/minor for taken devices
It's only when we take/release from/to logind we need these two
integers, so only retrieve them when that's done. Making this change
makes it possible to open devices that don't have these parameters.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
e6421dc5da kms: Have the device impl open device files themself
This changes the way the KMS backends load; if we're headless, we always
use the dummy one and fail otherwise; in other cases, we first try the
atomic backend, and if that fails, fall back on the simple one.

The aim for this is to have the impl device open and close the device
when needed, using the device pool directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
f3457b678c kms/device: Use device pool to open/close dri devices
This replaces the usage of MetaLauncher.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Jonas Ådahl
ee8c252a8c native: Add device pool for tracking device file descriptors
This practically does the same thing as part of MetaLauncher, except
with added thread safety and caching. For example, opening the same file
a second time will return the same MetaDeviceFile, and only once all
acquired MetaDeviceFile's are released, will the file descriptor be
closed and control of the device released.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>
2021-07-07 21:03:25 +02:00
Carlos Garnacho
841ee0a227 backends/native: Fix logic error
ClutterInputDevice's get_group_n_modes() vfunc is meant to return
-1 for groups that are out of the known range, not within. Fix the
early return condition, and let the native backend return correctly
the number of modes for the given group.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1920>
2021-07-07 18:37:54 +02:00
Jonas Ådahl
8ca087fee9 kms/impl-device/simple: Pass the NULL to discard_page_flip() on shut-down
The second argument is an optional GError, not an impl device pointer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1911>
2021-07-07 14:51:46 +00:00
Michel Dänzer
8de0771aad screen-cast/area-src: Add before-paint watch to catch scanouts
Scanouts are taken away after painting. However, when we're
streaming, what we actually want is to capture whatever is
going to end up on screen - and that includes the scanout
if there's any.

Add a before-paint watch that only records new frames if a
scanout is set.

Inspired by (and commit log mostly copied from) e6a13e5d57
("monitor-stream-src: Add before-paint watch to catch scanouts").

v2:
* Do not call stage_painted from before_stage_painted (Georges Basile
  Stavracas Neto)

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1707
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1902>
2021-07-05 15:57:20 +00:00
Michel Dänzer
7bcbf6d5c7 screen-cast/area-src: Drop phase parameter from add_view_painted_watches
It was always META_STAGE_WATCH_AFTER_ACTOR_PAINT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1902>
2021-07-05 15:57:20 +00:00
Jonas Ådahl
1d7920872d kms: Gracefully handle page flipping direct scanouts failing
When drmModePageFlip() or drmModeAtomicCommit() unexpectedly failed (e.g.
ENOSPC, which has been seen in the wild), this failure was not handled
very gracefully. The page flip listener for the scanout was left in the
MetaKmsUpdate, meaning when the primary plane composition was later page
flipped, two page flip listeners were added, one for the primary plane,
and one for the scanout. This caused the 'page-flipped' event to be
handled twice, the second time being fatal.

Handle this by making 'no-discard' listener flag be somewhat reversed,
and say 'drop-on-error', and then drop all 'drop-on-error' listeners
when a MetaKmsUpdate failed to be processed.

Also for a "preserve" flagged update, don't ever trigger "discard"
callbacks just yet, as preserved updates are used again for the primary
plane composition, in order to not miss e.g. CRTC gamma updates, or
cursor plane updates, which were added separately.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1809
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1910>
2021-07-02 13:29:54 +00:00
Christoph Trassl
4b0fd9ab76 input-mapper: Fix (libwacom) tablet mapping to monitor
Remove early return when using libwacom, so guess_candidates returns
monitor candidates for those devices, too.

Additionally, changing the output of an input requires removing the
input from its current output first.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1712
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1887>
2021-07-01 06:36:33 +02:00
Jonas Ådahl
a0343b0abd renderer/native: Clear pending update list before repopulating
Before we did a simple copy, meaning the old list was overriden. Copy
was too eager, as it meant views without modes to set was waited for,
resulting in a dead lock. Instead only the relevant views were added to
the list for view which had pending updates needed. What was missed was
that the list was never cleared, meaning we just appended the new list
on top of the old, causing issues.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1846
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1843
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1844
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1895>
2021-06-12 21:09:55 +02:00
Jonas Ådahl
c0758c63b5 native: Properly ignore devices on init too
There is an udev rule marking whether a device should be ignored by
mutter or not, but it was only respected on hotplug events not on init,
partly defeating its purpose. Fix this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1892>
2021-06-09 19:21:44 +00:00
Jonas Ådahl
8478db96f9 renderer-native: Don't attempt to queue mode sets on non-onscreen views
A view is only a 'CoglOnscreen' if it ends up on a CRTC, thus needs a
mode. Other views are for virtual monitors, and require no mode setting,
so exclude them from the pending mode set list.

This avoids a dead lock when we'll be waiting indefinitely for mode
setting on a virtual monitor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1891>
2021-06-09 17:40:34 +00:00
Jonas Ådahl
2a81c6d393 screen-cast: Clean up sessions on 'prepare-shutdown'
However, leave the remote desktop screen cast sessions to the remote
desktop manager to close.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1891>
2021-06-09 17:40:34 +00:00
Jonas Ådahl
5c77b640d4 egl: Add helper for eglBindWaylandDisplayWL
Lets us untangle awkward Cogl setup dependencies.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
ebfeb106bc egl: Fly-by indentation fix
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1863>
2021-05-18 14:03:22 +00:00
Jonas Ådahl
18d670e69f backends: Introduce MetaIdleManager
This object takes over the functionality of meta-idle-monitor-dbus.c,
meta-idle-monitor.c and meta-backend.c, all related to higher level
management of idle watches etc.

The idle D-Bus API is changed to be initialized by the backend instead
of MetaDisplay, as it's more of a backend functionality than what
MetaDisplay usually deals with.

It also takes over the work of implementing "core" idle monitors. The
singleton API is replaced with thin wrapper functions on the backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1859>
2021-05-18 13:19:36 +00:00
Jonas Ådahl
389432de46 backend/x11-cm: Add missing chain-up to finalize()
Reported by @muktupavels.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1869>
2021-05-17 19:22:25 +02:00
Jonas Ådahl
b0a73f04b7 main: Move rect related macro to util-private.h
No reason that it should be in main-private.h, lets place it in
util-private.h. This also mean we can remove main-private.h.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
3bb6865912 stage/x11: Fix clutter backend variable naming
Being in backends/, `backend` tends to refer to a `MetaBackend`, so
avoid that naming convention for things that are not, e.g. clutter
backends.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
6558d43cd5 main: Let the X11 CM backend deal with selecting the display
It's specific to that backend, so do it there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
c9992a2953 main: Initialize Wayland just before MetaDisplay
Wayland support is not really a "backend" thing, it just lacked a better
place to store its instance pointer. Eventually we'll have a better
place, but prepare for that by initializing it together with the more
similar subsystems.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Pascal Nowack
25e2839339 screencast: Fix transform_position(), when using fractional scaling
Commit 64c9c9c5b0 fixed monitor
screencasting, when fractional screencasting is enabled.
For the remote desktop usage, NotifyPointerMotionAbsolute() submits
the new mouse pointer position in addition to the stream, where the
mouse pointer was moved.
When not using fractional scaling, the mouse pointer position is
correct.
With the usage of fractional scaling, the mouse pointer position is
wrong, as the scale of the position is applied two times.

Fix this behaviour, by reverting the second scale by dividing by the
logical monitor scale, when fractional scaling is used.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1808
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1867>
2021-05-17 16:11:47 +02:00
Jonas Ådahl
4a057535e7 remote-desktop: Close sessions on prepare-shutdown
When finalizing, the MetaDisplay instance will already be gone, so to be
able to gracefully tear down the clipboard integration, make sure to
close sessions before the display is closed, i.e. on prepare-shutdown.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1853>
2021-05-11 16:18:13 +00:00
kirbykevinson
64c9c9c5b0 clutter: Make stage capture support fractional scaling
This commit adds scaling support to clutter_stage_capture_into, which
is currently used when screencasting monitors. This is supposed to
fix graphical issues that arise when using fractional scaling.

Fixes #1131

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1855>
2021-05-08 22:27:52 +07:00
Jonas Ådahl
a49dc78396 remote-desktop-session: Don't recreate virtual device over and over
In 'remote-desktop-session: Create virtual input devices on demand' the
intention was to create input devices on-demand, but during a
refactorization of the code, instead the virtual input device was
recreated over and over. Lets fix that.

Fixes: a0af52caf0
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1799
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1858>
2021-05-07 13:16:27 +00:00
Jonas Ådahl
c4a73e7950 backend: Cleanup renderer on shutdown
This removes left-over views, and related resources.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
abf2f17387 renderer: Cleanup views in dispose
The views needs to be cleaned up before things cleaned up on finalize
that they depend on existing, so do so in dispose().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
558cb4fac3 backend: Cleanup cursor tracker on shutdown
It keeps references to cursors, and cursors keep references to DRM
buffers. In order to be able to clean up on exit, explicitly destroy the
cursor tracker on shutdown.

We can't rely on GObject reference counting, as gjs might hold onto a
reference until it's garbage collected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
f1a120ca36 backend: Clean up GPU instances last
Various things, e.g, the renderer, the stage, either directly or
indirectly depends on GPU objects being alive during tear-down. Make it
so, by moving GPU cleanup after the other cleaning. This will allow
tearing down a couple of more objects.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
22417b8a94 backend/native: Split up KMS shutdown in two phases
The first phase happens early, which discards pending page flips,
meaning the references held by those page flip closures are released.

The second phase happens late, after other units depending on the KMS
abstraction, have been cleaned up.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
1af874fca6 kms/impl-device/atomic: Discard pending page flip datas on finalize
This is so page flip listeners can clean up any references attached to a
page flip.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
7c924a562f kms/impl-simple: Clean up pending page flip datas on finalize
They might be holding on to references, so lets keep track of them and
clean up on finalize.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
2ed4e8c906 kms-impl/simple: Discard pending flips when finalizing
Removing the reference isn't enough, the callbacks needs to be invoked
so the buffer state machinery gets notified about the page flips being
discarded.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
4dec1f5ddf kms/impl-simple: Add helper for dispatching page flip datas
Instead of a invoke helper, and a clear helper, use a single dispatch
helper that does both.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
c29f8c8b73 onscreen/native: Complete buffer swap also if we discarded
We already swapped the front buffer, and even if it didn't get
presented, we should still swap our representation of the state, to not
get into a confused buffer tracking state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
4cb6033a27 onscreen/native: Simplyify notify_view_crtc_presented()
We don't really need to fetch the rendering mode, as we'd only ever call
a function that is effectively a no-op if render modes it isn't relevant
to.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
b731eb29b5 kms: Remove idle flush callback when flushing
We might flush in other places than the idle callback; in this case, we
don't need the idle callback anymore, so remove it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
023dd13d6c onscreen/native: Get backend pointer from GPU
If we clean things up during destruction, the singleton pointer to the
backend is already gone; get it from a better place instead, to not
crash.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Jonas Ådahl
d077baadbb renderer/native: Destory EGL context on GPU data tear down
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Carlos Garnacho
63d969537f backends: Drop MetaInputSettings::seat property
This is now entirely unused, and it's dubious it should ever
be again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1849>
2021-05-05 19:07:26 +00:00
Carlos Garnacho
7ba1448e5b clutter: Move pointer a11y settings management from MetaInputSettings
All pointer a11y is a fabrication of Clutter backend-independent
code, with the help of a ClutterVirtualInputDevice and with some
UI on top.

On the other hand, MetaInputSettings is a backend implementation
detail, this has 2 gotchas:
- In the native backend, the MetaInputSettings (and pointer a11y
  with it) are initialized early, before the ClutterSeat core
  pointer is set up.
- Doing this from the MetaInputSettings also means another dubious
  access from the input thread into main thread territory.

Move the pointer a11y into ClutterSettings, making this effectively
backend-independent business, invariably done from the main thread
and ensured to happen after seat initialization.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1765
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1849>
2021-05-05 19:07:26 +00:00
Florian Müllner
d4a042b88d native: Fix compiler warning
cogl_context is only used when building with EGLDevice support,
resulting in an "unused variable" warning otherwise.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1852>
2021-05-05 10:32:28 +02:00
Jonas Ådahl
8989c42d40 backend/native: Add udev rule to ignore vkms devices
Virtual Kernel Mode Setting (vkms) is a virtual /dev/dri/card* device
not backed by any actual hardware. It's intended for testing purposes,
e.g. to run tests suites with a reproducable setup, or in continuous
integration pipelines.

Currently mutter don't have any tests that can run on top of vkms, but
will eventually get that. To prepare for the ability to do that, and
having said kernel module loaded without causing wierd issues with any
active session, add an udev rule that tells mutter to ignore any vkms
device.

Otherwise, when vkms is loaded, mutter would detect it, assume it's a
regular monitor, configure it as such, thus add a region of the stage
that ends up nowhere, which isn't very helpful. It might also conflict
with running actual tests that need to interact with vkms if the active
session has taken control of it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1740>
2021-04-30 15:10:28 +02:00
Jonas Ådahl
4af0f05603 udev: Move device tag detection into helper
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1740>
2021-04-30 15:10:28 +02:00
Jonas Ådahl
eaf75f0706 udev: Don't only check 'platform' device for KMS modifier tag
Only checking the 'platform' device missed the tags added for i915 and
others, meaning the multi head configurations yet again started to fail
due to default modifier behavior is incompatible with multi many head
configurations.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1769
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1774
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1843>
2021-04-29 18:48:24 +00:00
Jonas Ådahl
c5e4d7db45 native: Invalidate CRTC gamma when resuming or leaving power save
With atomic mode setting, commits don't work when CRTCs aren't enabled,
which they aren't when we're power saving. This means the gamma state
fails to being update. To fix night light and for whatever other reason
gamma ramps was changed during power saving by marking the CRTC gamma
state as invalid when leaving power saving, as well as when resuming.
This means that the next frame will append the CRTC gamma state to the
KMS commit.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1755
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1835>
2021-04-29 18:04:04 +00:00
Jonas Ådahl
a0af52caf0 remote-desktop-session: Create virtual input devices on demand
This avoids triggering heuristics based on available input device types;
e.g. hiding the cursor when connecting a touchscreen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1800>
2021-04-29 17:24:08 +00:00