1
0
Fork 0
Commit graph

9390 commits

Author SHA1 Message Date
Jonas Ådahl
59a10cd188 monitor-manager/native: Allow starting without outputs when headless
This will allow starting, then adding virtual outputs when needed e.g.
via the screen cast API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
34b0f9c124 kms/device: Move universal plane cap check to mode set init
This leaves only the atomic mode setting cap check before creating the
impl device, aiming to make it possible to create a non-mode-setting
MetaKmsImplDevice implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
7c25953c65 kms/impl-device: Make non-abstract types explicitly init mode setting
This is a step towards making it possible to add a MetaKmsImplDevice
that doesn't actually do any mode setting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
c4a422bc24 crtc/kms: Add an abstract MetaCrtcNative that sits under MetaCrtcKms
There is going to me another non-abstract MetaCrtcNative type, just as
there will be for MetaOutputNative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
074d4f3418 output/kms: Make EDID be read via MetaOutputNative object
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
fd4ea67b27 native: Add abstract MetaOutputNative object
MetaOutputKms is made to inherit from this, but it doesn't do anything
special yet.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
3091cd89dc native: Rename MetaMonitorManagerKms to MetaMonitorManagerNative
We'll sooner or later start managing not only KMS backend monitors, but
virtual / remote ones too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
42d614f6fa backend-native: Add non-functional 'headless' mode
Make it possible to pass --headless as a command line argument in order
to turn the native backend "headless". This currently doesn't do
anything, but the intention is that it should not use logind nor KMS,
and work completely headless with only virtual outputs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Dreßler
b770ea606a background-content: Optimize rounded clipping shader a bit
We're using the gtk4 shader for rounded rect clipping here, and gtk just
introduced a small optimization to make this shader a bit faster, so
let's do the same.

See 57e354c297

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1774>
2021-03-11 22:59:07 +01:00
Marco Trevisan (Treviño)
244e881912 backends/input-settings: Do not disconnect seat signals
This was added with commit c956193d, when we did connect to the seat
signals in input settings, but this is not the case anymore since commit
2c1558dd, so we can safely remove this call now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1763>
2021-03-10 16:18:25 +00:00
Marco Trevisan (Treviño)
8d008112b6 backends/x11: Pass the seat to the input settings
Input settings requires a valid seat in order to initialize the a11y
settings (since commit 1609d145), however in X11 we never set it and
even if we create the input settings early (as per commit 7547891a) we
never initialize the seat for it.

This leads to startup critical errors on X11:
 clutter_seat_get_pointer_a11y_settings: assertion
   'CLUTTER_IS_SEAT (seat)' failed

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1763>
2021-03-10 16:18:24 +00:00
Suryashankar Das
b353b97512 backends/x11: Fix device hierarchy event handling for x11 backend
This commit adds the events created in the function
`meta_seat_x11_notify_devices` to the clutter events queue, which
are currently only added to the stage queue making the events not
being picked up by the `clutter_seat_handle_event_post` function.
This results in devices not getting added to the device-list of
`MetaInputSettings`.

Fixes the bug in which mouse and touchpad settings are not working in
the settings app during x11 session.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1767>
2021-03-10 15:44:46 +01:00
Marco Trevisan (Treviño)
012c0a18ef clutter: Ensure we always call handle_event_post for processed events
Since commit 2ceac4a device-related X11 events aren't processed anymore,
causing the input settings not to handle the devices.
This is due to the fact that we may never call clutter_seat_handle_event_post()
for such events.

While this is always happening for the native backend, it doesn't happen in
X11 because the events are removed from the queue as part of
meta_x11_handle_event(), and thus no event was queued to the stage by the
backend events source.

This also makes sure that the event post handler is called after the
event is actually processed, and not before an event is queued.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1564
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1769>
2021-03-10 13:56:54 +00:00
Marco Trevisan (Treviño)
ccbdf91776 backends/x11: Add dummy input-settings implementation
The nested backend may need to have an input setting implementation,
while we don't want to change the host settings (re-using an X11 input
settings) we can add a dummy implementation, until something more
complex is needed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1769>
2021-03-10 13:56:54 +00:00
Jonas Ådahl
9b90b5a1b0 window-actor/x11: Queue full actor redraw when redraw queued
With frame timings, we might end up in a situation where a frame drawn
is expected, but no damage was posted. Up until now, mutter handled
this, if the window wasn't completely hidden, by posting a 1x1 pixel
damage region. The problem with this is that we now are a bit more
aggressive optimizing away no-op redraws, meaning we still might end up
not drawing, making things get stuck.

Fix this by doing a full actor redraw, as that is the only reliable way
to both a new frame being drawn, as well as the actor in question itself
getting redrawn.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1516
Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3369
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1471
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1754>
2021-03-09 17:42:58 +00:00
Jonas Ådahl
44a4e61665 compositor/x11: Notify the sync ring about frames on updates
The sync ring has an API about "frames", where it is notified about
the end of frames. However, its "insert wait" call is done before
updates, meaning that some "insert waits" will never see the "after
frame" if there was no frame drawn. This will cause mismatching in the
frame counting, causing freezes in the synchronization until something
else triggers an actual frame, effectively "unfreezing" the sync ring.

Fix this by not only notifying the sync ring about frames when there
were actual frames drawn, but also on plain updates which didn't result
in a drawn frame.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/1516
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1754>
2021-03-09 17:42:58 +00:00
Sebastian Keller
c2968c89fe frame: Fix crash when clicking below titlebar with broken gtk themes
When a gtk theme uses larger shadows for the unfocused state than for
the focused one, this can cause a crash in meta_frame_left_click_event.
Since whether to call meta_frame_left_click_event is decided based on
the decoration size before focusing and the control that was clicked on
after focusing, this can result in an event handled in
meta_frame_left_click_event being on the client area.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1748>
2021-03-08 21:16:09 +00:00
Jonas Dreßler
3263084bcf backends/native: Translate right coords when creating motion events
With commit 7d78768809 we switched to
storing pointer coordinates in MetaInputDeviceNative instead of
ClutterInputDevice, and while we had set the coordinates of the
ClutterInputDevice in ClutterStage when queueing an event, we now set
the MetaInputDeviceNative coordinates in new_absolute_motion_event().

Here a small mistake snuck in: new_absolute_motion_event() only
translates the coordinates of the event, but we call
meta_input_device_native_set_coords() using the x and y variables
(which remain untranslated), so now the input device coordinates are no
longer translated.

Fix that by translating the coordinates of the x and y variables in case
we're we handling a tablet/stylus event instead of only translating the
event coordinates.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1760>
2021-03-08 15:33:36 +00:00
Jonas Ådahl
b962822f26 onscreen/native: Fix cast from CoglOnscreenEgl
It used the defunct platform pointer, meaning if this path would have
hit, it'd end up with a segmentation fault due to the platform pointer
being NULL.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1759>
2021-03-08 15:02:30 +00:00
Jonas Ådahl
372737e282 tests/clutter/timeline-interpolate: Use correct clock
This fixes the interpolate test to not use the wall clock, but the
monotonic clock. It also cleans up the timestamp granularity naming, so
that the different granularity is clearer, as in the test, different
timestamps have different granularity.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1751>
2021-03-08 14:37:00 +00:00
Jonas Ådahl
6f30764320 tests/clutter/timeline-interpolate: Rework test to be less flaky
This more or less rewrites this test so that it explicitly tests the
"interpolation" when a timeline loops, i.e. that if something occupies
the thread when a timeline was supposed to have looped, we end up in the
right place "in the middle" of the next timeline cycle.

The test more or less does this:

 * Start a 3 second looping timeline
 * Sleep so that we're in the middle of the first cycle
 * Sleep again so that we end up in the middle of the next cycle

The semantics checked are that we see the following frames:

 * The first frame with timestamp 0
 * The second frame in the middle of the first cycle (timestamp ~= 1.5
   sceonds)
 * The third frame in the end of the first cycle (timestamp == 3.0
   seconds)
 * The fourth frame, first in the second cycle, with timestamp ~= 1.5
   seconds)

This means we can increase the "grace period" to the double (from 0.5 s
to 1 s), while at the same time decrease the time spent running the test
(from 10 s to 4.5 s). This should hopefully make the test less flaky,
especially in slower runners, e.g. aarch64.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1751>
2021-03-08 14:37:00 +00:00
Jonas Ådahl
0d3840b056 tests/clutter/timeline-interpolate: Assorted style cleanups
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1751>
2021-03-08 14:37:00 +00:00
Jonas Ådahl
b155063227 tests/test-client: Set padding to 0 too
This makes size dependent stacking tests less flaky.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1751>
2021-03-08 14:37:00 +00:00
Jonas Dreßler
301198a9b8 Revert "backends: Use also a native cursor renderer for tablets"
With commit c985753442 the support for
multiple hardware cursors broke, but those were never properly supported
anyway as we usually assume there's only one hardware cursor around.

With the introduction of the KMS thread in the future, we'll only have
one KMS cursor that gets updated directly from the input thread. So
apart from the fact that it never really makes sense to have two cursors
visible, in this new model having multiple cursors won't work anyway.

