1
0
Fork 0
Commit graph

677 commits

Author SHA1 Message Date
Jonas Ådahl
5d3e7d6ffd window: Always sync window geometry on state change
When a state changed, e.g. a window went from unfullscreen to
fullscreen, always sync the window geometry, otherwise a compositor
application (e.g. gnome-shell) might end up with an unfinished window
state transition effect.

Without always syncing, the compositor plugin will see a 'size-change'
event, as a result of the state change, but if the size didn't change,
it would never see the 'size-changed' event. If an effect, for example
gnome-shell's fullscreen effect, is triggered on 'size-change' it might
rely on the actual size change to not get stuck. This commit allows it
to have this dependency.

This fixes a bug where a fullscreen effect gets "stuck" when a window
goes fullscreen without changing the window geometry.

https://bugzilla.gnome.org/show_bug.cgi?id=780292
2017-03-23 22:12:25 +08:00
Rui Matos
bb2e8ff09a window: Make move_to_monitor work for zero sized and offscreen windows
Wayland windows are initially zero sized until clients commit the
first buffer. Despite being invisible, clients are allowed to request
such windows to be fullscreened on a specific output before they
attach the first buffer which means we need to be able to move them.

meta_window_move_to_monitor() doesn't handle this case because these
windows' initial monitor is a placeholder since their initial
coordinates are 0,0+0+0, which results in us using a rectangle as
old_area for meta_window_move_between_rects() that might be to the "right"
of the window causing the move to go further out of the visible
screen's coordinates. This is later "corrected" by the constraints
system but the window might end up in the wrong monitor.

To fix this, we can make meta_window_move_between_rects() accept a
NULL old_area, meaning that we move the window to the new_area without
trying to keep a relative position.

https://bugzilla.gnome.org/show_bug.cgi?id=772525
2017-02-21 19:51:32 +01:00
Jonas Ådahl
4e812410cc monitor-manager: Move logical monitor into its own file
https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:53 +08:00
Jonas Ådahl
1fb0e8e9bb monitor-manager: Store logical monitors in a GList
Instead of storing the logical monitors in an array and having users
either look up them in the array given an index or iterate using
indices, put it in a GList, and use GList iterators when iterating and
alternative API where array indices were previously used.

This allows for more liberty regarding the type of the logical monitor.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:52 +08:00
Jonas Ådahl
016359ede2 window: Remove public meta_window_get_all_monitors API
It's not used anywhere and used monitor indices which is unoptimal.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:52 +08:00
Jonas Ådahl
410bad88a8 screen: Don't use monitor indices in check_fullscreen_func
Rewrite check_fullscreen_func to not use indexes (and
offset-index-as-pointer) tricks. This also removes the usage of an API
constructing temporary logical monitor arrays carrying indices.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:52 +08:00
Jonas Ådahl
98ee85ce82 Let the MetaWindow calculate its main logical monitor itself
There is no point in going via a MetaScreen API to calculate the "main
monitor" of a window, so let the window do that calculation itself.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:52 +08:00
Jonas Ådahl
2df4ebff47 Put logical monitor grid lookup API in MetaMonitorManager
Don't falsely assume the screen has anything to do with the monitor
grid, and thus move the related API to MetaMonitorManager.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:52 +08:00
Jonas Ådahl
317b734dcc Move cursor tracker ownership to the backend
Let the backend initialize the cursor tracker, and change all call
sites to get the cursor tracker from the backend instead of from the
screen. It wasn't associated with the screen anyway, so the API was
missleading.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:51 +08:00
Jonas Ådahl
ecf796f82b window: Keep track of fullscreen monitors directly
Instead of keeping around array indexes, keep track of them by storing
a pointer instead. This also changes from using an array (imitating the
X11 behaviour) to more explicit storing.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:51 +08:00
Jonas Ådahl
79fd91ec35 Add API for getting work area given a logical monitor
To complement the current API which takes an index referencing a
logical monitor in the logical monitor array, add API that takes a
direct reference to the logical monitor itself. The intention is to
replace the usage of the index based API with one that doesn't rely on
internal implementation details.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:51 +08:00
Jonas Ådahl
c936056663 MetaMonitorManager: Track primary monitor by pointer instead of index
Instead of keeping an index in an array to keep track of the current
primary logical monitor, just keep a pointer instead.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:51 +08:00
Jonas Ådahl
e22bbd4b14 MetaScreen: Remove redundant copy of logical monitors array
It was just pointer to the actual list; having to synchronize a list of
logical monitors with the actual monitors managed by the backend is
unnecessary.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:51 +08:00
Jonas Ådahl
103df63023 MetaWindow: Clear fullscreen monitors when monitors change
The fullscreen monitors state is set given a set of xinerama monitor
identification numbers. When the monitor configuration changes (e.g. by
a hotplug event) these are no longer valid, and may point to
uninitialized or unallocated data. Avoid accessing
uninitialized/unallocated memory by clearing the fullscreen monitor
state when the monitor configuration changes.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:51 +08:00
Jonas Ådahl
842ff5d6aa Rename MetaMonitorInfo MetaLogicalMonitor
In preparation for further refactorizations, rename the MetaMonitorInfo
struct to MetaLogicalMonitor. Eventually, part of MetaLogicalMonitor
will be split into a MetaMonitor type.

