1
0
Fork 0
Commit graph

2748 commits

Author SHA1 Message Date
Jonas Ådahl
4bb8b2a9f3 util: Remove unused logging functions
They are tunneled through g_message() now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2094>
2021-11-21 20:53:33 +00:00
Jonas Ådahl
59166d745e util: Implement meta_topic() using g_message()
This will get us things like timestamps.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2094>
2021-11-21 20:53:33 +00:00
Jonas Ådahl
8c8bbb8008 util: Remove push/pop no msg prefix logging
Used to log multiple line entries. Just make continue prefix things, no
need to mess with maybe-prefixing; it'll just complicate using some less
custom logging functionality.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2094>
2021-11-21 20:53:33 +00:00
Sebastian Keller
6902a724ce window: Store unconstrained_rect everytime a size is requested
Currently the stored unconstrained_rect is only ever updated if there
was a move, resize or state change according to the move_resize_internal
implementation.  For Wayland windows however resizes or state changes
are done in two steps, first the new configuration is sent to the client
and then once client acknowledges it, it is set on the mutter side in
another move_resize_internal call. Only the second call would result in
the unconstrained_rect being updated.

This started causing problems when unfullscreening windows was
immediately followed by a strut change. These strut changes started
happening in gnome-shell due to the visibility of the panel now being
considered for the struts and the presence of a fullscreen causing it to
be hidden until unfullscreen. In this situation first the unfullscreen
would resize the window to its pre-fullscreen size as expected, but then
the strut change triggers another window resize. This window resize is
based on the stored unconstrained_rect, which is still at the fullscreen
size because the unfullscreen resize only has sent its configuration,
but it has not been acknowledged yet. As a result the strut change
causes a resize to the fullscreen size which due to the constraints now
looks like a maximized window.

To fix this always update the unconstrained_rect when the requested size
has changed, but not when a previous request has been acknowledged
unless it is originating from the client itself.

If this included the move_resize_internal call from acknowledging the
size as well, it would be possible for this to be delayed long enough on
the client side to overwrite an intermediate resize originating from
mutter. And if this did not include resizes originating from the client,
clients would not be able to set an initial window size.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2066>
2021-11-17 09:42:13 +00:00
Sebastian Keller
8eb268fc3b window/wayland: Differentiate between requested and direct resizes
meta_window_wayland_finish_move_resize() is called for both, finishing
a resize that has been requested through/by mutter and for resizes
directly done by the client. This introduces a CLIENT_RESIZE flag to
differentiate the former from the latter. Having this distinction is
required to know what the last requested size by either the client or
mutter is while ignoring older requests that might only have been
applied now.

This excludes client resizes when there are still pending
configurations, because the resize is known to be only temporary.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2066>
2021-11-17 09:42:13 +00:00
Mark
8e1a125f70 startup: Optionally run (and exit with) a command
Treat the first non-option as a command, and any others as its CLI
arguments. Run the command with those arguments; communicate its exit
status (if nonzero); and exit with it. Document this added functionality
in the manpage and usage description.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1981
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1982>
2021-11-04 04:18:32 -05:00
Carlos Garnacho
5125f66afa core: Use b/w unicode for tablet mode OSD
This unicode was initially meant to be b/w, but fonts and pango
eventually had another plan and we ended up with color glyphs
being used here, so we get strings like "". Change the
unicode used to ensure these are simpler b/w glyhps like
"● ○ ○ ○" that are easier to read on the OSD (and maybe even a
bit less ugly).

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4733
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2064>
2021-10-28 10:56:26 +00:00
Jonas Ådahl
b4fe1fdd95 xwayland: Make setup/teardown a bit more symmetrical
We setup Xwayland in an early phase of the X11 display, before we had a
MetaX11Display, and teared down in a couple of places happening when
tearing down the Xwayland integration if the X server died or
terminated. It was a bit hard to follow what happened and when it
happened. Attempt to clean this up a bit, with things being structured
as follows:

 * Early during X11 display connection setup, only setup the rudimentary
   X11 hooks, being the libX11 error callbacks, and adding the local
   user to XHost.

 * Move "initialize Xwayland component" code to a new
   'x11-display-setup' signal handler. Things setup here are cleaned up
   in the 'x11-display-closing' handler.

 * Connect to 'x11-display-setup' and 'x11-display-closing' up front,
   and stay connected to these two.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1796>
2021-10-26 16:54:58 +02:00
Carlos Garnacho
0a7547a195 core: Drop code to do edge resistance on timeouts
This has been long indirectly disabled (these timeouts were defined
as 0ms long, thus not set), so edge resistance timeouts can be safely
deemed dead code.

CID: #1418253
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-25 15:45:35 +02:00
Carlos Garnacho
70a5f29ef1 core: Drop repeated early return condition in function
We are already checking for prev_state == META_SEQUENCE_PENDING_END,
no need to do it twice.

CID: #1418251
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2061>
2021-10-24 19:16:42 +02:00
Sebastian Keller
c2bb80a26d util: Export and annotate meta_get_clutter_debug_flags
This will be useful for getting the initial state when adding switches
for these flags to looking glass.

Related: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/3968
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2028>
2021-10-18 16:46:59 +00:00
Jonas Ådahl
3a6f6c264d util: Add 'render' debug topic
Meant for MetaRenderer and everything related that deals with turning
composited frames, or client buffers, into mode set updates. This is
slightly related to the debug topic 'kms' is meant for the KMS details.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:14:21 +02:00
Jonas Ådahl
bd841e8dc5 util: Fix placement of META_DEBUG_WAYLAND in switch statement
When added, it was added to the wrong place; fix that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1854>
2021-10-18 17:13:23 +02:00
Sebastian Keller
e38db1237d window: Don't change workspaces of unmanaged windows
If the ancestor a window is transient for has already been unmanaged
when the window is activated via meta_window_activate_full while its
transient_for property still points to that ancestor, this will cause
the already unmanaged ancestor to get added to the windows workspace.
This is after the ancestor had its workspace set to NULL when it was
unmanaged, causing this to look like an actual workspace change. Once
the window has been added to the workspace, it will never be removed
again, because the it has already been unmanaged. This confuses things
like the shell window tracker and leads to phantom windows being
considered present for apps that are not even running anymore.

Fixes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4184
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2003>
2021-09-29 09:34:30 +00:00
Jonas Ådahl
fca9010963 mutter: Add signal handlers
With the introduction of MetaContext, the responsibility for handling
signals was changed to the application (e.g. GNOME Shell) using
libmutter. What wasn't fixed was making the stand-alone mutter do the
equivalent as well. This commit fixes this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2007>
2021-09-22 11:38:17 +00:00
Corentin Noël
f140d01df2 context: Add some missing introspection data
Allows to use option groups/entries from the introspection.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1976>
2021-09-16 07:23:24 +00:00
Nishal Kulkarni
7555688d8d display: Set xattr on focus window cgroup dir
Added a function `meta_window_set_inactive_since` it sets
xattr on the cgroup directory for the given MetaWindow.

Resource management daemons can then monitor these changes on xattr
and make allocation decisions accordingly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1960>
2021-09-02 21:54:30 +00:00
Nishal Kulkarni
c2efe25597 window: Add cgroup management to MetaWindow
Currently the only way to get cgroup for a MetaWindow is to get it's
PID and perform a bunch of file accesses and string manipulations.
This is especially not feasible if we want to get the cgroup every
time a MetaWindow has gained or lost focus.

A solution to this is to cache the GFile for a cgroup path.
The creation and access of this GFile is handled by
`meta_window_get_unit_cgroup` function.

`meta_window_unit_cgroup_equal` is a utility function which allows
us to compare whether two MetaWindows belong to the same cgroup.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1960>
2021-09-02 21:54:30 +00:00
Florian Müllner
d17e9adc73 context: Add (hidden) --unsafe-mode option
When running gnome-shell, it is possible to toggle unsafe-mode in
looking glass. We'll eventually start using the property in mutter
as well, so to make stand-alone debugging easier, also expose it
as a hidden command line option.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1983>
2021-09-02 16:58:46 +00:00
Florian Müllner
c62e86cb23 context: Add :unsafe-mode property
We are going to restrict several sensitive D-Bus APIs to a set
of allowed callers (like Settings or portal implementations).

Add an :unsafe-mode property to the context to allow turning off
those restrictions temporarily, in order to not get in the way
of development/debugging.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1983>
2021-09-02 16:58:46 +00:00
Florian Müllner
41d1a8407e keybindings: Remove 'panel-run-dialog' handler
There is very little point in sending an X11 client message to
gnome-panel in case gnome-shell isn't handling the binding. We
can just as well do nothing, so do exactly that.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1886>
2021-08-30 21:43:34 +00:00
Florian Müllner
b5ba216163 keybindings: Remove support for 'panel-main-menu' binding
Nothing uses it anymore, and probably nobody expects mutter to
send an X11 client message to gnome-panel in that case.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1886>
2021-08-30 21:43:34 +00:00
Alexander Mikhaylenko
ed391eb06b window: Make default focus window on each workspace appear focused
Makes workspace transitions in gnome-shell look more seamless, since
both outgoing and incoming workspace have focused windows.