So make the cursor we show for stylii a software cursor again.
Eventually the plan is to make the input device that's driving the KMS
cursor interchangeable, so that we can always use hardware cursors.

This reverts commit 165b7369c8.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1758>
2021-03-08 13:13:22 +00:00
Ivan Molodetskikh
82af1fb87e wayland: Send presentation feedbacks to cursors
This commit assumes that cursor surfaces work in a "mailbox" fashion. If
they are painted multiple times before a successful flip, all commits
but the last get discarded, and the last commit gets presented after the
flip succeeds. This is more or less how it works in the atomic backend,
and also more or less how it works in other backends, with the exception
that the cursor painting might fail without any way of knowing. This
assumption is still better than unconditionally discarding all cursor
surface feedbacks as if the cursor painting always fails.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:12 +00:00
Ivan Molodetskikh
cd9ae13465 backend: Pass stage view to cursor-painted signal
Will be used for presentation-time handling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:12 +00:00
Ivan Molodetskikh
2ce3a050f0 wayland: Wire up presentation-time machinery
- add surfaces to the presentation list,
- move their feedbacks to the map in on-after-update,
- fire the feedbacks in on_presented().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:12 +00:00
Ivan Molodetskikh
f0c2200466 wayland: Store map of ready presentation feedbacks
These are feedbacks for updates that were drawn or otherwise displayed
on screen, and need to be fired as soon as their presentation happens.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:12 +00:00
Ivan Molodetskikh
0c3490223e wayland: Store list of presentation-time surfaces
These are surfaces that might have registered presentation-time
callbacks, similar to the frame callback surface list.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:12 +00:00
Ivan Molodetskikh
bb57f35296 wayland: Add presentation_feedback_present()
Regarding the sequence = 0 fallback: in some cases (moving a cursor
plane on atomic amdgpu) we get sequence = 0 in the page flip callback.
This seems like an amdgpu bug, so work around it by assuming a sequence
delta of 1 (it is equal to 1 because of the sequence != 0 check above).

Sequence can also legitimately be 0 if we're lucky during the 32-bit
overflow, in which case assuming a delta of 1 will give more or less
reasonable values on this and next presentation, after which it'll be
back to normal.

Sequence is also 0 on mode set fallback and when running nested, in
which case assuming a delta of 1 every frame is the best we can do.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
dccc60ec3e wayland: Implement stub presentation-time
The presentation-time protocol allows surfaces to get accurate
timestamps of when their contents were shown on screen.

This commit implements a stub version of the protocol which correctly
discards all presentation feedback objects (as if the surface contents
are never shown on screen). Subsequent commits will implement sending
the presented events to surfaces shown on screen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
2f4027200f Generate presentation-time files
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
f02f17808a onscreen/native: Send a symbolic flip on discard
Now that symbolic flips were introduced, it makes more sense to use them
instead of emitting a fake page flip.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
47183a94eb cogl/frame-info: Add VSYNC flag
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
99efb40cce clutter/frame-info: Add sequence
It will be used for the presentation-time Wayland protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
c96fb181ab cogl/frame-info: Add sequence
It will be used for the presentation-time Wayland protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
4ba2df0bd2 cogl: Remove cogl_get_clock_time()
It's no longer used.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
4810164885 cogl: Make presentation time always MONOTONIC
This concerns only the cases when the presentation timestamp is received
directly from the device (from KMS or from GLX). In the majority of
cases this timestamp is already MONOTONIC. When it isn't, after this
commit, the current value of the MONOTONIC clock is sampled instead.

The alternative is to store the clock id alongside the timestamp, with
possible values of MONOTONIC, REALTIME (from KMS) and GETTIMEOFDAY (from
GLX; this might be the same as REALTIME, I'm not sure), and then
"convert" the timestamp to MONOTONIC when needed. An example of such a
conversion was done in compositor.c (removed in this commit). It would
also be needed for the presentation-time Wayland protocol. However, it
seems that the vast majority of up-to-date systems are using MONOTONIC
anyway, making this effort not justified.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:11 +00:00
Ivan Molodetskikh
d8606829c4 cogl: Report presentation time in microseconds
KMS and GLX device timestamps have microsecond precision, and whenever
we sample the time ourselves it's not the real presentation time anyway,
so nanosecond precision for that case is unnecessary.

The presentation timestamp in ClutterFrameInfo is in microseconds, too,
so this commit makes them have the same precision.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:10 +00:00
Ivan Molodetskikh
9f53b691c4 clutter/frame-info: Add HW_CLOCK flag
A flag indicating whether the presentation timestamp was provided by
the display hardware (rather than sampled in user space).

It will be used for the presentation-time Wayland protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:10 +00:00
Ivan Molodetskikh
9d54ef3994 cogl/frame-info: Add HW_CLOCK flag
A flag indicating whether the presentation timestamp was provided by the
display hardware (rather than sampled in user space).

It will be used for the presentation-time Wayland protocol.

This is definitely the case for page_flip_handler(), and I'm assuming
this is also the case for the two instances in the GLX code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1484>
2021-03-08 09:48:10 +00:00
Akihiko Odaki
a6df6796dd backend/native: Add tests for refresh rate calculation
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1737>
2021-03-05 14:37:48 +00:00
Akihiko Odaki
a41c30338f backend/native: Calculate refresh rate in double-precision
The old calculation was introduced to improve the precision
with commit c16a5ec1cf.

Here, I call the calculation as "revision 2", and the
calculation even older as "revision 1", and the new
calculation introduced with this commit as "reivion 3".

Revision 2 has two problems:
1. The calculation is mixed with fixed-point numbers and
   floating-point numbers.

To overcome the precision loss of fixed-point numbers division,
it first "calculates refresh rate in milliHz first for extra
precision", but this requires converting the value back to Hz.
An extra calculation has performance and precision costs.
It is also hard to understand for programmers.

2. The calculation has a bias.

In the process, it does:
refresh += (drm_mode->vtotal / 2);
It prevents the value from being rounded to a smaller value in
a fixed-point integer arithmetics, but it only adds a small
bias (0.0005) and consumes some fraction bits for
floating point arithmetic.

Revision 3, introduced with this commit always uses
double-precision floating-point values for true precision and
to ease understanding of this code. It also removes the bias.

Another change is that it now has two internal values, numerator
and denominator. Revision 1 also calculated those two values
first, and later performed a division with them, which minimizes
the precision loss caused by divisions. This method has risks of
overflowing the two values and revision 1 caused problems due to
that, but revision 3 won't thanks to double-precision. Therefore,
revision 3 will theoretically have the result identical with
the calculation with infinite-precision.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1737>
2021-03-05 14:37:48 +00:00
Jonas Dreßler
504af40c69 window: Don't stop irrelevant TOUCH_END events during window grab ops
During window grab ops we only react to touch events that have the
pointer emulating sequence, all other events should be propagated.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/427>
2021-03-04 22:46:20 +00:00
Jonas Dreßler
ef1b101821 window: Handle TOUCH_BEGIN events separately during grab ops
Handle the case of a TOUCH_BEGIN event during window dragging separately
instead of treating it like a TOUCH_UPDATE event: Simply return TRUE to
make Clutter stop event propagation if it's the pointer emulating
sequence and let Clutter propagate the event if it isn't.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/427>
2021-03-04 22:46:20 +00:00
Jonas Dreßler
9889e6dadd window: Cancel window grab ops on TOUCH_CANCEL events
Window dragging should be cancelled when the touch sequences we're using
are no longer available. Also listen to TOUCH_CANCEL events if the
window is grabbed and cancel the grab op when a TOUCH_CANCEL event
happens.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/427>
2021-03-04 22:46:20 +00:00
Jonas Ådahl
67acf99314 remote-desktop/session: Add CapsLockState and NumLockState properties
Will be used by remote desktop services that want to try to affect the
end result of these. We cannot let it set these directly, as these needs
to be done using virtual key events to not cause issues in all the XKB
state tracking, so remote desktop services try to deal with this
themself if they need to.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1342
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1739>
2021-03-04 17:39:08 +00:00
Jonas Ådahl
ce3fa3938a clutter/keymap: Make caps and num lock state properties
This removes the responsibility of tracking these from the backend to
the base object. The backends are instead responsible for calling the
function to update the values.

For the native backend, it's important that this happens on the correct
thread, so each time either of these states may change, post a idle
callback on the main thread that sets the, at the time of queuing said
callback, up to date state. This means that things on the main thread
will always be able to get a "new enough but not too new" state when
listening on the 'notify::' signals and getting the property value
after.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1739>
2021-03-04 17:39:08 +00:00
Jonas Ådahl
26912523fa native/seat-impl: Add helper for queuing main thread idle callbacks
Make the emit main thread signal use it. Will be used for calling code
on the main thread from the input thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1739>
2021-03-04 17:39:08 +00:00
Jonas Ådahl
adc6537917 remote-desktop: Add backend getter
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1739>
2021-03-04 17:39:08 +00:00
Ivan Molodetskikh
861d03aac0 x11-display: Use unsetenv if old value was NULL
Gets rid of a CRITICAL if NO_AT_BRIDGE was not set before.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1749>
2021-02-27 09:16:49 +00:00
Alexander Mikhaylenko
2a71ca373b clutter: Add API for retrieving gesture unaccelerated deltas
This will be useful for better aligning behavior between scrolling and
swiping for gnome-shell swipe tracker.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1353>
2021-02-27 08:52:00 +00:00
Jonas Dreßler
91d03f1c96 display: Reset all grab properties after a grab op
Make sure to reset all the state that was set for an interactive grab op
back to the defaults after a grab op has ended.

Especially important here is setting grab_frame_action back to FALSE,
since this will constrain window-titlebars to the panel. We set this to
TRUE on some grabs, for example when resizing, but not when moving
windows. Since this remained being set to TRUE, it would also constrain
non-grab window movements, like calling MetaWindow.move_frame(), which
is used by gnome-shells OSK. By resetting it back to FALSE after a grab,
the OSK can now always move non-maximized windows to the position it
wants.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1736>
2021-02-26 14:53:32 +00:00
Jonas Ådahl
3bbfaa03b3 background-content: Fix pipeline cache size
The cache had the size 9, which was "big enough" in the past, but when
more ways pipelines could be constructed, the size was not enough. The
need to increase the cache size was hard to spot though, since adding
pipeline flag didn't give any hints about the cache being directly tied
to these flag values.

So, when enough flag bits were set when attempting to retrieve and put a
pipeline in the cache, it'd instead overwrite some arbitrary stack
memory, which would sooner or later result in a memory corruption
induced crash. Valgrind could not detect this particular memory
corruption, as it messed up stack memory, not e.g. freed heap memory, so
it instead got confused and thought plain stack values were unreadable.

Fix these two issues by making the cache size the combination of all
pipeline flags + 1, so that we can safely put any flag combination in
the cache.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1747>
2021-02-24 15:59:58 +00:00
Philip Withnall
bec456ba0a xwayland: Fix some FD leaks on error paths
If `meta_xwayland_start_xserver()` returned via an error path, some of
the socket FDs were leaked.

Fix that, and add `steal_fd()` calls to make it clearer that FDs passed
to `g_subprocess_launcher_take_fd()` are transferred to it. There were
no bugs with how `GSubprocessLauncher` was being used.

Spotted while working on
https://gitlab.gnome.org/GNOME/glib/-/issues/2332.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1738>
2021-02-24 14:17:07 +00:00
Jonas Ådahl
36352f44f9 onscreen/native: Add ref to dumb buffer when using as scanout buffer
Each next and current scanout buffer has a reference on them making sure
they stay alive. When dumb buffers were used on the secondary GPU state,
this didn't happen, leading to crashes due to unref:ing one time too
many, with backtraces such as

  0) g_type_check_instance_is_fundamentally_a ()
  1) g_object_unref ()
  2) secondary_gpu_release_dumb ()
  3) import_shared_framebuffer ()
  4) update_secondary_gpu_state_post_swap_buffers ()
  5) meta_onscreen_native_swap_buffers_with_damage ()
  6) cogl_onscreen_swap_buffers_with_damage ()
  7) swap_framebuffer ()
  8) clutter_stage_cogl_redraw_view_primary ()
  9) clutter_stage_cogl_redraw_view ()
 10) _clutter_stage_window_redraw_view ()
 11) handle_frame_clock_frame ()

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1746>
2021-02-24 12:46:56 +00:00
Jonas Ådahl
83e74adb5a onscreen/native: Remove stray whitespace
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1746>
2021-02-24 12:46:56 +00:00
Jonas Ådahl
bd923035d4 x11-display: Set NO_AT_BRIDGE to 1 while opening the GDK display
gnome-shell has this hack where it sets the environment variable
"NO_AT_BRIDGE" to "1" before calling meta_init() and then unsets it
after meta_init() returns.

