1
0
Fork 0
Commit graph

829 commits

Author SHA1 Message Date
Carlos Garnacho
cda9579034 core: propagate the effective on-all-workspaces setting to transient window
Commit 09bab98b1e tried to avoid several workspace changes while in
window construction, but it missed a case:

If we have a window on a secondary monitor with no workspaces enabled
(so it implicitly gets on_all_workspaces = TRUE without requesting it)
and trigger the creation of a second window that has the first as
transient-for, it would first try to set the first workspace than the
transient-for window and then fallback to all/current workspace.

After that commit we only try to set the same workspace than the
transient-for window, but it gets none as neither is on a single workspace,
nor did really request to be on all workspaces.

Fixes crashes when opening transient X11 dialogs in the secondary monitor.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/714
2019-08-05 18:19:01 +00:00
Florian Müllner
56a5c5e4d1 cleanup: Stop using g_get_current_time ()
It has been deprecated because it isn't Y2k38 ready, so replace it
with g_get_real_time () which is.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/708
2019-08-03 16:12:32 +00:00
Carlos Garnacho
09bab98b1e core: Avoid consecutive workspace changes in window construction
We first set the workspace to the transient-for parent's, and then
try to set on the current workspace. If both happen, we double the
work on adding/removing it from the workspace, and everything that
happens in result.

Should reduce some activity while typing on the Epiphany address
bar, as the animation results in a number of xdg_popup being created
and destroyed to handle the animation.

https://gitlab.gnome.org/GNOME/mutter/issues/556
2019-07-24 21:06:50 +02:00
Carlos Garnacho
aee8bfce3f core: Only notify on MetaWindow::user-time on actual changes
If the timestamp is the same, it doesn't make sense to update and we
don't do so. So it doesn't make sense to notify on the property either.

https://gitlab.gnome.org/GNOME/mutter/issues/556
2019-07-24 13:55:53 +02:00
Marco Trevisan (Treviño)
84616bef27 window: Allow grab if the display focus is unset
As per commit 040de396b, we don't try to grab when shortcuts are inhibited,

However, this uses the focus window assuming that it is always set, while this
might not be the case in some scenarios (like when unsetting the focus before
requesting take-focus-window to acquire the input).

So allow the button grab even if the focus window is not set for the display

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/663
https://gitlab.gnome.org/GNOME/mutter/merge_requests/668
2019-07-03 18:13:25 +02:00
Olivier Fourdan
040de396b2 window: Don't use button grab modifiers with inhibit shortcuts
On Wayland, if a client issues a inhibit-shortcut request, the Wayland
compositor will disable its own shortcuts.

We should also disable the default handler for the button grab modifier
so that button events with the window grab modifiers pressed are not
caught by the compositor but are forwarded to the client surface.

That also fixes the same issue with Xwayland applications issuing grabs,
as those end up being emulated like shortcut inhibition.

Closes: https://gitlab.gnome.org/GNOME/mutter/issues/642
2019-07-03 10:36:34 +02:00
Marco Trevisan (Treviño)
e14613e74e window: Warn if try to focus unmanaging windows
https://gitlab.gnome.org/GNOME/mutter/merge_requests/307
2019-06-24 09:42:07 +00: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
Marco Trevisan (Treviño)
a6fc656e91 window: Emit an error and return when trying to activate an unmanaged
If something (i.e. gnome-shell or an extension) tries to activate an unmanaged
window, we should warn about this and avoid to perform further actions as this
could lead to a crash of mutter, since the window has not valid flags (like
workspace) set anymore at this stage.

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

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

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:31 +00:00
Carlos Garnacho
2f217109aa core: Relax requirement that MetaWindow shall have icon/mini-icon
We use a GtkIconTheme (thus icon-theme, thus xsettings, thus x11) just to
grab a "missing icon" icon to show in place. Relax this requirement that
surfaces for icon/mini-icon will be set, and just let it have NULL here.

