1
0
Fork 0
Commit graph

622 commits

Author SHA1 Message Date
Ivan Molodetskikh
47814fab71 Remove COGL_TRACE_BEGIN in favor of BEGIN_SCOPED
Scoped traces are less error prone, and they can still be ended
prematurely if needed (this commit makes that work). The only case this
doesn't support is starting a trace inside a scope but ending outside,
but this is pretty unusual, plus we have anchored traces for a limited
variation of that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3396>
2023-11-15 13:57:43 +00:00
Bilal Elmoussaoui
f5dac3a5d9 build: One config file to rule them all
Group all the three config files from clutter/cogl/meta into one
and also remove unnused configurations and replace duplicated ones

This also fixes Cogl usage of HAS_X11/HAS_XLIB to match the expected
build options

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3368>
2023-11-15 12:00:19 +00:00
Sebastian Wick
5a33b0075a core: Move window enter/leave to display
The following commits will make it possible to pass a NULL window to
display_handle_window_enter/leave to represent the cursor entering the
desktop. This means it can't be a method of the window class anymore.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3258>
2023-11-13 14:22:44 +00:00
Bilal Elmoussaoui
655b4a9c75 Port to MtkRegion
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3292>
2023-11-03 11:27:52 +00:00
Florian Müllner
b9008ee83d window: Handle layer of DESKTOP windows
Assigning the corresponding stack layer of DESKTOP windows is
currently X11 specific, because there is no way for wayland
clients to set the DESKTOP window type.

This is about to change, so move the code to the generic layer
handling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3305>
2023-10-24 19:25:24 +00:00
Carlos Garnacho
b567256873 x11: Add another mechanism to ignore crossing events
This is similar, but reserved for the crossing events induced by the
input shape changes on our overlay window. The mechanism in the previous
commit does again protect against this, so this mechanism may go away.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3267>
2023-09-28 15:39:44 +00:00
Carlos Garnacho
8b0da940cf x11: Simplify handling of focus-follows-mouse
Focus follows mouse is meant to avoid focusing windows that happened
to pop up under the pointer, e.g. due to mapping, workspace changes,
etc... On X11, this has been done since ancient times through a
moderately complex synchronization mechanism, so mutter would know
to ignore crossing events caused on those situations.

This mechanism is much prior to XInput 2 though, where we may know
this in a more straightforward way: If the sourceid of the crossing
event is a logical pointer (i.e. equals deviceid), the crossing event
was triggered logically, and not through user input.

Perform this simpler check, and drop the existing mechanism to
ignore logically induced crossing events.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3267>
2023-09-28 15:39:44 +00:00
Carlos Garnacho
cc874f5d33 x11: Avoid poking MetaCompositor during MetaDisplay destruction
Commit 9c3b130f67 changed slightly destruction order to handle use-after-free
situations, but missed a small new one introduced by the order change: The
MetaX11Display may schedule callbacks through MetaLaters, which depend on the
MetaCompositor, which is now freed before the MetaX11Display.

Since there is no winning move here, make the MetaX11Display aware of this
by avoiding to remove the callback if the MetaCompositor is already gone.
The MetaLaters infrastructure is already fully freed at this point (incl. the
data it contained), so this shouldn't be a leak.

Fixes: 9c3b130f67 ("display: Fix destruction order")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3247>
2023-09-06 09:28:09 +00:00
Carlos Garnacho
af10ead918 x11: Find nearest input affecting _NET_WM_MOVERESIZE X11 requests on Wayland
The _NET_WM protocol, written before the birth of XInput 2.x, does have
no notion of different input devices whatsoever. Anyways, in a X11 session
it is safe to assume this refers about the Virtual Core Pointer since
every input device by default drives it (incl. touchscreens through the
"pointer emulating sequence", and styli).

This assumption falls apart in a Wayland session with non-pointer input,
since we do actually distinguish between all the distinct pointer devices
and touchpoints, and do not let them emulate mouse input.

We do need to specify a device/sequence there to drive the window
move/resize operation. The _NET_WM_MOVERESIZE message just gives us the
x/y root coordinates the resize was started from, so work from there
into guessing what is the most likely device/sequence that did trigger
the request on the client side.

Conversely, on Wayland we do not need to check for possible race
conditions in the pressed button states since we have larger guarantees
about not missing these events if we checked for the button modifier
mask beforehand, so make that race condition check specific to the
X11 sessions.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2836
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3059>
2023-09-03 20:59:16 +00:00
Carlos Garnacho
ef366c5fcb mtk: Make error traps multi-display
Keep a per-display list of error traps, so we don't mix them
together, and possibly deem unintended error traps outdated.