This variable being set to "1" will then cause the ATK bridge in
at-spi2-gtk to fail to load, which GTK then ignores. This is on purpose,
since accessibility is supposed to be done done by GNOME Shell via
Clutter, not via GTK.

The problem is that, now, by default, setting "NO_AT_BRIDGE" to
"1" during meta_init() only has the desired effect on an X11 session,
where we always connect to the X11 server on startup (i.e. during
meta_init()). With Xwayland on-demand, we do not attempt to create the
GDK display during meta_init(), thus this hack falls apart.

Since there are no real altenatives to this hack, just move it to
mutter, which have a better idea when GDK displays are created or not.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1744>
2021-02-23 18:21:09 +01:00
Olivier Fourdan
2432508db7 core: Account for the globally active input case
Commit afa43154 tried to make sure the focus was properly changed when
calling focus_default_window() by checking the focused window just after
trying to set the focus.

However, the X11 “Inter-Client Communication Conventions Manual” version
2.0 (ICCCM 2 for short) states that some X11 client may want to use a so
called “globally active input” model in which case the client expects
keyboard input and set input focus even when it's not one of its own
window.

To comply with this, when dealing with such clients, mutter will not
change the focus and send a WM_TAKE_FOCUS message instead.

That mechanism will defeat the logic introduced by commit afa43154
because the focused window is not changed in this case. As a result, the
input focus will fallback to the no-focus window.

To avoid this, only check that the focus change occurred for windows
using a synchronous focus model.

v2: Split specific test for "globally active input" model (Florian).
v3: Remove the check for window->unmanaging which is useless (Jonas).

Fixes: afa43154 - "core: Make sure focus_default_window() worked"
Close: https://gitlab.gnome.org/GNOME/mutter/-/issues/1620
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1716>
2021-02-23 11:08:59 +00:00
Olivier Fourdan
6438919a89 window: Add "is_focus_async" API
X11 clients can use different models of input handling, of which some
may not result focus being set synchronously.

For such clients, meta_focus_window() will not change the focus itself
but rely on the client itself to set the input focus on the desired
window.

Add a new MetaWindow API to check when dealing with such a window.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1716>
2021-02-23 11:08:59 +00:00
Jonas Ådahl
9de36fed4d virtual-input-device/native: Verify device cleanup in impl_state_free()
We free it in the task function, so it's already NULL when freeing the
state struct. Change the redudant unref to a NULL check warning.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1688>
2021-02-23 10:05:32 +00:00
Jonas Ådahl
671bda2509 virtual-input-device/native: Emit added/removed events
Without these devices, things that depend on the existance of input
device classes won't know about the existance of e.g. pointer devices,
if the only pointer device is from a virtual one.

This requires handling situations where e.g. a device doesn't have a
device node thus can't be matched against a udev device.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1688>
2021-02-23 10:05:32 +00:00
Jonas Ådahl
5e34ae2154 backend: Only create idle monitors for added physical input devices
The rest of the things we do aren't applicable, e.g. mapping tablet
devices/tools to monitors and hiding cursors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1688>
2021-02-23 10:05:32 +00:00
Jonas Ådahl
e6b70f1a2b seat-impl: Dispatch source also when there are already queued events
Libinput will queue a few initial events when a seat is assigned to the
udev backend; a result of it probing udev adding detected devices. For
us to see these events, we need to dispatch libinput before going idle,
as nothing will show up on the libinput file descriptor until something
else (e.g. keyboard event or mouse movement) wakes us up.

Do this by adding a prepare() function to the libinput GSource, that
checks whether there are any events in the queue already, and return
TRUE if so is the case, causing us to dispatch before going fully idle.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1688>
2021-02-23 10:05:32 +00:00
Pascal Nowack
9b5fb1b593 remote-desktop: Clarify the type of keycode for NotifyKeyboardKeycode()
The API for NotifyKeyboardKeycode() does not mention what type of
keycode is expected to be submitted.
So, clarify in the API that the keycode to submit is expected to be an
evdev keycode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1732>
2021-02-23 08:18:05 +00:00
Pascal Nowack
72cfe9b3fd backends/x11: Interpret keycode correctly
Currently, when a remote desktop user submits a keycode, it will be
interpreted differently, when using the x11 session, instead of a
wayland session.
In a wayland session, submitting a keycode will have the expected
result (as if the key was pressed locally).
In a x11 session, this is not the case. Instead of getting the expected
key, some other key will be pressed (or sometimes even none).
The reason for this is that the native backend interprets the keycode
as evdev keycode and the x11 backend interprets the keycode as xkb
keycode.

To ensure that both backends produce the same behaviour when submitting
a keycode, fix the x11 backend to always interpret the keycode as evdev
keycode, instead of a xkb keycode.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1732>
2021-02-23 08:18:05 +00:00
Pascal Nowack
ff48f6c26b remote-desktop: Fix typo in API description
For NotifyKeyboardKeycode() the API user submits keycodes instead of
keysyms.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1732>
2021-02-23 08:18:05 +00:00
Robert Mader
aa6b7ed468 monitor-manager-xrandr: Change g_memdup() to g_memdup2()
This was propably overlooked in 30e1c51b33

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1512>
2021-02-22 13:52:27 +01:00
Robert Mader
6eeeffdc68 src: Stop using GSlice
It has been inofficially deprecated for years, is known to cause issues
with valgrind and potentially hides memory corruption.
Lets stop using it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1512>
2021-02-22 13:52:27 +01:00
Jonas Dreßler
9512d58c28 display: Don't add MetaDisplay argument to grab-op-* signals twice
GObject signals pass the emitting GObject as the first argument to
signal handler callbacks. When refactoring the grab-op-begin/end signals
to remove MetaScreen with commit 1d5e37050d,
the "screen" argument was replaced with a "display" argument instead of
being removed completely. This made us call the signal handlers with two
identical MetaDisplay arguments, which is very confusing and actually
wasn't handled in a grab-op-begin handler in gnome-shell.