It seems better to have the callers (presumably UI layers) aware of this
and set a proper icon by themselves, but AFAICS there is none in sight,
not even plain mutter seems to use MetaWindow::[mini-]icon. Probably
worth a future cleanup.

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/420
2019-05-24 15:30:30 +00:00
Jonas Ådahl
439afb3f19 window: Move all attached windows with parent
We'd break the loop for moving attached windows at the first window,
meaning we'd only ever move a single attached dialogs or popup if it was
the first window in the list. This doesn't work out well when there are
multiple popups open, so don't break out of the loop at all until all
windows are potentially moved.

This fixes an issue in gtk4 where one or more non-grabbing popups would
end up unattached if there were more than one and the parent window was
moved.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/592
2019-05-24 15:07:03 +00:00
Marco Trevisan (Treviño)
f7ecf3b618 meta: Remove meta_free_gslist_and_elements
This function was added for historic reasons, before that we had GSlist's
free_full function.

Since this can be now easily implemented with a function call and an explicit
GDestroyFunc, while no known dependency uses it let's move to use
g_slist_free_func instead.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/57
2019-05-15 14:49:56 -05:00
Daniel van Vugt
7738b5c00b core/window: Fix copy/paste error in size-changed docs
It appears it was copied from MetaWindow::position-changed and pasted
for MetaWindow::size-changed, without updating all the words.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/567
2019-05-08 09:28:16 +00:00
Ray Strode
502da973eb window: free close dialog before unmanaging window from compositor
When an application stops responding, the shell darkens its windows.

If a window from a not-responding application gets unmanaged
then the shell will currently throw an exception trying to retrieve
the now-dissociated window actor.

That leads to a "stuck window" ghost on screen and a traceback
in the log.

This commit addresses the problem by making sure the effect is cleaned
up before the actor is disocciated from its window.

https://gitlab.gnome.org/GNOME/mutter/issues/575
2019-04-29 14:06:12 -04: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
Jonas Ådahl
f2d7165a52 window: Don't try to move hidden attached windows
When a parent window is moved, attached windows (attached modal dialogs
or popups) is moved with it. This is problematic when such a window
hasn't been shown yet (e.g. a popup that has been configured but not
shown), as it'll mean we try to constrain an empty window. Avoid this
issue by not trying to auto-move empty windows.

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)
58d2a674c4 window: Return focusable ability looking at properties only
As per commit 43633d6b, we mark an unmanaging window as not focusable, while
this is true, it might cause not resetting the current focused window when
unmanaging it causing a crash.

Also this wouldn't allow to check if a window can be focused when unmanaging it,
so let's revert the previous behavior.

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/462
2019-02-14 13:49:51 +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
Josh Triplett
b4ae6cdd62 Don't include potentially sensitive window titles in logs
For various error and warning messages, mutter includes a description of
the window, and that description includes a snippet of the title of the
window. Those snippets find their way into system logs, which then means
they can potentially find their way into bug reports and similar. Remove
the window title information to eliminate this potential privacy issue.
2019-02-03 06:32:14 +01:00
Florian Müllner
d5a7bbd094 Fix builds with G_DISABLE_ASSERT
Commit 25f416c13d added additional compilation warnings, including
-Werror=return-type. There are several places where this results
in build failures if `g_assert_not_reached()` is disabled at compile
time and the compiler misses a return value.

https://gitlab.gnome.org/GNOME/mutter/issues/447
2019-01-25 09:43:06 +01:00
Olivier Fourdan
582b67a2f1 window: Handle maximize when headless
When for some reason a window is maximized while the compositor is
headless, `window->monitor` will be NULL, so check for a NULL monitor
to avoid a NULL-pointer dereference.

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

https://gitlab.gnome.org/GNOME/mutter/merge_requests/383
2019-01-09 15:19:20 +01:00
Niels De Graef
0478c225b7 Add some gtk-doc comments. 2019-01-06 21:57:16 +01:00
Jonas Ådahl
781ec74fd2 window: Fix introspection warnings
(transfer none) was added for fundamental types, which can't be
transfered.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/356
2018-12-14 15:57:36 +01:00
Olivier Fourdan
7a5e0c7824 window: Expose the client type in the API
We already have the enum exposed, but no accessor function.

