Commit Graph

29862 Commits

Author SHA1 Message Date
Jonas Ådahl
176b706e66 screen-cast: Fix warning message
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2811>
2023-01-28 12:35:54 +01:00
Jonas Ådahl
c95a24f6e8 backend: Fix a couple of minor GError leaks
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2811>
2023-01-28 12:35:54 +01:00
Jan Tojnar
81cc05e61e build: Fix Sysprof interface path with split sysprof package
When sysprof-4 and libsysprof-capture-4 are installed into different
prefixes, such as with Nix package manager, the D-Bus interfaces
are likely not discoverable from the latter package.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2572>
2023-01-28 10:34:57 +01:00
Florian Müllner
6d7a5a91bf schemas: Consistently use child schemas
Currently subschemas in org.gnome.mutter are marked as child schemas,
but subschemas in org.gnome.mutter.wayland are not. There's no harm
with that, it's just nice to be consistent, and having schemas show
up in `gsettings list-children` is a nice touch.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2809>
2023-01-27 21:12:18 +01:00
Florian Müllner
813b85e081 schemas: Remove unused keys
Mutter's own tab popup implementation was removed almost a decade
ago, about time to clean out the left-over settings.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2809>
2023-01-27 21:02:17 +01:00
Sebastian Keller
cff631cb39 clutter/text: Don't call clutter_text_set_buffer() on finalize
clutter_text_set_buffer() tries to freeze/thaw notify, which is not
allowed during finalize and recent glib versions started warning about
this. This call can simply be removed, because the buffer is already set
to NULL on dispose, making the call in finalize redundant.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2566
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2790>
2023-01-25 22:10:03 +00:00
Jonas Ådahl
8abdbbdf24 wayland/transaction: Don't free queue node on tear down
The GQueue node for transactions are inlined in the transaction struct,
meaning we should never let the GQueue API free the node itself, as that
actuall frees the transaction itself.

We did this during tear down if there were left-over transactions,
meaning we ended up with use-after-free issues after having popped
transactions from the queue.

Fix this by just popping the link itself, which won't attempt to free
it. It is effectively freed when freeing the transaction itself so we
won't leak any memory.

Fixes: 56260e3e07
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2805>
2023-01-25 13:53:11 +00:00
Florian Müllner
0e6395d932 x11/events: Do not update focus XWindow during grabs
During grabs, it is expected that the X11 focus does not correspond
to the display's focus window, as focus should be on the stage's
XWindow instead.

This still messes up the keyboard focus even after we stopped moving
the X11 focus, because we end up with a presumed X11 focus window
of None, and as a result the stage is considered unfocused.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2776>
2023-01-25 13:31:49 +00:00
Florian Müllner
7531669b4f display: Do not move X11 input focus during grabs
On X11, the stage itself is backed by an XWindow, and moving the
input focus elsewhere will bypass any Clutter-level grabs.

This effectively allows newly opened windows to steal the focus
from gnome-shell itself, which is clearly undesirable. To prevent
that, only move the X11 focus when no grab is in place, just like
commit 50e89e376 did for the stage focus.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2776>
2023-01-25 13:31:49 +00:00
Florian Müllner
24f796a30c x11/display: Add some logging
https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5932

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2776>
2023-01-25 13:31:49 +00:00
Carlos Garnacho
8f268f2930 backends/native: Keep general direction when crossing monitors
When the pointer crosses monitors, we account for a single motion event
resulting in the pointer moving across more than 2 monitors, in order
to correctly account each monitor scale and the distance traversed
across each monitor in the resulting relative motion vector.

However, memory on the direction is kept short, each iteration to
find the target view just remembers the direction it came from. This
brings a pathological case with 4 monitors with the same resolution
in a 2x2 grid, and a motion vector that crosses monitors at the
intersection of all 4 in a perfect diagonal. (Say, monitors are
all 1920x1080 and pointer moves from 1920,1080 to 1919,1079).

In that case, the intersection point at the crossing between 4
monitors (say, 1920,1080) will be considered to intersect with 2
edges of each view. Since there is always at least 2 directions to
try, the loop will always find the direction other than the one
it came from, and as a result endlessly jump across all 4 possible
choices.

In order to fix this, consider only the global v/h directions,
we already know if the pointer moves left/right or up/down, so
only consider those directions to jump across monitors.