This means init/deinit calls are now stackable, and need to
happen evenly. In order to honor this, move the MetaX11Display
error trap destrution to finalize.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3230>
2023-09-02 09:52:54 +00:00
Carlos Garnacho
6f46edd93b x11: Replace Mutter X11 errors with Mtk ones
Use Mtk X11 errors in favor of our own implementation.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3230>
2023-09-02 09:52:54 +00:00
Daniel van Vugt
fdbd38121b x11/events: Don't define an unused function when tracing is disabled
This fixes a compiler warning:
```
src/x11/events.c:523:1: warning: ‘get_event_name’ defined but not used [-Wunused-function]
  523 | get_event_name (MetaX11Display *x11_display,
      | ^~~~~~~~~~~~~~
```

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3223>
2023-08-31 22:18:11 +00:00
Carlos Garnacho
630f13db78 x11: Handle ConfigureRequest events in frames
Under strange timings, the GTK frames client may implicitly queue
relayouts that end up disagreeing with the latest frame size as
given by Mutter, this results in GTK calling XResizeWindow, and
Mutter plain out ignoring the resulting XConfigureRequestEvent
received.

This however makes GTK think there's pending resize operations,
so at the next resize it will freeze the window, until enough
resizes happened to thaw it again. This is seen as temporary
loss of frame-sync ness (e.g. frozen frame, and other weird
behavior).

In order to make GTK happy and balanced, reply to this
XConfigureRequest, even if just to ignore it in a more polite
way (we simply re-apply the size Mutter thinks the frame should
have, not GTK), this results in the right amount of
ConfigureNotify received on the frames client side, and the
surface to be thawed more timely, while enforcing the size as
managed by Mutter.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2837
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3189>
2023-08-31 20:53:04 +00:00
Bilal Elmoussaoui
3d693e8309 mutter: Completely replace MetaRectangle with MtkRectangle
There are still various helpers that might be worth to move to mtk as
well

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:14 +02:00
Bilal Elmoussaoui
9b2cba4e86 mtk: Move Rectangle.equal from Meta
Moves equal the equal function and removes the clutter equivalent. The
tests were not moved until all the remaining helper functions are moved.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:13 +02:00
Bilal Elmoussaoui
918ae0f4d4 mutter: Replace cairo_rectangle_int_t with MtkRectangle
Note: the various helpers in boxes.c were not ported yet, see the next
commit. This was intentionally done to simplify the porting process

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3128>
2023-08-30 16:46:13 +02:00
Sandro Bonazzola
ff4d87727b Update license access method
Dropped obsolete Free Software Foundation address pointing
to the FSF website instead as suggested by
https://www.gnu.org/licenses/gpl-howto.html
keeping intact the important part of the historical notice
as requested by the license.

Resolving rpmlint reported issue E: incorrect-fsf-address.

Signed-off-by: Sandro Bonazzola <sbonazzo@redhat.com>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3155>
2023-08-30 08:48:23 +02:00
Bilal Elmoussaoui
cd27cb5c85 cleanup: Fix various typos
Using the typos cli app

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3169>
2023-08-12 20:13:37 +00:00
Michel Dänzer
b081e51a21 Remove unused meta_x11_display_increment_event_serial
Unused since dfcefd3315 ("Remove meta_core_increment_event_serial").

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Michel Dänzer
1a5fb51396 Remove unused meta_window_x11_has_active_sync_alarms
Never used AFAICT.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3154>
2023-08-12 19:53:46 +00:00
Carlos Garnacho
ca3256ee97 backends/x11: Rename function to reset X11 cached current monitor info
This is done from the backend X11 connection, but needs directing at times
from the frontend X11 connection. Commit 5a8509f895 added a XEvent
argument presumably for possible future expansions that did never come.