Add `meta_window_get_client_type()` which returns the
`MetaWindowClientType` of a window.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/306
2018-12-14 13:26:16 +01: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
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
Jonas Ådahl
49780245f4 window/wayland: Don't initialize a window as showing
With Wayland, a window is not showing until it's shown. Until this
patch, the initial state of MetaWindow, on the other hand, was that a
window is initialized as showing. This means that for a window to
actually be classified as shown (MetaWindow::hidden set to FALSE),
something would first have to hide it.

Normally, this wasn't an issue, as normally we'd first create a window,
determine it shouldn't be visible (due to missing buffer), hide it
before the next paint, then eventually show it. This doesn't work if
mutter isn't drawing any frames at the moment (e.g. the user switched
VT), as we'd miss the hiding before showing as e result of a buffer
being attached. The most visible side effect is that a window can't be
moved as the window actor remains frozen.

This commit fixes this issue by correctly classifying a newly created
Wayland window as "hidden".

Fixes: https://gitlab.gnome.org/GNOME/mutter/issues/331
2018-10-05 17:50:22 +02: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
Olivier Fourdan
b443bd42ac window: unmanage dialog when clearing transient_for
On Wayland, xdg-foreign would leave a modal dialog managed even after
the imported surface is destroyed.

This is sub-optimal and this breaks the atomic relationship one would
expect between the parent and its modal dialog.

Make sure we unmanage the dialog if transient_for is unset even for
Wayland native windows.

Related: https://gitlab.gnome.org/GNOME/mutter/issues/174
Related: https://gitlab.gnome.org/GNOME/mutter/issues/221
2018-09-14 11:11:31 +02: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
Jonas Ådahl
8d3e053059 window: Force update monitor on hot plugs
Commit a3da4b8d5b changed updating of
window monitors to always use take affect when it was done from a
non-user operation. This could cause feed back loops when a non-user
driven operation would trigger the changing of a monitor, which itself
would trigger changing of the monitor again due to a window scale
change.

The reason for the change, was that when the window monitor changed due
to a hot plug, if it didn't actually change, eventually the window
monitor pointer would be pointing to freed memory.

Instead of force updating the monitor on all non-user operations, just
do it on hot plugs. This allows for the feedback loop preventing logic
to still do what its supposed to do, without risking dangling pointers
on hot plugs.

Related: https://gitlab.gnome.org/GNOME/mutter/issues/189
Closes: https://gitlab.gnome.org/GNOME/mutter/issues/192
2018-08-27 08:33:00 +00:00
Jonas Ådahl
f4d07caa38 window: Pass flag to meta_window_update_monitor() instead of bool
The bool determines whether the call was directly from a user operation
or not. To add more state into the call without having to add more
boolenas, change the boolean to a flag (so far with 'none' and 'user-op'
as possible values). No functional changes were made.

https://gitlab.gnome.org/GNOME/mutter/issues/192
2018-08-27 08:33:00 +00:00
Florian Müllner
d99442d6e6 window: Explicitly exclude unmanaging window from focus again
Since commit b3b9d9e16 we no longer have to pass the unmanaging window
to make sure we don't try to focus it again, however the parameter also
influences the focus policy by giving ancestors preference over the normal
stack order.

https://gitlab.gnome.org/GNOME/mutter/issues/15
2018-07-30 17:48:40 +00:00
Florian Müllner
148da24f95 window: Don't refuse to move focus to the grab window
We refuse to move focus while a grab operation is in place. While this
generally makes sense, there's no reason why the window that owns the
grab shouldn't be given the regular input focus as well - we pretty
much assume that the grab window is also the focus window anyway.

In fact there's a strong reason for allowing the focus change here:
If the grab window isn't the focus window, it probably has a modal
transient that is focused instead, and a likely reason for the focus
request is that the transient is being unmanaged and we must move
the focus elsewhere.

https://gitlab.gnome.org/GNOME/mutter/issues/15
2018-07-30 17:48:39 +00:00
Jonas Ådahl
6d12d2eac2 tests: Move window-shown verification to test-runner
Previously we relied on the test-client to make sure that a window was
shown. For X11, we did not need to do anything, but for Wayland we had
to make sure we had drawn the first frame, otherwise mutter wouldn't
have a buffer making the window not showable.

Doing it this way doesn't work anymore however, since the 'after-paint'
event will be emitted even if we didn't actually paint anything. This is
the case with current Gtk under Wayland, where we won't draw until the
compositor has configured the surface. In effect, this mean we'll get a
dummy after-paint emission before the first frame is actually painted.