This is only done for click focus mode, since it's not known which
window would be focused for the other modes.

Track the state and recompute it when it changes, to avoid redrawing
the windows needlessly.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/850>
2021-08-12 21:41:40 +05:00
Alexander Mikhaylenko
7afefbbb61 workspace: Add meta_workspace_get_default_focus_window()
Each workspace has a window that will be focused when switching to that
workspace. Add a function to retrieve that window.

This is only relevant for click-to-focus focus mode, since with the two
other modes no window will be focused upon switching, and will only gain
focus when hovered.

This will be used in the next commit to make this window appear focused.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/850>
2021-08-12 21:39:05 +05:00
Alexander Mikhaylenko
448ffaefc5 stack: Check workspace in get_default_focus_window()
Check against the window argument, instead of active workspace.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/850>
2021-08-12 21:39:05 +05:00
Florian Müllner
eed1db4379 window: Add meta_window_lower_with_transients()
The only thing x11-specific about the existing code is that it is only
used to implement titlebar actions on server-side decorations.

We are about to bring that functionality to wayland, so move the code
into MetaWayland.

https://gitlab.gnome.org/GNOME/mutter/-/issues/602

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1944>
2021-08-04 14:41:43 +00:00
Marco Trevisan (Treviño)
58c2f423f7 boxes: Add function to check if rectangle is adjacent to region
We may need to check if rectangles region has adjacent neighbors and
so if there are no gaps in between monitors.

This can be done by checking if each monitor is adjacent to any other in
the same region.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/522>
2021-08-04 14:02:16 +00:00
Pascal Nowack
537e2dfafe core/selection: Cancel selection transfer requests after a timeout
When a selection owner advertises a mime type, but does not provide the
content upon a request for the mime type content, the requesting side
might wait indefinitely on the content.
To avoid this situation, add a timeout source, which will cancel the
selection transfer request after a certain timeout (15 seconds) passed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1874>
2021-07-28 15:26:04 +00:00
Carlos Garnacho
dc6d3cead2 backends: Shuffle ClutterBackendX11 code into MetaClutterBackendX11
We have a Clutter implementation of the X11, just to subclass it in
our backends. Move the implementation entirely to src/backends/x11.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Carlos Garnacho
0ac257212e core: Add private utility function to get Clutter debug flags
This will be used to fetch the debug flags from backend code.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1862>
2021-07-16 19:08:06 +02:00
Jonas Ådahl
4b6631338e util: Add 'backend' debug topic
Meant for backend things that are not large enough to warrant their own
topic.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1931>
2021-07-16 18:17:04 +02:00
Jonas Ådahl
8a4aa92a54 context: Move the signal handling and dir management to user
Signals and changing current directory is a process global action, thus
isn't that suitable for a library. Thus, move that responsibility to
gnome-shell.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 13:40:34 +02:00
Jonas Ådahl
724a7eee74 tests: Move 'wait-for-X11-display' helper to MetaContextTest
Gets rid of a un-prefixed helper function relying on a global singleton.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:42:40 +02:00
Jonas Ådahl
ff0afb186a context: Move 'replace-current-wm' tracking to the context
This move yet another scattered global static variable into the
context's control.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
50ed027b6f context: Move X11 display policy under the context
The context implementations already effectively dictate the policy, so
let them do it more directly instead of going indirectly via global
variables.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
e62f7e2910 context: Allow controlled destruction
Add a method meta_context_destroy() that both runs dispose and unrefs
the context. Tear down is moved to dispose() so that things owned by the
context are destroyed when calling meta_context_destroy(), or when the
last reference is released.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
2deb751fd9 context: Add explicit state tracking
This will help finding out when things happen in the wrong order.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
c1beb204c2 x11-display: Get _GNOME_WM_KEYBINDINGS from the context
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
7d0aaa14d1 x11-display: Get _NET_WM_NAME from context
It's equivalent to the name that was passed when the context was
created.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
d3b7d8df0d wayland: Initialize in a single step
Before we first created the MetaWaylandCompositor instance, which would
repare Clutter/Cogl so they could initialize and turn on Wayland display
server features, then later to initialize the rest. Now that part is
done by the Wayland infrastructure itself, so we don't need the early
initialization. Simplify things a bit by centralizing it all into a
single meta_wayland_compositor_new() call.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
0330ce1f15 context: Make the context own MetaWaylandCompositor
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
6768b509ea Remove meta_quit()
It is no longer used, so remove it. This also removes the intermediate
MetaContext global singleton, as it is no longer needed.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:37 +02:00
Jonas Ådahl
122aa94642 x11/session: Use MetaContext to terminate instead of meta_quit()
This is done by keeping around a pointer to MetaContext as
"client_pointer" (which is practically the same as "user_pointer"
elsewhere), as well as creating a `MetaIceConnection` wrapper for ICE
connections.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:34:36 +02:00
Jonas Ådahl
68b376a944 context: Make context owner of MetaDisplay
It may still be closed from elsewhere, e.g. when being replaced, but the
reference is owned by MetaContext instead of itself.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
1972d4ec90 main: Remove now unused functions used for running mutter
The way to do this now is using a MetaContext.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
ed53dd90f3 context: Add way to add custom option group
This will be used by gnome-shell.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
d76743736f context: Add way to set plugin GType instead of name
Will be used by gnome-shell.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
fe0ce2814e main: Remove meta_test_init()
This was the last user of the configuration override API, so that goes
as well.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
725510ea29 mutter: Port to MetaContext
Uses the new MetaContextMain, replacing piece by piece "real display
server" setup done using mostly main.c functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
aa306ac3ca Introduce MetaContextMain
This object intends to replace the scattered functions that are used to
make up what is effectively a "mutter context". It takes care of the
command line arguments that is now done in main.c, persistant virtual
monitors, and the like.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
2712555c71 display: Don't include sn.h from display-private.h
It has some annoying macro requirement to not nag about API stability;
try to limit its exposure.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
e09de6787f context: Handle dealing with option entries
Users can add option entries, and it'll be part of the configuration
phase.

Create the main group manually to be able to set a user_data pointer;
this will be required to not have to rely on globals when parsing
options using a callback.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 11:25:21 +02:00
Jonas Ådahl
6732e3e585 main: Temporarily tie meta_quit() to meta_context_terminate*()
Makes it possible for mutter internally to use meta_quit() both if we're
running using a MetaContext or the scattered functions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 10:59:40 +02:00
Jonas Ådahl
2e784e23a2 context: Add 'notify_ready()' vfunc and method
This intends to replace the call to `meta_register_with_session()` that
deals with X11 session management, and is called when the user is
"ready". In thet test context, doing that makes no sense, so make it a
no-op.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 10:59:40 +02:00
Jonas Ådahl
8bf7d5c155 context: Init debug utils during setup phase
Is currently done during meta_init().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 10:59:40 +02:00
Jonas Ådahl
ecc40e7b23 context: Init introspection paths during setup
This is currently done during meta_init().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 10:59:40 +02:00
Jonas Ådahl
a32b005848 context: Change to home directory during setup
Is currently done during meta_init().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 10:59:40 +02:00
Jonas Ådahl
6f4b973329 context: Initialize signal handlers during setup
Is currently done during meta_init().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 10:59:40 +02:00
Jonas Ådahl
8ace1bf3ea context: Init prefs when starting
Is currently done by meta_start().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 10:59:40 +02:00
Jonas Ådahl
02176eab83 context: Add start/run/terminate phases
The start phase creates the MetaDisplay object, and initializes Wayland, and
creates the main loop.

The run phase runs the main loop and handles returning an error if the
context was terminated with an error.

The terminate phase terminates the main loop, with or without an error.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 10:59:40 +02:00
Jonas Ådahl
fe652518af context: Load plugin during setup phase
The plugin must be configured by the context implementation during the
configure phase.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 10:59:40 +02:00
Jonas Ådahl
75f9085ab9 context: Add setup phase
During this phase, the backend is created and configured. Currently only
configured, but will gain more logic that currently main.c does with
various helpers.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 10:59:40 +02:00
Jonas Ådahl
df8074c636 util: Export meta_set_syncing() symbol
Will be set by MetaContextTest, until we can move away from the function
completely.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 10:59:40 +02:00
Jonas Ådahl
c45a1619f5 context: Set up locale on init
Taken from main.c, which does that when getting the main option context,
which happens to happen early in a process's lifetime.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 10:59:40 +02:00
Jonas Ådahl
6e4d3e0f85 context: Add create_backend() vfunc
This lets the context implementation create a backend. Will later be
used in a 'setup' phase.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 10:59:40 +02:00
Jonas Ådahl
6c6b5b9a48 context: Add entry points for context configuration
Configuration is the first step of the lifetime of a context, after
creation; it's here where argc/argv is processed, and it's determined
what kind of compositor, etc, it is going to be.