https://bugzilla.gnome.org/show_bug.cgi?id=777732
2017-01-25 16:28:51 +08:00
Rui Matos
2b59b4c793 keybindings: Grab buttons with any modifier combo on unfocused windows
We currently only focus unfocused windows on button press if no
modifiers (or just ignored modifiers) are in effect. This behavior
seems surprising and counter-intuitive so let's do it for any modifier
combination instead.

https://bugzilla.gnome.org/show_bug.cgi?id=746642
2016-11-23 18:40:11 +01:00
Rui Matos
1956a6ae76 window: Use the target rect for the grab anchor position on unmaximize
A window's unconstrained_rect is essentially just the target rectangle
we hand to meta_window_move_resize_internal() except it's not updated
until the window actually moves or resizes.

As such, for wayland client resizes, since they're async, using
window->unconstrained_rect right after calling move_resize_internal()
to update the grab anchor position on unmaximize doesn't work as it
does for X clients.

To fix this, we can just use the target rectangle for the grab
anchor. Note that comment here was already wrong since it says we
should be taking constraints into account and yet the code used the
unconstrained rect anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=770345
2016-11-23 18:37:47 +01:00
Rui Matos
1d280d8fa1 window: Inform the compositor when a window effectively changes size
In order for the compositor plugin to be able to animate window size
changes properly we need to let it know of the starting and final
window sizes.

For X clients this can be done synchronously and thus with a single
call into the compositor plugin since it's us (the window manager)
who's in charge of the final window size.

Wayland clients though, have the final say over their window size
since it's determined from the client allocated buffer.

This patch moves the meta_compositor_size_change_window() calls before
move_resize_internal() which lets the compositor plugin know the old
window size and freezes the MetaWindowActor.

Then we get rid of the META_MOVE_RESIZE_DONT_SYNC_COMPOSITOR flag
since it's not needed anymore as the window actor is frozen and that
means we can use meta_compositor_sync_window_geometry() as the point
where we inform the compositor plugin of the final window size.

https://bugzilla.gnome.org/show_bug.cgi?id=770345
2016-11-23 18:37:35 +01:00
Olivier Fourdan
998d921d41 window: Do not unfocus on new window
mutter would remove focus from a toplevel when showing one of its
transient window which is not on top and not focused.

When using xdg_popup without grab as allowed in xdg_shell v6, the popup
wouldn't be focused, and if an intermediate event occurs before the
popup is shown, it's not placed on top either, which could randomly
trigger a loss of focus in the corresponding toplevel window.

Remove that special case, it doesn't make much sense to globally unset
focus when mapping a new window.

https://bugzilla.gnome.org/show_bug.cgi?id=773210
2016-10-27 17:21:21 +02:00
Florian Müllner
bccff5bdd8 window: Expose Flatpak application ID
GNOME Shell's window matching currently fails frequently with Flatpak
applications, as one of the primary hints used to link windows with
.desktop files - the WM_CLASS - no longer matches when flatpak renames
the exported .desktop file. Luckily, Flatpak provides us with a fail-safe
way to map from the PID to the corresponding application ID, so expose an
appropriate method that allows GNOME Shell to reliably match windows to
the corresponding Flatpak app.

