1
0
Fork 0
Commit graph

61 commits

Author SHA1 Message Date
Bilal Elmoussaoui
94f9d88371 x11: Drop error trap helpers
They are no longer that useful as they end up calling
mtk functions nowadays

Followup of https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3230

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3483>
2024-01-10 13:58:18 +00:00
Bilal Elmoussaoui
57b59f95a6 x11: Drop unused private functions
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3492>
2024-01-09 13:14:35 +00:00
Carlos Garnacho
7fbc0ccc01 x11: Hook X11 focus management to MetaDisplay signal
This makes the MetaX11Display indirectly react to MetaDisplay changes,
rather than having the MetaDisplay also drive the MetaX11Display focus.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3269>
2023-12-18 17:55:27 +00:00
Carlos Garnacho
a36616f81d core: Drop focus_frame argument from meta_display_set_input_focus()
Sort that out in the X11 display, where it matters, without the need
of this argument in generic API.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3269>
2023-12-18 17:55:27 +00:00
Carlos Garnacho
4179679239 x11: Adopt code to focus stage window on Clutter key focus
We currently offer the mechanism for GNOME Shell to implement, and
while this is not exercised often (our entries are typically surrounded
by a ClutterGrab ensuring key events, so this is reserved to grab-less
entries, probably there are some in extensions), this is arguably
something Mutter should cover by itself without GNOME Shell guidance.

This is only necessary on the X11 backend, although it is conceptually
more tied to the MetaX11Display connection, so perform the focus
tracking there only if not running as a Wayland compositor (i.e. --x11).

This avoids the only case where the low-level
meta_x11_display_set_input_focus_xwindow() function is used, or rather
makes it completely a MetaX11Display implementation detail, leaving
only the MetaDisplay API as the high-level entry points to handle
window key focus.

The public API that allowed GNOME Shell to implement these mechanisms
is also gone in this commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3269>
2023-12-18 17:55:27 +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
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
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
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
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
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
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
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
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
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
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
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
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
Carlos Garnacho
92feea3033 ui: Excise old frames UI
This is no longer used, in favor of the standalone frames client.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1077
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:53 +00:00
Carlos Garnacho
6a80bc3a54 x11: Decouple sync alarms from window XIDs
Store the alarms in a different hashtable, and look up the MetaSyncCounter
right away. It so far avoids the MetaWindow middle man, but will also be
simpler when each window can possibly have more than one active alarms.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:53 +00:00
Carlos Garnacho
3994297429 x11: Integrate frames client into Mutter
Replace the in-process implementation of frames with the external
frames client.

When a client window is created and managed by Mutter, Mutter will
determine whether it is a window that requires decorations and
hint the creation of a frame for it by setting the _MUTTER_NEEDS_FRAME
property on the client window.

After the frames client created a window that has the _MUTTER_FRAME_FOR
property, Mutter will proceed to reparent the client window on the
frame window, and show them as a single unit.

Rendering and event handling on the frame window will be performed by
the external client, Mutter is still responsible for everything else,
namely resizing client and frame window in synchronization, and
managing updates on the MetaWindowActor.

In order to let the frame be managed by the external client, Mutter
needs to change the way some properties are forwarded to the client
and/or frame windows. Some properties are necessary to keep propagating
to the client window only, some others need to happen on the frame
window now, and some others needs to be propagated on both so they
are synchronized about the behavior.

Also, some events that were previously totally unexpected in frame
windows are now susceptible to happen, so must be allowed now.

MetaFrame in src/core/frame.c now acts as the wrapper of foreign
windows created by the frames client, from the Mutter side. Location,
size, and lifetime are still largely in control of Mutter, some
details like visible/invisible borders are obtained from the client
instead (through the _MUTTER_FRAME_EXTENTS and _GTK_FRAME_EXTENTS
properties, respectively).

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2175>
2022-12-01 20:10:53 +00:00
Jonas Ådahl
dec3c49e5a tests/test-client: Handle alarm event processing automatically
Instead of having users of the test client manually deal with alarm
filters, let the test client automatically add itself as filters. This
changes the MetaX11Display a bit, to handle an array of filters instead
of a single filter.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2704>
2022-11-21 16:30:05 +00:00
Jonas Ådahl
b8cdc91c19 x11-display: Clean up GdkDisplay opening
It exposed unnecessary public and private API, and used a global static
variable instead of a return value, none which was necessary. Remove
both API and use a return value for communicating to the caller.

This doesn't remove a public symbol, lets do that for GNOME 44.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2619>
2022-09-19 14:46:00 +00:00
Jonas Ådahl
0debb24e12 barriers: Make barriers fully part of the backend
Prior to this commit, barriers were created with a MetaDisplay pointer,
despite being entities related and owned by the backend. In the X11
case, it was also not hooked up to the backend X11 connection, but the
clutter one, meaning for example that the logic was active (but dormant)
also for the Xwayland connection.

Fix this by moving X11 barrier management and event processing fully to
the backend. Also replace passing a display pointer with passing a
backend pointer. Keep the display pointer around for a release, but mark
it as deprecated.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2442>
2022-07-26 20:27:24 +00:00
Sebastian Keller
e1c4e55880 x11: Handle selection windows being destroyed before new selection
Wine destroys its old selection window immediately before creating a new
selection. This would trigger restoring the clipboard, which would
overwrite the new selection with the old one. The selection window
however can also be destroyed as part of the shutdown process of
applications, such as Chromium for example. In those cases we want the
clipboard to be restored after the selection window has been destroyed.