Instead, move the verification that a "show" command has completed by
having the test-runner wait for a "shown" signal on the window, which is
emitted in the end of meta_window_show(). This requires an additional
call to gdk_display_sync() in the test-client after creating the window,
to make sure that the window creation vents has been received in the
compositor.
2018-07-17 16:30:18 +02:00
Armin Krezović
81c1c70c0a Move workspace related code from MetaDisplay to MetaWorkspaceManager
https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:17 +02:00
Armin Krezović
390314adfb Rename errors.[ch] to meta-x11-errors.[ch]
Also rename meta_error_trap_* to meta_x11_error_trap_* and
move meta-x11-errors.c to src/x11

https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:17 +02:00
Armin Krezović
e8171ccdc1 Use MetaMonitorManager insted of MetaDisplay where possible
This drops display's monitors-changed signal and makes all
the code rely on MetaMonitorManager.

https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:17 +02:00
Armin Krezović
8e7e1eeef5 Prepare for making MetaX11Display conditional
- Stop using CurrentTime, introduce META_CURRENT_TIME
- Use g_get_monotonic_time () instead of relying on an
  X server running and making roundtrip to it

https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:16 +02:00
Armin Krezović
1d5e37050d Stop using MetaScreen where it is unnecessary
https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:16 +02:00
Armin Krezović
b7c3dada81 Move workspace handling to MetaDisplay and MetaX11Display
https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:16 +02:00
Armin Krezović
e1c67a1824 Move monitor management API to MetaDisplay
This includes changing various users to use MetaDisplay directly, who
used MetaScreen only for this before.

https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:16 +02:00
Armin Krezović
68f261e8e2 Move rest of non-X11 specific objects from MetaScreen
This moves following objects from MetaScreen to MetaDisplay

- workareas_later and in_fullscreen_later signals and functions
- startup_sequences signals and functions
- tile_preview functions

https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:16 +02:00
Armin Krezović
05899596d1 Move X11 helper windows and xprops to MetaX11Display
https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:16 +02:00
Armin Krezović
98d912ba5f Move stack tracking and guard_window outside of MetaScreen
Move stack, stack_tracker to MetaDisplay guard_window to MetaX11Display

https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:16 +02:00
Armin Krezović
722c975aca Move alarm and xids management to MetaX11Display
https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:16 +02:00
Armin Krezović
cd8f4259be Move screen size and cursor setting to MetaDisplay
Split X11 specific parts into MetaX11Display. This also required
changing MetaScreen to stop listening to any signals by itself, but
instead relying on MetaDisplay forwarding them. This was to ensure the
ordering. MetaDisplay listens to both the internal and external
monitors-changed signal so that it can pass the external one via the
redundant MetaDisplay(prev MetaScreen)::monitors-changed.

https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:16 +02:00
Armin Krezović
dacc041d0c Switch meta_error_trap functions to MetaX11Display
They are X11 specific functions, used for X11 code. They have been
improved per jadahl's suggestion to use gdk_x11_lookup_xdisplay and
gdk_x11_display_error_trap_* functions, instead of current code.

https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:16 +02:00
Armin Krezović
18779109de Start populating MetaX11Display
- Moved xdisplay, name and various atoms from MetaDisplay
- Moved xroot, screen_name, default_depth and default_xvisual
  from MetaScreen

- Moved some X11 specific functions from screen.c and display.c
  to meta-x11-display.c

https://bugzilla.gnome.org/show_bug.cgi?id=759538
2018-07-06 19:47:16 +02:00
Sam Spilsbury
8626c69c2f window: Return -1 if meta_window_get_monitor is called on an unmanaged window
As opposed to crashing. In this case, letting the caller deal with
it is the best policy, since this is public API.

https://bugzilla.gnome.org/show_bug.cgi?id=788834
2018-06-28 16:24:07 +00:00
Georges Basile Stavracas Neto
822c2666f5 window: Let implementations finish state changes
In the old, synchronous X.org world, we could assume that
a state change always meant a synchronizing the window
geometry right after. After firing an operation that
would change the window state, such as maximizing or
tiling the window,