Since this function is nothing about events, drop the XEvent argument and
make the name a little bit more ad-hoc (according to what it does, at
least).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
2023-08-08 04:00:11 +02:00
Bilal Elmoussaoui
a955f0e47c cleanup: Make include macro usages consistent
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3157>
2023-08-07 22:24:36 +00:00
Bilal Elmoussaoui
ead9a3024c cleanup: Switch to pragma once
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3157>
2023-08-07 22:24:36 +00:00
Bilal Elmoussaoui
b852bbba47 cleanup: Stop translating nick/blurb for pspecs
As those strings are intended to be used by some UI but nothing uses
that in reality except GStreamer.
So drop them similar to what GTK did at
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/4717

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3101>
2023-07-19 11:33:59 +00:00
Sebastian Keller
6274bb3518 x11: Use input region from frame window for decorated windows
Previously the input region was ignored for decorated windows, which
since the introduction of the frames client meant that the entire shadow
region of the frame window was considered interactive.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2706
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3031>
2023-06-02 20:21:56 +00:00
Jonas Ådahl
33a210d768 x11/events: NULL Check input event when getting name
Fixes a SIGSEGV when trying to get the name of an XIEvent for profile
trace data gathering. We don't use GDK anymore, so we can't rely on any
GDK semantics.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2998>
2023-05-31 08:37:52 +00:00
Marco Trevisan (Treviño)
889cd056e7 x11/x11-errors: Use the default error handler when display is destroyed
An X11 server connection may still be around when we close the display,
and mutter_x_error could be triggered when x11_display has been already
destroyed leading to a crash.

To prevent this use the default X11 error handler.

As per this, also move the ownership of the error traps to x11-errors.

See: https://gitlab.gnome.org/GNOME/mutter/-/issues/2835
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3020>
2023-05-31 07:53:41 +00:00
Robert Mader
4a5a31edc6 mutter: Remove stray spaces
To silence code-style-check complains.

Fixes d44f02ba64

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3018>
2023-05-24 14:16:41 +02:00
Bilal Elmoussaoui
d44f02ba64 mutter: Cleanup gi-docgen annotations
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2939>
2023-05-22 15:47:37 +00:00
Carlos Garnacho
3218626d7e x11: Do not unminimize windows with initial IconicState
This is a revert of commit be5c2ebc, adapted to this day and age.
While this worked around issues in wine/proton, it did contravene
icccm in the interpretation of initially iconic windows.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2043
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3001>
2023-05-16 15:34:25 +00:00
Bilal Elmoussaoui
3e95609073 compositor/dnd: Guard X11 types
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:36:23 +02:00
Bilal Elmoussaoui
761a254e6f core/display: Guard X11 types
This also moves a couple of function calls to
MetaDisplay::x11-display-opened a signal handler

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:36:23 +02:00
Bilal Elmoussaoui
aaa3f34cc0 compositor: Guard X11 types
This also moves meta_compositor_x11_redirect_windows to DisplayX11
where it makes more sense as meta_display_x11_redirection_windows

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2272
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2445>
2023-05-15 20:23:37 +02:00
Marco Trevisan (Treviño)
184b8e9c8c x11/x11-display: Fix some wrong code style to please CI checker
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:06:40 +02:00
Marco Trevisan (Treviño)
8039b58410 x11/x11-display: Always set the compositor manager selection on init
Set the compositor manager selection during the initialization phase as
we do with the window manager selection

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:06:37 +02:00
Marco Trevisan (Treviño)
2625edec10 x11/x11-display: Set compositor selection earlier on XWayland
When the X11 display is actually XWayland there's no point to delay the
compositor selection, given that mutter itself is the compositor and
doing this may cause the first X11 client that starts not to receive the
right information (and in some cases misbehave).

Since some toolkits are not handling the compositor selection changes
properly at later times, let's make their life easier by just
initializing the selection as early as the other X11 properties, given
that in this case there's nothing to replace.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2472
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2970>
2023-05-15 19:04:59 +02:00
Sebastian Keller
dddaf19d07 x11: Always initialize all fields of XEvents sent via XSendEvent
The X server ignores the send_event and serial in incoming XEvents, so
they were not initialized when calling XSendEvent in a few places.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2641
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2964>
2023-04-17 01:52:36 +02:00
Sebastian Keller
6fbe4286ea x11: Fix remaining leaks from switch to XGetAtomName()
After this got changed from gdk_x11_get_xatom_name() to XGetAtomName(),
this no longer returns a const char* and it now also needs to be freed.

Fixes: e66f4396e ("x11: Avoid GDK API in X11 selections")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2957>
2023-04-14 13:27:19 +00:00
Sebastian Keller
94bd5c7319 x11: Use Atoms when constructing a new MetaX11SelectionOutputStream
This was pointlessly being converted between atom and string and back,
which with the switch from gdk_x11_get_xatom_name() to XGetAtomName()
also introduced a leak for every XGetAtomName() call.

Fixes: e66f4396e ("x11: Avoid GDK API in X11 selections")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2957>
2023-04-14 13:27:19 +00:00
Sebastian Keller
01ae1d32ee x11: Remove unused member variables from MetaX11SelectionInputStream
The private format and type member variables were not being used by any
of the callers, so they can simply be removed. This also fixes a leak of
type which was introduced when switching from gdk_x11_get_xatom_name()
to XGetAtomName().