So fix this by not adding the MetaDisplay as an argument to those
signals, GObject will take care of that for us.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1734>
2021-02-19 14:52:22 +01:00
Jonas Dreßler
5527b6e483 background-content: Add support for rounded clipping when drawing
We're going to round the workspace backgrounds in the new overview for
gnome-shell 40.

So far corner-rounding was only possible for StWidgets because the
rounded clipping was done using cairo drawing. We now need rounded
clipping for ClutterActors too because backgrounds are drawn using
ClutterActors (or more specifically a ClutterContent). To implement
that, first a ClutterOffscreenEffect subclass together with a fragment
shader from GSK (see gskSetOutputColor() [1] in the GSK GL renderer
code) was investigated, and while that was generic and worked quite
well, it was extremely slow for the case of drawing wallpapers because
of all the FBOs that had to be allocated.

This is the new, more performant approach: Use the same fragment shader,
but perform the rounded clipping right in MetaBackgroundContent while
we're painting the wallpaper. This has almost no performance impact,
with the downside of not being a generic solution.

To allow for rounded clipping not only at the edges of the wallpaper,
but using any given bounding rectangle, the API exposes not only the
radius, but also a bounding rect.

[1] https://gitlab.gnome.org/GNOME/gtk/-/blob/master/gsk/resources/glsl/preamble.fs.glsl

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1717>
2021-02-18 20:26:42 +00:00
Pascal Nowack
7076945488 remote-desktop: Document NotifyPointerAxis() more explicit
Currently, the documentation for NotifyPointerAxis() just mentions that
a smooth scroll event is emitted.
However, this is not entirely correct. For each NotifyPointerAxis(),
mutter emits an emulated discrete scrolling event based on the
submitted accumulated smooth scrolling deltas.
Additionally, it doesn't mention how the motion deltas need to be
interpreted.

So, document the NotifyPointerAxis() notification better by mentioning
the emulation of discrete scroll events, how these discrete scroll
events are calculated and how the motion deltas need to be interpreted.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1727>
2021-02-17 21:47:00 +01:00
Pascal Nowack
c77e943ce2 backends/native: Handle triple resolution mouse wheels better
When a remote desktop user emits a virtual smooth scrolling event, a
smooth scroll event, that is not emulated, is emitted and on occasion
a discrete scroll event, that is emulated, is emitted.
As base for the discrete scrolling event, the smooth scrolling steps
are accumulated.
When the accumulated smooth scrolling steps surpass the
DISCRETE_SCROLL_STEP, the discrete scrolling event is emitted.

Currently, mutter uses for DISCRETE_SCROLL_STEP the value 10, which is
a terrible value to work with, especially for high resolution mouse
wheels.
When a triple resolution mouse wheel is used, each scrolling step will
have the value 3 1/3.
Three of such events won't however surpass the DISCRETE_SCROLL_STEP.

To fix this situation, add DBL_EPSILON to the calculation step, when
checking for the discrete scroll event to ensure that 3 smooth scroll
events, with each having the value 3 1/3, emit a discrete scrolling
event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1727>
2021-02-17 21:39:03 +01:00
Pascal Nowack
a5d692582d backends/x11: Emit discrete scroll events for accumulated smooth events
MetaVirtualInputDeviceX11 currently doesn't handle smooth scroll events
at all.
So, if a user of the remote desktop API uses smooth scroll events, then
only the wayland backend handles these events.
The user of the remote desktop API however, might not know which
backend is being used and actually the user should not even have to
care about it.

Actual smooth events cannot be emulated in the X11 events.
What can be done however is accumulating smooth events and then when
the accumulated steps surpass the DISCRETE_SCROLL_STEP value, emit a
discrete scroll event.
So, do exactly that, to make smooth scroll events work when the remote
desktop API is used with the x11 backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1727>
2021-02-17 21:39:03 +01:00
Carlos Garnacho
a5db9ee2d7 backends/x11: Emulate pointer motion while the pointer is off stage
Given X11 nature, the pointer "leaves" the stage anytime it wanders into
a client window, or any other areas that are not deemed part of the
stage input region.

Yet we want to stay correct in those situations, e.g. have the clutter
side reasonably in sync, picking and highlighting to work properly, etc.

In order to achieve that, emulate motion events on XI_RawMotion. These
are as much throttled as our pointer tracking for a11y, in order to avoid
too many XIQueryPointer sync calls. This emulation only kicks in anytime
that X11 notifies us that we are not "on" the stage.

This replaces some sync_pointer() calls in GNOME Shell code that are
there just to compensate for this trait of X11, e.g. in the message tray
code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1659>
2021-02-14 13:23:29 +00:00
Carlos Garnacho
437f5d1c66 compositor: Sync pointer after begin/end modal on X11
Ensure we issue a motion event for the current pointer position,
as there might be situations where compositor modals get X grabs
from other clients stacked on top, or missed events in between
otherwise.

Ensure the Clutter state is still up-to-date afterwards here. This
replaces some sync_pointer() calls done in GNOME Shell code, always
done after modality changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1659>
2021-02-14 13:23:29 +00:00
Carlos Garnacho
00c7f45a0f compositor: Refactor backend-specific code into MetaCompositor vfuncs
Do these Wayland operations (that apply on both native and nested backends)
in the MetaCompositorServer subclass. We want to add more backend specific
behavior here in the future.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1659>
2021-02-14 13:23:29 +00:00
Carlos Garnacho
698fe3f1a9 wayland: Avoid automatically decoupling source/offer after grab
In the case that DnD is performed and succeeds, we want to release
the grab early, and let the transfer IPC happen in the back. For
that to happen without a hitch, drag source and offer must be left
related to each other after undoing the grab, even though the default
ungrabbing code does that automatically (indirectly, by unsetting the
drag focus).

In these cases, we used to manually unset the current source, so
this decoupling was skipped. Notably, one missed case is X11 DnD,
so we might end up with the situation there that DnD did succeed,
transfer is ongoing, but the source and offer are already decoupled,
this confused the machinery and missed the finishing XdndFinished
to be emitted to the X11 drag source.

The prior commits prepared for this source/offer decoupling being
a manual operation, this commit avoids doing this automatically
when ungrabbing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1720>
2021-02-09 19:33:13 +00:00
Carlos Garnacho
0f9dc84d3b wayland: Manually detach source/offer on failure paths
Adapt more paths to manual detaching of source/offer. This is still
done automatically when the grab is finished.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1720>
2021-02-09 19:33:13 +00:00
Carlos Garnacho
8e01ea1e04 wayland: Plug XDnD drag source leak
This object is just being detached, with no code unref'ing it. Do
this whenever the XDnD selection goes unowned, usually a good
indication that the drag source no longer is one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1720>
2021-02-09 19:33:13 +00:00
Carlos Garnacho
3799606fc2 wayland: Make XDnD grab unlink source/offer manually
This currently happens by default whenever the grab is finished.
We want to eventually do this manually everywhere, so start here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1720>
2021-02-09 19:33:13 +00:00
Olivier Fourdan
3322e4fa54 surface-actor-wayland: Handle Xwayland vanishing gracefully
When a game is playing fullscreen, mutter may use a direct scanout of
the surface.

However, if that surface is from Xwayland and Xwayland had vanished (now
that mutter can survive that), the actual surface might be NULL, so
check for that case to avoid a crash.

Close: https://gitlab.gnome.org/GNOME/mutter/-/issues/1638
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1718>
2021-02-09 19:06:22 +00:00
Olivier Fourdan
445373d028 x11: Check for XCB reply
Now that mutter can survive Xwayland vanishing in mid-flight, we need to
actually check if the Xserver reply fetched though XCB is not NULL,
otherwise we may crash, that would be a shame.

Close: https://gitlab.gnome.org/GNOME/mutter/-/issues/1638
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1718>
2021-02-09 19:06:22 +00:00
Dor Askayo
9b8cff8673 renderer/native: Remove unnecessary field and logic
This field was never set and only ever cleared.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1715>
2021-02-09 08:27:11 +00:00
Dor Askayo
5d32b251ed renderer/native: Remove unused field
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1715>
2021-02-09 08:27:11 +00:00
Dor Askayo
80fd030f10 onscreen/native: Move function declaration to the correct header file
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1715>
2021-02-09 08:27:11 +00:00
Dor Askayo
d6abea3ba7 onscreen/native: Add missing error messages
g_set_error_literal() asserts that the provided message is not NULL.
If it is NULL, the function is entirely no-op.