The tests always run as Wayand compositors, so the configuration is
quite simple, but will involve more steps later on.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 10:43:28 +02:00
Jonas Ådahl
bf84b2423d main: Move MetaCompositorType to a new meta-enums.h
It'll be part of and owned by MetaContext, intending to replace
`meta_is_wayland_compositor()`, but place it in a new file for public
enums so that it can be used from wherever.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 10:43:28 +02:00
Jonas Ådahl
e020fdfddf Introduce mostly empty MetaContext type
This type is intended to replace the scattered functions used to
configure how the Mutter compositor is run. It currently doesn't do
anything, and only has a human readable name, intended to be set to e.g.
"GNOME Shell".

It's an abstract type, and is intended to be used via either a future
`MetaContextMain` for real display server use cases, and a
`MetaContextTest` for test cases.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
2021-07-15 10:43:28 +02:00
Carlos Garnacho
665081d268 core: Add ::timeout signal to MetaStartupSequence
These objects are missing explicit notifications about when they
are going away by themselves, add one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1845>
2021-07-09 09:34:28 +00:00
Florian Müllner
357c506ee7 events: Only support super+scroll on wayland
On Xorg, the event only reaches us when the pointer is within the
stage input region. That makes the feature more confusing than
useful, so make it wayland-only.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1922>
2021-07-08 00:02:41 +02:00
Carlos Garnacho
44af2c0d37 core: Be more careful around n_modes signedness
This is returned as an integer, which we deal with as an unsigned
integer. Deal with it as an integer all along, and skip safely
negative values.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1920>
2021-07-07 18:37:54 +02:00
Daniel van Vugt
ea626a5059 main: Avoid calling meta_wayland_compositor_get_default() on X11
Because it contains an assertion that will fail, and crash.
Started in 301d2c55c6.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1883>
2021-06-02 16:45:04 +08:00
Jonas Ådahl
301d2c55c6 wayland: Make init and shutdown symmetric
We first initialized the Wayland infrastructure, then the display, but
on shutdown, we first teared down the Wayland infrastructure, then the
display.

Make things a bit more symmetric and tear down the display before
Wayland. This however means we need to tear down some things Wayland a
bit earlier than the rest. For now this is a separate function, but
eventually, it can be replaced with a signal shared by the backend's
'prepare-shutdown' signal.

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

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

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1859>
2021-05-18 13:19:36 +00:00
Jonas Ådahl
243dd868b6 main: Move grab op macro to relevant file
It was in main-private.h for some reason, but only used in display.c.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
af501ac472 prefs: Make init function private
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
7b390b4c5b display: Don't have the display meta_quit() when closing
Instead only do that e.g. when we're being replaced; elsewhere let the
one intending to actually quit, do the quitting.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
89053cc6f7 display: Make meta_display_open() report errors
Instead of just exit():ing, report the error, so the caller can decide
how to deal with the error.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
6c1793b7d3 Rename MetaDisplayPolicy to MetaX11DisplayPolicy
This lack of X11 in the name was a bit confusing, since this is about
the X11 policy, not some policy of MetaDisplay.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
f677e0cbfb display: Make the display handle its own prefs handlers
Two prefs were handled by display.c itself, and another in main.c.
Unscattter things a bit by moving the one in main.c to the others in
display.c.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
9cd99ee7ac main: Move away debug flag management to util.c
The rest of debug flag details are in util.c and util.h, make things
less scattered by moving the rest to util.c too.

While at it, put the coredump:ability setting needed for being suid
there too, so we have a common place for initializing "debug utils".

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
62ef293cdb main: Let session management code deal with DESKTOP_AUTOSTART_ID
No need to have that outside of meta_session_init().

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1833>
2021-05-17 16:08:42 +00:00
Jonas Ådahl
799c6dcf2f main: Tear down Wayland support before MetaDisplay
MetaDisplay does a lot of things, and is a central part to anything
window management. To let Wayland units have an easier time tearing
down, make it so that the Wayland infrastructure is terminated before
MetaDisplay.

This also makes sure that X11 support is turned off, so that we don't
stumble upon Xwayland terminating due to the Wayland socket connection
being broken. Will mitigate that in a better way in a later commit.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1822>
2021-05-05 19:52:04 +00:00
Carlos Garnacho
1d82e0f236 core: Drop X11 error trap from pointer warping code
This code is backend-agnostic, and should not do anything special
about X11. Drop these error traps, and let the backend deal with
the possible errors.

Fixes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1725
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1807>
2021-03-29 13:54:06 +02:00
Jonas Ådahl
12f2fcd332 main: Expose hooks to manage context with more granularity
This is to allow gnome-shell to tear down more gracefully. It's a stop
gap solution until there is a better context handling system, but will
have to do for now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1775>
2021-03-13 18:56:21 +00:00
Marco Trevisan (Treviño)
42287a5f04 restart: Request to hide the restart message if not accepted
In case the shell ignores or can't accept the restart request we should
hide the message that has been just requested to be shown.

As per ::show-restart-message signal documentation, this has to be done by
emitting the signal with a NULL message.

So follow the API properly in such case

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1780>
2021-03-13 15:12:36 +00:00
Benjamin Berg
9b25248c96 main: Force Xwayland startup if not on systemd
In non-systemd managed session we are unable to start services on
demand. Instead, gnome-session will start everything at login time,
including any X11 related service (i.e. gsd-xsettings).

However, in order to start gsd-xsettings, Xwayland needs to be started
already. Otherwise it will connect to GNOME_SETUP_DISPLAY and login will
hang at that point.

Fix this by detecting whether mutter is running in a systemd unit. If it
is, we assume that we are systemd managed and the machinery to start the
services works fine. If not, we assume that the session management may
unconditionally try to start X11 related services and Xwayland must be
started in order to not block this.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1771>
2021-03-12 19:28:25 +01:00
Jonas Ådahl
005c49063d main: Add --virtual-monitor argument
Make it possible to create persintent virtual monitors using command
line argument. This will not be the only way to create virtual monitors,
the primary way will be using the screen cast API, but using command
line argumenst is convenient for debugging purposes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
b31a639378 backend: Add 'prepare-shutdown' signal
This will be used to avoid doing various work when we're shutting down,
e.g. react to changes triggering monitor reconfigurations.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
a0e4f5226c workspace: Nag less about tiny but sane work areas
It's useful to be able to have very very tiny monitors (e.g. 60x60
pixels) when doing reference testing, as tests have reference images
that the output is compared to. Smaller reference images the less
storage they use.

To avoid annoying pointless warnings when this is done, change the
pedantic workspace work area code to be more forgiving if the work area
happens to match the display size.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
2021-03-12 15:09:45 +00:00
Jonas Ådahl
9bf57f82d3 main: Make it possible to set properties when overriding configuration
This makes it possible to pass custom properties to backends when
constructing tests. This will be used to create "headless" native
backend instances for testing the headless native backend.

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
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 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
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
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
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
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
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
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
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
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
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
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
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
Olivier Fourdan
cde0cd5d23 xwayland: Enable Xwayland on demand by default
Make "Xwayland on demand" the default policy when Xwayland supports
"initfd" and remove the corresponding experimental feature.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1673>
2021-01-19 09:33:33 +01:00
Florian Müllner
c255031b6d events: Bypass wayland when scrolling with mouse-button modifier pressed
<super> is considered a system modifier, and applications cannot use it
for keyboard shortcuts or as button modifier. It doesn't seem too much
of a loss taking <super>+scroll-event away as well, so that it becomes
available to gnome-shell/extensions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1674>
2021-01-18 20:59:17 +01:00
Carlos Garnacho
6011562aa9 backends: Update pointer drag-threshold/double-click settings location
Following recent gsettings-desktop-schemas changes.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1416>
2021-01-14 13:58:16 +00:00
Carlos Garnacho
b938749cce core: Trigger repick via ClutterStage
This is equivalent now.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1654>
2020-12-23 12:54:49 +01:00
Olivier Fourdan
76d1a64204 core: Be more selective looking for a focusable ancestor
find_focusable_ancestor() may pick an ancestor window which is not
mapped or hidden, and setting focus on that window will fail.

Be a tad more selective when looking for a focusable ancestor, to reduce
the chance of meta_window_focus() not focusing the happy chosen one.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1643>
2020-12-18 17:17:50 +00:00
Olivier Fourdan
afa431547b core: Make sure focus_default_window() worked
The function focus_default_window() optionally takes a MetaWindow
argument denoting a window that should not be focused.

That function calls focus_ancestor_or_top_window() which in turn
calls meta_window_focus() to pass focus to another window.

However meta_window_focus() gives no guarantee that the given window
will end up being the one focused, and can fail in various and creative
ways.

If that fails, we could possibly end up with the focus window being the
one to avoid, while the caller assumes focus was changed, going as far
as asserting that fact like meta_window_unmanage() does.

As a result, mutter may abort simply because meta_window_focus() failed
to set focus on the expected window.

To avoid that issue, check that the focus did not end up on the window
that we explicitly did not want, and if that's the case, simply fallback
to the default focus window.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/862
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1643>
2020-12-18 17:17:50 +00:00
Jonas Dreßler
ae6d83fb47 clutter: Switch to storing device->actor associations in ClutterStage
As planned and prepared with the last commits, let ClutterStage take
care of tracking input devices and their respective actors. This means
we now can remove the old infrastructure for this from
ClutterInputDevice.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1633>
2020-12-18 16:17:00 +01:00
Carlos Garnacho
4a0c56f928 clutter: Simplify stage state management
Making this an event is overly convoluted, accounting that we
emit the event, then convert it to a ClutterStage signal, then
its only consumer (a11y) sets the active ATK state.