Solve this by not immediately restoring the clipboard but instead using
a timeout which can be canceled by any new selection owner, such as in
the Wine case.

Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/1338
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1369
2020-07-27 08:34:40 +00:00
Jonas Ådahl
e17d70a592 x11/window-controls: Pass around MetaX11Display directly
Instead of passing around an X11 Display pointer that is retrieved from
the default Gdk backend, then finding the MetaX11Display from said X11
Display, pass the MetaX11Display directly.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/854
2019-10-15 07:17:29 +00:00
Carlos Garnacho
6922f0e16a x11: Minor refactor of input focus handling code
Instead of open coding the X11 focus management in display.c, expose
it as a single function with similar arguments to its MetaDisplay
counterpart. This just means less X11 specifics in display.c.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/751
2019-09-13 20:55:57 +00:00
Jonas Ådahl
8ee00cee60 compositor/x11: Move stage input region setting to MetaX11Display
It doesn't use anything specific to MetaCompositor, and
MetaCompositorX11 isn't exposed, so move it to MetaX11Display.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/727
2019-08-19 08:44:58 +00:00
Carlos Garnacho
879f5f0dbb x11: Add "closing" flag to MetaX11Display
So code not directly in dispose() can know to avoid certain things
when the X11 display is about to close.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
9109fa0eb8 x11: Add meta_x11_get_display_name() function
Instead of poking the DISPLAY envvar at places.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/709
2019-08-06 00:41:36 +00:00
Carlos Garnacho
86de79cfc5 core: Untangle input focus management
In all places (including src/wayland) we tap into meta_x11_display* focus
API, which then calls meta_display* API. This relation is backwards, so
rework input focus management so it's the other way around.

We now have high-level meta_display_(un)set_input_focus functions, which
perform the backend-independent maintenance, and calls into the X11
functions where relevant. These functions are what callers should use.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
1d77641f0b x11: Separate X11 focus handling into MetaX11Display method
Updating the MetaWindow focus and the X Window focus is interrelated but
independent. Call one after the other in the places we handle window focus
changes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
ef074ea510 x11: Add MetaX11Stack object
This object takes care of the X11 representation of the window stack,
namely the _NET_CLIENT_LIST and _NET_CLIENT_LIST_STACKING root window
properties.

This code has been lifted from src/core/stack.c into src/x11 as it's
dependent on the X11 display availability. This also leaves MetaStack
squeaky clean of x11 specifics.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
0200f4fcd9 x11: Move focus sentinel to MetaX11Display
This focus sentinel is a mechanism to avoid some X11-specific race
conditions in focus-follows-pointer, using X11 mechanisms. Move it to
MetaX11Display altogether.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:30 +00:00
Carlos Garnacho
02c99524bf Make MetaSelection, MetaSelectionSource and MetaMemorySelectionSource public
This exposes the base so that we can reimplement StClipboard on top. Some
gtk-docs have been added for documentation and introspection purposes.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:31:45 +02:00
Carlos Garnacho
37144f0609 x11: Add X11 selection management
This code takes care of both setting up X11 selection sources whenever
X11 clients claim selection ownership, and claiming selection ownership
on a mutter X11 window whenever other selection sources claim ownership.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:22:45 +02:00
Carlos Garnacho
c95db7c542 x11: Add X11 MetaSelectionSource implementation
This object represents the selection ownership from an X11 client. The
list of supported targets is queried upfront, so its initialization is
asynchronous. Requests to read contents from the selection will hand
a MetaX11SelectionInputStream.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 16:22:08 +02:00
Carlos Garnacho
156980eff9 x11: Add X11 selection input/output streams
These are rip off of GTK+ ones, with some adaptions to integrate them in
mutter event dispatching code and make them easier to use in future
commits.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/320
2019-05-02 15:40:13 +02:00
Florian Müllner
7abceb434d x11-display: Split out restoring of active workspace
Splitting out the X11 display initialization from display_open() broke
restoring the previously active workspace in two ways:

 - when dynamic workspaces are used, the old workspaces haven't
   been restored yet, so we stay on the first workspace

 - when static workspaces are used, the code tries to access
   the compositor that hasn't been initialized yet, resulting
   in a segfault

Fix both those issues by splitting out restoring of the active workspace.

https://gitlab.gnome.org/GNOME/mutter/issues/479
2019-03-04 19:42:00 +00:00
Marco Trevisan (Treviño)
e02fef8e2f meta: Hide libmutter symbols by default and selectively export them
Make meson link libmutter using -fvisibility=hidden, and introduce META_EXPORT
and META_EXPORT_TEST defines to mark a symbols as visible.
The TEST version is meant to be used to flag symbols that are only used
internally by mutter tests, but that should not be considered public API.

This allows us to be more precise in selecting what is exported and what is
not, without the need of a version-script file that would be more complicated
to maintain.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/395
2019-01-23 14:18:13 +01:00
Carlos Garnacho
26fbd56a95 x11: Refactor the X11 startup notification bits into src/x11
Only one little bit left in MetaDisplay, because SnStartupSequence
is exposed in API there. These bits will be removed in future
commits.
2018-11-23 12:27:13 +00:00
Jonas Ådahl
176e6fcded x11: Require XInput 2.3 at build time
The needed libXi version was released 5 years ago, so should be fine.
2018-11-06 17:17:36 +01:00
Andrea Azzarone
31f525d566 x11: close display in an idle function
Closing a GdkDisplay during an event handler is not currently supported by Gdk
and it will result in a crash when doing e.g. 'mutter --replace'. Using an idle
function will close it safely in a subsequent main loop iteration.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/issues/595
2018-11-05 12:04:01 +00:00
Armin Krezović
d4c4d6e64d Split GDK initialization from MetaUI
Get rid of the deprecated gdk_display_get_default_screen ()

https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:16 +02:00
Armin Krezović
9333a6da75 Make bell and libstartup-notification bits work without X11
https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:16 +02:00
Armin Krezović
8adab02757 Make workspace management work without X11
https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:16 +02:00