1
0
Fork 0
Commit graph

299 commits

Author SHA1 Message Date
Florian Müllner
ccf6bbc673 window: Add has_modals() function
We'll soon use that to enforce modal behavior for foreign transient
windows. It'll only be used inside mutter (for the time being), so
keep it private for now.

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

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2123>
2021-12-14 18:23:23 +01:00
Carlos Garnacho
26676a829e core: Change behavior of "application is alive" checks
Change some things in these "app is alive" checks:
- The dialog timeout is separated from the ping timeout, in order
  to show it again at a constant rate after dismissing, despite in
  flight pings. It still shows immediately after the first failed
  ping.
- As we want to tap further into is-alive logic, MetaWindow now
  made it a property, that other places in code can fetch and
  subscribe.
- Motion events trigger ping (as long as there was none other in
  flight for the same window), and are counted between ping and
  pong, in order to preemptively declare the window as not alive
  before there is trouble with event queues being overflown.

This results in a separate logic between "the application does
not respond" and "we are showing the close dialog" so that the
former may get triggered independently.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2122>
2021-12-07 17:15:21 +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
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
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
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
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
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
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
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
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
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
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
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
4bacb3621b window/wayland: Make .._wayland_move_resize() name more explanatory
The intention of meta_window_wayland_move_resize() is to finish a
move-resize requested previously, e.g. by a state change, or a
interactive resize. Make the function name carry this intention, by
renaming it to meta_window_wayland_finish_move_resize().

https://gitlab.gnome.org/GNOME/mutter/merge_requests/907
2019-12-09 10:09:40 +01:00
Florian Müllner
c843102eec stack: Delegate layer calculation to a window vfunc
While most of the code to compute a window's layer isn't explicitly
windowing backend specific, it is in practice: On wayland there are
no DESKTOP windows(*), docks(*) or groups.

Reflect that by introducing a calculate_layer() vfunc that computes
(and sets) a window's layer.

(*) they shall burn in hell, amen!

https://gitlab.gnome.org/GNOME/mutter/merge_requests/949
2019-11-29 15:14:38 +01:00
Florian Müllner
b753213f9b window: Add get_default_layer() helper
Most of the layer computation that the stack does actually depends
on the windowing backend, so we will move it to a vfunc.

However before we do that, split out the bit that will be shared.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/949
2019-11-29 15:14:38 +01:00
Florian Müllner
599d8e3287 stack: Move HAS_TRANSIENT_TYPE macro to window-private
We'll soon need it elsewhere, so move it to a shared location.
While at it, convert it to a function.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/949
2019-11-29 15:14:38 +01:00
Jonas Ådahl
155b7bf569 tests/monitor-unit-tests: Add window tiling hot plug test
This test that we handle hot plugs correctly together with tiled
windows.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/912
2019-11-05 10:36:25 +01:00
Hans de Goede
ae238d1d4d window: Add adjust_fullscreen_monitor_rect virtual method
Add an adjust_fullscreen_monitor_rect virtual method to MetaWindowClass
and call this from setup_constraint_info() if the window is fullscreen.

This allows MetaWindowClass to adjust the monitor-rectangle used to size
the window when going fullscreen, which will be used in further commits
for a workaround related to fullscreen games under Xwayland.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/739
2019-11-01 14:12:17 +01:00
Rémi Bernon
8f242f8bf0 core: Fix multiple reparent requests handling
If window decoration is modified within a short period of time, mutter
sometimes starts processing the second request before the first
UnmapNotify event has been received. In this situation, it considers
that the window is not mapped and does not expect another UnmapNotify /
MapNotify event sequence to happen.

This adds a separate counter to keep track of the pending reparents. The
input focus is then restored when MapNotify event is received iff all
the expected pending ReparentNotify events have been received.

Signed-off-by: Rémi Bernon <rbernon@codeweavers.com>

https://gitlab.gnome.org/GNOME/mutter/merge_requests/657
2019-09-02 15:50:37 +00:00
Olivier Fourdan
ad62a659eb window: Move UI frame event handler to a separate function
In order to tell whether an event has been handled by the frame UI, move
the UI frame handler to a specific helper function.