Fixes: e66f4396e ("x11: Avoid GDK API in X11 selections")
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2957>
2023-04-14 13:27:19 +00:00
Carlos Garnacho
a42bc34e4d core: Pass MetaWindow on passive button grab machinery
In practical effects the passed Window is always window->xwindow,
so pass the MetaWindow and get the better X11 Window deep in the
call stack.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2954>
2023-04-12 11:28:50 +02:00
Carlos Garnacho
1e459c8302 x11: Wrap X call with error traps
Lest it fails. Try to recover from that and keep reading
the mimetypes present in the atom list.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/6555
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2945>
2023-04-04 18:35:11 +00:00
Carlos Garnacho
2e82702084 x11: Pass Atom directly
We convert an atom to string just to convert it to an atom. We
can avoid the roundtrip.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2945>
2023-04-04 18:35:11 +00:00
Jonas Ådahl
08bdee58c9 Revert "core: Avoid setting up frames on fullscreen windows"
This caused feedback loops with old statically compiled SDL
applications. The bug is fixed in upstream SDL, but that doesn't help
when the executables have old SDL's built into them.

This reverts commit beeeea546b.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2678
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2921>
2023-03-18 18:25:39 +00:00
Carlos Garnacho
5daddf0bc7 core: Retrieve DESKTOP_AUTOSTART_ID early on startup
With the move away from GTK3, and the indirect dependency on GTK4
grown in the GNOME Shell side, we've indirectly gotten a small sneaky
behavioral change: The GTK4 library will, right on dlopen, get
DESKTOP_AUTOSTART_ID for itself and delete it from the environment.

This happens before our own X11 session management code is
initialized, which confuses the hell out of it, into thinking
initialization is actually shutdown, gnome-session does not follow
along with this request, which leaves GNOME Shell into a confused
startup state where it never calls SmcSaveYourselfDone() and grinds
startup to a halt until gnome-session decides to move things forward.

In order to fix this, get the DESKTOP_AUTOSTART_ID before we lend
control to GNOME Shell bits and GTK4 is possibly initialized, and
feed it directly to our X11 session manager bits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2906>
2023-03-18 15:40:17 +00:00
Carlos Garnacho
608d3019b6 x11: Ignore _NET_ACTIVE_WINDOW client messages while grabbed
When a X11 application is started, typically what happens is:

- A startup notification token is created, with a _TIME%d suffix
- The application being spawned receives it through the environment
- (dbus piping, maybe)
- The application replies the startup notification token, and
  fetches the timestamp from it
- The application makes a _NET_ACTIVE_WINDOW client message request
  with this timestamp
- Mutter handles this client request and activates/focuses the window

Prevent this last step if windows are not interactable (e.g. there is
a compositor grab) and ignore the focus request. This specifically
applies to X11 clients requesting focus themselves, and unlike previous
approaches, doesn't try to prevent focus changes that do come through
interaction with Mutter/GNOME Shell.

This should only break if applications do not observe _NET_ACTIVE_WINDOW
and perform XSetInputFocus on themselves, but in that case the X11
keyboard focus is stolen from our hands already.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2878>
2023-03-05 07:17:02 +00:00
Carlos Garnacho
92792d6850 Revert "x11/events: Do not update focus XWindow during grabs"
This reverts commit 0e6395d932.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2878>
2023-03-05 07:17:02 +00:00
Carlos Garnacho
7de834b915 Revert "x11: Do not move X11 input focus during grabs"
This reverts commit a68b8e9595.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2878>
2023-03-05 07:17:02 +00:00
Olivier Fourdan
5e7754f742 x11/display: Delay cursor updates
When a client (either Wayland or X11) is started, the window activation
will update the cursor to the "busy" cursor.

Mutter will then set the X11 cursor on the X11 root window to match that
so that X11 applications which do not explicitly set a cursor inherit
from that default (busy) cursor.

Updating the X11 cursor too often can hammer the X11 connection and
cause a deadlock with Xwayland.

Reload the X11 cursor in a later handler to avoid that issue.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2849>
2023-03-04 09:07:44 +00:00
Carlos Garnacho
beeeea546b core: Avoid setting up frames on fullscreen windows
Ensure we preserve the fast zero-copy paths in Xwayland fullscreen
windows, instead of maybe rendering the client surface on top of the
frame surface, and providing the latter to the compositor.