For the case at hand, this will result in three monitors visited,
(either bottomright/bottomleft/topleft, or bottomright/topright/topleft)
with a total distance of 0,0 in the middle one, effectively
resulting in a correct diagonal motion.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2598
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2803>
2023-01-24 17:30:46 +00:00
Carlos Garnacho
34a9141a6c backends/native: Minor refactor
Refactor code so that variables don't depend the on motion line
content, but the other way around. This makes it clearer what each
vector means.

This has no functional changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2803>
2023-01-24 17:30:46 +00:00
Jonas Ådahl
5235f2b4ac tests/color: Assert we saw the expected messages
g_test_expect_message() needs a g_test_assert_expected_messages() to be
of much use, so add those calls too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2800>
2023-01-24 13:09:42 +00:00
Jonas Ådahl
11d35f99be util: Make meta_topic() log using the debug level in tests
Some tests expect warnings to be logged, and handle that using
g_test_expect_message(). However, if debug topics are enabled, this
causes g_logv() to expect expected messages to also contain entries with
the debug level 'message' or higher to be listed in the expected message
list. Since meta_topic() always logged using g_message(), enabling debug
topics caused any test that used g_test_expect_message() and had debug
logging somewhere along the code path to fail.

Fix this by changing the log level of meta_topic() to 'debug' if we're
in a test. This doesn't mean they won't be visible, they still will
since debug log entries are printed by default during testing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2800>
2023-01-24 13:09:42 +00:00
Jonas Ådahl
e5602062e2 cogl/frame: Keep track of target presentation time
It's yet to be used for anything, but will later on.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2795>
2023-01-23 15:57:51 +01:00
Jonas Ådahl
08b0e563d4 clutter: Pass 'ClutterFrame' in all stage update signals
That means before-update, prepare-paint, before-paint, paint-view, after-paint,
after-update. While yet to be used, it will be used as a transient frame
book keeping object, to maintain object and state that is only valid
during a frame dispatch.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2795>
2023-01-23 15:57:50 +01:00
Jonas Ådahl
24f44aa33e tests/kms/render: Fix paint-view callback type signature
It was missing a cairo_region_t. This also needs adapting the test case,
since prior to this, we didn't actually bump the paint counter when
painting.

When a scanout test isn't waiting to go from compositing to scanout, but
from scanout to compositing, we should not early out when we actually
composited, since that's what we're expecting to see.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2795>
2023-01-23 15:57:30 +01:00
Jonas Ådahl
c54b350313 clutter/frame: Turn into boxed type
This will allow us to pass a ClutterFrame in interfaces, including ones
that end up being introspected.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2795>
2023-01-23 12:19:54 +01:00
Jonas Ådahl
56da8418f9 clutter/frame: Carry target presentation time
This will be used, when available, to both check whether frames missed a
vsync cycle, or to calculate when page flips should be queued.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2795>
2023-01-23 12:19:54 +01:00
Jonas Ådahl
916b21674e clutter/frame-clock: Pass ClutterFrame via the frame clock interface
Let the ClutterFrame live for the whole frame, and be carried as an
argument to the frame clock listener interface functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2795>
2023-01-23 12:19:54 +01:00
Jonas Ådahl
1c574068e0 frame-clock: Store interface pointer in variable
It's accessed a few times, so keep it around.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2795>
2023-01-23 12:19:54 +01:00
Niels De Graef
768ec7b0c1 clutter/stage-view: Properly chain up finalize
Fix a silly copy-paste mistake. Since `GObject` is the parent class,
chaining up to `dispose()` from within your `finalize()`
implementation just leads to a little memory leak and nothing worse.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2799>
2023-01-22 18:49:15 +01:00
Jonas Ådahl
84538f402e tests/kvm: Run with 1GB RAM
This makes things like valgrind and catch able to run.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2798>
2023-01-21 14:22:33 +01:00
Carlos Garnacho
c6c7f310d8 x11: Account for variable being possibly NULL
We might end up with a NULL opaque_region here in some circumstances
(client deleted _NET_WM_OPAQUE_REGION, or passed invalid data or a
region with 0 rectangles), account for that when freeing the variable.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2758>
2023-01-20 22:23:55 +00:00
Carlos Garnacho
2b6651327e compositor: Observe frame opaque region when updating shapes
Apply either frame or client window opaque regions (or both as
an union). For client windows without an alpha channel, the frame
shape already contains the client area. If the client window does
have an alpha channel, the client rectangle is cleared to let the
client's opaque region take care of it.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2555
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2758>
2023-01-20 22:23:55 +00:00
Carlos Garnacho
4752a8055c core: Update frame opaque region from _NET_WM_OPAQUE_REGION property
Both read this property on frame creation, and listen to property changed
events about it in the frame window.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2758>
2023-01-20 22:23:55 +00:00
Carlos Garnacho
82b2b76882 core: Add infrastructure to keep window frames' opaque regions
These frames client will use a visual with alpha information, and
report the opaque frame shapes through the _NET_WM_OPAQUE_REGION
window property. We can use this information in the Mutter side
for accurate opaque shapes, despite X11 windows with frames now
being seen as possibly transparent.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2758>
2023-01-20 22:23:55 +00:00
Carlos Garnacho
07e1f87e3b x11: Add function to know whether a client X11 window has an alpha channel
Since the windows created by the frames client will have a RGBA visual, we
no longer can perform simple tests about whether the window is opaque. For
that, we will need to additionally know whether the client-side window has
a visual with an alpha channel.