Take the event out of the equation, unify activation/deactivation
of the stage in MetaStage, and use it from the X11 backend too.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
96e320ba5a clutter: Drop CLUTTER_DESTROY_NOTIFY event
Stop propagating this as a Clutter event. DestroyNotify is only
relevant on nested X11 sessions, so handle it specifically in place.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Carlos Garnacho
49b3ac2f86 clutter: Drop CLUTTER_CLIENT_MESSAGE event
This is used nowhere and emitted nowhere. We can do without it.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
2020-12-08 15:37:38 +00:00
Jonas Ådahl
7eb20b2c39 window: Add some trace instrumentation to implement show/hide
Showing and hiding caused several second stalls, and still cause large
enough stalls to cause missed frames, makes this visible to Sysprof.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1616>
2020-12-01 11:41:11 +00:00
Jonas Ådahl
48a90e3a86 stack: Add some trace instrumentation
The stack and stack tracker tend to cause missed frames from time to
time, especially when there are many open windows. Add some
instrumentation to make it this easily verifiable when profiling.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1616>
2020-12-01 11:41:11 +00:00
Jonas Ådahl
d43c8cd842 window: Freeze stack when calculating showing state
Constantly manipulating the stack caused severe stalls (several seconds)
with many open windows when switching workspaces. The cause for this was
that each show/hide call dealt with the stack in isolation, meaning if
you hid N windows, we'd manipulate and synchronize the stack N times,
potentially doing synchronous calls to the X server while doing so.

Avoid the most severe stalls by freezing the stack while calculating
showing; this made the worst case go from several seconds to around
10-20 ms, which is still bad, but by far not as bad.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1616>
2020-12-01 11:41:11 +00:00
Carlos Garnacho
4013bed6e4 backends: Make MetaInputMapper take over MetaInputSettings public API
Banish MetaInputSettings from MetaBackend "public" API, it's now meant to
spend the rest of its days in the backend dungeons, maybe hanging
off a thread.

MetaInputMapper replaces all external uses.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
5f30d1b8ac backends: Split pad action mapping to a separate object
This now lives in the core, and will get updated from events in the
UI thread.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
00cbcb7ba1 core: Centralize cursor renderer and tracker updates
These use now more of a "pull" model, where they receive update
notifications and the relevant input position is queried, instead
of the coordinates being passed along.

This allows to treat cursor renderers all the same independently
of the device they track. This notifying of position changes should
ideally be more backend-y than core-y, a better location will be
figured out in future commits.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Carlos Garnacho
e721fde259 backends: Add argument for best scale on MetaCursorSprite::prepare-at
Instead of letting implementations poke backend internals from various
places, give that information right away.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
2020-11-27 15:14:33 +00:00
Olivier Fourdan
27131198c7 window: Fix size hints with CSD
Commit 03c69ed8 ("Do not go past size hints on resize") was meant to
ensure the size hints set by the client would be honored during resize,
as going past those values could cause the window to move on resize.

However, it did so by calling ensure_size_hints_satisfied() which works
with the frame rect rather than the client rect. As a result, the
minimum size enforced would end up being larger than expected with
client-side decorations.

Use meta_window_maybe_apply_size_hints() instead which automatically
adjusts for client size.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/1542
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1594>
2020-11-23 10:17:55 +01:00
Carlos Garnacho
7738ce2a64 backends/x11: Move to backend-specific meta_input_device_x11_get_device_id()
Make this info part of the MetaInputDeviceX11, as it's actually just
relevant to that backend.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1569>
2020-11-18 19:10:48 +00:00
Carlos Garnacho
7cc6457b9f core: Move away from clutter_event_get_device_id()
Fetch the device, and the ID from there.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1569>
2020-11-18 19:10:48 +00:00
Jonas Ådahl
f57c39f511 tests/clutter: Disable X11 client support
This avoids test failure happening due to Xwayland getting the CPU time
instead of the tests themself, causing failures e.g. due to
missing frames.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1555
2020-11-09 16:12:35 +00:00
Christian Rauch
a51ad8f932 core/window: Store/load window dimensions before/after fullscreen
We will use a dedicated variable when transitioning to/from fullscreen state
and leave the previously used 'saved_rect' exclusively for transitioning
between floating and maximized state.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/801
2020-10-22 16:29:09 +00:00
Christian Rauch
3faea8532c core/window: Move size hints to dedicated function
https://gitlab.gnome.org/GNOME/mutter/merge_requests/801#note_676932
2020-10-22 16:29:09 +00:00
Christian Rauch
20519a1486 core/window: Do not apply limits if no previous size has been stored
A previously stored width and height of 0 signifies that no previous window
size has been stored. This might be the case if an application starts in
maximized or fullscreen mode. If no previous window size has been stored,
the client needs to determine its own size.

https://bugzilla.gnome.org/show_bug.cgi?id=783901
https://gitlab.gnome.org/GNOME/mutter/merge_requests/801#note_607607
2020-10-22 16:29:09 +00:00
Jonas Ådahl
cd52288ddc wayland: Allow specifying Wayland display name from command line
Useful to avoid warnings when starting when there is already an active
Wayland compositor in the session.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1515
2020-10-20 21:16:30 +00:00
Daniel van Vugt
716ecf6cdf util: Add META_DEBUG_WAYLAND debug topic
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1387
2020-10-20 09:53:52 +00:00
Olivier Fourdan
7ab3eac0e2 constraints: Use "orig" rectangle for interactive resize
Bug 448183 fixed an issue with _NET_WM_MOVERESIZE_WINDOW not moving a
window by basing the resize on the current (new) rectangle instead of
the original rectangle.

While this fixes the issue with _NET_WM_MOVERESIZE_WINDOW, this also
causes windows with a size increment to move when the resize also
implies a move, such windows might drift while resizing.

Make sure to use the current rectangle for non-interactive resizes only.

Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/543
2020-10-19 11:16:12 +02:00
Olivier Fourdan
03c69ed8cf window: Do not go past size hints on resize
On interactive resize, mutter calculates the difference in size based on
the pointer location and relies on window constraints to ensure the
minimum size is honored.

Wayland however does asynchronous window configuration, meaning that not
checking for size hints early enough may lead to the window moving as
the locations was initially computed on a size which will be invalidate
by the client eventually.

Make sure to respect the client size hint on update_resize() so that we
don't end up with a window moving unexpectedly when the client
eventually acked the configuration.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1495
2020-10-19 11:16:12 +02:00
Florian Müllner
22902a5e2c window: "Hide" edge resistance behind modifier key
Aligning windows manually with other windows has become less important
since the advent of tiling. This decreases the usefulness of edge
resistance, which in fact many users perceive as lag nowadays.

Account for that by limiting resistance to screen and monitor edges by
default, and only include windows when the control key is pressed.

https://bugzilla.gnome.org/show_bug.cgi?id=679609
2020-10-14 15:45:24 +00:00
Florian Müllner
f9edb6bad3 edge-resistance: Replace booleans with flags parameter
Multiple boolean parameters don't make for great API, so before we
add another one, replace them with a single flag parameter.

https://bugzilla.gnome.org/show_bug.cgi?id=679609
2020-10-14 15:45:23 +00:00
Florian Müllner
64ced1632e window: Don't override tile monitor
Commit 033f0d11bf added a fallback in case the tile monitor wasn't
set before, but didn't actually check for a previously set value.
As a result, the "fallback" is not set unconditionally, which may
differ from the expected monitor: The tile monitor is determined
by the pointer position, while the window's monitor is the one
where the biggest part of the window resides on.

https://gitlab.gnome.org/GNOME/mutter/-/issues/1389
2020-10-14 15:30:05 +00:00
Jonas Ådahl
43c6f70605 util: Don't expand meta_*() debug log arguments if topic not enabled
It's pointless to call into functions that produce information that will
end up nowhere, so lets not. This will generate less angst when doing
more intense data gathering and string generation in debug log calls.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1467
2020-10-14 14:29:36 +00:00
Jonas Ådahl
2c95e08998 Remove misplaced line break in g_* logging functions
They resulted in empty lines in the log.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1466
2020-10-08 16:38:41 +02:00
Jonas Ådahl
313e3e771c Make meta_* logging utilities not require line break
Unlike g_* logging utilities, the meta_* counterparts behave like odd
printf() functions. Lets change that so they fit better into how logging
is done everywhere else.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1466
2020-10-08 16:38:41 +02:00
Carlos Garnacho
bbc4116f10 backends: Use graphene_point_t on meta_cursor_tracker_get_pointer()
It's nicer to propagate along.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1475
2020-10-06 21:33:10 +02:00
Jonas Ådahl
498248586a util: Remove now unused debug functions
They have been replaced with using debug string parsing and topics.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1465
2020-10-06 15:52:54 +00:00
Jonas Ådahl
b1ffd14d62 main: Parse MUTTER_DEBUG as debug string
This makes it possible to run e.g.

    env MUTTER_DEBUG=input:geometry gnome-shell