With Wayland, however, this is not valid anymore, since
Wayland is asynchronous. In this scenario, we call
meta_window_move_resize_internal() twice: when the user
executes an state-changing operation, and when the server
ACKs this operation. This breaks the previous assumptions,
and as a consequence, it breaks the GNOME Shell animations
in Wayland.

The solution is giving the MetaWindow control over the time
when the window geometry is synchronized with the compositor.
That is done by introducing a new result flag. Wayland asks
for a compositor sync after receiving an ACK from the server,
while X11 asks for it right away.

Fixes #78
2018-04-25 21:55:05 -03:00
Georges Basile Stavracas Neto
63e2c0329f window: Fix a small memory leak 2018-03-21 21:16:23 -03:00
Georges Basile Stavracas Neto
00b8ca7aeb Revert "window: Raise and lower tile match in tandem"
Raising and lowering windows in tandem without a proper grouping
mechanism ended up being more annoying than functional.

This reverts commit e76a0f564c.
2018-03-09 20:13:14 +01:00
Egmont Koblinger
67bf936ef8 theme: Fix icon scaling
When painting the titlebar, button icons that aren't available in the
desired size need to be scaled. However the current code inverses the
scale factor, with the result that the adjusted icons are much worse
than the original icons, whoops.

This went unnoticed for a long time given that most icons are availa-
ble in the desired 16x16 size, and the most likely exceptions - window
icons - are not shown by default.

https://gitlab.gnome.org/GNOME/mutter/issues/23
2018-03-03 15:48:35 +00:00
Gwan-gyeong Mun
abd6b7affd Change naming of GParmSpec enum id string for naming consistency
GParamSpec enum string usually follows "PROP_" prefix and PROP_LAST is used
for last PROP string.

https://gitlab.gnome.org/GNOME/mutter/issues/28

Closes: #28
2018-02-10 13:49:14 +01:00
Olivier Fourdan
5f05112b9a wayland: update location prior to maximize
When maximizing a window, the previous location is saved so that
un-maximize would restore the same original window location.

However, if a Wayland client starts with a window maximized, the
previous location will be 0x0, so if we have to force placement in
xdg_toplevel_set_maximized(), we should update the location as well so
that the window is placed on the right monitor when un-maximizing.

For that purpose, add a new flag to force the update of the window
location, and use that flag from xdg_toplevel_set_maximized().

https://bugzilla.gnome.org/show_bug.cgi?id=783901
2018-01-11 11:03:04 +01:00
Olivier Fourdan
1139ace244 core: Add new unmaximize flag
Wayland clients know their size better, so for Wayland we'd rather not
try to resize the client on un-maximize, but for this to work we need a
new MetaMoveResizeFlags.

https://bugzilla.gnome.org/show_bug.cgi?id=783901
2018-01-11 11:03:04 +01:00
Olivier Fourdan
bd9a300801 window: Defer stack placement without a buffer
When closing a window and showing a new one, the new one may not be
granted input focus until it gets a buffer on Wayland.

If another window is chosen to receive focus and raised on top of stack,
the newly mapped window is focused but placed underneath that other
window.

Meaning that for Wayland surfaces, we need to defer adding the window to
the stack until we actually get to show it, once we have a buffer
attached.

Rather that checking the windowing backend prior to decide if a window
is stackable or not, introduce a new vfunc is_stackable() which tells
if a window should be added to the stack regardless of the underlying
windowing system.

Also add meta_window_is_in_stack() API rather than checking the stack
position directly (replacing the define WINDOW_IN_STACK only available
in stack.c) and remove a window from the stack only if it is present
in the stack, so that the test in meta_stack_remote() becomes
irrelevant.

https://bugzilla.gnome.org/show_bug.cgi?id=780820
2018-01-11 11:03:04 +01:00
Olivier Fourdan
1546989845 xwayland: Add MetaWindowXwayland
MetaWindowXwayland derives from MetaWindowX11 to allow for some Xwayland
specific vfunc that wouldn't apply to plain X11 windows, such as
shortcut inhibit routines.