https://gitlab.gnome.org/GNOME/mutter/issues/88
2019-08-19 09:16:04 +02:00
Jonas Ådahl
59bf1f4838 window/wayland: Don't always use constrained size when unfullscreening
When we're unfullscreening, we might be returning to a window state that
has its size either managed by constraints (tiled, maximized), or not
(floating). Lets just pass the configure size 0x0 when we're not using
constrained sizes (i.e. the window going from being fullscreen to not
maximized) and let the application decide how to size itself.

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/621
2019-06-13 16:40:57 +00:00
Jonas Ådahl
db0f85ba5d window: Add tile mode getter
Lets avoid peeking in the MetaWindow struct itself and add a getter for
the relevant state.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/621
2019-06-13 16:40:57 +00:00
Carlos Garnacho
5e0523cc8b x11: Move X11 calls to map/unmap a MetaWindow to MetaWindowX11
Add 2 vmethods so that MetaWindowX11 may handle the X11 calls itself.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Jonas Ådahl
f580b28a27 window: Replace placement constrained bool with state
Using an actual state instead of a boolean makes it clearer it's a state
that changes. Eventually we might add more state too.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/496
2019-03-17 14:12:40 +00:00
Jonas Ådahl
b4f1569640 window: Unmanage rule placed window if ending up outside of parent
If a client maps a persistent popup with a placement rule, then resizes
the parent window so that the popup ends up outside of the parent,
unmanage the popup and log a warning about the client being buggy.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/496
2019-03-17 14:12:40 +00:00
Niels De Graef
1c6ea5d1db Use a consistent style for enum braces
https://gitlab.gnome.org/GNOME/mutter/merge_requests/361
2019-02-28 09:31:01 +01:00
Marco Trevisan (Treviño)
f798912cbd window: Move can_ping to a function and implement in X11
https://gitlab.gnome.org/GNOME/mutter/merge_requests/421
2019-02-13 02:07:41 +00:00
Marco Trevisan (Treviño)
3bf80a967c window-x11: Move delete_window to MetaWindowX11Private
https://gitlab.gnome.org/GNOME/mutter/merge_requests/421
2019-02-13 02:07:41 +00:00
Marco Trevisan (Treviño)
6c3b0cfc36 window-x11: Move take_focus to MetaWindowX11Private
https://gitlab.gnome.org/GNOME/mutter/merge_requests/421
2019-02-13 02:07:41 +00:00
Marco Trevisan (Treviño)
43633d6b2f window: Add is_focusable class method
Implement is_focusable for both x11 and wayland and just use this check
so that we can abstract things more and be less dependent on window backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/421
2019-02-13 02:07:41 +00:00
Olivier Fourdan
bbcb66ddf4 window: Add window id
Generate a unique 64bit window-id which is unrelated to any windowing
backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
2018-12-14 13:26:16 +01:00
Florian Müllner
6e1b14b26b x11: Remove hide-titlebar-when-maximized support
It's a UI pattern that has been superseded by client-side decorations,
apps that used to set the hint have generally moved on to headerbars.
Given that and the limitation to server-side decorated X11 windows,
GTK4 removed the client-side API for setting the hint, it's time to
follow suite and retire the feature.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/221
2018-11-26 13:12:18 +00:00
Emilio Pozuelo Monfort
5e005316ef output: Turn winsys_id into a uint64_t
We need a 64 bit field to combine the device id and connector
id into the output id (winsys_id).
2018-11-19 14:58:48 +00:00
Olivier Fourdan
fa495286a1 window: Really force update monitor on hot plugs
Commit 8d3e05305 ("window: Force update monitor on hot plugs") added the
flag `META_WINDOW_UPDATE_MONITOR_FLAGS_FORCE` passed to
`update_monitor()` from `update_for_monitors_changed()`.

However, `update_for_monitors_changed()` may choose to call another code
path to `move_between_rects()` and `meta_window_move_resize_internal()`
eventually.

As `meta_window_move_resize_internal()` does not use the "force" flag,
we may still end up in case where the window->monitor is left unchanged.

To avoid that problem, add a new `MetaMoveResizeFlags` that
`update_for_monitors_changed()` can use to force the monitor update from
`meta_window_move_resize_internal()`.

Fixes: 8d3e05305 ("window: Force update monitor on hot plugs")
Closes: https://gitlab.gnome.org/GNOME/mutter/issues/189
2018-11-13 10:10:30 +01:00
Jonas Ådahl
640a04d0e4 window: Make edge constraint code more readable
It relied on indices in arrays determining tile direction and
non-obvious bitmask logic to translate to _GTK_EDGE_CONSTRAINTS. Change
this to explicitly named edge constraints, and clear translation methods
that converts between mutters and GTK+s edge constraint formats.
2018-11-08 13:21:21 +01:00
Jonas Ådahl
5fc07fcc23 window: Store tile mode as MetaTileMode
An unnecessary memory optimization, storing the tile mode as a 2 bit
unsigned integer, was used. While saving a few bytes, it made debugging
harder. Remove the useless byte packing.
2018-11-08 13:21:21 +01:00
Jonas Ådahl
2f4a68c8c3 Clean up include macros mess
The order and way include macros were structured was chaotic, with no
real common thread between files. Try to tidy up the mess with some
common scheme, to make things look less messy.
2018-11-06 17:17:36 +01:00
Jonas Ådahl
fa1add2ee6 window: Remember relative position after constraining with custom rule
In order to allow a window with a custom rule placement to be moved
together with its parent, the final rule used derived from the
constraining were used for subsequent constraints. This was not enough
as some constraining cannot be translated into a rule, such as sliding
across some axis.

Instead, make it a bit simpler and just remember the position relative
to the parent window, and use that the next time.

This is a rework of 5376c31a33 which
caused the unwanted side effects.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/332
2018-10-08 16:17:50 +00:00
Carlos Garnacho
8dcac664fa core: Preserve focus across decoration changes
Changes in window decoration result in the window being reparented
in and out its frame. This in turn causes unmap/map events, and
XI_FocusOut if the window happened to be focused.

In order to preserve the focused window across the decoration change,
add a flag so that the focus may be restored on MapNotify.

Closes: #273
2018-09-24 13:44:53 +00:00
Jonas Ådahl
e2e7296612 window: Move out 'updates frozen' state into implementations
Implementation of said state was just related to X11, so move it into
window-x11.c. The Wayland path always fell back on the returning TRUE,
so just do that for now.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/229
2018-09-19 15:39:54 +00:00
Jonas Ådahl
5376c31a33 window: Keep windows with placement rule attached to parent
A window placed using a placement rule should keep that relative
position even if the parent window moves, as the position tied to the
parent window, not to the stage. Thus, if the parent window moves, the
child window should move with it.

In the implementation in this commit, the constraints engine is not
used when repositioning the children; the window is simply positioned
according to the effective placement rule that was derived from the
initial constraining, as the a xdg_popup at the moment cannot move
(relative its parent) after being mapped.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/274
2018-08-27 12:15:06 +00:00