which will enable the 'META_DEBUG_INPUT' and 'META_DEBUG_GEOMETRY'
topics.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1465
2020-10-06 15:52:54 +00:00
Jonas Ådahl
24c374ffb2 util: Remove unused meta_debug_spew()
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1465
2020-10-06 15:52:54 +00:00
Jonas Ådahl
9a75de9309 util: Remove a bunch of unused debug topics
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1465
2020-10-06 15:52:54 +00:00
Jonas Ådahl
b536a531cb place: Use 'placement' topic for logging monitor rect
It was logged using the 'xinerama' topic during placement calculation,
which doesn't seem very relevant here since a handful of years.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1465
2020-10-06 15:52:54 +00:00
Olivier Fourdan
98df888f03 main: Release backend on teardown
This allows to call the backend finalize function on teardown.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1438
2020-10-06 15:45:43 +00:00
Carlos Garnacho
86fa8aff4a core: Do not update last device on CLUTTER_DEVICE_ADDED/REMOVED
We only update the last device from actual input interaction here,
avoid this pair of events. This is specially nasty with
CLUTTER_DEVICE_REMOVED, since the device we're notifying upon will be
disposed soon after emission.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1460
2020-09-30 18:26:20 +00:00
Carlos Garnacho
a72ab765c9 core: Do not force cursor renderer update here
This is already taken care of in meta_backend_monitors_changed(), called
from the same code paths that emit ::monitors-changed-internal. It is
better to leave this up to backend internals.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1448
2020-09-23 16:32:11 +02:00
Carlos Garnacho
978e6511e0 core: Remove unused struct field
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1448
2020-09-23 16:32:07 +02:00
Florian Müllner
c1c061140f core/display: Remove obsolete typedef
The corresponding type was replaced in 2001.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1425
2020-08-31 21:07:03 +02:00
Robert Mader
20982bf2c8 util: Add paint debug flags
Analogous to `ClutterDrawDebugFlag` but intended for concepts that
are not present in Clutter, such as Wayland/X11 opaque regions.
Also add the first flag for the later.

To set the flag, run:
`Meta.add_debug_paint_flag(Meta.DebugPaintFlag.OPAQUE_REGION)`

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1372
2020-08-31 15:47:08 +00:00
Robert Mader
1dc6a15eac util: Small style cleanups
To make the code more pleasant to read.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1372
2020-08-31 15:47:08 +00:00
Björn Daase
5ec9bde64f *: Fix spelling mistakes found by codespell
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1410
2020-08-29 09:10:31 +00:00
Jonas Ådahl
06d5973851 main: Split up meta_run() into meta_start() and meta_run_main_loop()
meta_run() is still left intact and does the same as before; the new
functions are only intended to be used by tests, as they may need to set
things up after starting up. Doing so linearly in the test case is much
easier than adding callbacks, so meta_run() is split up to make this
possible.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1364
2020-08-13 17:51:30 +02:00
Jonas Ådahl
28cb025190 clutter: Remove DELETE event, signal and vfunc
The delete event was used for signalling the close button was clicked on
clutter windows. Being a compositor we should never see these, unless
we're running nested. Remove the plumbing of the DELETE event and just
directly call meta_quit() when we see it, if we're running nested.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1364
2020-08-13 14:45:10 +02:00
Sergio Costas
f894f5cc13 wayland: Add API to launch trusted clients
Allowing code from inside mutter to create a child process and
delegate on it some of its tasks is something very useful. This can
be done easily with the g_subprocess and g_subprocess_launcher classes
already available in GLib and GObject.

Unfortunately, although the child process can be a graphical program,
currently it is not possible for the inner code to identify the
windows created by the child in a secure manner (this is: being able
to ensure that a malicious program won't be able to trick the inner
code into thinking it is a child process launched by it).

Under X11 this is not a problem because any program has full control
over their windows, but under Wayland it is a different story: a
program can't neither force their window to be kept at the top (like a
docker program does) or at the bottom (like a program for desktop icons
does), nor hide it from the list of windows. This means that it is not
possible for a "classic", non-priviledged program, to fulfill these
tasks, and it can be done only from code inside mutter (like a
gnome-shell extension).

This is a non desirable situation, because an extension runs in the
same main loop than the whole desktop itself, which means that a
complex extension can need to do too much work inside the main loop,
and freeze the whole desktop for too much time. Also, it is important
to note that javascript doesn't have access to fork(), or threads,
which means that, at most, all the parallel computing that can do is
those available in the _async calls in GLib/GObject.

Also, having to create an extension for any priviledged graphical
element is an stopper for a lot of programmers who already know
GTK+ but doesn't know Clutter.

This patch wants to offer a solution to this problem, by offering a
new class that allows to launch a trusted child process from inside
mutter, and make it to use an specific UNIX socket to communicate
with the compositor. It also allows to check whether an specific
MetaWindow was created by one of this trusted child processes or not.

This allows to create extensions that launch a child process, and
when that process creates a window, the extension can confirm in a
secure way that the window really belongs to that process
launched by it, so it can give to that window "superpowers" like
being kept at the bottom of the desktop, not being listed in the
list of windows or shown in the Activities panel... Also, in future
versions, it could easily implement protocol extensions that only
could be used by these trusted child processes.

Several examples of the usefulness of this are that, with it, it
is possible to write programs that implements:

- desktop icons
- a dock
- a top or bottom bar
...

all in a secure manner, avoiding insecure programs to do the same.
In fact, even if the same code is launched manually, it won't have
those privileges, only the specific process launched from inside
mutter.

Since this is only needed under Wayland, it won't work under X11.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/741
2020-08-04 08:42:29 +00:00
Olivier Fourdan
17417a82a5 cleanup: remove controversial naming
Replace "whitelist" and "blacklist" with "allow_list" and "deny_list"
which better represent the purpose of those variables.

There is no functional change.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1396
2020-08-04 10:04:16 +02:00
Olivier Fourdan
d0ee02fae7 cleanup: Remove duplicate semicolons in C code
No functional change, it just hurts my eyes when reading the code.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1385
2020-07-28 10:32:46 +02:00
Florian Müllner
c1933cfd09 workspace: Add :active convenience property
There are a couple of places in gnome-shell where we aren't interested
in which workspace is active, but whether a given workspace is active.

Of course it's easy to use the former to determine the latter, but we
can offer a convenience property on the workspace itself almost for
free, so let's do that.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1336
2020-06-29 14:07:20 +00:00
Jonas Dreßler
7539de2320 clutter/input-device: Make clutter_input_device_get_actor() public
Make the clutter_input_device_get_actor() API public and remove
clutter_input_device_get_pointer_actor() in favour of the new function.

This allows also getting the "pointer" actor for a given touch sequence,
not only for real pointer input devices like mice.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1275
2020-06-16 10:09:26 +00:00
Jonas Ådahl
53f61f3778 stack-tracker: Don't log warnings on race conditions
X11 window stacking operations are by nature prone to race conditions.
For example, we might queue a "raise above" operation, but before it
actually takes place, the sibling the window was to be rased above, is
withdrawn.

In these cases we'd log warnings even though they are expected to
happen. Downgrade these warnings to debug messages, only printed when
MUTTER_VERBOSE is set.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1300
2020-06-09 18:46:38 +00:00
Jonas Ådahl
74c0d9140c stack-tracker: Fix coding style of meta_stack_op_apply()
Change tabs to spaces, clean up variable declarations.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1300
2020-06-09 18:46:38 +00:00
Sebastian Keller
019643bad0 core: Free clipboard selection source on shutdown
The clipboard manager is the only code to ever set the display selection
source, so it should also be responsible for unsetting it when the
clipboard manager gets shut down.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1293
2020-06-08 12:11:11 +00:00
Sebastian Keller
a031ac067e core: Fix memory selection source leak after clipboard owner disappears
When an app disappears after some data from it has been copied to the
clipboard, the owner of the clipboard selection becomes a new memory
selection source. The initial reference this new selection source is
never unref'ed, which leads to this being leaked on the next clipboard
selection owner change.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1293
2020-06-08 12:11:11 +00:00
Peter Hutterer
f712387325 compositor: use XDG_CONFIG_HOME as initial lookup path for xkb
Using XDG_CONFIG_HOME allows users to place their keyboard configuration into
their home directory and have them loaded automatically.
libxkbcommon now defaults to XDG_CONFIG_HOME/xkb/ first, see
https://github.com/xkbcommon/libxkbcommon/pull/117

However - libxkbcommon uses secure_getenv() to obtain XDG_CONFIG_HOME and thus
fails to load this for the mutter context which has cap_sys_nice.
We need to manually add that search path as lookup path.

As we can only append paths to libxkbcommon's context, we need to start with
an empty search path set, add our custom path, then append the default search
paths.

The net effect is nil where a user doesn't have XDG_CONFIG_HOME/xkb/.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/936
2020-06-08 11:29:30 +00:00
Jonas Ådahl
25f9406e69 compositor: Get the stage via the backend
We would get the MetaDisplay from the backend singleton before creating
the MetaCompositor, then in MetaCompositor, get the backend singleton
again to get the stage. To get rid of the extra singleton fetching, just
pass the backend the MetaCompositor constructors, and fetch the stage
directly from the backend everytime it's needed.