https://bugzilla.gnome.org/show_bug.cgi?id=783342
2017-12-18 13:15:09 +01:00
Marco Trevisan (Treviño)
ab5ac21104 window: rename get_flatpack_id into get_sandboxed_app_id
This function can be more generic now.

https://bugzilla.gnome.org/show_bug.cgi?id=789277
2017-10-21 13:36:16 -05:00
Jonas Ådahl
6eb7d13894 window: Handle updating from no to no monitor
When we received two hot plug events that both resulted in headless
configuration, we tried to find a new window monitor given the old.
That resulted in a null pointer dereference; avoid that by only trying
to find the same monitor if there was an old one.

https://bugzilla.gnome.org/show_bug.cgi?id=788607
2017-10-07 00:36:03 -04:00
Georges Basile Stavracas Neto
a5f4ffa58c window: Track edge constraints
GTK has the ability to handle client-decorated windows
in such a way that the behavior of these windows must
match the behavior of the current window manager.

In Mutter, windows can be tiled horizontally (and, in
the future, vertically as well), which comes with a few
requirements that the toolkit must supply. Tiled windows
have their borders' behavior changed depending on the
tiled position, and the toolkit must be aware of this
information in order to properly match the window manager
behavior.

In order to provide toolkits with more precise and general
data regarding resizable and constrained edges, this patch
makes MetaWindow track its own edge constraints.

This will later be used by the backends to send information
to the toolkit.

https://bugzilla.gnome.org/show_bug.cgi?id=751857
2017-10-03 19:38:32 -03:00
Georges Basile Stavracas Neto
a1c39e142d window: Also consider touching edges for matching tiled windows
When computing a potential match for a tiled window, there is a
chance we face the case where 2 windows really complement each
other's tile mode (i.e. left and right) but they have different
sizes, and their borders don't really touch each other.

In that case, the current code would mistakenly assume they're
tile matches, and would resize them with either a hole or an
overlapping area between windows. This is clearly a misbehavior
that is a consequence of the previous assumptions pre-resizable
tiles.

This patch adapts the tile match algorithm to also consider the
touching edges when computing the matching tile, unless:

 * the window is not currently tiled (for example when computing
   the tile preview)
 * the window is currently resized in tandem with an existing
   tile match

https://bugzilla.gnome.org/show_bug.cgi?id=645153

bar
2017-10-03 19:38:32 -03:00
Georges Basile Stavracas Neto
e76a0f564c window: Raise and lower tile match in tandem
When a pair of tiled windows are grouped together, they
are treated as parts of a whole and interacting with one
affects the other.

Following the idea that sibling tiled windows are treated
as part of the same group, they should also be raised and
lowered together.

It is still possible to break tiled windows grouping by
simply untiling the window with the keyboard or by grabbing
and resizing or moving the window with the cursor.

This patch makes sibling tiled windows be lowered and raised
in tandem. For future reference, this behavior is documented
in [1].

[1] https://wiki.gnome.org/GeorgesNeto/MinutesOfFeaneron/Tiling

https://bugzilla.gnome.org/show_bug.cgi?id=645153
2017-10-03 19:38:31 -03:00
Georges Basile Stavracas Neto
1dbf6b096b edge-resistance: Add snapping for tiled windows
When windows are tiled, it improves the interaction with
them when they have a set of snapping edges relative to
the monitor. For example, when there's a document editor
and a PDF file opened, I might want to rescale the former
to 2/3 of the screen and the latter to 1/3.

These snapping sections are not really tied to any other
window, and only depend on the current work area of the
window. Thus, it is not necessary to adapt the current
snapping edge detection algorithm.

This patch adds the necessary code in edge-resistance.c
to special-case tiled windows and allow them to cover
1/4, 1/3 and 1/2 (horizontally) of the screen. These
values are hardcoded.

https://bugzilla.gnome.org/show_bug.cgi?id=645153
2017-10-03 19:38:31 -03:00
Georges Basile Stavracas Neto
6fe71ecc01 window: Tile and resize considering the tile match
After the introduction of the possibility to resize tiled windows,
it is a sensible decision to make windows aware of their tiling
match. A tiling match is another window that is tiled in such a
way that is the complement of the current window.