This resulted in a NULL dereference of the GError, which remained
NULL in this case, when trying to print a warning in
clutter_stage_cogl_redraw_view().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1715>
2021-02-09 08:27:11 +00:00
Dor Askayo
2c0bd98f21 connector/kms: Add missing else statement
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1715>
2021-02-09 08:27:11 +00:00
Björn Daase
7a75c7ea1f core: Don't show copyright when printing version
Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/86
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1702>
2021-02-09 07:46:10 +00:00
Jonas Ådahl
c60cba4eeb tests: Add test for destroyed frame clock free timeline actor
This would without 'clutter/timeline: Clear stage view listener when
actor destroyed' result in backtraces such as

Program terminated with signal SIGSEGV, Segmentation fault.
  #0  on_stage_stage_views_changed ()
  #1  g_closure_invoke ()
  #2  signal_emit_unlocked_R ()
  #3  g_signal_emit_valist ()
  #4  g_signal_emit ()
  #5  update_stage_views ()
  #6  clutter_actor_update_stage_views ()
  #7  clutter_stage_update_actor_stage_views ()
  #8  handle_frame_clock_frame ()
  #9  clutter_frame_clock_dispatch ()
  #10 frame_clock_source_dispatch ()
  #11 g_main_dispatch ()

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1719>
2021-02-08 19:40:05 +00:00
Jonas Ådahl
b838ba8166 tests/stage-view-tests: Make 'wait_for_paint()' block
Otherwise it's a busy loop, skipping any poll():ing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1719>
2021-02-08 19:40:05 +00:00
Georges Basile Stavracas Neto
aa2cb8a4f7 screen-cast-*-stream-src: Switch to cogl_framebuffer_flush()
PipeWire recently introduced busy buffers, which actually fixes the last remaining
issue that blocked us from downgrading these cogl_framebuffer_finish() calls into
cogl_framebuffer_flush() ones.

Switch to cogl_framebuffer_flush() in all three stream sources.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1701>
2021-02-08 08:37:08 +00:00
Ivan Molodetskikh
dae089f79e clutter: Remove CLUTTER_ENABLE_EXPERIMENTAL_API
It is no longer used anywhere.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1707>
2021-02-05 17:05:19 +00:00
Ivan Molodetskikh
9b44aa77b6 clutter: Remove clutter_stage_set_sync_delay
The sync_delay field is never accessed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1707>
2021-02-05 17:05:19 +00:00
Jonas Ådahl
2cdb0414c2 remote-desktop/session: Maybe emit 'owner-changed' after clipboard enabled
If there is a clipboard owner when enabling the clipboard integration
without immediately overriding the owner, send an initial owner-changed
event.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
2021-02-05 16:44:27 +00:00
Jonas Ådahl
5104a9b2ce remote-desktop/session: Add support for SelectionTransfer/Write
When a transfer request is done to the MetaSelectionSourceRemote source,
it's translated to a SelectionTransfer signal, which the remote desktop
server is supposed to respond to with SelectionWrite.

A timeout (set to 15 seconds) is added to handle too long timeouts,
which cancels the transfer request.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
2021-02-05 16:44:27 +00:00
Jonas Ådahl
d7c8535ac6 remote-desktop/session: Implement SelectionRead()
This makes it possible to retrieve the clipboard content from the
current selection clipboard source.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
2021-02-05 16:44:27 +00:00
Jonas Ådahl
a220506bf7 remote-desktop: Add dummy remote selection source
It doesn't yet fetch data from the remote desktop session, but hooks up
correctly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
2021-02-05 16:44:27 +00:00
Jonas Ådahl
6398d5a109 remote-desktop/session: Forward MetaSelection::owner-changed
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
2021-02-05 16:44:27 +00:00
Jonas Ådahl
ac1a5366b1 remote-desktop/session: Added boiler plate for clipboard integration
Nothing is hooked up, it only does basic sanity checking i.e. whether
the clipboard was enabled when interacting with it. No actual clipboard
integration is hooked up yet.

This also syncs org.gnome.Mutter.RemoteDesktop.xml from
gnome-remote-desktop.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
2021-02-05 16:44:27 +00:00
Jonas Ådahl
54b024465e util: Add 'remote-desktop' debug topic
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1552>
2021-02-05 16:44:27 +00:00
Carlos Garnacho
b2b66aa8c6 backends/native: Disable touch-mode with pointer presence
The original implementation of ::touch-mode tested for keyboard
presence to know whether the OSK and other touch-only features were
enabled.

However that didn't pan out, every webcam, card reader and kitchen
sink like to live a second life as EV_KEY devices. This made the
detection of actual external keyboards a much harder task than it
sounds, and was thus removed in commit f8e2234ce5.

Try a different approach here, and test for pointer devices, it
doesn't matter if internal or external devices, the rationales:

- It is significantly easier to get this right, there's virtually
  no devices with abs/rel axes that don't try to be a real input
  device of some sorts.
- It's not as good as testing for keyboard presence, but it's the
  next best thing. These usually come in pairs, except in weird
  setups.
- It is better than not having anything for a number of situations:
  - Non-convertible laptops with a touchscreen will get touch-mode
    disabled due to touchpad presence (plus keyboard). There's
    been complains about OSK triggering with those.
  - Same for desktop machines with USB touchscreens, the mouse
    (and presumably keyboard) attached would make touch-mode
    get in the middle.
  - Convertible laptops with a broken tablet-mode switch get a
    chance to work on tablet modes that do disable input devices
    (e.g. detachable keyboards, or via firmware)
  - Kiosk machines, tablets, and other devices that have a
    touchscreen but will not regularly have a mouse/keyboard
    will get the touch-mode enabled.

All in all, this seems to cover more situations the way we expect it,
there's only one situation that the OSK would show where it might
not be desirable, and one that might not show when it better should:

- Tablets and kiosk machines that get one keyboard plugged, but not a
  mouse, will still show the OSK, despite being able to type right
  away.
- Convertible laptops with broken/unreliable tablet-mode switch (e.g.
  ignored by the kernel) rely entirely on the device/firmware
  characteristics to work. If after folding into tablet mode the
  touchpad remains active, touch-mode will not turn on.
  Fixing the tablet-mode switch on these devices should be preferred,
  as that'll also make libinput magically disable the touchpad.

The latter can be worked around with the a11y toggle. The former is
merely inconvenient, and nothing prevents the user from plugging a mouse
in addition.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1710>
2021-02-05 16:07:55 +01:00
Robert Mader
7da34f154b compositor/dnd-actor: Take geometry scale into account on DnD-cancel
Technically this is still wrong if the source actor or dnd actor are
transformed in other ways. However geometry scale is the by far most
common case and we currently lack convenience API in Clutter to
easily compute the right values.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1683>
2021-02-05 09:51:56 +00:00
Robert Mader
04eeeb78d1 wayland/dnd-surface: Use new API to set geometry scale of feedback actor
The removed parts are now all handled in MetaFeedbackActor.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1683>
2021-02-05 09:51:56 +00:00
Robert Mader
dfa659b5b5 feedback-actor: Add API to set and get geometry scale
Analogous to MetaWindowActor. Also take it into account for positioning
when an anchor is set.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1683>
2021-02-05 09:51:56 +00:00
Jonas Dreßler
04c6934363 screencast: Log a debug message when we can't get a buffer from pipewire
When recording the screen and real time encoding it using a gstreamer
pipeline, that pipeline can stall when the encoder is too slow. Log a
debug message using the new SCREEN_CAST debug topic in that case so we
know when framedrops are happening.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1709>
2021-02-05 09:27:38 +00:00
Jonas Dreßler
a869df1dd7 util: Add a SCREEN_CAST debug topic
This is going to be useful to log dropped frames and other more common
errors about screencasting.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1709>
2021-02-05 09:27:38 +00:00
Florian Müllner
ee3d26f228 keybindings: Reset modifier-only-pressed on scroll
Since commit c255031b6d, we allow some modifier+scroll events to
pass through to Clutter to enable gnome-shell to handle them. That
action shouldn't trigger a modifier-only action at the same time, so
reset the corresponding tracking just like we do for modifier+click.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1695>
2021-02-04 19:26:18 +00:00
Florian Müllner
ac3d9a0641 events: Process modifier+scroll after keybindings
Allowing the keybindings code to see the event enables it to
process it for its internal modifier-only-pressed state.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1695>
2021-02-04 19:26:18 +00:00
Florian Müllner
7901b98808 display: Expose window_grab_modifiers
Since commit c255031b6d we pass scroll-events through to
the compositor if the window_grab_modifiers are pressed;
in order to allow gnome-shell to check for those events,
expose the struct member as a MetaDisplay property.