To achieve this, additionally synchronize frame state when
recalculating features (e.g. after fullscreen/unfullscreen), and
account for this new condition when creating or destroying frames.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2797>
2023-03-03 20:33:18 +00:00
Carlos Garnacho
a4f508db57 x11: Drop all bypass_gtk checks
There's no longer a GTK to appease, we can drop these
checks to tiptoe over it the right way.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2864>
2023-03-03 20:17:01 +00:00
Carlos Garnacho
ab9ea61d3d x11: Open a X11 Display directly
Do the few remaining things that GDK is doing for us:
- Open and close the X11 Display
- Set up a GSource on the Display FD to handle events
- Allocate and free the content of XGenericEventCookie,
  to "unroll" the few XInput2 events that Mutter still
  does handle.

And remove the GdkDisplay we've so long relied on.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2864>
2023-03-03 20:17:01 +00:00
Carlos Garnacho
a5042000c6 x11: Adopt X11 error trap infrastructure from GDK
From reading the comment in the top of the file, not for the first
time. Keep our own error handler and maintain our own list of
failable x11 sequences in MetaX11Display, so we can move away from
GTK's.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2864>
2023-03-03 20:17:01 +00:00
Robert Mader
b521747d81 Remove support for window shading
It's been broken for an unknown time and was never supported on Wayland.
Thus let's remove the leftovers.

Helpful command: `rg 'shade(?!r)' --pcre2`

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2884>
2023-03-03 19:17:51 +00:00
Carlos Garnacho
53126bf008 x11: Prevent use-after-free if a filter is removed during handling
Keep a pointer to the next element, to protect against filters removing
themselves.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2640
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2868>
2023-02-24 14:11:55 +00:00
Carlos Garnacho
e0634a4060 x11: Make some unnecessarily public API private again
There's a few functions that GNOME Shell shouldn't ever need,
stop exporting them as public API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2779>
2023-02-23 17:19:22 +01:00
Carlos Garnacho
22c6374374 x11: Drop unused methods
These are not used anywhere in Mutter or GNOME Shell, it seems
we can drop them.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2779>
2023-02-23 17:19:22 +01:00
Carlos Garnacho
a799ac8ff0 x11: Add public API to handle X11 events
This API will be used by GNOME Shell to handle X11 events
in the relevant places, as a substitute to gdk_window_add_filter().

It is ATM still a bit ironic, since the Mutter X11 event handler
is itself a GdkFilterFunc, but it may move away from that eventually.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2779>
2023-02-23 17:19:22 +01:00
msizanoen1
899af9d58c window/x11: Make process_property_notify a virtual method
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2725>
2023-02-20 16:55:36 +00:00
Carlos Garnacho
81c0cf0834 x11: Avoid updating focus on wayland compositor
Reading upon the history of this code branch (commits 6891ce95dc
and 7a4c808e43 are most relevant), it seems this code is meant to
synchronize Mutter focus state taking the Xserver state as true.
That is, if Mutter tried to change the focus but something truncated
that action, Mutter focus will be changed to be in sync with the
Xserver again.

This sounds backwards in a Wayland session. Mutter focus should be
the canonical source, and not second-guessed from the current Xserver
focus window. These race conditions might still apply between X11
clients, so make these paths only apply in that case.

An example of this breaking can be reproduced with a Spotify and
Firefox window, moving the focus from the first to the second by
going to the GNOME Shell overview in between, and clicking the
Firefox window from there. The Firefox window will be raised, but
refuse to take focus.

It's unclear what made this an issue recently, perhaps commit
0e6395d932 since the now possibly ignored XI_FocusIn/Out events
affect this accounting of the Xserver focused window. Anyhow it
sounds better to ignore these paths for Wayland/native altogether.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2841>
2023-02-14 15:51:17 +00:00
Jonas Ådahl
32dc870f37 wayland: Add X11 interop service client protocol
This protocol is intended to let special clients create transient-for
relationships between X11 and Wayland windows. The client that needs
this is xdg-desktop-portal-gnome, which will create e.g. file chooser
Wayland dialogs that should be mapped on top of X11 windows.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2810>
2023-02-13 15:34:24 +00:00
Carlos Garnacho
a68b8e9595 x11: 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 allow moving the X11 focus to a Window when no grab is
in place, just like commit 50e89e376 did for the stage focus.