The newly introduced behavior attepts to make tiling as smooth as
possible, with the following rules:

 * Windows now compute their tile match when tiling and, if there's
   a match, they automatically complement the sibling's width.
 * Resizing a window with a sibling automatically resizes the sibling
   too to be the complement of the window's width.
 * It is not possible to resize below windows' minimum widths.

https://bugzilla.gnome.org/show_bug.cgi?id=645153
2017-10-03 19:38:31 -03:00
Georges Basile Stavracas Neto
57e58eaf2a window: Maximize tiled windows when resizing to work area
Now that tiled windows are resizable, the user may grow a tiled
windows until it covers the entire work area. As this makes the
window state mostly indistinguishable from maximization, avoid
subtle differences by properly maximizing the window in that case.

https://bugzilla.gnome.org/show_bug.cgi?id=645153
2017-10-03 19:38:31 -03:00
Florian Müllner
00a5db71cf window: Allow resizing of tiled windows
Currently tiled windows are not resizable and their size is fixed
to half the screen width. Adjust the code to work with fractions
other than half, and allow users to adjust the split by dragging
the window edge that is not constrained by a monitor edge.

Follow-up patches will improve on that by resizing neighboring
tiled windows by a shared edge, and making the functionality
available to client-side decorated windows implementing the
new edge constraints protocol.
2017-10-03 19:38:31 -03:00
Florian Müllner
c7fa57cd28 window: Pass mode as parameter to tile() operation
Now that the preview tile mode has been split from the window's
tile_mode property, it is much more natural to pass the requested
tile_mode to the tile() function instead of setting it externally
and calling the function to apply the state.
2017-10-03 19:38:31 -03:00
Florian Müllner
8f2c86d79e window: Split out preview_tile_mode
The existing semantics of the tile_mode property are terribly confusing,
as it depends on some other property whether it represents the requested
or current mode. Clear this up by just using separate variables for the
two. As it is unlikely that we will ever support more than one tile
preview, we can track the requested mode globally instead of adding
another per-window variable.

https://bugzilla.gnome.org/show_bug.cgi?id=645153
2017-10-03 19:38:31 -03:00
Georges Basile Stavracas Neto
56f1da5c66 window: Update tile monitor before move
The actual move may involve the tile monitor, so make sure to not use
an outdated value by setting it before calling move_between_rects().

https://bugzilla.gnome.org/show_bug.cgi?id=645153
2017-10-03 19:38:31 -03:00
Florian Müllner
30a205c0e3 window: Remove obsolete code
Commit 91b7dedf36 removed the ability to temporarily break out
of maximization/tiling during grab operations, so this code is no
longer necessary.

https://bugzilla.gnome.org/show_bug.cgi?id=645153
2017-10-03 19:38:31 -03:00
Jonas Ådahl
6dd819a61e window: Don't try to auto-maximize when headless
Automatic maximization is done when a window is almost the size of the
work area of a monitor. This makes no sense to try when there is no
monitor available, so skip trying to do this when headless.

https://bugzilla.gnome.org/show_bug.cgi?id=787637
2017-10-02 18:02:19 -04:00
Jonas Ådahl
39aae19ed7 window: Treat being headless as not monitor sized
When we are headless, treat this as if the window is always not monitor
sized. This might cause windows to temporarly become redirected while
being headless, but this is harmless as when a new monitor is
connected, we'll recalculate weather it should be redirected or not.

https://bugzilla.gnome.org/show_bug.cgi?id=787637
2017-10-02 18:02:16 -04:00
Vasilis Liaskovitis
e3d59832c5 x11/window: Implement _NET_RESTACK_WINDOW and XConfigureRequestEvent sibling
Implement _NET_RESTACK_WINDOW, based on metacity commit 0b5a50c8.

Also respect "above" field (sibling) of XConfigureRequestEvent. When it is
set, perform a stack operation relative to that sibling.

https://bugzilla.gnome.org/show_bug.cgi?id=786363
https://bugzilla.gnome.org/show_bug.cgi?id=786365
2017-09-29 18:30:26 +02:00
Jonas Ådahl
2c85bb4178 window: Make should_be_on_all_workspaces() handle being headless
Also adds a soft assert to meta_window_is_on_primary_monitor() to make
it easier to spot when callers might want to handle headless
in a certain way.