Reviewed-by: Michel Dänzer <mdaenzer@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2758>
2023-01-20 22:23:55 +00:00
Carlos Garnacho
1f51dfa112 x11: Wait synchronously for the frames client to exit
This does nothing wrt making race conditions shorter in the
X11 window manager switch case, but is a nice to have in order
to ensure an orderly shutdown of X11 stuff.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2796>
2023-01-20 21:25:02 +00:00
Carlos Garnacho
a9bf493ec7 frames: Quit immediately on SIGTERM
Restarting a X11 window manager is a busy process, trying to leniently
quit the main loop may result in old and new instances each having a
frames client up and running, and the window handover to be less clean
than it should due to the frames client that is about to exit still
being able to react to the batch of events resulting from the window
manager switch that is already undergoing.

In order to avoid extending this transition period any long, make
the frames client exit() the process immediately when SIGTERM is
gotten from the parent process.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2796>
2023-01-20 21:25:02 +00:00
Florian Müllner
0fa1581699 frames/window-tracker: Stop using deprecated API
GTK deprecated gtk_widget_show() in favor of gtk_widget_set_visible()
and gtk_window_present().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2783>
2023-01-20 20:41:30 +00:00
Jonas Ådahl
ad371a4435 color-device: Don't write to fields when cancelled
Writing to fields (in this case the MetaColorDevice::pending_state) in
response to an asynchronous operation that was cancelled means we'll
write to an arbitrary memory location, potentially causing segmentation
faults or memory corruption.

Avoid these segfaults or memory corruption by only updating state if we
weren't cancelled. Also avoid trying to dereference the device pointer
if we're cancelled.

The memory corruption due to this has been causing test flakyness in the
monitor unit tests due, which should now hopefully be fixed.

Fixes: 19837796fe
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2794>
2023-01-20 15:34:53 +00:00
Carlos Garnacho
e4ee40d7ff compositor: Wrap x11 surface actor destruction in error trap
This does a number of X11 calls. For what it might happen, better
wrap these in error traps.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2793>
2023-01-19 13:57:35 +00:00
Carlos Garnacho
2be5662ee9 compositor: Wrap XDamageCreate call with error trap
I hit this rare error running the "x11" test from the suite locally:

(mutter:194027): Gdk-ERROR **: 18:21:52.525: The program 'mutter' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadDrawable (invalid Pixmap or Window parameter)'.
  (Details: serial 663 error_code 9 request_code 143 (DAMAGE) minor_code 1)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the GDK_SYNCHRONIZE environment
   variable to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)

The only call from the Damage extension in use by Mutter that could
return BadDrawable is XDamageCreate(), and it's likely to be this
call. Wrap this X11 in an error trap, in order to catch possible
failures.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2793>
2023-01-19 13:57:35 +00:00
Jonas Dreßler
57ce4e04e5 tests/clutter/event-delivery: Flush input thread inside wait_stage_updated()
Flushing the input thread might implicitly iterate the mainloop, and thus
update the stage while still inside the clutter_test_flush_input() call.
This means the stage update has already happened when we call
wait_stage_updated(), and that's why we call clutter_stage_schedule_update()
there currently.

This clutter_stage_schedule_update() call is not necessary though, instead
we can flush the input thread from inside wait_stage_updated() after
setting was_updated to FALSE.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2792>
2023-01-19 13:36:25 +00:00
Carlos Garnacho
909eaa117d core: Delete _MUTTER_NEEDS_FRAME property when destroying frame
If the window is unmapped or otherwise unmanaged while still existing,
we would fail to let the frames client follow up in destroying the
frame for the window.