But particularly the updating of x11_display->focus_xwindow is not
prevented. Since it's more consistent to the MetaDisplay/MetaX11Display
dual focus tracking and across Wayland/X11 backends, ensure the X11
input focus is actually set on the last focus Window after the
grabs are gone and windows became interactable again.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2832>
2023-02-13 12:45:37 +00:00
Carlos Garnacho
e66f4396ee x11: Avoid GDK API in X11 selections
Use MetaX11Display's Display, and XInternAtom/XGetAtomName to
convert between Atoms and strings.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2836>
2023-02-10 20:43:11 +00:00
Carlos Garnacho
9ff008e31b x11: Do not use buffer size on configure requests unless managed
Windows that are decorated may get configure requests before
the frames client created a corresponding frame window and Mutter
reparented the window.

Since the configure request results in the buffer size being
used to update the window size and the window does not have a
buffer yet, these requests could mistakenly result in the client
window being given a minimal size.

In these situations, do not use the buffer size but the given
size. The window still has to undergo frame creation and
reparenting before being shown for the first time.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2588
Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2605
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2808>
2023-02-10 15:40:00 +00:00
Carlos Garnacho
8530e471bc x11: Avoid sloppy/mouse mode handling on Wayland
On Wayland sessions, this handling is unnecessary and even prone
to confusion (e.g. crossing serials are only ignored in X11-exclusive
paths, so this handling competes directly with that in MetaWaylandPointer).

Avoid it entirely there, so MetaWaylandPointer can figure out
sloppy/mouse mode focus for all Wayland/Xwayland surfaces.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2828>
2023-02-09 14:38:39 +01:00
Carlos Garnacho
caf68a6563 x11: Handle accounting of ignored serials in X11 code
Move this out of MetaDisplay.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2828>
2023-02-09 14:38:39 +01:00
Carlos Garnacho
67a69709b9 core: Make "adding ignored serials" private API
This sounds unnecessary from shell code, and possibly even harmful.
Make this API private and move it into the X11 parts where it belongs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2828>
2023-02-09 14:38:39 +01:00
Carlos Garnacho
3356823ca2 x11: Reset ignored crossing serials from X11 code
They are only ever set and ignored from X11 code, we can also move
this bit of sloppy/mouse mode handling to the X11 parts.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2828>
2023-02-09 14:38:39 +01:00
Carlos Garnacho
b321d545b1 x11: Bypass GTK on XFixesSelectionNotify
In GTK this is only used for GTK clipboard/DnD selections, and
finding out whether there is a compositing manager in charge.
In Mutter, we manage our own clipboard/DnD selections, and don't
perform any rendering through GTK in the Mutter process.

So there's no special reason to let these events go through GTK,
and (related to xwayland-on-demand?) there may be race conditions
in the handling of the second feature.

There's a chance this race condition may be in Mutter, but it
does not sound worth to chase this race condition when we can
let GTK ignore these events. And it does not make sense to "fix"
gtk3 for this Mutter-only condition, when we intend to eventually
avoid it.

So, take the easy path and ignore these events.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2617
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2831>
2023-02-09 13:04:22 +00:00
Carlos Garnacho
d687e5634d core: Pass device/sequence on meta_window_begin_grab_op()
This is a public API change. Add device/sequence parameters to this
operation, so that window dragging and resizing can stick to one
set of pointing events of them all.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
bec8a5860a core,wayland,compositor,x11: Migrate to MetaWindowDrag
Flip the switch in using MetaWindowDrag, leaving display grab
ops and a bunch other code unused. Some places checked the grab op
and/or window in complex ways, others just checked for grab existence
and should now look for clutter ones, and others already were already
doing this in addition.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
bb9cab1491 x11: Move away from MetaEventRoute
Nowadays, there's just 2 types of it, and can be pretty much
solved with a META_GRAB_OP_NONE check.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
12773cf8e2 window: Drop frame_action argument from meta_window_begin_grab_op()
The final effect of this boolean can now be expressed through the
META_GRAB_OP_WINDOW_FLAG_UNCONSTRAINED flag to MetaGrabOp. Use that
in the relevant places, and drop the argument.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
f62200a17b core: Drop unused arguments to meta_display_grab_op()
Now that it is called from a single place, there's a few arguments
that are unnecessary:

- button and modifiers are unused
- already_grabbed was originally added to handle grab transitions between
  window menus (GtkMenus, back in the day) with display grabs. It's no
  longer necessary now
- frame_action can be passed through the META_GRAB_OP_WINDOW_FLAG UNCONSTRAINED
  flag

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +00:00
Carlos Garnacho
8685a706cc x11: Use meta_window_begin_grab_op() to begin window grab
Move away from meta_display_begin_grab_op().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2683>
2023-01-30 10:56:29 +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
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
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
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
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
Bilal Elmoussaoui
6e818c8c38 build: Allow disabling xwayland
Mostly moving things around to allow a build without xwayland.
Note that more work might still be needed once the x11 build option
lands as that would allow us to have a proper xwayland only build
without the x server part.