This also makes it available earlier than before, as we didn't set our
instance private stage pointer until the manage() call.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289
2020-06-05 21:39:27 +00:00
Jonas Ådahl
1571f8078a Reshuffle Wayland initailization
Move Wayland support (i.e. the MetaWaylandCompositor object) made to be
part of the backend. This is due to the fact that it is needed by the
backend initialization, e.g. the Wayland EGLDisplay server support.

The backend is changed to be more involved in Wayland and clutter
initialization, so that the parts needed for clutter initialization
happens before clutter itself initialization happens, and the rest
happens after. This simplifies the setup a bit, as clutter and Wayland
init now happens as part of the backend initialization.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1218
2020-05-26 16:35:00 +02:00
Jonas Dreßler
b97a6e62a3 window: Add a note about the trustworthiness of the client PID
Since PIDs are inherently insecure because they are reused after a
certain amount of processes was started, it's possible the client PID
was spoofed by the client.

So make sure users of the meta_window_get_pid() API are aware of those
issues and add a note to the documentation that the PID can not be
totally trusted.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
Jonas Dreßler
4fac1a4862 window: Cache the client PID
Since the PID of a window can't change as long as the window exists, we
can safely cache it after we got a valid PID once, so do that by adding
a new `window->client_pid` private property.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
Jonas Dreßler
70ba844c3c window: Return pid_t in meta_window_get_pid()
Just as with the last commit, pid_t is compatible with all platforms and
we should use that everywhere, so also make meta_window_get_pid() return
a pid_t.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
Jonas Dreßler
bc0b9f7628 window: Use pid_t for get_client_pid() vfunc
It makes sense to use pid_t when getting the PID since that will work on
all platforms and architectures.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
Jonas Dreßler
c971d6ea1f window: Remove support for _NET_WM_PID
We have the client pid API that works on both Wayland and X11 nowadays,
so the _NET_WM_PID property is no longer needed, remove it.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
Jonas Dreßler
dac09a8e23 window: Use client PID for meta_window_get_pid()
The shell uses the PID of windows to map them to apps or to find out
which window/app triggered a dialog. It currently fails to do that in
some situations on Wayland, because meta_window_get_pid() only returns a
valid PID for x11 clients.

So use the client PID instead of the X11-exclusive _NET_WM_PID property
to find out the PID of the process that started the window. We can do
that by simply renaming the already existing
meta_window_get_client_pid() API to meta_window_get_pid() and moving
the old API providing the _NET_WM_PID to meta_window_get_netwm_pid().

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1180
2020-05-21 23:10:23 +00:00
Akatsuki
6f62c5b575 core/place: Use work area when centering new window.
use the workarea instead of the logical monitor

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/964
2020-05-09 09:47:42 +00:00
Jonas Ådahl
033f0d11bf window: Set fall-back tile monitor if not set
When tiling, we want to set the tile monitor. To not have to do this
from the call site, make meta_window_tile() fall back to the current
monitor if nothing set it prior to the call.

This will make it more convenient for test cases to test tiling
behavior.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Jonas Ådahl
668eb318c7 window: Add meta_window_untile()
It does the same as the untile keyboard shortcut does, i.e. handles
going back to saved maximized state. It's split out to be able to be
tested by the stacking tests.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Jonas Ådahl
476ef76de6 tests/test-runner: Add 'assert_size' command
The 'assert_size' command checks that the size of the window, both
client side and compositor side, corresponds to an expected size set by
the test case.

The size comparison can only be done when the window is using 'csd', in
order for both the client and server to have the same amount of
understanding of the title bar. For ssd, the client cannot know how
large the title bar, thus cannot verify the full window size.

Sizes can be specified to mean the size of the monitor divided by a
number. This is that one can make sure a window is maximized or
fullscreened correctly.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1171
2020-05-07 23:15:24 +00:00
Sergey Zigachev
5201d77b0b keybindings: Use current monitor for move-to-center
Move to center uses all monitors for calculating work area.

This can lead to an unexpected behaviour on some monitor
configurations resulting in current window being split between
monitors. We should move window to the center of the active display.

Closes https://gitlab.gnome.org/GNOME/mutter/-/issues/1073
2020-05-06 16:03:45 +05:00
Olivier Fourdan
61356caa06 keybindings: Mask out the reserved modifiers mask
When switching layouts, special modifiers bits may be be set for
internal use by Xkb.

As we now ignore a set of modifiers when processing the special
modifiers keys, we ought to also mask out those reserved modifiers
otherwise we would discard the [Super] key after switching layouts
in X11.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1144
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1219
2020-04-27 15:51:47 +00:00
Jonas Dreßler
551a57ed7f Add read-only anonymous file abstraction MetaAnonymousFile
Add MetaAnonymousFile, an abstraction around anonymous read-only files.
Files can be created by calling meta_anonymous_file_new(), passing the
data of the file. Subsequent calls to meta_anonymous_file_open_fd()
return a fd that's ready to be sent over the socket.

When mapmode is META_ANONYMOUS_FILE_MAPMODE_PRIVATE the fd is only
guaranteed to be mmap-able readonly with MAP_PRIVATE but does not
require duplicating the file for each resource when memfd_create is
available. META_ANONYMOUS_FILE_MAPMODE_SHARED may be used when the
client must be able to map the file with MAP_SHARED but it also means
that the file has to be duplicated even when memfd_create is available.

Pretty much all of this code was written for weston by Sebastian Wick,
see https://gitlab.freedesktop.org/wayland/weston/merge_requests/240.

Co-authored-by: Sebastian Wick <sebastian@sebastianwick.net>

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1012
2020-04-21 17:52:08 +02:00
Carlos Garnacho
4bdf9a1e70 core: Cater for reading selection in chunks
For the cases where we read a fixed size from the selection (eg. imposing
limits for the clipboard manager), g_input_stream_read_bytes_async() might
not read up to this given size if the other side is spoonfeeding it content.

Cater for multiple read/write cycles here, until (maximum) transfer size is
reached.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1198
2020-04-16 16:26:04 +00:00
Jonas Ådahl
65a6c4c361 compositor: Add support for direct scanout of Wayland surfaces
Try to bypass compositing if there is a fullscreen toplevel window with
a buffer compatible with the primary plane of the monitor it is
fullscreen on. Only non-mirrored is currently supported; as well as
fullscreened on a single monitor. It should be possible to extend with
more cases, but this starts small.

It does this by introducing a new MetaCompositor sub type
MetaCompositorNative specific to the native backend, which derives from
MetaCompositorServer, containing functionality only relevant for when
running on top of the native backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
dc4fe780f7 display: Initialize MetaCompositor in two steps
MetaCompositor is the place in mutter that manages the higher level
state of compositing, such as handling what happens before and after
paint. In order for other units that depend on having a compositor
instance active, but should be initialized before the X11 implementation
of MetaCompositor registers as a X11 compositing manager, split the
initialization of compositing into two steps:

 1) Instantiate the object - only construct the instance, making it
    possible for users to start listening to signals etc
 2) Manage - this e.g. establishes the compositor as the X11 compositing
    manager and similar things.

This will enable us to put compositing dependent scattered global
variables into a MetaCompositor owned object.

For now, compositor management is internally done by calling a new
`meta_compositor_do_manage()`, as right now we can't change the API of
`meta_compositor_manage()` as it is public. For the next version, manual
management of compositing will removed from the public API, and only
managed internally.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
d682cdb078 util: Move MetaLater to its own file
While at it, fix some style inconsistencies, for now use a single
singleton struct instead of multiple static variables, and
other non-functional cleanups. Semantically, there is no changes
introduced.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 15:05:52 +02:00
Jonas Ådahl
5dad87cfb9 surface-actor-x11: Move window related unredirect logic to MetaWindowX11
Better to have the relevant object figure out whether it is a good
position to be unredirectable other than the actor, which should be
responsible for being composited.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/798
2020-04-16 14:08:19 +02:00
Carlos Garnacho
fbd6366edd core: Add private function to get the current selection owner
This is a bit untidy to expose, however may be necessary internally.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1186
2020-04-09 21:30:05 +00:00
Jonas Ådahl
8df3b21a51 window: Check aliveness a bit less aggressively
Currently we check whether a window is alive everytime it's focused.
This means that an application that doesn't respond to the check-alive
event during startup always showing the "application froze" dialog,
without the user ever trying to interact with it.

An example where this tends to to happen is with games, and for this
particular scenario, it's purely an annoyance, as I never tried to
interact with the game window in the first place, so I don't care that
it's not responding - it's loading.

To avoid these unnecessary particular "app-is-frozen" popups, remove the
alive check from the focus function, and instead move it back to the
"meta_window_activate_full()" call. To also trigger it slightly more
often, also add it to the path that triggers the window focus when a
user actively clicks on the window.

This means that we currently check whether a window is alive on:

  * Any time the window is activated. This means e.g. alt-tab or
    selecting the window in the overview.
  * The user clicks on the window.