https://bugzilla.gnome.org/show_bug.cgi?id=772614
2016-10-10 23:35:02 +02:00
Florian Müllner
1fab6e69b7 window: Add get_client_pid() method
It is often useful to identify the client process that created
a particular window, however the existing meta_window_get_pid()
method relies on _NET_WM_PID, which is only available on X11 and
depends on applications to set it correctly (which may not even
be possible when the app runs in its own PID namespace as Flatpak
apps do). So add a get_client_pid() method that uses windowing
system facilities to resolve the PID associated with a particular
window.

https://bugzilla.gnome.org/show_bug.cgi?id=772613
2016-10-10 23:35:01 +02:00
Jonas Ådahl
6c8f6afdc4 window: Fix focus of unmappable modal transient's parent
When a modal transient is unmanaging, most likely the parent of the
modal transient should be focused.

In Wayland, a MetaWindow is created when a shell surface role (like
xdg_toplevel) is created, but a window cannot be shown until a buffer
is attached. If a client would create two modal transients and make
them both have the same parent, but only one get a buffer attached
(i.e. shown), when unmanaging the modal transient that was showing,
when finding a new focus candidate, the stacking code will ignore the
not-to-be-shown buffer-less modal transient when finding a good
candidate for focusing. In the case described here, this means it will
find the parent of the unmanaging modal transient.

This newly chosen candidate will then be passed to meta_window_focus();
meta_window_focus() will then try to find any modal transient to focus
instead, will find the one without any buffer, then fail to focus it
because it cannot be mapped, thus making meta_window_focus() not focus
anything. Since meta_window_focus() didn't change any focus state, the
assert in meta_window_unmanage() checking that the unmanaging window
isn't focused anymore will be hit, causing mutter to abort.

For now, fix this by checking whether the modal transient can actually
be focused in meta_window_focus(). For X11 client windows, a window
will be defined to be focusable always, but for Wayland client windows,
a window will be determined focusable only if it has a buffer attached.

In the future, we should probably do a more thorough refactorization of
focus handling to get rid of any X11 - Wayland differences.

https://bugzilla.gnome.org/show_bug.cgi?id=757568
2016-09-01 21:09:10 +08:00
Florian Müllner
89f6fdce5d events: Only pass key events to Wayland if focus is on the stage
Even without a compositor grab, key events may still be expected to
be processed by the compositor and not applications, for instance
when using ctrl-alt-tab to keynav in the top bar. On X11, focus is
moved to the stage window in that case, so that events are processed
before they are dispatched by the window manager. On wayland, we need
to handle this case ourselves, so make sure to not pass key events to
wayland in that case, and move the key focus back to the stage when
appropriate.

https://bugzilla.gnome.org/show_bug.cgi?id=758167
2016-08-30 00:20:31 +02:00
Jonas Ådahl
658d97d00e window: Don't unmanage transient_for when attached
For some reason, when a modal dialog was made an attaching
transient-for, if the window wasn't "constructing", it would be
unmanaged and rely on some side effect to be recreated. This side
effect is not triggered for Wayland clients, thus if one happen to set
a surface as "modal" via gtk_surface.set_modal before
xdg_toplevel.set_parent, it'd be unmanaged and never show up.

Instead, simply just set the tranciency anyway for Wayland clients.
This makes GTK+ clients that set_modal() before set_transient_for()
work.

https://bugzilla.gnome.org/show_bug.cgi?id=770324
2016-08-26 09:59:55 +08:00
Jonas Ådahl
8942e98e1d Revert "window: Make meta_window_has_pointer() per protocol implemented"
Windows from Xwayland still needs to use the Wayland path, but is
represented an MetaWindowX11, thus the abstraction introduced in
"window: Make meta_window_has_pointer() per protocol implemented"
is wrong. Lets turn back time, and reconsider how this can be
abstracted more correctly in the future.

This reverts commit 9fb891d216.
2016-08-26 06:51:19 +08:00
Jonas Ådahl
8833991201 core: Add support for custom window placement rules
Add support for assigning a window a custom window placement rule used
for calculating the initial window position as well as defining how a
window is constrained.