Delete the _MUTTER_NEEDS_FRAME property, so that the frames client
can react to meta_window_destroy_frame(), this avoids stale invisible
frame windows for clients that simply unmap windows to reuse them
later.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2791>
2023-01-18 15:35:58 +01:00
Carlos Garnacho
0fff52ee28 frames: Avoid default NULL frame title
The default GtkWindow title if NULL is set is obtained from g_get_prgname(),
prefer an empty string here.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2791>
2023-01-18 14:17:00 +01:00
Daniel van Vugt
89b254a74b gles3: Ensure missing_extensions is always populated
This appears to be the only explanation for `init_secondary_gpu_data_gpu`
crashing in `g_strjoinv`, but I don't know the exact conditions causing
`glGetString (GL_EXTENSIONS)` to return NULL.

https://launchpad.net/bugs/1994011

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2674>
2023-01-18 10:14:39 +00:00
Corey Berla
102736c7f5 docs: Fix dependency names
Dependency names need to match the namespace name exactly (including
capitalization) otherwise they won't be shown as dependencies.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2788>
2023-01-17 20:45:46 +00:00
Corey Berla
a60ceaa377 docs: Mark Gtk and Gdk as related libraries
Since Gtk and Gdk are no longer hard dependencies, gi-docgen considers
them related libraries.  They will not show up in the documentation
if they are tagged as dependencies without actually being dependencies.

See: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2788>
2023-01-17 20:45:46 +00:00
Olivier Fourdan
8ee85cb228 xwayland: Add support for byte-swapped clients
Instructs Xwayland to allow/disallow connections from X11 clients with a
different endianess based on the "xwayland-allow-byte-swapped-clients"
setting.

This option has no effect if Xwayland does not support the command
option +byteswappedclients/-byteswappedclients.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2576
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2785>
2023-01-17 11:14:19 +01:00
Olivier Fourdan
5be6e7b18e settings: Add Xwayland byte-swapped clients
Recent versions of Xwayland can allow or disallow X11 clients from
different endianess to connect.

Add a setting to configure this feature from mutter, who spawns
Xwayland.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2785>
2023-01-17 11:14:19 +01:00
Carlos Garnacho
9e0b5b1886 clutter: Avoid string translation to find text direction
Use Pango and Harfbuzz for the task, getting the default language,
then its scripts, then their directions. We pick the first valid
horizontal direction, resorting to LTR as a fallback.

Related: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5385
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2780>
2023-01-13 11:46:13 +00:00
Carlos Garnacho
95c2154039 wayland: Drop HAVE_XSETIOERROREXITHANDLER checks
This define was dropped by commit 0e8aaebc00 (xwayland: Make
XSetIOErrorExitHandler() mandatory), but some #ifdef checks were
brought back by commit 36f30341ac (wayland: Add a prepare-shutdown
signal).

Since there's no define anymore in config.h, these pieces of code
were unintentionally disabled, and a meta_get_display() call be
also left over. Remove the ifdefs and update the code to build
again.

Fixes: 36f30341ac - wayland: Add a prepare-shutdown signal
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2786>
2023-01-12 14:54:31 +00:00
Carlos Garnacho
78a3631d15 core: Wrap XMapWindow() request with error traps
Other X11 calls happening during the process of assigning a frame
to a window are already wrapped with error traps, wrap this as well
to avoid possible X11 errors.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2745>
2023-01-12 14:07:32 +01:00
Carlos Garnacho
2019536f3c core: Wrap an extra X11 call with error trap
This XChangeWindowAttributes call was never surrounded by an error trap
and was not really expected to fail with BadWindow since the frame window
would be owned by Mutter itself.

This however is no longer true, and we might be getting a BadWindow from
the frame window given the right timing.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2745>
2023-01-12 14:00:52 +01:00
Carlos Garnacho
c7b3d8c607 frames: Push error traps around various X11 calls
It is a possibility that these requests result in an error, so handle
the possible fallout.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2745>
2023-01-12 14:00:52 +01:00
Carlos Garnacho
5816268c1d x11: Push error trap reading X11 selection
It is a possibility that this request results in an error, so handle
the possible fallout.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2745>
2023-01-12 14:00:52 +01:00
Carlos Garnacho
8789e1b7d9 x11: Push error trap querying the _MUTTER_FRAME_FOR property
It is a possibility that this request results in an error, so handle the
possible fallout.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2745>
2023-01-12 14:00:52 +01:00
Carlos Garnacho
1cee0579fa wayland: Push an error trap while querying XDND mimetype list
It is a possibility that this request results in an error, so handle the
possible fallout.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2745>
2023-01-12 14:00:52 +01:00