Note that the second only works for an already focused window on
Wayland, as on X11, we don't refocus it. This particular case isn't
changed with this commit, as we didn't call meta_window_focus() to begin
with here.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1182
2020-04-07 10:46:01 +02:00
Robert Mader
6aa546145f core: Demote tiff and bmp image formats in the clipboard manager
Support for them appears to be way less common than e.g. png, which is
currently the preferred format from Firefox, Chromium, Libreoffice and others.
Adopt to that fact.

As a side effect, this works around a bug observed when copying images in
Firefox on Wayland.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1141
2020-03-27 14:37:29 +00:00
Jonas Ådahl
238e41d493 cogl: Install cogl-trace.h and include from cogl.h
This is so that cogl-trace.h can start using things from cogl-macros.h,
and so that it doesn't leak cogl-config.h into the world, while exposing
it to e.g. gnome-shell so that it can make use of it as well. There is
no practical reason why we shouldn't just include cogl-trace.h via
cogl.h as we do with everything else.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1059
2020-03-26 09:05:38 +01:00
Carlos Garnacho
3c4f5ddcb4 core: Let pad mode switch events always go through MetaInputSettings
We used to inhibit all pad actions while the OSD is shown, but one we
would actually want to handle are mode switches while the OSD is open.
So it has an opportunity to catch up to the mode switch.

This lets MetaInputSettings reflect the mode switch (eg. when querying
action labels), so the OSD has an opportunity to update the current
actions.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/975
2020-03-25 19:56:09 +01:00
Florian Müllner
d4c070da88 window: Really propagate effective on-all-workspaces setting to transients
Commit cda9579034 fixed a corner case when setting the initial workspace
state of transient windows, but it still missed a case:

should_be_on_all_workspaces() returns whether the window should be on all
workspaces according to its properties/placement, but it doesn't take
transient relations into account.

That means in case of nested transients, we can still fail the assert:

 1. on-all-workspaces toplevel
 2. should_be_on_all_workspaces() is TRUE for the first transient's parent,
    as the window from (1) has on_all_workspaces_requested == TRUE
 3. should_be_on_all_workspaces() is FALSE for the second transient's
    parent, as the window from (2) is only on-all-workspace because
    of its parent

We can fix this by either using the state from the root ancestor
instead of the direct transient parent, or by using the parent's
on_all_workspaces_state.

The latter is simpler, so go with that.

https://gitlab.gnome.org/GNOME/mutter/issues/1083
2020-03-24 18:15:33 +00:00
Carlos Garnacho
d052f9c070 backends: Drop internal WacomDevice in MetaInputSettings
Use the one from MetaInputDevice instead. Since we no longer try
to ask for WacomDevices that weren't first retrieved:

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1086

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1109
2020-03-24 18:07:31 +00:00
Carlos Garnacho
23da6c2426 keybindings: Check the special modifiers specifically
Make sure it is only the special modifier (hardcoded to 1 currently)
which is being pressed (not counting locked modifiers) before notifying
that the special modifier is pressed, as we are interested in it being
pressed alone and not in combination with other modifier keys.

This helps in two ways:
- Pressing alt, then ctrl, then releasing both won't trigger the locate
  pointer action.
- Pressing alt, then ctrl, then down/up to switch workspace won't interpret
  the last up/down keypress as an additional key on top of the special ctrl
  modifier, thus won't be forwarded down to the focused client in the last
  second.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/812

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1014
2020-03-13 21:37:32 +01:00
Carlos Garnacho
67dd0b4fec keybindings: Avoid double calls to process_event() on the same event
If you first press a key that triggers the "special modifier key" paths
(ctrl, super), and then press another key that doesn't match (yet?) any
keybindings (eg. ctrl+alt, super+x), the second key press goes twice
through process_event(), once in the processing of this so far special
combination and another while we let the event through.

In order to keep things consistent, handle it differently depending on
whether we are a wayland compositor or not. For X11, consider the event
handled after the call to process_event() in process_special_modifier_key().
For Wayland, as XIAllowEvents is not the mechanism that allows clients see
the key event, we can just fall through the regular paths, without this
special handling.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1014
2020-03-13 21:22:28 +01:00
Alynx Zhou
aba0b9ef64 keybindings: Move common window grab code out of X-only if statement
`3c8d4171` moved some common codes into X11-only code blocks by mistake,
and it prevents keyboard window resize/move mode under Wayland because
those variables are unset. This commit fixed it via moving such common
codes out of X11-only code blocks.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/949

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/997
2020-03-12 08:42:04 +00:00
Olivier Fourdan
50ff30bf2b xwayland: Log actual error message if available
If X11 initialization fails, print the actual error message if the error
is set, to help with debugging.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1102
2020-03-09 17:49:51 +00:00
Jonas Ådahl
d08a8de265 window: Implement asynchronous popup moving
This commits adds support on the MetaWindow and constraints engine side
for asynchronously repositioning a window with a placement rule, either
due to environmental changes (e.g. parent moved) or explicitly done so
via `meta_window_update_placement_rule()`.

This is so far unused, as placement rules where this functionality is
triggered are not yet constructed by the xdg-shell implementation, and
no users of `meta_window_update_placement_rule()` exists yet.

To summarize, it works by making it possible to produce placement rules
with the parent rectangle a window should be placed against, while
creating a pending configuration that is not applied until acknowledged
by the client using the xdg-shell configure/ack_configure mechanisms.

An "temporary" constrain result is added to deal with situations
where the client window *must* move immediately even though it has not yet
acknowledged a new configuration that was sent. This happens for example
when the parent window is moved, causing the popup window to change its
relative position e.g. because it ended up partially off-screen. In this
situation, the temporary position corresponds to the result of the
movement of the parent, while the pending (asynchronously configured)
position is the relative one given the new constraining result.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
0dac91cffc Add MetaGravity and replace X11 equivalent with it
MetaGravity is an enum, where the values match the X11 macros used for
gravity, with the exception that `ForgetGravity` was renamed
`META_GRAVITY_NONE` to have less of a obscure name.

The motivation for this is to rely less on libX11 data types and macros
in generic code.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
ff381d1d52 constraints: Pass constrained relative coordinates to window impl
A placement rule placed window positions itself relative to its parent,
thus converting between relative coordinates to absolute coordinates,
then back to relative coordinates implies unwanted restrictions for
example when the absolute coordinate should not be calculated againts
the current parent window position.

Deal with this by keeping track of the relative position all the way
from the constraining engine to the move-resize window implementation.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
05e9d6ab9e window: Put placement related fields in a anynomous struct
To organize things a bit better, put the fields related to the placement
rule state in its own anonymous struct inside MetaWindow. While at it,
rename the somewhat oddly named variable that in practice means the
current relative window position.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Jonas Ådahl
9b97e5ed58 place: Make placement rule processing provide relative coordinates
A placement rule is always about placing a window relative to its
parent. In order to eventually place it against predicted future parent
positions, make the placement rule processing output relative
coordinates, having the caller deal with turning them into absolute.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/705
2020-02-29 21:01:50 +00:00
Carlos Garnacho
64eaf70279 xwayland: Allow setting up maintenance processes
This is made a signal, so the upper layers (read: gnome-shell) may
decide what services to spawn. The signal argument contains a task
that will resume MetaX11Display startup after it is returned upon.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/945
2020-02-29 20:41:26 +00:00
Carlos Garnacho
38e58b837b core: Use DISPLAY envvar to forward in the launch context
The meta_x11_get_display_name() will return our private connection, which
is not what we want to transfer to clients being launched.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/945
2020-02-29 20:41:26 +00:00
Carlos Garnacho
25c9e66c73 xwayland: Do not block on Xwayland initialization
We artificially made Xwayland initialization synchronous, as we used
to rely on MetaX11Display and other bits during meta_display_open().
With support for Xwayland on demand and --no-x11, this is certainly
not the case.

So drop the main loop surrounding Xwayland initialization, and turn
it into an async operation called from meta_display_init_x11(). This
function is turned then into the high-level entry point that will
get you from no X server to having a MetaX11Display.

The role of meta_init() in Xwayland initialization is thus reduced
to setting up the sockets. Notably no processes are spawned from here,
deferring that till there is a MetaDisplay to poke.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
2020-02-28 20:20:35 +00:00
Carlos Garnacho
649911b6b3 core: Make meta_display_init_x11() an async function
This ATM completes the task right away, but we will want to do
further things here that are asynchronous in nature, so prepare
for this operation being async.

Since the X11 backend doesn't really need this, make it go on
the fast lane and open the MetaX11Display right away, the case
of mandatory Xwayland on a wayland session is now handled
separately.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
2020-02-28 20:20:35 +00:00
Carlos Garnacho
87a06c63ad x11: Set up the compositing manager selection on meta_display_init_x11()
This used to be set on meta_compositor_manage(), but only if there is a
MetaX11Display. Given meta_display_init_x11() is Wayland only, and we can
always assume compositing to be enabled, just have it invariably set after
the X server is up.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/944
2020-02-28 20:20:35 +00:00
Jonas Ådahl
a11f9bd513 boxes: Add 'round' rounding strategy
It just calls roundf(), and is intended to be used when the graphene
rectangle is approximately integer aligned.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1042
2020-02-25 18:39:51 +01:00
Jonas Ådahl
2da27720ca display: Make check-alive timeout configureable
The check-alive feature is there for the user to be able to terminate
frozen applications more easily. However, sometimes applications are
implemented in a way where they fail to be reply to ping requests in a
timely manner, resulting in that, to the compositor, they are
indistinguishable from clients that have frozen indefinitely.