https://bugzilla.gnome.org/show_bug.cgi?id=730551
2017-09-29 10:35:13 -04:00
Marco Trevisan (Treviño)
6dc499f305 window: Support snap packages for sandboxed app IDs
For now we abuse of meta_window_get_flatpak_id not to break the APIs,
so that it's working seamlessly in gnone shell too.

Rename flatpak_id to sandboxed_app_id internally to get prepared to the future
API.

https://bugzilla.gnome.org/show_bug.cgi?id=788217
2017-09-27 22:08:57 +08:00
Jonas Ådahl
2df4ccd1cd window: Handle being headless better
This avoids updating state (such as position, size etc) when going
headless. Eventually, when non-headless, things will be updated again,
and not until then will we be able to update to a valid state.

https://bugzilla.gnome.org/show_bug.cgi?id=730551
2017-08-30 13:44:05 +08:00
Jonas Ådahl
7562eb6006 core/window: Don't set a preferred output when there is none
If there are no active logical monitors, don't try to dereference a
NULL one to get a preferred output winsys id. Instead just set an
invalid one.

https://bugzilla.gnome.org/show_bug.cgi?id=730551
2017-08-30 13:09:38 +08:00
Olivier Fourdan
dd12f569d9 wayland: add inhibit shortcut mechanism
Add a mechanism to MetaWaylandSurface that inhibits compositor's own
shortcuts when the surface has input focus, so that clients can receive
all key events regardless of the compositor own shortcuts.

This will help with implementing "fake" active grabs in Wayland and
XWayland clients.

https://bugzilla.gnome.org/show_bug.cgi?id=783342
2017-08-02 11:58:55 +02:00
Jonas Ådahl
4afa66fe41 wayland/window: Update toplevel main monitor before non-toplevel
When updating the main monitor, make sure to update the toplevel main
monitor before trying to use that as the main monitor for non-toplevel
windows (such as popups). Without this, when the main monitor is
updated as a side effect to monitors being changed (for example due to
a hot plug event, or coming back from being suspended) the
main monitor pointer may, after 'monitors-changed' has completed, point to
freed memory resulting in undefined behaviour.

https://bugzilla.gnome.org/show_bug.cgi?id=784867
2017-07-17 09:59:34 +08:00
Carlos Garnacho
408292959e core: Add meta_close_dialog_focus() vmethod
This is used to request key focus on the close dialog whenever
a window that is frozen would receive key focus. Also, ensure
that the dialog gets focus when first shown if the window was
meant to receive input.

https://bugzilla.gnome.org/show_bug.cgi?id=762083
2017-07-16 19:21:41 +02:00
Jonas Ådahl
7bd69f0b32 window: Don't crash when moving across non-adjecent logical monitors
When moving a window between two non-adjecent logical monitors, don't
try to tile a window when the window position is outside of any logical
monitor.

https://bugzilla.gnome.org/show_bug.cgi?id=783630
2017-07-12 12:30:54 +08:00
Florian Müllner
5f49bda591 window: Include window itself in transient loop check
While it doesn't make sense to set a window as transient to
itself, our existing check whether making a window transient
doesn't cover it, so it's still possible to create an infinite
loop.

https://bugzilla.gnome.org/show_bug.cgi?id=783502
2017-06-22 08:49:40 +02:00
Florian Müllner
4d7329a7e2 window: Include STATE_CHANGED flag when tiling
For size change animations, plugins rely on the size change effect being
followed by size changed signal (or effects being kill altogether).
However unless the move_resize operation included the STATE_CHANGED flag,
the size changed event emitted when the compositor syncs the window
geometry only happens when the operation resulted in an actual change.

To avoid animations getting stuck in that case, make sure to include the
flag when tiling a window.

https://bugzilla.gnome.org/show_bug.cgi?id=783293
2017-06-06 15:35:06 +02:00
Alessandro Bono
270da95cbc window: Notify about size-change when tiling
Call meta_compositor_size_change_window while tiling in order
to emit the size-change signal. Since the untiling action is
considered a unmaximize size change, treat tiling as a maximize
size change for consistency.

https://bugzilla.gnome.org/show_bug.cgi?id=782968
2017-05-24 09:51:29 +02:00