The custom rule is a declarative rule which defines a set of parameters
which the placing algorithm and constrain algorithm uses for
calculating the position of a window. It is meant to be used to
implement positioning of menus and other popup windows created via
Wayland.

A custom placement rule replaces any other placement or constraint
rule.

https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Jonas Ådahl
9fb891d216 window: Make meta_window_has_pointer() per protocol implemented
https://bugzilla.gnome.org/show_bug.cgi?id=769936
2016-08-25 12:19:40 +08:00
Rui Matos
5ee0f24ab9 window: Stop updating layers on focus changes
Commit 3a4ae679ea removed the
FOCUSED_WINDOW layer definition but it was already unused for a long
time. There's no layers to update on focus changes.

https://bugzilla.gnome.org/show_bug.cgi?id=768221
2016-07-06 19:11:30 +02:00
Rui Matos
fcc7501eb8 core: Remove META_LAYER_FULLSCREEN
This layer isn't really being used and in fact, it causes
meta_stack_get_default_focus_window() to return a fullscreen window
even if the naturally topmost window in the stack isn't a fullscreen
one.

Note that commit a3bf9b01aa changed how
we choose the default focus window from the MRU to the topmost in the
stack.

https://bugzilla.gnome.org/show_bug.cgi?id=768221
2016-07-06 19:11:30 +02:00
Olivier Fourdan
492854e14d window: Do not try to focus O-R windows in focus-follow-mouse
Doing so would raise a critical warning.

https://bugzilla.gnome.org/show_bug.cgi?id=767997
2016-07-06 09:14:56 +02:00
Rui Matos
8f7a36c53f window: Don't create invalid UTF-8 window description strings
printf string precision counts bytes so we may end up creating invalid
UTF-8 strings here. Instead, use glib's unicode aware methods to clip
the title.

https://bugzilla.gnome.org/show_bug.cgi?id=765535
2016-06-07 20:17:37 +02:00
Marek Chalupa
6cc688d575 wayland: don't send notify when window is being unmanaged
If we try to send notify event (either from surface_state_changed()
or from meta_window_wayland_move_resize_internal()),
we will crash, because we don't have a sufrace anymore.
There's no reason why to resize the window that is being
unmanaged anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=751847
2016-05-12 20:06:11 +02:00
Jonas Ådahl
10a0114856 wayland: Move buffer use count to MetaWaylandSurface
Each wl_surface.commit with a newly attached buffer should result in
one wl_buffer.release for the attached buffer. For example attaching
the same buffer to two different surfaces must always result in two
wl_buffer.release events being emitted by the server. The client is
responsible for counting the wl_buffer.release events and be sure to
have received as many release events as it has attached and committed
the buffer, before reusing it.

https://bugzilla.gnome.org/show_bug.cgi?id=762828
2016-03-29 18:26:10 +08:00
Olivier Fourdan
4e82a751fb window: check for possible loop in transients
If a broken or naughty application tries set up its windows to create
a loop in the transient relationship, mutter will hang, looping forever
in meta_window_foreach_ancestor()

To avoid looping infinitely at various point in the code, check for a
possible loop when setting the transient relationship and deny the
request to set a window transient for another if that would create a
loop.

Bugzilla: https://bugzilla.gnome.org/show_bug.cgi?id=759299
2016-02-18 09:03:56 +01:00
Florian Müllner
46eb682c83 Revert "window: Remove old tiling code"
This reverts commit 8bded7d497.
2016-01-10 15:16:09 +01:00
Florian Müllner
3aea8d8ce6 Revert "Add "size states" which save window size information"
This reverts commit 2c7ef2269f.
2016-01-10 15:16:09 +01:00
Florian Müllner
40c3c69435 Revert "window: Add new tiling code"
This reverts commit 50e3e3b929.
2016-01-10 15:16:08 +01:00
Jasper St. Pierre
50e3e3b929 window: Add new tiling code
The new tiling code, instead of based around "tiling states", is instead
based around constrained edges. This allows us to have windows that have
three constrained edges, but keep one free-floating, e.g. a window tiled
to the left has the left, top, and bottom edges constrained, but the
right edge can be left resizable.