Also take the opportunity to pick a more generic name, now
that the modifier is no longer used exclusively for mouse
clicks (unless we maintain the notion of scroll events as
button 4 and 5 "clicks").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1695>
2021-02-04 19:26:18 +00:00
Jonas Ådahl
30e1c51b33 Change all g_memdup() to g_memdup2()
Using g_memdup() is dangerous due to the type of the size argument. See
https://gitlab.gnome.org/GNOME/glib/-/issues/2319 and
https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1926 for details.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1708>
2021-02-04 19:16:28 +01:00
Sebastian Keller
a9d9aee6c0 kms/impl-device-atomic: Fix blob_ids array leak
release_blob_ids() only destroys the DRM property blobs, but does not
free the array they were stored in.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1699>
2021-02-02 14:41:52 +00:00
Jonas Ådahl
ca22622517 screen-cast/src: Only allocate DMA buffers if other end supports it
The other end of the PipeWire stream can set the buffer data type to a
bitmask of supported buffer types. We should respect this, and not
attempt to allocate a DMA buffer if it isn't asked for.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1697>
2021-02-02 10:25:12 +00:00
Jonas Ådahl
ca95ccdef0 screen-cast/src: Always first set spa buffer data to NULL
We use that elsewhere for sanity checking, and it's not initialized to
anything, so might be pointing to invalid memory if buffer allocation
failed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1697>
2021-02-02 10:25:12 +00:00
Jonas Ådahl
08ad107df5 screen-cast/src: Handle failing to allocate shm buffers
Don't leak the file descriptors, and don't fall over when trying to
clean up buffers that failed to allocate.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1697>
2021-02-02 10:25:12 +00:00
Jonas Ådahl
70d9a7b4bf screen-cast/src: Pass dimension and stride when needed
Instead of getters, pass the width, height and stride around when
relevant. This also removes the redudant "stream_size" and
"stream_height" variables from the src struct, as they are already part
of the video format.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1697>
2021-02-02 10:25:12 +00:00
Olivier Fourdan
a2e2cfe437 window/x11: Check before freezing commits
Now that we have a window actor API that can hint whether or not the
window actor would support freezing commits, use it to avoid freezing
Xwayland commit on actors that will not be thawed after paint.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1615
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1678>
2021-01-30 10:13:03 +00:00
Olivier Fourdan
df5a5d279d window-actor: Add a new can_freeze_commits() API
Mutter freezes Xwayland commits when resizing windows, and thaw them in
the window actors' after_paint() for X11.

Yet, after_paint() could be never called, as when a new window is mapped
while the overview is active in gnome-shell.

As a result, the content of the X11 window will remain invisible to the
overview.

Add a new window actor API to tell whether commits can be frozen. For
Wayland window actors, this always return FALSE, whereas for X11 window
actors, it checks whether the Clutter actor is mapped.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1678>
2021-01-30 10:13:03 +00:00
Jonas Ådahl
cda26b493e wayland: Only use async configured geometry if actually changed
When (un)maximizing, (un)fullscreening, the move/resize action is
flagged with 'ACTION_MOVE' and 'ACTION_RESIZE' , while e.g.
'appears-focus' does not.

When a client misbehaved and didn't immediately reply to a configure
request with a commit with the corresponding ack_configure, the
following commit would trigger a oddly timed move, making the window
appear to move back to a previous position.

Avoid this issue by only carrying over the target window position if the
configuration actually contained a new position.

We cannot only rely on the flags however, as e.g. a new position should
be respected during interactive resize, even though only 'ACTION_RESIZE'
is passed in such scenarios.

Do the same for the size, except if the window state dictates that the
size is fixed to a certain size, e.g. being fullscreen or maximized.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1445>
2021-01-30 09:49:13 +00:00
Jonas Ådahl
b2482a2069 cogl: Add CoglX11Onscreen interface
Mutter needs to fetch the X11 Window ID from the onscreen and did that
by using an X11 specific API on the CoglOnscreen, where the X11 type was
"expanded" (Window -> uint32_t). Change this by introducing an interface
called CoglX11Onscreen, implemented by both the Xlib and GLX onscreen
implementations, that keeps the right type (Window), while avoiding X11
specific API for CoglOnscreen.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
0fdf6a6405 cogl/onscreen: Move direct scanout to CoglOnscreen class
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
fe72876b20 cogl/onscreen: Make swap_buffer/region CoglOnscreen class vfuncs
No need to go via the "winsys" vtable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
60e1516b1c cogl/gl-framebuffer: Split up into FBO and back drivers
One is for when we're painting to the back buffer (onscreen), and the
other when we're painting to an FBO (offscreen).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:46 +00:00
Jonas Ådahl
0936d7bd06 cogl/onscreen: Use CoglFramebufferClass::allocate() to init
Instead of calling "init_onscreen()" on two different separate vtables
from the allocate() funtion, just have the CoglOnscreen sub types
themself implement allocate() and initialize in there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
0b568b68c6 Make all CoglOnscreen sub types inherit CoglOnscreen
Thins means that e.g. MetaOnscreenNative now inherits CoglOnscreenEgl,
which inherits CoglOnscreen which inherits CoglFramebuffer, all being
the same GObject instance.

This makes it necessary to the one creating the onscreen to know what it
wants to create. For the X11 backend, the type of renderer (Xlib EGL or
GLX) determines the type, and for the native backend, it's currently
always MetaOnscreenNative.

The "winsys" vfunc entries related to onscreens hasn't been moved yet,
that will come later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
73dc19fc58 onscreen/native: Remove uselses size check
The comment made no sense in the context it was in, and the size check
can never fail as we create views directly from mode dimenisons.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
3e4ece50d3 renderer/native: Move out CoglOnscreen code to separate file
To get meta-renderer-native.c down to a bit more managable size, and to
isolate "onscreen" functionality from other (at least partly), move out
the things related to CoglOnscreen to meta-onscreen-native.[ch].

A couple of structs are moved to a new shared header file, as
abstracting those types (e.g. (primary, secondary) render devices) will
be dealt with later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
b5afa6db23 cogl/onscreen: Change to follow mutters naming convention
The mutter naming convention for types and their instance variables is:

Type name:
   [Namespace][BaseName][SubType]

Instance name:

   [base_name]_[sub_type]

This means that e.g. CoglOnscreenGLX is renamed CoglOnscreenGlx, and
glx_onscreen is renamed onscreen_glx. This is in preparation for
GObjectification.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
a057432e3d cogl/glx: Move onscreen code to a separate file
Mostly in order to untangle it from the rest, preparing turning it into
a GObject.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
7cf24ccc34 cogl/onscreen/egl: Move struct to C file
In praparation for declaring the EGL onscreen part using G_DECLARE*.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:45 +00:00
Jonas Ådahl
d0831cbbcd cogl: Move CoglOnscreen struct to C file
That means all sub types need to use helper methods, so make them do
that too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1514>
2021-01-30 09:11:44 +00:00
Jonas Ådahl
b55b26661f workspace: Downgrade assert to warning when adding window
An extension can by accident cause us to end up in a state where we try
to add the same window to a workspace twice. When this happens we
shouldn't crash, but instead complain loudly.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/992
Related: https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/157
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1692>
2021-01-29 17:14:08 +00:00
Thomas Mühlbacher
180e62519b tests/monitor-config: Improve debugging output
Make it easier to find out what went wrong with `migrated_data` by
having it included in the debug logs.

Closes: <https://gitlab.gnome.org/GNOME/mutter/-/issues/1011>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1685>
2021-01-29 16:49:58 +00:00
Thomas Mühlbacher
88647ae23c monitor-config: Free meta_monitor_spec safely
`g_free()` alone can't help if the value it gets is `NULL` + the offset
of the struct members.

This prevents gnome-shell from segfaulting if `monitors.xml` contains
invalid XML.

Closes: <https://gitlab.gnome.org/GNOME/mutter/-/issues/1011>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1685>
2021-01-29 16:49:58 +00:00
Thomas Mühlbacher
70cdd72040 monitor-config-store: Properly escape monitor spec
Makes sure that monitor specs which may be read from EDID data do not
contain characters that are invalid in XML. Makes it possible to restore
monitor configs of monitor models with characters such as '&' in them.

To make this change not break any tests, the sample monitor configs need
to be adjusted as well. Apostrophes don't strictly have to be escaped in
XML text elements. However, we now do escape the elements in
`<monitorspec>` specifically.

Closes: <https://gitlab.gnome.org/GNOME/mutter/-/issues/1011>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1685>
2021-01-29 16:49:58 +00:00
Sebastian Keller
c9aa43aa7a wayland/gtk-shell: Add an explicit gtk-shell surface release request
Previously the wl_resource and MetaWaylandGtkSurface corresponding to
any client gtk_surface have been kept around until the exit of the
client due to the client side destroy method not signaling the
destruction to the server. Ideally the protocol would have specified a
destroy request marked as destructor to handle this automatically,
however this is no longer possible due to the destroy method being
implicitly generated in the absence of an explicit request in the
protocol. Adding a destroy request marked as destructor now would
generate a new destroy method that unconditionally would send the
request to the server, which would break clients running on servers not
supporting that request.

So instead of modifying the destroy request add a new "release"
destructor, that indicates to the server that it can release the
resource. This can be optionally be used by clients depending on the
server protocol version.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1307>
2021-01-29 16:21:16 +00:00
Sebastian Keller
b41c4aec26 wayland/gtk-shell: Fix MetaWaylandGtkSurface leak on surface destroy
The MetaWaylandSurface corresponding to a MetaWaylandGtkSurface can be
destroyed before the MetaWaylandGtkSurface is destroyed. In its destroy
function MetaWaylandSurface however was unsetting the destructor of the
correspnding resource along with the gtk_surface1 interface
implementation. This was done to prevent further gtk_surface1 requests
on a NULLed MetaWaylandSurface, if it has been destroyed before the
MetaWaylandGtkSurface.