When using an application that has these issues, the GUI showed in
response to the failure to respond to ping requests can become annoying,
as it disrupts the visual presentation of the application.

To allow users to work-around these issues, add a setting allowing them
to configure the timeout waited until an application is considered
frozen, or disabling the check completely.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1080
2020-02-23 17:28:57 +00:00
Sebastian Keller
aedcfcd010 sound-player: Fix invalid write after playback is cancelled early
The cancellable of a request might already be cancelled by the time
the cancelled_cb is connected resulting in finish_cb being called via
ca_context_cancel before g_cancellable_connect returns. In this case
the request that is written to has already been freed.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/1060
2020-02-21 16:06:18 +00:00
Jonas Ådahl
44ae38599f wayland: Move MetaWindow ownership to window owning roles
There are two surface roles owning a MetaWindow: MetaWaylandShellSurface
(basis of MetaWaylandXdgToplevel, MetaWaylandXdgPopup,
MetaWaylandWlShellSurface, etc), and MetaXwaylandSurface.

With these two role types, the MetaWindow has two different types of
life times. With MetaWaylandShellSurface, the window is owned and
managed by the role itself, while with MetaXwaylandSurface, the
MetaWindow is tied to the X11 window, while the Wayland surface and its
role plays more the role of the backing rendering surface.

Before, for historical reasons, MetaWindow was part of
MetaWaylandSurface, even though just some roles used it, and before
'wayland: Untie MetaWindowXwayland lifetime from the wl_surface' had
equivalent life times as well. But since that commit, the management
changed. To not have the same fied in MetaWaylandSurface being managed
in such drastically different ways, rearrange it so that the roles that
has a MetaWindow themself manages it in the way it is meant to; meaning
MetaWaylandShellSurface practically owns it, while with Xwayland, the
existance of a MetaWindow is tracked via X11.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/835
2020-02-19 22:34:28 +00:00
Jonas Dreßler
e51279dcf0 display: Only send one ping to a window at a time
If a window already is being pinged, it doesn't make sense to send more
pings to the window, instead we should just wait for that answer or
timeout until we send a new one.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/891
2020-02-19 21:20:29 +00:00
Jonas Dreßler
9b58033375 display: Make sure ping serials are never reused
Using a timestamp twice in a row (e.g. when activating two windows in
response to the same event or due to other bugs) will break the window
detection and show a close dialog on the wrong window. This is a grave
error that should never happen, so check every timestamp before sending
the ping for uniqueness and if the timestamp was already used and its
ping is still pending, log a warning message and don't send the ping.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/891
2020-02-19 21:20:29 +00:00
Jonas Dreßler
0bf9727a31 display: Fix intendation of an argument and add details to a warning
https://gitlab.gnome.org/GNOME/mutter/merge_requests/891
2020-02-19 21:20:29 +00:00
Jonas Dreßler
d053ccfb18 window: Check window responsiveness on every window focus
Increase the number of checks whether a window is still responsive and
ping windows on every call to `meta_window_focus()` instead of
`meta_window_activate_full()`. This ensures the window is also pinged in
case normal interaction like clicks on the window happen and a close
dialog will eventually get shown.

Related https://gitlab.gnome.org/GNOME/mutter/issues/395

https://gitlab.gnome.org/GNOME/mutter/merge_requests/891
2020-02-19 21:20:29 +00:00
Jonas Dreßler
efe1bc2e59 util: Add INPUT debug topic
Allow debugging input issues more easily by adding an INPUT debug topic.
Currently there are only debug messages for the native backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1065
2020-02-19 18:28:29 +00:00
Carlos Garnacho
f7646af810 core: Do not update idle times for slave devices
Those go nowhere, so just avoid doing this.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1039
2020-02-12 22:07:55 +00:00
Florian Müllner
aa0aa89a1e window: Ignore requests to be placed on non-existent workspaces
When an X11 window requests an initial workspace, we currently trust
it that the workspace actually exists. However dynamic workspaces
make this easy to get wrong for applications: They make it likely
for the number of workspaces to change between application starts,
and if the app blindly applies its saved state on startup, it will
trigger an assertion.

Make sure that we pass valid parameters to set_workspace_state(),
and simply let the workspace assignment fall through to the default
handling otherwise.

https://gitlab.gnome.org/GNOME/mutter/issues/1029
2020-02-04 00:07:54 +00:00
Robert Mader
b91d66bf98 core: Extend list of image formats to be stored in the clipboard manager
These types are probably common enough to support.

See also:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1034
2020-02-03 16:51:15 +01:00
Carlos Garnacho
832c0fb0ea core: Define specific image formats to be stored in the clipboard manager
And order those preferences in order of lossiness (jpeg < png < bmp). This
avoids us from prefering other formats that are not useful or widely
recognized.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/939
2020-02-03 13:19:00 +00:00
Carlos Garnacho
2fbbf657d5 core: Demote image formats' priority from preservation in clipboard manager
Most usually, applications either expose clipboard content either as text
or as images, so the prioritization here is pointless. However there's some
outliers like LibreOffice Calc which exports content as both image and text
formats (besides other internal ones).

In that mixed case, we probably prefer to keep text formats, rather than
image based ones.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/919
2020-02-03 13:19:00 +00:00
Sebastian Keller
98040e67a2 core: Fix task leak in meta_selection_source_memory_read_async
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
e7928ce6ee selection: Fix task leak in error case of source_read_cb
Fixes the last part of https://gitlab.gnome.org/GNOME/mutter/issues/1006
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
d699c80ac2 display: Unref selection on shutdown
Otherwise it will be leaked and the dispose method added in the previous
commit would never be run.

Fixes parts of https://gitlab.gnome.org/GNOME/mutter/issues/1006
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
35316a034f selection: Unref selection owners on dispose
Selection owners are set using g_set_object, which adds a reference to
the owner, which then never was removed on shutdown.

Fixes parts of https://gitlab.gnome.org/GNOME/mutter/issues/1006
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Sebastian Keller
05301d280c clipboard-manager: Plug mimetypes list leak
Fixes https://gitlab.gnome.org/GNOME/mutter/issues/1005
https://gitlab.gnome.org/GNOME/mutter/merge_requests/1001
2020-02-01 14:02:19 +00:00
Carlos Garnacho
1e9682b417 backends: Move warp_pointer() to ClutterSeat
The onscreen pointer sprite is a per-seat element, so it makes sense
to move pointer warping over there too.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:12:58 +01:00
Carlos Garnacho
e9fbbd5853 backends: Do not use device IDs on idle monitors
Device IDs are somewhat x11 specific, seems better to avoid those
on public API. We can rely everywhere on ClutterInputDevice, so use
it instead.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:11:23 +01:00
Carlos Garnacho
f55d4f33af backends: Make meta_backend_update_last_device() take a clutter device
Instead of a pretty x11 specific device ID. This also updates the argument
of the ::last-device-changed signal to be a ClutterInputDevice.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:34 +01:00
Carlos Garnacho
7644ddeddc core: Replace ClutterDeviceManager usage in favor of ClutterSeat
https://gitlab.gnome.org/GNOME/mutter/merge_requests/852
2020-01-30 18:02:34 +01:00
Olivier Fourdan
5618e41cea window: Remove Wayland code from meta_window_show()
As we now call `meta_wayland_compositor_repick()` when the effects are
complete for Wayland surfaces, we can safely remove the Wayland specific
code to do the same from `meta_window_show()`.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1026
2020-01-30 09:37:58 +01:00
Olivier Fourdan
c0321c7b21 frame: Pass the frame area for get_mask()
Currently, `meta_frame_get_mask()` and `meta_ui_frame_get_mask()` will
return the frame mask applied to the current frame size, by querying the
frame themselves.

To be able to get the frame mask at an arbitrary size, change the API to
take a rectangle representing the size at which the frame mask should be
rendered.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1009
2020-01-29 10:44:50 +00:00
Jonas Ådahl
6e5ac0b585 Use G_GNUC_FALLTHROUGH instead of comments
Get the same task done in a bit more C:y way.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/998
2020-01-09 17:58:29 +01:00
Jonas Ådahl
132fbf49d7 wayland: Let MetaWaylandXdgPopup dismiss incorrectly placed popups
It's a xdg_popup detail, and not until the actual position is finalized
is the actual correctness known.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Jonas Ådahl
4bf5b7d78d window: Don't constrain an acked window geometry
In Wayland, window configuration is asynchronous. Window geometry is
constrained, the constrained geometry is sent to the client, and the
client will adapt its surface and acknowledge the configuration. When
acknowledged, we shouldn't reconstrain again, as that may invalidate the
constraint calculated for the configured size.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00