Related: https://gitlab.gnome.org/GNOME/mutter/-/issues/2272
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2399>
2023-01-03 20:45:04 +00:00
Bilal Elmoussaoui
8b42bc77dc build: Make GTK dependency specific to X11
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:13:54 +01:00
Bilal Elmoussaoui
64ee8d02f7 core: Add a in-tree copy of GtkBorder
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:13:54 +01:00
Bilal Elmoussaoui
fb4161853f cleanup: Make GDK dependency specific to X11
This way, the dependencies on GTK/GDK could be completely dropped if
built with Wayland only.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2407>
2022-12-22 15:09:03 +01:00
Jonas Ådahl
4b3cab2cca compositor: Don't make internal API public
Things like meta_compositor_destroy() and meta_compositor_add_window()
isn't intended to be used externally, and if they was, things would
probably fall apart rather quickly.

MetaCompositor also isn't introspected, meaning things that technically
belong to the compositing parts isn't easily available via some object,
but much take detours via other objects like MetaDisplay.

So move the API intended for internal usage to compositor-private.h, and
leave API that is meant to be expose in the public compositor.h.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
3a1ded73ad x11/session: Make state tracking context aware
Instead of passing around state using GINT_TO_POINTER() pass around a
state struct that also carries a pointer to the context. This allows
avoiding using old singletons for getting a window list.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
1b737190cc x11: Setup and user ownership chains
On the path towards clear ownership chains and always using them to find
other components, do the same for X11 client support paths too.

x11-display: Don't get backend from signleton

x11/selection: Don't get display from singleton

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
e5908f5752 startup-notification/x11: Let the libsn user handle API annoyances
The API has no concept of user data, and requires the user to some how
get an instance without context, i.e. via static globals. Limit this to
the file where this is needed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
2731f0cda4 wayland: Setup and use ownership chains
As elsewhere, make sure objects that need to have a ownership up to the
context, and use this ownership chain to find relevant components, such
as the backend or the Wayland compositor object instance.

wayland/data-device: Hook up data devices to seats

They are tied to a seat - make that connection in struct fields too, so
that related objects can get to the context via it.

wayland: Don't get Wayland compositor via singleton getter

This means via the ownership chain or equivalent.

xwayland: Hook up manager to Wayland compositor

Same applies to the drag-n-drop struct.

xwayland: Make X11 event handling compositor instance aware

This avoids finding it via singletons in the callee.

xwayland: Don't get Wayland compositor from singleton

xwayland: Pass manager when handling dnd event

window/xwayland: Don't get Wayland compositor from singleton

xwayland/grab-keyboard: Don't get backend from singleton

xwayland: Don't get backend from singleton

wayland: Always get the backend from the context

This means traveling up the ownership chain or equivalent when
necessary.

wayland: Hook up data devices, offers and sources to the compositor

This allows tying them to a context without going through any
singletons.

wayland: Don't get display from singleton

xwayland: Don't get display from singleton

tablet: Don't get display from singleton

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
dd2beae6a8 core: Setup and use ownership chains
As with other parts, make objects have the ability to walk up the
ownership chain to the context, to get things like the Wayland
compositor or backend instances.

Contains these squashed commits:

display: Don't get backend from singleton

window: Don't get backend from singleton

keybindings: Don't get backend from singleton

workspace: Don't get backend from singleton

display: Don't get Wayland compositor from singleton

selection: Add display getter

context/main: Get backend directly from the context

clipboard-manager: Don't get display from singleton

stack-tracker: Don't use singleton MetaLater API

startup-notification: Hook up sequences and activations to display

This allows using context aware API directly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 15:13:48 +01:00
Jonas Ådahl
26dce13c52 x11-display: Remove init GDK method from public APi
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2718>
2022-12-17 13:52:50 +00:00
Carlos Garnacho
5cfc626bfb x11: Drop unused function
The meta_prop_get_motif_hints() function was only used in the
old MetaUI frames code. The remaining code in mutter accesses
directly the MetaPropValue when loading properties for a window,
and does not use this API call.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2741>
2022-12-09 16:28:33 +00:00
Carlos Garnacho
66b1f43967 Revert "x11: Move Motif WM hints to a separate header"
Since we use XCB in the Mutter side, but Xlib in the frames client,
we cannot share the same struct definition since both libraries
will expect different type lengths (respectively, 32-bit ints vs.
longs).