It would be enough to just unset the resource implementation, while
keeping the destructor to fix this leak. However the following commit
will rely on the implementation being available after the
MetaWaylandSurface has been destroyed. So instead introduce NULL checks
for all functions that can be called on the gtk_surface1 interface and
do not unset the implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1307>
2021-01-29 16:21:16 +00:00
Jonas Ådahl
893c0cd2f9 screen-cast/area-src: Handle monitors changes here too
Like with the monitor source, we need to reattach to the new views after
monitor changes, otherwise the screen cast will get stuck.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1691>
2021-01-29 08:35:02 +00:00
Jonas Ådahl
e877b06fdd screen-cast/monitor-stream: Don't fall apart when monitor changes
If the monitor configuration changed, even though the streamed monitor
didn't change, we'd still fail to continue streaming, as we failed to
update the stage watchers, meaning we wouldn't be notified about when
the stage views were painted.

Fix this by reattaching the stage watches, i.e. update the painted
signalling listeners to listen to the right views, when monitor changes
happens.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1691>
2021-01-29 08:35:02 +00:00
Jonas Ådahl
9f6a441665 screen-cast-stream: Add getter for stream src
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1691>
2021-01-29 08:35:02 +00:00
Jonas Ådahl
036ce1f28e native/cogl-utils: Minor macro cleanup
We don't use 'pragma once' in mutter, and cogl/cogl.h isn't a system
include.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1690>
2021-01-28 20:33:01 +00:00
Jonas Ådahl
caa798c672 native/cogl-utils: Fix license header
The intention was to add a license header the same as other files in the
mutter backend files, so make it so.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1690>
2021-01-28 20:33:01 +00:00
Jonas Ådahl
1d4e535e7a clutter/stage: Remove 'paint' argument in capture_into()
There are more suitable API when the stage needs to be actually painted
into something. Nothing actually used this anymore too, so remove this
functionality.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
662e29990a input-mapper: Remove stray newline
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
9c50353ffa monitor: Stop exporting a bunch of unused symbols
No tests accessed them, so don't export them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
b883a31796 tests/monitor-unit-tests: Sanity check some monitor info
Check that some information about the monitor is the same as the main
output they are derived from.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
432682f305 monitor-manager: Clean up hot-plug paths slightly
Make the API used more shared and better named.

meta_monitor_manager_on_hotplug() was renamed
meta_monitor_manager_reconfigure(), and meta_monitor_manager_reload()
was introduced to combine reading the current state and reconfiguring.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
e48be709f8 seat-impl: Remove unused udev client instance
No point in having an unused udev client lingering.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
6ecdf03efb backend/native/clutter: Get seat ID from backend
We don't need to have MetaLauncher set it and guess it if that fails,
when we now have a getter from MetaBackendNative.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
2d2521a106 backend/native/clutter: Cleanup backend pointer variable naming
It was named "backend_native" and "backend" which is easily confused with
MetaBackendNative and MetaBackend which tends to have those names.
Prepare for introducing the usage of a MetaBackendNative and MetaBackend
pointers here by cleaning up the naming.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
8de3190627 udev: Fetch seat-id via backend instead of laucher
Configurations where we won't have a MetaLauncher will be added, so
avoid using its API directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
41246cb31d backend/native: Remove left-over function declaration
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
35ecc6ba7c backend/native: Gracefully handle failing to create monitor manager
We tried to start listening to a signal even if it didn't construct
properly. Stop doing that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
f75e9032c1 meta: Remave meta_activate_session()
It's not used anywhere, lets drop it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
dce906a4d1 output/kms: Remove redundant typedef
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
e41a0e47dc monitor-manager: Cleanup class struct
It was wierdly formatted, missed argument variable names, didn't use
stdint types. Clean this up a bit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
0e9a92a429 output: Make MetaTileInfo use stdints
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Jonas Ådahl
11fee3f753 monitor-manager/kms: Remove left-over struct
From the time it dealt with reading DRM file descriptors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1689>
2021-01-28 20:05:23 +00:00
Sebastian Keller
ff4f8d2aa0 frames: Consider events on fullscreen windows to be on the client area
Fullscreen X11 windows that attempt to change the resolution on Wayland
use a surface viewport to achieve this without affecting the resolution
of the display. This however also means that pointer events will be
delivered in the display coordinates while the code handling the window
frame is not aware of any such viewport scaling. So a right click
outside of the area corresponding to the new resolution will not be
considered to be on the client area. And since the only area that is
ignored when determining whether to perform the right click action, such
as opening the context menu, is the client area, this will result in the
action being performed, despite happening on the (scaled) client area.

While it would be possible to scale the event coordinates so that
get_control() correctly determines the frame element the cursor is on,
viewport scaling only affects fullscreen windows. Since fullscreen
windows have no frame, we can always assume that if the window gets
delivered an event for a fullscreen window, it is on the client area
without doing any additional calculations.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1661>
2021-01-28 15:30:29 +00:00
Florian Müllner
81f3694804 window: Guard can_ping() against unmanaging windows
We remove pending pings when unmanaging a window, but currently
don't prevent new pings to be scheduled after that.

The previous commit fixed a code path where this did indeed happen,
but as the result of gnome-shell trying to attach a Clutter actor
to a non-existent window actor is pretty bad, also guard can_ping()
against being called for an unmanaging window.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1676>
2021-01-28 14:47:28 +00:00
Florian Müllner
e7b58c23b8 window: Do not handle ungrabbed events when unmanaging
Once we are no longer managing a window, we have no business in
dealing with it anymore, and operations like focusing, raising or
pinging the window aren't expected to work, and can go horribly
wrong if we try.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1676>
2021-01-28 14:47:28 +00:00
Georges Basile Stavracas Neto
4927452b84 workspace-manager, x11-display: Default to a single row
This seems to have been the default in the past, but was (accidentally?) modified
by 8adab0275.

For GNOME 40, we'll be returning to our root with horizontal workspaces, so instead
of overriding it in GNOME Shell side, change the default back to what it once was.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1684>
2021-01-27 11:48:10 -03:00
Daniel van Vugt
f512d4fefa shaped-texture: Update the full bounding box of each clip rectangle
When using fractional scaling this matters, so that you don't miss a
line of pixels at the edge of the clip rectangle by rounding down. This
was observed as a line of corrupt pixels in Firefox (Wayland) tooltips.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1554>
2021-01-27 17:05:38 +08:00
Jonas Ådahl
ff25ec3f36 tests/monitor-unit-tests: Set up async waiter after X11 client
We'll have two persistent client connections alive for the whole test,
one X11 client, and one Wayland client. So in order to be able to set up
the async waiter, do so after setting up the X11 client, as after that
we know we'll have a MetaX11Display ready to use.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1681>
2021-01-25 15:14:35 +00:00
Jonas Ådahl
798fc63755 tests/utils: Spawn Xwayland before X11 test client
This is so we can add our async waiter up front. Using
XOpenDisplay(NULL) didn't work; for some reason it dead locked when
XInitThreads() had been called prior.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1681>
2021-01-25 15:14:35 +00:00
Jonas Ådahl
02859221ea tests/test-runner: Hook up async waiter on demand
Not all tests will spawn Xwayland; so don't expect it to be there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1681>
2021-01-25 15:14:35 +00:00
Jonas Ådahl
d8e75027a4 xwayland: Split Xwayland display name getter into two
One for the public channel, and one for the private maintainance
channel. Use the public one for test clients, otherwise tests become
flaky, and the private one for MetaX11Display.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1681>
2021-01-25 15:14:35 +00:00
Jonas Ådahl
fb38c451b5 kms: Add atomic MetaKmsImplDevice backend
This adds a MetaKmsImplDevice backend using atomic drmMode* API in constrast to
non-atomic legacy drmMode* API used in MetaKmsImplDeviceSimple.

This has various behavioral differences worth noting, compared to the
simple backend:

 * We can only commit once per CRTC per page flip.

This means that we can only update the cursor plane once. If a primary
plane composition missed a dead line, we cannot commit only a cursor
update that would be presented earlier.

 * Partial success is not possible with the atomic backend.

Cursor planes may fail with the simple backend. This is not the case
with the atomic backend. This will instead later be handled using API
specific to the atomic backend, that will effectively translate into
TEST_ONLY commits.

For testing and debugging purposes, the environment variable
MUTTER_DEBUG_ENABLE_ATOMIC_KMS can be set to either 1 or 0 to
force-enable or force-disable atomic mode setting. Setting it to some
other value will cause mutter to abort().

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/548
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
8e235768da kms/update: Encapsulate custom page flip fields in object
Makes more sense to pass around an encapsulated object with the relevant
data, than passing around a vfunc and a gpointer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
4afe3afdf0 kms/impl-device/simple: Make process update vfunc type a typedef
It made the function type declaration a bit unreadable, so split it out.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
6bffeeed28 kms/page-flip: Pass ownership of listener user data along with closure
In order to reliably manage the reference count of the user data passed
to page flip listeners - being the stage view - make the ownership of
this data travel through the different objects that take responsibility
of the next step.

Initially this is the MetaKmsPageFlipListener that belongs to a
MetaKmsUpdate.