This system also is easily extended to support corner tiling. We also,
using the new "size state" system, also keep normal, tiled, and
maximized sizes independently, allowing the maximize button to bounce
between maximized and tiled states without reverting to normal in
between. Dragging from the top will always restore the normal state,
though.

https://bugzilla.gnome.org/show_bug.cgi?id=751857
2016-01-09 18:09:30 -08:00
Jasper St. Pierre
2c7ef2269f Add "size states" which save window size information
https://bugzilla.gnome.org/show_bug.cgi?id=751857
2016-01-09 18:08:35 -08:00
Jasper St. Pierre
8bded7d497 window: Remove old tiling code
We'll soon replace this with a better scheme

https://bugzilla.gnome.org/show_bug.cgi?id=751857
2016-01-09 18:08:32 -08:00
Rui Matos
3a2cd3389a window: Re-evaluate window visibility when making it transient
In case a window is hidden when we're ordered to make it transient to
a different parent we must re-evaluate its visibility status or we'll
get into an inconsistent state where the parent is visible and the
child isn't.

https://bugzilla.gnome.org/show_bug.cgi?id=759297
2016-01-06 18:56:07 +01:00
Rui Matos
88acfb8e60 window: Focus windows on button press regardless of modifier state
This seems like a more generally useful and intuitive behavior. Note
that, in X sessions, this is what already happened in practice since
meta_display_begin_grab_op() calls meta_window_grab_all_keys() which,
on X11, does meta_window_focus().

https://bugzilla.gnome.org/show_bug.cgi?id=756789
2016-01-05 20:42:05 +01:00
Rui Matos
8e22dce5d7 window: Remove a spurious meta_verbose()
This was duplicated here by mistake in the big re-work commit
7a109a18af .

https://bugzilla.gnome.org/show_bug.cgi?id=756789
2016-01-05 20:42:04 +01:00
Jonas Ådahl
213f0fa160 window: Update the stack after setting the transient_for field
Don't update the stack until after setting the window->transient_for
field. Updating before will cause the stack transient-for constraint to
be missing until the next time constraints are applied.

https://bugzilla.gnome.org/show_bug.cgi?id=755606
2015-12-23 14:59:36 +08:00
Jasper St. Pierre
8cc345fcf5 window: Allow minimizing windows which don't advertise support for it
Wine removes the minimize func from its Motif hints on full-screen
windows, because, as the Win32 API literally says, the minimize button
is indeed not visible on full-screen windows.

Given that this code was added to prevent minimizing a panel by
accident, I don't necessarily think that it's relevant anymore.

https://bugzilla.gnome.org/show_bug.cgi?id=758186
2015-12-05 10:46:21 -08:00
Carlos Garnacho
c625d2ee9d core: Make meta_window_handle_ungrabbed_event() touch-aware
This fixes the effects of this function on touchscreens in wayland
(most notably, window raising & focusing).
2015-11-25 18:00:36 +01:00
Marek Chalupa
99c0b82b15 window: do not force placing window if it is not mapped
When managing window, we queue showing the window.
Under wayland, if we commit surface quickly enough,
the showing is unqueued and commit procedure takes care
of mapping and placing the window. In the oposite case,
queue is processed before client sets all we need and
then we have wrong size of window, which leads to broken placement.
Therefore force placement in queue only if the window should already
be mapped. If it is not mapped, we don't care where it is anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=751887
2015-11-16 10:21:09 +08:00
Rui Matos
76e816a14f window: Properly update window->monitor for the desktop window
We don't want to move the desktop window but we still need to update
window->monitor or otherwise we'll be left with a pointer to invalid
memory.

https://bugzilla.gnome.org/show_bug.cgi?id=757148
2015-10-27 14:33:34 +01:00
Cosimo Cecchi
a692fd3808 compositor: add hooks for fullscreen and unfullscreen animations
https://bugzilla.gnome.org/show_bug.cgi?id=707248
2015-10-12 22:28:30 -04:00
Owen W. Taylor
1ab8b854df Improve debug logging of Wayland windows
Displaying all Wayland windows with the XID of 0x0 makes it hard
to figure out what is going on ... use the recently-added
window->stamp to show Wayland windows as W1/W2/W3...
2015-10-12 09:52:25 -04:00