Revert the changes that made both executables share the same
struct, since not both of them can get it right (and retrieve
correctly the struct with the contained flags) in reading the
Motif WM hints.

This reverts commit 2fb3c5a4f5.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2741>
2022-12-09 16:28:33 +00:00
Carlos Garnacho
2fb3c5a4f5 x11: Move Motif WM hints to a separate header
These are now referenced on the frames client side (in order to
track deletable state from the client window) and the mutter side
(pretty much everything else, like figuring out if a window wants
WM decorations).

It makes sense to make this a separate header, so that we don't
need to doubly define these flags/structs.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2735>
2022-12-05 12:40:53 +01:00
Bram Stolk
7a103bbfe9 core: Avoid generating XEvent from uninitialized data
The uninitialized fields in this event causes use of uninitialised
data as seen in valgrind:

==71864== Syscall param writev(vector[0]) points to uninitialised byte(s)
==71864==    at 0x5026EBD: __writev (writev.c:26)
==71864==    by 0x5026EBD: writev (writev.c:24)
==71864==    by 0x6482A3B: UnknownInlinedFun (xcb_conn.c:296)
==71864==    by 0x6482A3B: _xcb_conn_wait.part.0 (xcb_conn.c:551)
==71864==    by 0x6482BAF: UnknownInlinedFun (xcb_out.c:469)
==71864==    by 0x6482BAF: _xcb_out_send (xcb_out.c:470)
==71864==    by 0x6483DD7: UnknownInlinedFun (xcb_out.c:416)
==71864==    by 0x6483DD7: xcb_writev (xcb_out.c:409)
==71864==    by 0x53B79B4: _XSend (xcb_io.c:587)
==71864==    by 0x53BBF38: _XReply (xcb_io.c:679)
==71864==    by 0x53AFFC9: XQueryTree (QuTree.c:47)
==71864==    by 0x4982A5F: query_xserver_stack (stack-tracker.c:508)
==71864==    by 0x4EA1F5F: g_closure_invoke (gclosure.c:832)
==71864==    by 0x4ECFD45: signal_emit_unlocked_R.isra.0 (gsignal.c:3796)
==71864==    by 0x4EC0129: g_signal_emit_valist (gsignal.c:3549)
==71864==    by 0x4EC03B2: g_signal_emit (gsignal.c:3606)
==71864==  Address 0x287d5900 is 32 bytes inside a block of size 16,384 alloc'd
==71864==    at 0x4849444: calloc (vg_replace_malloc.c:1340)
==71864==    by 0x53A5FE8: XOpenDisplay (OpenDis.c:240)
==71864==    by 0x6100E3C: _gdk_x11_display_open (gdkdisplay-x11.c:1565)
==71864==    by 0x60CF675: gdk_display_manager_open_display (gdkdisplaymanager.c:462)
==71864==    by 0x49D59F1: open_gdk_display (meta-x11-display.c:1041)
==71864==    by 0x49D5D64: meta_x11_display_new (meta-x11-display.c:1156)
==71864==    by 0x49564AD: meta_display_init_x11_finish (display.c:743)
==71864==    by 0x495679D: on_x11_initialized (display.c:818)
==71864==    by 0x4D67558: g_task_return_now (gtask.c:1232)
==71864==    by 0x4D67782: UnknownInlinedFun (gtask.c:1301)
==71864==    by 0x4D67782: g_task_return (gtask.c:1258)
==71864==    by 0x495663C: on_xserver_started (display.c:788)
==71864==    by 0x4D67558: g_task_return_now (gtask.c:1232)
==71864==  Uninitialised value was created by a stack allocation
==71864==    at 0x49D4A59: take_manager_selection (meta-x11-display.c:640)
==71864==

To fix this, fully initialize the event struct before sending it.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/2535
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2724>
2022-12-01 20:42:36 +00:00
Carlos Garnacho
20bf7f5ceb x11: Delay next resize op after sync resize until frame is painted
Since the frames are now rendered by a separate process, we no longer
can guarantee at this point that all updates were handled. Engaging
in a new synchronous resize operation will again freeze the actor,
so sometimes we are left with a not-quite-current buffer for the
frame+window surface.

In order to ensure that the right changes made it onscreen, delay
this next synchronous resize step until the moment the surface was
repainted. This avoids those glitches, while still ensuing the
resize operation ends up in sync with the pointer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:53 +00:00
Carlos Garnacho
84785951fd x11: Remove MetaX11WindowControl
These interfaces are no longer used, in favor of CSD-alike messaging
between the frames client and Mutter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:53 +00:00