When a page flip is successfully queued, the ownership is transferred to
a MetaKmsPageFlipClosure that is part of a MetaKmsPageFlipData. In the
simple impl device, the MetaKmsPageFlipData is passed to
drmModePageFlip(), then returned back via the DRM event. In the future
atomic impl device, the MetaKmsPageFlipData is stored in a table, then
retrieved when DRM event are handled.

When the DRM events are handled, the page flip listener's interface
callbacks are invoked, and after that, the user data is freed using the
passed GDestroyNotify function, in the main context, the same as where
the interface callbacks were called.

When a page flip fails, the ownership is also transferred to a
MetaKmsPageFlipClosure that is part of a MetaKmsPageFlipData. This page
flip data will be passed to the main context via a callback, where it
will discard the page flip, and free the user data using the provided
GDestroyNotify.

Note that this adds back a page flip listener type flag for telling the
KMS implementation whether to actively discard a page flip via the
interface, or just free the user data. Avoiding discarding via the
interface is needed for the direct scanout case, where we immediately
need to know the result in order to fall back to the composite pipeline
if the direct scanout failed. We do in fact also need active discard via
the interface paths, e.g. in the simple impl device when we're
asynchronously retrying a page flip, so replace the ad-hoc discard paths
in meta-renderer-native.c and replace them by not asking for no-discard
page flip error handling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
6d6fd9c43d kms/page-flip: Make tha data struct use gatomicref instead of int
While there are no threads that makes this necessary, lets change this
now so we don't forget later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
d2ccc824ce kms/page-flip: Add helpers for closure constructor and destroyer
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
5dca49b6d6 kms/crtc: Log some CRTC state when updating
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
f0318d8964 kms: Update device state when resuming
Suspending might have changed the CRTC configuration, turning some off,
some on, etc. We need to update our internal representation of this
state, so that we know how to reconfigure upon resuming, e.g. what CRTCs
to turn off again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
214850143d crtc/kms: Turn g_debug()s to meta_topic()s
This way they can easily be enabled with e.g. MUTTER_DEBUG=kms.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
588c0a456a renderer/native: Keep onscreens alive until after the next mode set
Destroying an onscreen destroyes the gbm_surface, the gbm_bo's, and the
fb_id's. Doing this (drmModeRmFB() of the fb_id specifically), may on
some hw implicitly disable the CRTC of the plane that framebuffer was
assigned to. This would cause following atomic commit that attempts to
disable the CRTC to fail as disabling an already disabled CRTC is not
allowed.

It'd also mean we'd always disable the plane before having finished next
mode set, leaving it monitor content potentially empty when not really
necessary.

Solve this by keeping the CoglOnscreens (thus the gbm_surface, gbm_bo
and fb_id) alive until the following global mode set has completed, i.e.
the new state has been fully committed and applied.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
ae812ca81e renderer/native: Make dummy power save flips symbolic
They won't have a timestamp, thus isn't meant to be used for timing
calculations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
5f6aee3419 kms/update: Make power saving an update wide change
This makes "power save" (i.e. when you make a monitor go into power save
mode, or make it come out of power save mode), a per device action when
turning on power saving (power save being set to 'off'), and implicitly
handled when turning off power saving (power save being set to 'on')
when doing a mode set.

This is needed as with atomic mode setting, the configuration of DPMS
(Display Power Management Signaling), is replaced by directly turning on
or off CRTCs, and via the CRTC drm properties. Thus in order to handle
both with a common API, make that API high level enough for both cases
being covered.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
3ec5418104 backend/native: Set CRTC gamma once per frame
Before we received new gamma updates via D-Bus and posted the update to
KMS directly. This won't be possible with atomic KMS, since one can only
update the state of a CRTC once per cycle.

Thus, to handle this, when configured by D-Bus, only cache the value,
and mark it as invalid. The next frame, the native renderer will pick
up the newly cached gamma value and configure the CRTCs accordingly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
7d8dd6cc75 kms/crtc: Make MetaKmsCrtcGamma reusable
Expose it outside the private realms of MetaKms* so that e.g.
MetaMonitorManagerKms can use it too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
88e6400052 monitor-manager/kms: Turn on DPMS together with mode set
We cannot switch DPMS state to 'on' first, then mode set later, when
using atomic KMS. So when we're turning it on, just let the eventual
mode set handle DPMS too.

When switching DPMS to 'off', do it directly, synchronously, both by
setting the DPMS state and switching off CRTCs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
d8279ba474 kms/device: Add plane getter
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
dd03ffa89d renderer/native: Prepare for real page flips without primary plane changes
This is something that the atomic backend will need, as cursor updates
go through page flips too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
c985753442 cursor-renderer/native: Update HW state during frames
Before each frame is maybe redrawn, push any new cursor KMS state to the
pending update. It'll then either be posted during the next page flip,
or when the same frame finishes, in case nothing was redrawn.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
487ea0dd95 kms: Add symbolic page flips and cogl frame infos
This makes it possible to post a symbolic page flip and frame callback,
meant to be used by immediate symbolic page flip reply when emulating
cursor plane changes using legacy drmMode* functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
84f454fd4f clutter/frame-clock: Add notify_ready()
In constrast to notify_presented(), notify_ready() also returns the
state machine to the idle state, but without providing new frame
information, as no frame was actually presented.

This will happen for example with the simple KMS impl backend will do a
cursor movement, which will trigger a symbolic "page flip" reply in
order to emulate atomic KMS behavior. When this happen, we should just
try to reschedule again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
fea8ebcca9 cursor-renderer/native: Store struct in CRTC private
In this struct, for now only the buffer is stored, but it'll be used for
more state in later commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
447c51e68e renderer-native: Always post device wide updates during mode set
Don't mode set each CRTC in separate KMS updates, as reconfiguring one
CRTC might cause other CRTCs to be implicitly reset thus as well,
causing KMS return EBUSY if using atomic modesetting.

Prepare for this by compositing each CRTC first including adding steps
to the KMS update, but wait until all views has rendered at least once
before posting the initial update. After this each CRTC is posted
separately.

Using EGLStreams instead of normal page flipping seems to fail when
doing this though, so handle that the old way for the EGLStream case,
i.e. eglSwapBuffers() -> mode set with dumb buffer -> eglStream
"acquire" (resulting in page flip under the hood).

For this we also introduce a new error code so that we don't use client
buffers when doing mode sets, which could accidentally configure the
CRTC in a way that is incompatible with the primary plane buffers.

Do the same also when we're in power save mode, to only have one special
case path for this scenario in the regular swap-buffer path.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
92d4cb5184 clutter/frame: Make rendering backends set the frame result
Instead of setting the frame result in the most generic layer, have the
backends do it themselves. This is necessary to communicate that a
swap-buffer call didn't really succeed completely to present the swapped
buffer, e.g. errors from KMS.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
6bda72e3eb kms/plane: Make get_primary_plane() actually get the primary plane
The plane was not type checked, so it retrieved whatever plane happened
to come first.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
249512b068 cogl/onscreen: Add opaque user_data pointer to onscreen present calls
This argument is intended to be used by clutter to be able to
communicate with the onscreen backend, that happens to be the native
backend. It will be used to pass a ClutterFrame pointer, where the
result of page flips, mode sets etc can be communicated whenever it is
available.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
72b35e07c0 clutter: Introduce ClutterFrame
ClutterFrame aims to carry information valid during dispatching a frame.
A frame may or may not include redrawing, but will always end with a
result.

A asynchronous page flip, for example, will result in a
CLUTTER_FRAME_RESULT_PENDING_PRESENTED, while a frame that only
dispatched events etc will result in CLUTTER_FRAME_RESULT_IDLE. Instead
of this being implicit, make the ClutterStageWindow implementation
handle this itself.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
722f7ae2c3 clutter/stage-window: Pass 'view' to finish_frame() too
Not used yet, just done separately to decrease future diffs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
3bd0037fa1 tests/monitor: Check that the CRTC "layout" is correct
The layout should be the region of the stage the CRTC represents; check
that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
7215b0d88c output: Tie the output to the monitor it's part of
Outputs correspond to active connectors, that we translate into
monitors. Make this association more real by adding a pointer back to
the monitor from the output.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
5edc118d62 monitor-manager: Connect assigned CRTCs to their outputs both ways
We had a pointer from the output to the assigned CRTC, but had no way to
get the outputs an CRTC was assigned to. Add that connection.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
b7441514fe kms: Add some basic debug logging
Enabled using MUTTER_DEBUG=kms or via
Meta.add_verbose_topic(Meta.DebugTopic.KMS) in looking glass.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
c0e9a6fe15 kms/impl-device: Make the actual implementation handle the drm event
The way drm events are handled depends on whether we're using atomic or
not. Lets move the handling to the implementation, so that later the
atomic backend can handle the event they it need to.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00
Jonas Ådahl
b693e58c53 kms/update: If reassigning a plane handle the fb changed flag
If we reassign e.g. a cursor plane twice before it's updated, we need to
make sure the 'fb-unchanged' flag is correctly handled, so that if we
changed the fb first, then updated the assignment again only changing
the position, the new assignment should not be flagged with
fb-unchanged.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
2021-01-22 16:47:08 +00:00