2014-03-19 13:26:17 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Red Hat
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* Written by:
|
|
|
|
* Jasper St. Pierre <jstpierre@mecheye.net>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-07-10 08:36:24 +00:00
|
|
|
#include "wayland/meta-window-wayland.h"
|
2014-03-19 13:26:17 +00:00
|
|
|
|
2016-06-10 07:21:21 +00:00
|
|
|
#include <errno.h>
|
2018-07-10 08:36:24 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "backends/meta-backend-private.h"
|
2016-12-01 04:52:07 +00:00
|
|
|
#include "backends/meta-backend-private.h"
|
2016-12-13 02:37:11 +00:00
|
|
|
#include "backends/meta-logical-monitor.h"
|
2015-03-03 03:13:05 +00:00
|
|
|
#include "compositor/meta-surface-actor-wayland.h"
|
2019-07-12 17:33:17 +00:00
|
|
|
#include "compositor/meta-window-actor-private.h"
|
2018-07-10 08:36:24 +00:00
|
|
|
#include "core/boxes-private.h"
|
|
|
|
#include "core/stack-tracker.h"
|
|
|
|
#include "core/window-private.h"
|
|
|
|
#include "meta/meta-x11-errors.h"
|
|
|
|
#include "wayland/meta-wayland-actor-surface.h"
|
|
|
|
#include "wayland/meta-wayland-private.h"
|
|
|
|
#include "wayland/meta-wayland-surface.h"
|
2019-07-05 16:10:14 +00:00
|
|
|
#include "wayland/meta-wayland-window-configuration.h"
|
2018-07-10 08:36:24 +00:00
|
|
|
#include "wayland/meta-wayland-xdg-shell.h"
|
2014-03-19 13:26:17 +00:00
|
|
|
|
2022-05-18 11:51:44 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
|
|
|
|
PROP_SURFACE,
|
|
|
|
|
|
|
|
PROP_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
static GParamSpec *obj_props[PROP_LAST];
|
|
|
|
|
2014-03-19 13:26:17 +00:00
|
|
|
struct _MetaWindowWayland
|
|
|
|
{
|
|
|
|
MetaWindow parent;
|
2014-04-28 20:19:06 +00:00
|
|
|
|
2017-02-24 10:10:52 +00:00
|
|
|
int geometry_scale;
|
|
|
|
|
2022-05-18 11:51:44 +00:00
|
|
|
MetaWaylandSurface *surface;
|
|
|
|
|
2019-07-05 16:10:14 +00:00
|
|
|
GList *pending_configurations;
|
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-18 02:42:33 +00:00
|
|
|
gboolean has_pending_state_change;
|
2014-05-12 22:05:31 +00:00
|
|
|
|
2020-11-11 09:49:25 +00:00
|
|
|
gboolean has_last_sent_configuration;
|
2021-12-17 15:31:48 +00:00
|
|
|
MetaRectangle last_sent_rect;
|
2020-02-13 21:20:15 +00:00
|
|
|
int last_sent_rel_x;
|
|
|
|
int last_sent_rel_y;
|
wayland/window: Don't lose precision in MetaWaylandWindowConfiguration
Commit 8bdd2aa7 would offset the window position by the difference
between the configured window size and the committed size from the
client to prevent the window from drifting while resizing.
This, however, did not take into account the actual geometry scale, so
when using any scale greater than 1, the window would rapidly drift away
due to that offset.
In order to solve this, we need to make sure we store away the pending
window configuration in the stage coordinate space, in order to not
loose precision. When we then calculate the offset given the result from
the client, it'll use the right scalars, while before, one scalar was in
surface coordinates, while the other in stage coordinates.
https://gitlab.gnome.org/GNOME/mutter/-/issues/1490
2020-10-29 09:11:15 +00:00
|
|
|
int last_sent_geometry_scale;
|
2020-10-07 17:58:47 +00:00
|
|
|
MetaGravity last_sent_gravity;
|
2018-09-14 17:06:55 +00:00
|
|
|
|
2022-09-28 15:23:10 +00:00
|
|
|
MetaWaylandWindowConfiguration *last_acked_configuration;
|
|
|
|
|
2018-09-14 17:06:55 +00:00
|
|
|
gboolean has_been_shown;
|
2014-03-19 13:26:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _MetaWindowWaylandClass
|
|
|
|
{
|
|
|
|
MetaWindowClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (MetaWindowWayland, meta_window_wayland, META_TYPE_WINDOW)
|
|
|
|
|
2019-07-12 17:33:17 +00:00
|
|
|
static void
|
|
|
|
set_geometry_scale_for_window (MetaWindowWayland *wl_window,
|
|
|
|
int geometry_scale)
|
|
|
|
{
|
|
|
|
MetaWindowActor *window_actor;
|
|
|
|
|
|
|
|
wl_window->geometry_scale = geometry_scale;
|
|
|
|
|
|
|
|
window_actor = meta_window_actor_from_window (META_WINDOW (wl_window));
|
|
|
|
if (window_actor)
|
|
|
|
meta_window_actor_set_geometry_scale (window_actor, geometry_scale);
|
|
|
|
}
|
|
|
|
|
2017-02-24 10:10:52 +00:00
|
|
|
static int
|
|
|
|
get_window_geometry_scale_for_logical_monitor (MetaLogicalMonitor *logical_monitor)
|
|
|
|
{
|
2017-10-16 09:02:51 +00:00
|
|
|
g_assert (logical_monitor);
|
|
|
|
|
2017-02-24 10:10:52 +00:00
|
|
|
if (meta_is_stage_views_scaled ())
|
|
|
|
return 1;
|
|
|
|
else
|
2017-05-25 08:12:51 +00:00
|
|
|
return meta_logical_monitor_get_scale (logical_monitor);
|
2017-02-24 10:10:52 +00:00
|
|
|
}
|
|
|
|
|
2014-03-19 13:36:15 +00:00
|
|
|
static void
|
|
|
|
meta_window_wayland_manage (MetaWindow *window)
|
|
|
|
{
|
2017-02-24 10:10:52 +00:00
|
|
|
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
|
2014-03-19 13:36:15 +00:00
|
|
|
MetaDisplay *display = window->display;
|
|
|
|
|
2017-10-16 09:02:51 +00:00
|
|
|
wl_window->geometry_scale = meta_window_wayland_get_geometry_scale (window);
|
2017-02-24 10:10:52 +00:00
|
|
|
|
2014-03-19 13:36:15 +00:00
|
|
|
meta_display_register_wayland_window (display, window);
|
|
|
|
|
|
|
|
{
|
2017-08-26 17:03:51 +00:00
|
|
|
meta_stack_tracker_record_add (window->display->stack_tracker,
|
2014-09-09 01:20:14 +00:00
|
|
|
window->stamp,
|
2014-03-19 13:36:15 +00:00
|
|
|
0);
|
|
|
|
}
|
2015-02-24 19:55:45 +00:00
|
|
|
|
2022-05-18 11:51:44 +00:00
|
|
|
meta_wayland_surface_window_managed (wl_window->surface, window);
|
2014-03-19 13:36:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_wayland_unmanage (MetaWindow *window)
|
|
|
|
{
|
|
|
|
{
|
2017-08-26 17:03:51 +00:00
|
|
|
meta_stack_tracker_record_remove (window->display->stack_tracker,
|
2014-09-09 01:20:14 +00:00
|
|
|
window->stamp,
|
2014-03-19 13:36:15 +00:00
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
|
|
|
meta_display_unregister_wayland_window (window->display, window);
|
|
|
|
}
|
|
|
|
|
2014-03-20 19:12:44 +00:00
|
|
|
static void
|
|
|
|
meta_window_wayland_ping (MetaWindow *window,
|
|
|
|
guint32 serial)
|
|
|
|
{
|
2022-05-18 11:51:44 +00:00
|
|
|
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
|
|
|
|
|
|
|
|
meta_wayland_surface_ping (wl_window->surface, serial);
|
2014-03-20 19:12:44 +00:00
|
|
|
}
|
|
|
|
|
2014-03-20 19:07:44 +00:00
|
|
|
static void
|
|
|
|
meta_window_wayland_delete (MetaWindow *window,
|
|
|
|
guint32 timestamp)
|
|
|
|
{
|
2022-05-18 11:51:44 +00:00
|
|
|
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
|
|
|
|
|
|
|
|
meta_wayland_surface_delete (wl_window->surface);
|
2014-03-20 19:07:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_wayland_kill (MetaWindow *window)
|
|
|
|
{
|
2022-05-18 11:51:44 +00:00
|
|
|
MetaWaylandSurface *surface = meta_window_get_wayland_surface (window);
|
2014-03-25 16:05:21 +00:00
|
|
|
struct wl_resource *resource = surface->resource;
|
|
|
|
|
|
|
|
/* Send the client an unrecoverable error to kill the client. */
|
|
|
|
wl_resource_post_error (resource,
|
|
|
|
WL_DISPLAY_ERROR_NO_MEMORY,
|
|
|
|
"User requested that we kill you. Sorry. Don't take it too personally.");
|
2014-03-20 19:07:44 +00:00
|
|
|
}
|
|
|
|
|
2014-03-20 19:16:57 +00:00
|
|
|
static void
|
|
|
|
meta_window_wayland_focus (MetaWindow *window,
|
|
|
|
guint32 timestamp)
|
|
|
|
{
|
2018-11-13 07:56:53 +00:00
|
|
|
if (meta_window_is_focusable (window))
|
2018-12-30 20:23:07 +00:00
|
|
|
{
|
|
|
|
meta_display_set_input_focus (window->display,
|
|
|
|
window,
|
|
|
|
FALSE,
|
|
|
|
timestamp);
|
|
|
|
}
|
2014-03-20 19:16:57 +00:00
|
|
|
}
|
|
|
|
|
2019-07-05 16:10:14 +00:00
|
|
|
static void
|
2020-02-13 21:20:15 +00:00
|
|
|
meta_window_wayland_configure (MetaWindowWayland *wl_window,
|
|
|
|
MetaWaylandWindowConfiguration *configuration)
|
2019-07-05 16:10:14 +00:00
|
|
|
{
|
2022-05-18 11:51:44 +00:00
|
|
|
meta_wayland_surface_configure_notify (wl_window->surface, configuration);
|
2019-07-05 16:10:14 +00:00
|
|
|
|
|
|
|
wl_window->pending_configurations =
|
|
|
|
g_list_prepend (wl_window->pending_configurations, configuration);
|
|
|
|
}
|
|
|
|
|
2014-05-20 19:54:39 +00:00
|
|
|
static void
|
|
|
|
surface_state_changed (MetaWindow *window)
|
|
|
|
{
|
|
|
|
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
|
2020-02-13 21:20:15 +00:00
|
|
|
MetaWaylandWindowConfiguration *configuration;
|
2021-12-17 23:15:56 +00:00
|
|
|
int bounds_width;
|
|
|
|
int bounds_height;
|
2014-05-20 19:54:39 +00:00
|
|
|
|
2016-03-17 13:52:46 +00:00
|
|
|
/* don't send notify when the window is being unmanaged */
|
|
|
|
if (window->unmanaging)
|
|
|
|
return;
|
|
|
|
|
2020-11-11 09:49:25 +00:00
|
|
|
g_return_if_fail (wl_window->has_last_sent_configuration);
|
|
|
|
|
2021-12-17 23:15:56 +00:00
|
|
|
if (!meta_window_calculate_bounds (window, &bounds_width, &bounds_height))
|
|
|
|
{
|
|
|
|
bounds_width = 0;
|
|
|
|
bounds_height = 0;
|
|
|
|
}
|
|
|
|
|
2020-02-13 21:20:15 +00:00
|
|
|
configuration =
|
2020-09-17 12:06:27 +00:00
|
|
|
meta_wayland_window_configuration_new (window,
|
2021-12-17 15:31:48 +00:00
|
|
|
wl_window->last_sent_rect,
|
2021-12-17 23:15:56 +00:00
|
|
|
bounds_width, bounds_height,
|
wayland/window: Don't lose precision in MetaWaylandWindowConfiguration
Commit 8bdd2aa7 would offset the window position by the difference
between the configured window size and the committed size from the
client to prevent the window from drifting while resizing.
This, however, did not take into account the actual geometry scale, so
when using any scale greater than 1, the window would rapidly drift away
due to that offset.
In order to solve this, we need to make sure we store away the pending
window configuration in the stage coordinate space, in order to not
loose precision. When we then calculate the offset given the result from
the client, it'll use the right scalars, while before, one scalar was in
surface coordinates, while the other in stage coordinates.
https://gitlab.gnome.org/GNOME/mutter/-/issues/1490
2020-10-29 09:11:15 +00:00
|
|
|
wl_window->last_sent_geometry_scale,
|
2020-02-14 08:55:00 +00:00
|
|
|
META_MOVE_RESIZE_STATE_CHANGED,
|
2020-10-07 17:58:47 +00:00
|
|
|
wl_window->last_sent_gravity);
|
2020-02-13 21:20:15 +00:00
|
|
|
|
|
|
|
meta_window_wayland_configure (wl_window, configuration);
|
2014-05-20 19:54:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_wayland_grab_op_began (MetaWindow *window,
|
|
|
|
MetaGrabOp op)
|
|
|
|
{
|
2014-07-17 19:53:38 +00:00
|
|
|
if (meta_grab_op_is_resizing (op))
|
|
|
|
surface_state_changed (window);
|
2014-05-20 19:54:39 +00:00
|
|
|
|
|
|
|
META_WINDOW_CLASS (meta_window_wayland_parent_class)->grab_op_began (window, op);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_wayland_grab_op_ended (MetaWindow *window,
|
|
|
|
MetaGrabOp op)
|
|
|
|
{
|
2014-07-17 19:53:38 +00:00
|
|
|
if (meta_grab_op_is_resizing (op))
|
|
|
|
surface_state_changed (window);
|
2014-05-20 19:54:39 +00:00
|
|
|
|
|
|
|
META_WINDOW_CLASS (meta_window_wayland_parent_class)->grab_op_ended (window, op);
|
|
|
|
}
|
|
|
|
|
2014-03-19 14:30:12 +00:00
|
|
|
static void
|
|
|
|
meta_window_wayland_move_resize_internal (MetaWindow *window,
|
2020-02-14 08:44:43 +00:00
|
|
|
MetaGravity gravity,
|
2014-05-21 17:59:13 +00:00
|
|
|
MetaRectangle unconstrained_rect,
|
2014-03-19 14:30:12 +00:00
|
|
|
MetaRectangle constrained_rect,
|
2020-02-14 09:41:38 +00:00
|
|
|
MetaRectangle temporary_rect,
|
2020-02-14 07:52:48 +00:00
|
|
|
int rel_x,
|
|
|
|
int rel_y,
|
2014-03-19 14:30:12 +00:00
|
|
|
MetaMoveResizeFlags flags,
|
|
|
|
MetaMoveResizeResultFlags *result)
|
|
|
|
{
|
2014-04-28 20:19:06 +00:00
|
|
|
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
|
2020-02-14 09:41:38 +00:00
|
|
|
gboolean can_move_now = FALSE;
|
2021-12-17 15:31:48 +00:00
|
|
|
MetaRectangle configured_rect;
|
2017-02-24 09:05:01 +00:00
|
|
|
int geometry_scale;
|
2020-02-14 09:41:38 +00:00
|
|
|
int new_x;
|
|
|
|
int new_y;
|
|
|
|
int new_buffer_x;
|
|
|
|
int new_buffer_y;
|
2014-04-16 20:28:43 +00:00
|
|
|
|
2014-03-19 14:30:12 +00:00
|
|
|
g_assert (window->frame == NULL);
|
|
|
|
|
2016-03-17 13:52:46 +00:00
|
|
|
/* don't do anything if we're dropping the window, see #751847 */
|
|
|
|
if (window->unmanaging)
|
|
|
|
return;
|
|
|
|
|
2021-12-17 15:31:48 +00:00
|
|
|
configured_rect.x = constrained_rect.x;
|
|
|
|
configured_rect.y = constrained_rect.y;
|
2016-07-01 07:14:12 +00:00
|
|
|
|
2015-03-23 13:22:19 +00:00
|
|
|
/* The scale the window is drawn in might change depending on what monitor it
|
|
|
|
* is mainly on. Scale the configured rectangle to be in logical pixel
|
|
|
|
* coordinate space so that we can have a scale independent size to pass
|
|
|
|
* to the Wayland surface. */
|
2017-02-24 09:05:01 +00:00
|
|
|
geometry_scale = meta_window_wayland_get_geometry_scale (window);
|
2019-06-13 08:34:23 +00:00
|
|
|
|
2021-12-17 15:31:48 +00:00
|
|
|
configured_rect.width = constrained_rect.width;
|
|
|
|
configured_rect.height = constrained_rect.height;
|
2015-03-23 13:22:19 +00:00
|
|
|
|
2022-05-03 16:47:57 +00:00
|
|
|
/* The size is determined by the client, except when the client is explicitly
|
|
|
|
* fullscreen, in which case the compositor compensates for the size
|
|
|
|
* difference between what surface configuration the client provided, and the
|
|
|
|
* size of the area a fullscreen window state is expected to fill.
|
2014-03-19 14:30:12 +00:00
|
|
|
*
|
2022-05-03 16:47:57 +00:00
|
|
|
* For non-explicit-fullscreen states, since the size is always determined by
|
|
|
|
* the client, the we cannot use the size calculated by the constraints.
|
2014-03-19 14:30:12 +00:00
|
|
|
*/
|
|
|
|
|
2017-06-21 11:30:22 +00:00
|
|
|
if (flags & META_MOVE_RESIZE_FORCE_MOVE)
|
|
|
|
{
|
|
|
|
can_move_now = TRUE;
|
|
|
|
}
|
2018-10-22 14:41:12 +00:00
|
|
|
else if (flags & META_MOVE_RESIZE_WAYLAND_FINISH_MOVE_RESIZE)
|
2014-03-19 14:30:12 +00:00
|
|
|
{
|
2022-05-03 16:47:57 +00:00
|
|
|
MetaWaylandWindowConfiguration *configuration;
|
|
|
|
int new_width, new_height;
|
2014-03-19 14:30:12 +00:00
|
|
|
|
2022-05-03 16:47:57 +00:00
|
|
|
configuration = wl_window->last_acked_configuration;
|
|
|
|
if (configuration && configuration->is_fullscreen)
|
|
|
|
{
|
|
|
|
new_width = constrained_rect.width;
|
|
|
|
new_height = constrained_rect.height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
new_width = unconstrained_rect.width;
|
|
|
|
new_height = unconstrained_rect.height;
|
|
|
|
}
|
|
|
|
if (window->rect.width != new_width ||
|
|
|
|
window->rect.height != new_height)
|
2014-07-17 21:26:22 +00:00
|
|
|
{
|
|
|
|
*result |= META_MOVE_RESIZE_RESULT_RESIZED;
|
2022-05-03 16:47:57 +00:00
|
|
|
window->rect.width = new_width;
|
|
|
|
window->rect.height = new_height;
|
2014-07-17 21:26:22 +00:00
|
|
|
}
|
|
|
|
|
2022-09-28 15:01:50 +00:00
|
|
|
window->buffer_rect.width =
|
|
|
|
window->rect.width +
|
|
|
|
window->custom_frame_extents.left +
|
|
|
|
window->custom_frame_extents.right;
|
|
|
|
window->buffer_rect.height =
|
|
|
|
window->rect.height +
|
|
|
|
window->custom_frame_extents.top +
|
|
|
|
window->custom_frame_extents.bottom;
|
|
|
|
|
2014-04-16 20:28:43 +00:00
|
|
|
/* This is a commit of an attach. We should move the window to match the
|
|
|
|
* new position the client wants. */
|
2014-07-27 15:47:40 +00:00
|
|
|
can_move_now = TRUE;
|
2020-02-14 09:41:38 +00:00
|
|
|
if (window->placement.state == META_PLACEMENT_STATE_CONSTRAINED_CONFIGURED)
|
|
|
|
window->placement.state = META_PLACEMENT_STATE_CONSTRAINED_FINISHED;
|
2014-03-19 14:30:12 +00:00
|
|
|
}
|
2014-07-27 16:30:33 +00:00
|
|
|
else
|
2014-03-19 14:30:12 +00:00
|
|
|
{
|
2020-02-14 09:41:38 +00:00
|
|
|
if (window->placement.rule)
|
|
|
|
{
|
|
|
|
switch (window->placement.state)
|
|
|
|
{
|
|
|
|
case META_PLACEMENT_STATE_UNCONSTRAINED:
|
|
|
|
case META_PLACEMENT_STATE_CONSTRAINED_CONFIGURED:
|
|
|
|
case META_PLACEMENT_STATE_INVALIDATED:
|
|
|
|
can_move_now = FALSE;
|
|
|
|
break;
|
|
|
|
case META_PLACEMENT_STATE_CONSTRAINED_PENDING:
|
|
|
|
{
|
|
|
|
if (flags & META_MOVE_RESIZE_PLACEMENT_CHANGED ||
|
|
|
|
rel_x != wl_window->last_sent_rel_x ||
|
|
|
|
rel_y != wl_window->last_sent_rel_y ||
|
2021-03-26 13:19:43 +00:00
|
|
|
constrained_rect.width != window->rect.width ||
|
|
|
|
constrained_rect.height != window->rect.height)
|
2020-02-14 09:41:38 +00:00
|
|
|
{
|
|
|
|
MetaWaylandWindowConfiguration *configuration;
|
|
|
|
|
|
|
|
configuration =
|
2022-01-16 00:44:37 +00:00
|
|
|
meta_wayland_window_configuration_new_relative (window,
|
|
|
|
rel_x,
|
2020-02-14 09:41:38 +00:00
|
|
|
rel_y,
|
2021-12-17 15:31:48 +00:00
|
|
|
configured_rect.width,
|
|
|
|
configured_rect.height,
|
wayland/window: Don't lose precision in MetaWaylandWindowConfiguration
Commit 8bdd2aa7 would offset the window position by the difference
between the configured window size and the committed size from the
client to prevent the window from drifting while resizing.
This, however, did not take into account the actual geometry scale, so
when using any scale greater than 1, the window would rapidly drift away
due to that offset.
In order to solve this, we need to make sure we store away the pending
window configuration in the stage coordinate space, in order to not
loose precision. When we then calculate the offset given the result from
the client, it'll use the right scalars, while before, one scalar was in
surface coordinates, while the other in stage coordinates.
https://gitlab.gnome.org/GNOME/mutter/-/issues/1490
2020-10-29 09:11:15 +00:00
|
|
|
geometry_scale);
|
2020-02-14 09:41:38 +00:00
|
|
|
meta_window_wayland_configure (wl_window, configuration);
|
|
|
|
|
|
|
|
wl_window->last_sent_rel_x = rel_x;
|
|
|
|
wl_window->last_sent_rel_y = rel_y;
|
|
|
|
|
|
|
|
window->placement.state = META_PLACEMENT_STATE_CONSTRAINED_CONFIGURED;
|
|
|
|
|
|
|
|
can_move_now = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
window->placement.state =
|
|
|
|
META_PLACEMENT_STATE_CONSTRAINED_FINISHED;
|
|
|
|
|
|
|
|
can_move_now = TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case META_PLACEMENT_STATE_CONSTRAINED_FINISHED:
|
|
|
|
can_move_now = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-03-26 13:19:43 +00:00
|
|
|
else if (constrained_rect.width != window->rect.width ||
|
|
|
|
constrained_rect.height != window->rect.height ||
|
2020-02-14 09:41:38 +00:00
|
|
|
flags & META_MOVE_RESIZE_STATE_CHANGED)
|
2014-07-27 16:30:33 +00:00
|
|
|
{
|
2020-02-13 21:20:15 +00:00
|
|
|
MetaWaylandWindowConfiguration *configuration;
|
2021-12-17 23:15:56 +00:00
|
|
|
int bounds_width;
|
|
|
|
int bounds_height;
|
2020-02-13 21:20:15 +00:00
|
|
|
|
2022-05-18 11:51:44 +00:00
|
|
|
if (!meta_wayland_surface_get_buffer (wl_window->surface) &&
|
window/wayland: Replace constraint side effect peeking with state checks
When the MetaWindow resize machinery for toplevels ended up in the
Wayland window implementation, we tried to avoid configuring
not-yet-mapped windows that just had its zero sized dimension pass
through the constraint machinery, resulting in a 1x1 sized window.
If we'd properly set up the min size metadata earlier, that 1x1 would
likely be the minimum size set of a window, which makes things harder to
predict when peeking at side effects.
However, what the side effect peeking intends to do, as documented in
the comment, was to figure out when the client hadn't committed any
buffer yet, i.e. during the initial map, and in those cases avoid
sending that nasty 1x1 size, resulting in silly window sizes. A more
robust way to detect this is instead checking when we shouldn't really
try resize things our own way, and in those cases early out as was done
before.
This means that, for a yet to me mapped window, we only ever want to
send an initial non-zero configuration when 1) it's initially maximized,
2) initially fullscreen, or 3) initially tiled in any way, as those are
the situations where the compositor is the one deciding the size.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1912>
2021-07-02 08:25:49 +00:00
|
|
|
!META_WINDOW_MAXIMIZED (window) &&
|
|
|
|
window->tile_mode == META_TILE_NONE &&
|
|
|
|
!meta_window_is_fullscreen (window))
|
2014-09-17 15:36:31 +00:00
|
|
|
return;
|
|
|
|
|
2021-12-17 23:15:56 +00:00
|
|
|
if (!meta_window_calculate_bounds (window,
|
|
|
|
&bounds_width,
|
|
|
|
&bounds_height))
|
|
|
|
{
|
|
|
|
bounds_width = 0;
|
|
|
|
bounds_height = 0;
|
|
|
|
}
|
|
|
|
|
2020-02-14 09:41:38 +00:00
|
|
|
configuration =
|
2020-09-17 12:06:27 +00:00
|
|
|
meta_wayland_window_configuration_new (window,
|
2021-12-17 15:31:48 +00:00
|
|
|
configured_rect,
|
2021-12-17 23:15:56 +00:00
|
|
|
bounds_width, bounds_height,
|
wayland/window: Don't lose precision in MetaWaylandWindowConfiguration
Commit 8bdd2aa7 would offset the window position by the difference
between the configured window size and the committed size from the
client to prevent the window from drifting while resizing.
This, however, did not take into account the actual geometry scale, so
when using any scale greater than 1, the window would rapidly drift away
due to that offset.
In order to solve this, we need to make sure we store away the pending
window configuration in the stage coordinate space, in order to not
loose precision. When we then calculate the offset given the result from
the client, it'll use the right scalars, while before, one scalar was in
surface coordinates, while the other in stage coordinates.
https://gitlab.gnome.org/GNOME/mutter/-/issues/1490
2020-10-29 09:11:15 +00:00
|
|
|
geometry_scale,
|
2020-02-14 09:41:38 +00:00
|
|
|
flags,
|
|
|
|
gravity);
|
2020-02-13 21:20:15 +00:00
|
|
|
meta_window_wayland_configure (wl_window, configuration);
|
2014-07-27 16:30:33 +00:00
|
|
|
can_move_now = FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
can_move_now = TRUE;
|
|
|
|
}
|
2014-04-16 20:28:43 +00:00
|
|
|
}
|
2014-03-19 14:30:12 +00:00
|
|
|
|
2020-11-11 09:49:25 +00:00
|
|
|
wl_window->has_last_sent_configuration = TRUE;
|
2021-12-17 15:31:48 +00:00
|
|
|
wl_window->last_sent_rect = configured_rect;
|
wayland/window: Don't lose precision in MetaWaylandWindowConfiguration
Commit 8bdd2aa7 would offset the window position by the difference
between the configured window size and the committed size from the
client to prevent the window from drifting while resizing.
This, however, did not take into account the actual geometry scale, so
when using any scale greater than 1, the window would rapidly drift away
due to that offset.
In order to solve this, we need to make sure we store away the pending
window configuration in the stage coordinate space, in order to not
loose precision. When we then calculate the offset given the result from
the client, it'll use the right scalars, while before, one scalar was in
surface coordinates, while the other in stage coordinates.
https://gitlab.gnome.org/GNOME/mutter/-/issues/1490
2020-10-29 09:11:15 +00:00
|
|
|
wl_window->last_sent_geometry_scale = geometry_scale;
|
2020-10-07 17:58:47 +00:00
|
|
|
wl_window->last_sent_gravity = gravity;
|
2014-09-17 01:11:56 +00:00
|
|
|
|
2014-07-27 15:47:40 +00:00
|
|
|
if (can_move_now)
|
2014-04-16 20:16:01 +00:00
|
|
|
{
|
2020-02-14 09:41:38 +00:00
|
|
|
new_x = constrained_rect.x;
|
|
|
|
new_y = constrained_rect.y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
new_x = temporary_rect.x;
|
|
|
|
new_y = temporary_rect.y;
|
2014-07-07 17:06:47 +00:00
|
|
|
|
2020-02-14 09:41:38 +00:00
|
|
|
wl_window->has_pending_state_change |=
|
|
|
|
!!(flags & META_MOVE_RESIZE_STATE_CHANGED);
|
|
|
|
}
|
2014-06-26 15:02:57 +00:00
|
|
|
|
2020-02-14 09:41:38 +00:00
|
|
|
if (new_x != window->rect.x || new_y != window->rect.y)
|
|
|
|
{
|
|
|
|
*result |= META_MOVE_RESIZE_RESULT_MOVED;
|
|
|
|
window->rect.x = new_x;
|
|
|
|
window->rect.y = new_y;
|
|
|
|
}
|
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-18 02:42:33 +00:00
|
|
|
|
2020-02-14 09:41:38 +00:00
|
|
|
if (window->placement.rule &&
|
|
|
|
window->placement.state == META_PLACEMENT_STATE_CONSTRAINED_FINISHED)
|
|
|
|
{
|
|
|
|
window->placement.current.rel_x = rel_x;
|
|
|
|
window->placement.current.rel_y = rel_y;
|
2014-03-19 14:30:12 +00:00
|
|
|
}
|
2020-02-14 09:41:38 +00:00
|
|
|
|
|
|
|
new_buffer_x = new_x - window->custom_frame_extents.left;
|
|
|
|
new_buffer_y = new_y - window->custom_frame_extents.top;
|
|
|
|
|
|
|
|
if (new_buffer_x != window->buffer_rect.x ||
|
|
|
|
new_buffer_y != window->buffer_rect.y)
|
2014-07-27 15:47:40 +00:00
|
|
|
{
|
2020-02-14 09:41:38 +00:00
|
|
|
*result |= META_MOVE_RESIZE_RESULT_MOVED;
|
|
|
|
window->buffer_rect.x = new_buffer_x;
|
|
|
|
window->buffer_rect.y = new_buffer_y;
|
2014-07-27 15:47:40 +00:00
|
|
|
}
|
2020-02-14 09:41:38 +00:00
|
|
|
|
|
|
|
if (can_move_now &&
|
|
|
|
flags & META_MOVE_RESIZE_WAYLAND_STATE_CHANGED)
|
|
|
|
*result |= META_MOVE_RESIZE_RESULT_STATE_CHANGED;
|
2014-03-19 14:30:12 +00:00
|
|
|
}
|
|
|
|
|
2015-03-23 13:22:19 +00:00
|
|
|
static void
|
2016-04-06 12:07:08 +00:00
|
|
|
scale_size (int *width,
|
|
|
|
int *height,
|
|
|
|
float scale)
|
2015-03-23 13:22:19 +00:00
|
|
|
{
|
2016-04-06 12:07:08 +00:00
|
|
|
if (*width < G_MAXINT)
|
|
|
|
{
|
|
|
|
float new_width = (*width * scale);
|
|
|
|
*width = (int) MIN (new_width, G_MAXINT);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*height < G_MAXINT)
|
|
|
|
{
|
|
|
|
float new_height = (*height * scale);
|
|
|
|
*height = (int) MIN (new_height, G_MAXINT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
scale_rect_size (MetaRectangle *rect,
|
|
|
|
float scale)
|
|
|
|
{
|
|
|
|
scale_size (&rect->width, &rect->height, scale);
|
2015-03-23 13:22:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2018-08-24 10:54:50 +00:00
|
|
|
meta_window_wayland_update_main_monitor (MetaWindow *window,
|
|
|
|
MetaWindowUpdateMonitorFlags flags)
|
2015-03-23 13:22:19 +00:00
|
|
|
{
|
2016-12-01 04:52:07 +00:00
|
|
|
MetaBackend *backend = meta_get_backend ();
|
|
|
|
MetaMonitorManager *monitor_manager =
|
|
|
|
meta_backend_get_monitor_manager (backend);
|
2022-05-18 11:51:44 +00:00
|
|
|
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
|
2016-09-23 09:15:56 +00:00
|
|
|
MetaWindow *toplevel_window;
|
2016-12-01 07:15:52 +00:00
|
|
|
MetaLogicalMonitor *from;
|
|
|
|
MetaLogicalMonitor *to;
|
|
|
|
MetaLogicalMonitor *scaled_new;
|
2017-05-25 08:12:51 +00:00
|
|
|
float from_scale, to_scale;
|
2015-03-23 13:22:19 +00:00
|
|
|
float scale;
|
|
|
|
MetaRectangle rect;
|
|
|
|
|
|
|
|
from = window->monitor;
|
2016-09-23 09:15:56 +00:00
|
|
|
|
|
|
|
/* If the window is not a toplevel window (i.e. it's a popup window) just use
|
|
|
|
* the monitor of the toplevel. */
|
2022-05-18 11:51:44 +00:00
|
|
|
toplevel_window = meta_wayland_surface_get_toplevel_window (wl_window->surface);
|
2016-09-23 09:15:56 +00:00
|
|
|
if (toplevel_window != window)
|
|
|
|
{
|
2018-08-27 15:49:52 +00:00
|
|
|
meta_window_update_monitor (toplevel_window, flags);
|
2016-09-23 21:09:39 +00:00
|
|
|
window->monitor = toplevel_window->monitor;
|
|
|
|
return;
|
2016-09-23 09:15:56 +00:00
|
|
|
}
|
2015-03-23 13:22:19 +00:00
|
|
|
|
2021-12-17 23:03:21 +00:00
|
|
|
if (window->rect.width == 0 || window->rect.height == 0)
|
window/wayland: Always update the monitor when updating
If the window didn't have a size, it would still have a monitor, and
when we are asked to update, we must update, as the old monitor might
not be kept around, leaving us vulnerable to use after free.
Avoid not updating the monitor by using the stored IDs (preferred, or
previous) to find suitable logical monitors, with the primary monitor
being the last fallback unless we're completely headless.
This fixes the assert
!window->monitor ||
g_list_find (meta_monitor_manager_get_logical_monitors (monitor_manager),
window->monitor)
in meta_window_update_for_monitors_changed() being hit when a Wayland
window has been created, but not mapped, when a hotplug happens.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2554>
2022-08-03 21:01:00 +00:00
|
|
|
{
|
|
|
|
window->monitor = meta_window_find_monitor_from_id (window);
|
|
|
|
return;
|
|
|
|
}
|
2021-12-17 23:03:21 +00:00
|
|
|
|
2016-09-23 21:09:39 +00:00
|
|
|
/* Require both the current and the new monitor would be the new main monitor,
|
|
|
|
* even given the resulting scale the window would end up having. This is
|
|
|
|
* needed to avoid jumping back and forth between the new and the old, since
|
|
|
|
* changing main monitor may cause the window to be resized so that it no
|
|
|
|
* longer have that same new main monitor. */
|
2022-08-03 20:55:56 +00:00
|
|
|
to = meta_window_find_monitor_from_frame_rect (window);
|
2016-09-23 21:09:39 +00:00
|
|
|
|
2015-03-23 13:22:19 +00:00
|
|
|
if (from == to)
|
|
|
|
return;
|
|
|
|
|
2017-08-18 06:21:11 +00:00
|
|
|
if (from == NULL || to == NULL)
|
|
|
|
{
|
|
|
|
window->monitor = to;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-08-24 10:56:31 +00:00
|
|
|
if (flags & META_WINDOW_UPDATE_MONITOR_FLAGS_FORCE)
|
2018-06-18 10:39:11 +00:00
|
|
|
{
|
|
|
|
window->monitor = to;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-25 08:12:51 +00:00
|
|
|
from_scale = meta_logical_monitor_get_scale (from);
|
|
|
|
to_scale = meta_logical_monitor_get_scale (to);
|
|
|
|
|
2017-08-18 06:21:11 +00:00
|
|
|
if (from_scale == to_scale)
|
2015-03-23 13:22:19 +00:00
|
|
|
{
|
|
|
|
window->monitor = to;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-24 10:10:52 +00:00
|
|
|
if (meta_is_stage_views_scaled ())
|
|
|
|
{
|
|
|
|
window->monitor = to;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-03-23 13:22:19 +00:00
|
|
|
/* To avoid a window alternating between two main monitors because scaling
|
|
|
|
* changes the main monitor, wait until both the current and the new scale
|
|
|
|
* will result in the same main monitor. */
|
2017-05-25 08:12:51 +00:00
|
|
|
scale = to_scale / from_scale;
|
2015-03-23 13:22:19 +00:00
|
|
|
rect = window->rect;
|
|
|
|
scale_rect_size (&rect, scale);
|
2016-12-01 04:52:07 +00:00
|
|
|
scaled_new =
|
|
|
|
meta_monitor_manager_get_logical_monitor_from_rect (monitor_manager, &rect);
|
2015-03-23 13:22:19 +00:00
|
|
|
if (to != scaled_new)
|
|
|
|
return;
|
|
|
|
|
|
|
|
window->monitor = to;
|
|
|
|
}
|
|
|
|
|
2015-03-03 03:13:05 +00:00
|
|
|
static void
|
2016-11-25 06:31:38 +00:00
|
|
|
meta_window_wayland_main_monitor_changed (MetaWindow *window,
|
|
|
|
const MetaLogicalMonitor *old)
|
2015-03-03 03:13:05 +00:00
|
|
|
{
|
2017-02-24 10:10:52 +00:00
|
|
|
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
|
|
|
|
int old_geometry_scale = wl_window->geometry_scale;
|
|
|
|
int geometry_scale;
|
2015-03-23 13:22:19 +00:00
|
|
|
float scale_factor;
|
|
|
|
MetaWaylandSurface *surface;
|
|
|
|
|
2017-02-24 10:10:52 +00:00
|
|
|
if (!window->monitor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
geometry_scale = meta_window_wayland_get_geometry_scale (window);
|
|
|
|
|
2015-03-23 13:22:19 +00:00
|
|
|
/* This function makes sure that window geometry, window actor geometry and
|
|
|
|
* surface actor geometry gets set according the old and current main monitor
|
|
|
|
* scale. If there either is no past or current main monitor, or if the scale
|
|
|
|
* didn't change, there is nothing to do. */
|
|
|
|
if (old == NULL ||
|
|
|
|
window->monitor == NULL ||
|
2017-02-24 10:10:52 +00:00
|
|
|
old_geometry_scale == geometry_scale)
|
2015-03-23 13:22:19 +00:00
|
|
|
return;
|
2015-03-03 03:13:05 +00:00
|
|
|
|
2015-03-23 13:22:19 +00:00
|
|
|
/* MetaWindow keeps its rectangles in the physical pixel coordinate space.
|
|
|
|
* When the main monitor of a window changes, it can cause the corresponding
|
|
|
|
* window surfaces to be scaled given the monitor scale, so we need to scale
|
|
|
|
* the rectangles in MetaWindow accordingly. */
|
|
|
|
|
2017-02-24 10:10:52 +00:00
|
|
|
scale_factor = (float) geometry_scale / old_geometry_scale;
|
2015-03-23 13:22:19 +00:00
|
|
|
|
|
|
|
/* Window size. */
|
|
|
|
scale_rect_size (&window->rect, scale_factor);
|
2015-09-16 06:16:48 +00:00
|
|
|
scale_rect_size (&window->unconstrained_rect, scale_factor);
|
2016-01-10 14:16:09 +00:00
|
|
|
scale_rect_size (&window->saved_rect, scale_factor);
|
2016-04-06 12:07:08 +00:00
|
|
|
scale_size (&window->size_hints.min_width, &window->size_hints.min_height, scale_factor);
|
|
|
|
scale_size (&window->size_hints.max_width, &window->size_hints.max_height, scale_factor);
|
|
|
|
|
2015-03-23 13:22:19 +00:00
|
|
|
/* Window geometry offset (XXX: Need a better place, see
|
2018-10-22 14:41:12 +00:00
|
|
|
* meta_window_wayland_finish_move_resize). */
|
2015-03-23 13:22:19 +00:00
|
|
|
window->custom_frame_extents.left =
|
|
|
|
(int)(scale_factor * window->custom_frame_extents.left);
|
|
|
|
window->custom_frame_extents.top =
|
|
|
|
(int)(scale_factor * window->custom_frame_extents.top);
|
|
|
|
|
|
|
|
/* Buffer rect. */
|
|
|
|
scale_rect_size (&window->buffer_rect, scale_factor);
|
|
|
|
window->buffer_rect.x =
|
|
|
|
window->rect.x - window->custom_frame_extents.left;
|
|
|
|
window->buffer_rect.y =
|
|
|
|
window->rect.y - window->custom_frame_extents.top;
|
|
|
|
|
|
|
|
meta_compositor_sync_window_geometry (window->display->compositor,
|
|
|
|
window,
|
|
|
|
TRUE);
|
|
|
|
|
2022-05-18 11:51:44 +00:00
|
|
|
surface = wl_window->surface;
|
2015-03-03 03:13:05 +00:00
|
|
|
if (surface)
|
|
|
|
{
|
2017-12-22 06:28:28 +00:00
|
|
|
MetaWaylandActorSurface *actor_surface =
|
|
|
|
META_WAYLAND_ACTOR_SURFACE (surface->role);
|
2015-03-03 03:13:05 +00:00
|
|
|
|
2017-12-22 06:28:28 +00:00
|
|
|
meta_wayland_actor_surface_sync_actor_state (actor_surface);
|
2015-03-03 03:13:05 +00:00
|
|
|
}
|
2015-03-23 13:22:19 +00:00
|
|
|
|
2019-07-12 17:33:17 +00:00
|
|
|
set_geometry_scale_for_window (wl_window, geometry_scale);
|
2015-03-23 13:22:19 +00:00
|
|
|
meta_window_emit_size_changed (window);
|
2015-03-03 03:13:05 +00:00
|
|
|
}
|
|
|
|
|
2020-04-08 14:13:38 +00:00
|
|
|
static pid_t
|
2016-10-07 15:55:32 +00:00
|
|
|
meta_window_wayland_get_client_pid (MetaWindow *window)
|
|
|
|
{
|
2022-05-18 11:51:44 +00:00
|
|
|
MetaWaylandSurface *surface = meta_window_get_wayland_surface (window);
|
2016-10-07 15:55:32 +00:00
|
|
|
struct wl_resource *resource = surface->resource;
|
|
|
|
pid_t pid;
|
|
|
|
|
|
|
|
wl_client_get_credentials (wl_resource_get_client (resource), &pid, NULL, NULL);
|
2020-04-08 14:13:38 +00:00
|
|
|
return pid;
|
2016-10-07 15:55:32 +00:00
|
|
|
}
|
|
|
|
|
2014-03-19 13:26:17 +00:00
|
|
|
static void
|
2014-05-12 22:19:11 +00:00
|
|
|
appears_focused_changed (GObject *object,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
gpointer user_data)
|
2014-03-19 13:26:17 +00:00
|
|
|
{
|
2014-05-12 22:19:11 +00:00
|
|
|
MetaWindow *window = META_WINDOW (object);
|
2020-03-12 18:34:03 +00:00
|
|
|
|
|
|
|
if (window->placement.rule)
|
|
|
|
return;
|
|
|
|
|
2014-05-05 23:09:22 +00:00
|
|
|
surface_state_changed (window);
|
2014-05-12 22:19:11 +00:00
|
|
|
}
|
|
|
|
|
2018-09-14 17:06:55 +00:00
|
|
|
static void
|
|
|
|
on_window_shown (MetaWindow *window)
|
|
|
|
{
|
|
|
|
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
|
|
|
|
gboolean has_been_shown;
|
|
|
|
|
|
|
|
has_been_shown = wl_window->has_been_shown;
|
|
|
|
wl_window->has_been_shown = TRUE;
|
|
|
|
|
|
|
|
if (!has_been_shown)
|
|
|
|
meta_compositor_sync_updates_frozen (window->display->compositor, window);
|
|
|
|
}
|
|
|
|
|
2014-05-12 22:19:11 +00:00
|
|
|
static void
|
|
|
|
meta_window_wayland_init (MetaWindowWayland *wl_window)
|
|
|
|
{
|
|
|
|
MetaWindow *window = META_WINDOW (wl_window);
|
|
|
|
|
2017-02-24 10:10:52 +00:00
|
|
|
wl_window->geometry_scale = 1;
|
|
|
|
|
2014-05-12 22:19:11 +00:00
|
|
|
g_signal_connect (window, "notify::appears-focused",
|
|
|
|
G_CALLBACK (appears_focused_changed), NULL);
|
2018-09-14 17:06:55 +00:00
|
|
|
g_signal_connect (window, "shown",
|
|
|
|
G_CALLBACK (on_window_shown), NULL);
|
2014-03-19 13:26:17 +00:00
|
|
|
}
|
|
|
|
|
2017-03-17 12:34:52 +00:00
|
|
|
static void
|
|
|
|
meta_window_wayland_force_restore_shortcuts (MetaWindow *window,
|
|
|
|
ClutterInputDevice *source)
|
|
|
|
{
|
|
|
|
MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
|
|
|
|
|
|
|
|
meta_wayland_compositor_restore_shortcuts (compositor, source);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
meta_window_wayland_shortcuts_inhibited (MetaWindow *window,
|
|
|
|
ClutterInputDevice *source)
|
|
|
|
{
|
|
|
|
MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
|
|
|
|
|
|
|
|
return meta_wayland_compositor_is_shortcuts_inhibited (compositor, source);
|
|
|
|
}
|
|
|
|
|
2018-11-13 07:56:53 +00:00
|
|
|
static gboolean
|
|
|
|
meta_window_wayland_is_focusable (MetaWindow *window)
|
|
|
|
{
|
|
|
|
return window->input;
|
|
|
|
}
|
|
|
|
|
2019-01-30 19:41:11 +00:00
|
|
|
static gboolean
|
|
|
|
meta_window_wayland_can_ping (MetaWindow *window)
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2018-01-09 12:19:40 +00:00
|
|
|
static gboolean
|
|
|
|
meta_window_wayland_is_stackable (MetaWindow *window)
|
|
|
|
{
|
2022-05-18 11:51:44 +00:00
|
|
|
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
|
|
|
|
return meta_wayland_surface_get_buffer (wl_window->surface) != NULL;
|
2018-01-09 12:19:40 +00:00
|
|
|
}
|
|
|
|
|
2018-09-14 17:03:38 +00:00
|
|
|
static gboolean
|
|
|
|
meta_window_wayland_are_updates_frozen (MetaWindow *window)
|
|
|
|
{
|
2018-09-14 17:06:55 +00:00
|
|
|
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
|
|
|
|
|
|
|
|
return !wl_window->has_been_shown;
|
2018-09-14 17:03:38 +00:00
|
|
|
}
|
|
|
|
|
2021-02-11 16:53:59 +00:00
|
|
|
static gboolean
|
|
|
|
meta_window_wayland_is_focus_async (MetaWindow *window)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2022-05-18 11:51:44 +00:00
|
|
|
static MetaWaylandSurface *
|
|
|
|
meta_window_wayland_get_wayland_surface (MetaWindow *window)
|
|
|
|
{
|
|
|
|
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
|
|
|
|
|
|
|
|
return wl_window->surface;
|
|
|
|
}
|
|
|
|
|
2019-11-26 19:53:24 +00:00
|
|
|
static MetaStackLayer
|
|
|
|
meta_window_wayland_calculate_layer (MetaWindow *window)
|
|
|
|
{
|
|
|
|
return meta_window_get_default_layer (window);
|
|
|
|
}
|
|
|
|
|
2018-12-30 12:55:52 +00:00
|
|
|
static void
|
|
|
|
meta_window_wayland_map (MetaWindow *window)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_wayland_unmap (MetaWindow *window)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-05-16 14:48:01 +00:00
|
|
|
static void
|
|
|
|
meta_window_wayland_constructed (GObject *object)
|
|
|
|
{
|
|
|
|
MetaWindow *window = META_WINDOW (object);
|
|
|
|
|
|
|
|
window->client_type = META_WINDOW_CLIENT_TYPE_WAYLAND;
|
|
|
|
|
|
|
|
window->override_redirect = FALSE;
|
|
|
|
window->rect.x = 0;
|
|
|
|
window->rect.y = 0;
|
|
|
|
window->rect.width = 0;
|
|
|
|
window->rect.height = 0;
|
|
|
|
/* size_hints are the "request" */
|
|
|
|
window->size_hints.x = 0;
|
|
|
|
window->size_hints.y = 0;
|
|
|
|
window->size_hints.width = 0;
|
|
|
|
window->size_hints.height = 0;
|
|
|
|
|
|
|
|
window->depth = 24;
|
|
|
|
window->xvisual = NULL;
|
|
|
|
|
|
|
|
window->mapped = FALSE;
|
|
|
|
|
|
|
|
window->decorated = FALSE;
|
|
|
|
window->hidden = TRUE;
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (meta_window_wayland_parent_class)->constructed (object);
|
|
|
|
}
|
|
|
|
|
2019-07-05 16:10:14 +00:00
|
|
|
static void
|
|
|
|
meta_window_wayland_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (object);
|
|
|
|
|
2022-09-28 15:23:10 +00:00
|
|
|
g_clear_pointer (&wl_window->last_acked_configuration,
|
|
|
|
meta_wayland_window_configuration_free);
|
2019-07-05 16:10:14 +00:00
|
|
|
g_list_free_full (wl_window->pending_configurations,
|
|
|
|
(GDestroyNotify) meta_wayland_window_configuration_free);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (meta_window_wayland_parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
2022-05-18 11:51:44 +00:00
|
|
|
static void
|
|
|
|
meta_window_wayland_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
MetaWindowWayland *window = META_WINDOW_WAYLAND (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_SURFACE:
|
|
|
|
g_value_set_object (value, window->surface);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_window_wayland_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
MetaWindowWayland *window = META_WINDOW_WAYLAND (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_SURFACE:
|
|
|
|
window->surface = g_value_get_object (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-19 13:26:17 +00:00
|
|
|
static void
|
|
|
|
meta_window_wayland_class_init (MetaWindowWaylandClass *klass)
|
|
|
|
{
|
2019-07-05 16:10:14 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2014-03-19 13:36:15 +00:00
|
|
|
MetaWindowClass *window_class = META_WINDOW_CLASS (klass);
|
|
|
|
|
2019-07-05 16:10:14 +00:00
|
|
|
object_class->finalize = meta_window_wayland_finalize;
|
2022-05-18 11:51:44 +00:00
|
|
|
object_class->get_property = meta_window_wayland_get_property;
|
|
|
|
object_class->set_property = meta_window_wayland_set_property;
|
2022-05-16 14:48:01 +00:00
|
|
|
object_class->constructed = meta_window_wayland_constructed;
|
2019-07-05 16:10:14 +00:00
|
|
|
|
2014-03-19 13:36:15 +00:00
|
|
|
window_class->manage = meta_window_wayland_manage;
|
|
|
|
window_class->unmanage = meta_window_wayland_unmanage;
|
2014-03-20 19:12:44 +00:00
|
|
|
window_class->ping = meta_window_wayland_ping;
|
2014-03-20 19:07:44 +00:00
|
|
|
window_class->delete = meta_window_wayland_delete;
|
|
|
|
window_class->kill = meta_window_wayland_kill;
|
2014-03-20 19:16:57 +00:00
|
|
|
window_class->focus = meta_window_wayland_focus;
|
2014-05-20 19:54:39 +00:00
|
|
|
window_class->grab_op_began = meta_window_wayland_grab_op_began;
|
|
|
|
window_class->grab_op_ended = meta_window_wayland_grab_op_ended;
|
2014-03-19 14:30:12 +00:00
|
|
|
window_class->move_resize_internal = meta_window_wayland_move_resize_internal;
|
2015-03-23 13:22:19 +00:00
|
|
|
window_class->update_main_monitor = meta_window_wayland_update_main_monitor;
|
2015-03-03 03:13:05 +00:00
|
|
|
window_class->main_monitor_changed = meta_window_wayland_main_monitor_changed;
|
2016-10-07 15:55:32 +00:00
|
|
|
window_class->get_client_pid = meta_window_wayland_get_client_pid;
|
2017-03-17 12:34:52 +00:00
|
|
|
window_class->force_restore_shortcuts = meta_window_wayland_force_restore_shortcuts;
|
|
|
|
window_class->shortcuts_inhibited = meta_window_wayland_shortcuts_inhibited;
|
2018-11-13 07:56:53 +00:00
|
|
|
window_class->is_focusable = meta_window_wayland_is_focusable;
|
2018-01-09 12:19:40 +00:00
|
|
|
window_class->is_stackable = meta_window_wayland_is_stackable;
|
2019-01-30 19:41:11 +00:00
|
|
|
window_class->can_ping = meta_window_wayland_can_ping;
|
2018-09-14 17:03:38 +00:00
|
|
|
window_class->are_updates_frozen = meta_window_wayland_are_updates_frozen;
|
2019-11-26 19:53:24 +00:00
|
|
|
window_class->calculate_layer = meta_window_wayland_calculate_layer;
|
2018-12-30 12:55:52 +00:00
|
|
|
window_class->map = meta_window_wayland_map;
|
|
|
|
window_class->unmap = meta_window_wayland_unmap;
|
2021-02-11 16:53:59 +00:00
|
|
|
window_class->is_focus_async = meta_window_wayland_is_focus_async;
|
2022-05-18 11:51:44 +00:00
|
|
|
window_class->get_wayland_surface = meta_window_wayland_get_wayland_surface;
|
|
|
|
|
|
|
|
obj_props[PROP_SURFACE] =
|
|
|
|
g_param_spec_object ("surface",
|
|
|
|
"Surface",
|
|
|
|
"The corresponding Wayland surface",
|
|
|
|
META_TYPE_WAYLAND_SURFACE,
|
|
|
|
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
|
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, PROP_LAST, obj_props);
|
2014-03-19 13:26:17 +00:00
|
|
|
}
|
2014-04-28 21:44:45 +00:00
|
|
|
|
2014-05-20 13:08:11 +00:00
|
|
|
MetaWindow *
|
|
|
|
meta_window_wayland_new (MetaDisplay *display,
|
|
|
|
MetaWaylandSurface *surface)
|
|
|
|
{
|
2019-07-12 17:33:17 +00:00
|
|
|
MetaWindowWayland *wl_window;
|
|
|
|
MetaWindow *window;
|
2014-05-20 13:08:11 +00:00
|
|
|
|
2022-11-21 12:13:07 +00:00
|
|
|
window = g_initable_new (META_TYPE_WINDOW_WAYLAND,
|
|
|
|
NULL, NULL,
|
|
|
|
"display", display,
|
|
|
|
"effect", META_COMP_EFFECT_CREATE,
|
|
|
|
"surface", surface,
|
|
|
|
NULL);
|
2019-07-12 17:33:17 +00:00
|
|
|
wl_window = META_WINDOW_WAYLAND (window);
|
|
|
|
set_geometry_scale_for_window (wl_window, wl_window->geometry_scale);
|
|
|
|
|
|
|
|
return window;
|
2014-05-20 13:08:11 +00:00
|
|
|
}
|
|
|
|
|
2020-02-14 10:13:24 +00:00
|
|
|
MetaWaylandWindowConfiguration *
|
|
|
|
meta_window_wayland_peek_configuration (MetaWindowWayland *wl_window,
|
|
|
|
uint32_t serial)
|
|
|
|
{
|
|
|
|
GList *l;
|
|
|
|
|
|
|
|
for (l = wl_window->pending_configurations; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaWaylandWindowConfiguration *configuration = l->data;
|
|
|
|
|
|
|
|
if (configuration->serial == serial)
|
|
|
|
return configuration;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-07-05 16:10:14 +00:00
|
|
|
static MetaWaylandWindowConfiguration *
|
|
|
|
acquire_acked_configuration (MetaWindowWayland *wl_window,
|
2022-01-16 00:44:37 +00:00
|
|
|
MetaWaylandSurfaceState *pending,
|
|
|
|
gboolean *is_client_resize)
|
2014-07-28 10:04:23 +00:00
|
|
|
{
|
2019-07-05 16:10:14 +00:00
|
|
|
GList *l;
|
2022-01-16 00:44:37 +00:00
|
|
|
gboolean has_pending_resize = FALSE;
|
|
|
|
|
|
|
|
/* There can be 3 different cases where a resizing configurations can be found
|
|
|
|
* in the list of pending configurations. We consider resizes in any of these
|
|
|
|
* cases to be requested by the server:
|
|
|
|
* 1. Acked serial is resizing. This is obviously a server requested resize.
|
|
|
|
* 2. Acked serial is larger than the serial of a pending resizing
|
|
|
|
* configuration. This means there was a server requested resize in the
|
|
|
|
* past that has not been acked yet. This covers cases such as a resizing
|
|
|
|
* configure followed by a status change configure before the client had
|
|
|
|
* time to ack the former.
|
|
|
|
* 3. Acked serial is smaller than the serial of a pending resizing
|
|
|
|
* configuration. This means there will be a server requested resize in the
|
|
|
|
* future. In this case we want to avoid marking this as a client resize,
|
|
|
|
* because it will change in the future again anyway and considering it
|
|
|
|
* a client resize could trigger another move_resize on the server due to
|
|
|
|
* enforcing constraints based on an already outdated size. */
|
|
|
|
for (l = wl_window->pending_configurations; l; l = l->next)
|
|
|
|
{
|
|
|
|
MetaWaylandWindowConfiguration *configuration = l->data;
|
|
|
|
|
|
|
|
if (configuration->is_resizing)
|
|
|
|
{
|
|
|
|
has_pending_resize = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*is_client_resize = !has_pending_resize;
|
2019-07-05 16:10:14 +00:00
|
|
|
|
|
|
|
if (!pending->has_acked_configure_serial)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (l = wl_window->pending_configurations; l; l = l->next)
|
2014-07-28 10:04:23 +00:00
|
|
|
{
|
2019-07-05 16:10:14 +00:00
|
|
|
MetaWaylandWindowConfiguration *configuration = l->data;
|
|
|
|
GList *tail;
|
|
|
|
gboolean is_matching_configuration;
|
|
|
|
|
|
|
|
if (configuration->serial > pending->acked_configure_serial)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
tail = l;
|
|
|
|
|
|
|
|
if (tail->prev)
|
|
|
|
{
|
|
|
|
tail->prev->next = NULL;
|
|
|
|
tail->prev = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
wl_window->pending_configurations = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
is_matching_configuration =
|
|
|
|
configuration->serial == pending->acked_configure_serial;
|
|
|
|
|
|
|
|
if (is_matching_configuration)
|
|
|
|
tail = g_list_delete_link (tail, l);
|
|
|
|
g_list_free_full (tail,
|
|
|
|
(GDestroyNotify) meta_wayland_window_configuration_free);
|
|
|
|
|
|
|
|
if (is_matching_configuration)
|
|
|
|
return configuration;
|
|
|
|
else
|
|
|
|
return NULL;
|
2014-07-28 10:04:23 +00:00
|
|
|
}
|
|
|
|
|
2019-07-05 16:10:14 +00:00
|
|
|
return NULL;
|
2014-07-28 10:04:23 +00:00
|
|
|
}
|
|
|
|
|
2022-01-16 00:44:37 +00:00
|
|
|
gboolean
|
|
|
|
meta_window_wayland_is_resize (MetaWindowWayland *wl_window,
|
|
|
|
int width,
|
|
|
|
int height)
|
2021-11-22 06:42:08 +00:00
|
|
|
{
|
2022-01-16 00:44:37 +00:00
|
|
|
int old_width;
|
|
|
|
int old_height;
|
2021-11-22 06:42:08 +00:00
|
|
|
|
2022-01-16 00:44:37 +00:00
|
|
|
if (wl_window->pending_configurations)
|
2021-11-22 06:42:08 +00:00
|
|
|
{
|
2022-01-16 00:44:37 +00:00
|
|
|
old_width = wl_window->last_sent_rect.width;
|
|
|
|
old_height = wl_window->last_sent_rect.height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
MetaWindow *window = META_WINDOW (wl_window);
|
2021-11-22 06:42:08 +00:00
|
|
|
|
2022-01-16 00:44:37 +00:00
|
|
|
old_width = window->rect.width;
|
|
|
|
old_height = window->rect.height;
|
2021-11-22 06:42:08 +00:00
|
|
|
}
|
|
|
|
|
2022-01-16 00:44:37 +00:00
|
|
|
return !wl_window->has_last_sent_configuration ||
|
|
|
|
old_width != width ||
|
|
|
|
old_height != height;
|
2021-11-22 06:42:08 +00:00
|
|
|
}
|
|
|
|
|
2015-03-23 13:10:20 +00:00
|
|
|
int
|
2017-02-24 09:05:01 +00:00
|
|
|
meta_window_wayland_get_geometry_scale (MetaWindow *window)
|
2015-03-23 13:10:20 +00:00
|
|
|
{
|
2017-10-16 09:02:51 +00:00
|
|
|
if (!window->monitor)
|
|
|
|
return 1;
|
|
|
|
|
2017-02-24 10:10:52 +00:00
|
|
|
return get_window_geometry_scale_for_logical_monitor (window->monitor);
|
2015-03-23 13:10:20 +00:00
|
|
|
}
|
|
|
|
|
2020-10-07 17:58:47 +00:00
|
|
|
static void
|
2022-03-04 09:06:19 +00:00
|
|
|
calculate_position (MetaWaylandWindowConfiguration *configuration,
|
|
|
|
MetaRectangle *geometry,
|
|
|
|
MetaRectangle *rect)
|
2020-10-07 17:58:47 +00:00
|
|
|
{
|
|
|
|
int offset_x;
|
|
|
|
int offset_y;
|
|
|
|
|
|
|
|
rect->x = configuration->x;
|
|
|
|
rect->y = configuration->y;
|
|
|
|
|
|
|
|
offset_x = configuration->width - geometry->width;
|
|
|
|
offset_y = configuration->height - geometry->height;
|
|
|
|
switch (configuration->gravity)
|
|
|
|
{
|
|
|
|
case META_GRAVITY_SOUTH:
|
|
|
|
case META_GRAVITY_SOUTH_WEST:
|
|
|
|
rect->y += offset_y;
|
|
|
|
break;
|
|
|
|
case META_GRAVITY_EAST:
|
|
|
|
case META_GRAVITY_NORTH_EAST:
|
|
|
|
rect->x += offset_x;
|
|
|
|
break;
|
|
|
|
case META_GRAVITY_SOUTH_EAST:
|
|
|
|
rect->x += offset_x;
|
|
|
|
rect->y += offset_y;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-28 21:44:45 +00:00
|
|
|
/**
|
|
|
|
* meta_window_move_resize_wayland:
|
|
|
|
*
|
|
|
|
* Complete a resize operation from a wayland client.
|
|
|
|
*/
|
|
|
|
void
|
2019-07-05 16:10:14 +00:00
|
|
|
meta_window_wayland_finish_move_resize (MetaWindow *window,
|
|
|
|
MetaRectangle new_geom,
|
|
|
|
MetaWaylandSurfaceState *pending)
|
2014-04-28 21:44:45 +00:00
|
|
|
{
|
2014-04-28 22:15:03 +00:00
|
|
|
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
|
2019-07-26 16:49:17 +00:00
|
|
|
MetaDisplay *display = window->display;
|
2019-07-05 16:10:14 +00:00
|
|
|
int dx, dy;
|
2017-02-24 09:05:01 +00:00
|
|
|
int geometry_scale;
|
2020-02-14 08:44:43 +00:00
|
|
|
MetaGravity gravity;
|
2014-05-01 23:09:13 +00:00
|
|
|
MetaRectangle rect;
|
2014-04-28 21:44:45 +00:00
|
|
|
MetaMoveResizeFlags flags;
|
2019-07-05 16:10:14 +00:00
|
|
|
MetaWaylandWindowConfiguration *acked_configuration;
|
2019-07-26 16:49:17 +00:00
|
|
|
gboolean is_window_being_resized;
|
2022-01-16 00:44:37 +00:00
|
|
|
gboolean is_client_resize;
|
2015-03-23 13:22:19 +00:00
|
|
|
|
|
|
|
/* new_geom is in the logical pixel coordinate space, but MetaWindow wants its
|
|
|
|
* rects to represent what in turn will end up on the stage, i.e. we need to
|
|
|
|
* scale new_geom to physical pixels given what buffer scale and texture scale
|
|
|
|
* is in use. */
|
2017-02-24 09:05:01 +00:00
|
|
|
|
2022-03-04 08:57:49 +00:00
|
|
|
acked_configuration = acquire_acked_configuration (wl_window, pending,
|
|
|
|
&is_client_resize);
|
|
|
|
|
|
|
|
if (acked_configuration)
|
|
|
|
geometry_scale = acked_configuration->scale;
|
|
|
|
else
|
|
|
|
geometry_scale = meta_window_wayland_get_geometry_scale (window);
|
|
|
|
|
2017-02-24 09:05:01 +00:00
|
|
|
new_geom.x *= geometry_scale;
|
|
|
|
new_geom.y *= geometry_scale;
|
|
|
|
new_geom.width *= geometry_scale;
|
|
|
|
new_geom.height *= geometry_scale;
|
2015-03-23 13:22:19 +00:00
|
|
|
|
|
|
|
/* The (dx, dy) offset is also in logical pixel coordinate space and needs
|
|
|
|
* to be scaled in the same way as new_geom. */
|
2019-07-05 16:10:14 +00:00
|
|
|
dx = pending->dx * geometry_scale;
|
|
|
|
dy = pending->dy * geometry_scale;
|
2014-04-28 21:44:45 +00:00
|
|
|
|
2014-07-17 19:24:06 +00:00
|
|
|
/* XXX: Find a better place to store the window geometry offsets. */
|
2014-07-17 20:42:41 +00:00
|
|
|
window->custom_frame_extents.left = new_geom.x;
|
|
|
|
window->custom_frame_extents.top = new_geom.y;
|
2014-07-17 19:24:06 +00:00
|
|
|
|
2018-10-22 14:41:12 +00:00
|
|
|
flags = META_MOVE_RESIZE_WAYLAND_FINISH_MOVE_RESIZE;
|
2014-04-28 21:44:45 +00:00
|
|
|
|
2014-05-01 22:55:34 +00:00
|
|
|
/* x/y are ignored when we're doing interactive resizing */
|
2019-07-26 16:49:17 +00:00
|
|
|
is_window_being_resized = (meta_grab_op_is_resizing (display->grab_op) &&
|
|
|
|
display->grab_window == window);
|
|
|
|
|
2020-09-17 12:06:27 +00:00
|
|
|
rect = (MetaRectangle) {
|
|
|
|
.x = window->rect.x,
|
|
|
|
.y = window->rect.y,
|
|
|
|
.width = new_geom.width,
|
|
|
|
.height = new_geom.height
|
|
|
|
};
|
|
|
|
|
2019-07-26 16:49:17 +00:00
|
|
|
if (!is_window_being_resized)
|
2014-04-28 21:44:45 +00:00
|
|
|
{
|
2019-07-05 16:10:14 +00:00
|
|
|
if (acked_configuration)
|
2014-05-01 22:55:34 +00:00
|
|
|
{
|
2020-02-14 09:41:38 +00:00
|
|
|
if (window->placement.rule)
|
|
|
|
{
|
|
|
|
MetaWindow *parent;
|
|
|
|
|
|
|
|
parent = meta_window_get_transient_for (window);
|
|
|
|
rect.x = parent->rect.x + acked_configuration->rel_x;
|
|
|
|
rect.y = parent->rect.y + acked_configuration->rel_y;
|
|
|
|
}
|
2022-03-04 09:06:19 +00:00
|
|
|
else
|
2020-02-14 09:41:38 +00:00
|
|
|
{
|
2022-03-04 09:06:19 +00:00
|
|
|
if (acked_configuration->is_fullscreen)
|
|
|
|
flags |= META_MOVE_RESIZE_CONSTRAIN;
|
|
|
|
if (acked_configuration->has_position)
|
|
|
|
calculate_position (acked_configuration, &new_geom, &rect);
|
2020-02-14 09:41:38 +00:00
|
|
|
}
|
2014-05-01 22:55:34 +00:00
|
|
|
}
|
2014-04-28 21:44:45 +00:00
|
|
|
}
|
2020-02-14 09:41:38 +00:00
|
|
|
else
|
|
|
|
{
|
2020-09-17 12:06:27 +00:00
|
|
|
if (acked_configuration && acked_configuration->has_position)
|
2022-03-04 09:06:19 +00:00
|
|
|
calculate_position (acked_configuration, &new_geom, &rect);
|
2020-02-14 09:41:38 +00:00
|
|
|
}
|
2014-04-28 21:44:45 +00:00
|
|
|
|
2020-09-17 12:06:27 +00:00
|
|
|
rect.x += dx;
|
|
|
|
rect.y += dy;
|
|
|
|
|
2020-09-18 08:26:42 +00:00
|
|
|
if (rect.x != window->rect.x || rect.y != window->rect.y)
|
|
|
|
flags |= META_MOVE_RESIZE_MOVE_ACTION;
|
|
|
|
|
2019-07-05 16:10:14 +00:00
|
|
|
if (wl_window->has_pending_state_change && acked_configuration)
|
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-18 02:42:33 +00:00
|
|
|
{
|
|
|
|
flags |= META_MOVE_RESIZE_WAYLAND_STATE_CHANGED;
|
|
|
|
wl_window->has_pending_state_change = FALSE;
|
|
|
|
}
|
|
|
|
|
2014-05-01 23:09:13 +00:00
|
|
|
if (rect.width != window->rect.width || rect.height != window->rect.height)
|
2022-01-16 00:44:37 +00:00
|
|
|
{
|
|
|
|
flags |= META_MOVE_RESIZE_RESIZE_ACTION;
|
|
|
|
if (is_client_resize)
|
|
|
|
flags |= META_MOVE_RESIZE_WAYLAND_CLIENT_RESIZE;
|
|
|
|
}
|
2014-04-28 21:44:45 +00:00
|
|
|
|
2022-09-28 15:23:10 +00:00
|
|
|
g_clear_pointer (&wl_window->last_acked_configuration,
|
|
|
|
meta_wayland_window_configuration_free);
|
|
|
|
wl_window->last_acked_configuration = g_steal_pointer (&acked_configuration);
|
|
|
|
|
2020-01-09 16:55:56 +00:00
|
|
|
if (window->display->grab_window == window)
|
|
|
|
gravity = meta_resize_gravity_from_grab_op (window->display->grab_op);
|
|
|
|
else
|
|
|
|
gravity = META_GRAVITY_STATIC;
|
2014-05-01 23:09:13 +00:00
|
|
|
meta_window_move_resize_internal (window, flags, gravity, rect);
|
2014-04-28 21:44:45 +00:00
|
|
|
}
|
2015-03-25 06:39:30 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_wayland_place_relative_to (MetaWindow *window,
|
|
|
|
MetaWindow *other,
|
|
|
|
int x,
|
|
|
|
int y)
|
|
|
|
{
|
2017-02-24 09:05:01 +00:00
|
|
|
int geometry_scale;
|
2015-03-25 06:39:30 +00:00
|
|
|
|
|
|
|
/* If there is no monitor, we can't position the window reliably. */
|
|
|
|
if (!other->monitor)
|
|
|
|
return;
|
|
|
|
|
2017-02-24 09:05:01 +00:00
|
|
|
geometry_scale = meta_window_wayland_get_geometry_scale (other);
|
2015-03-25 06:39:30 +00:00
|
|
|
meta_window_move_frame (window, FALSE,
|
2017-02-24 09:05:01 +00:00
|
|
|
other->buffer_rect.x + (x * geometry_scale),
|
|
|
|
other->buffer_rect.y + (y * geometry_scale));
|
2015-03-25 06:39:30 +00:00
|
|
|
window->placed = TRUE;
|
|
|
|
}
|
2016-02-01 10:46:11 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_place_with_placement_rule (MetaWindow *window,
|
|
|
|
MetaPlacementRule *placement_rule)
|
|
|
|
{
|
2020-03-06 16:24:35 +00:00
|
|
|
gboolean first_placement;
|
|
|
|
|
|
|
|
first_placement = !window->placement.rule;
|
|
|
|
|
2020-02-13 21:40:15 +00:00
|
|
|
g_clear_pointer (&window->placement.rule, g_free);
|
|
|
|
window->placement.rule = g_new0 (MetaPlacementRule, 1);
|
|
|
|
*window->placement.rule = *placement_rule;
|
2016-02-01 10:46:11 +00:00
|
|
|
|
2020-02-14 09:41:38 +00:00
|
|
|
window->unconstrained_rect.x = window->rect.x;
|
|
|
|
window->unconstrained_rect.y = window->rect.y;
|
2016-02-01 10:46:11 +00:00
|
|
|
window->unconstrained_rect.width = placement_rule->width;
|
|
|
|
window->unconstrained_rect.height = placement_rule->height;
|
2020-03-06 16:24:35 +00:00
|
|
|
|
|
|
|
window->calc_placement = first_placement;
|
2020-02-14 09:41:38 +00:00
|
|
|
meta_window_move_resize_internal (window,
|
|
|
|
(META_MOVE_RESIZE_MOVE_ACTION |
|
|
|
|
META_MOVE_RESIZE_RESIZE_ACTION |
|
2022-03-04 14:23:38 +00:00
|
|
|
META_MOVE_RESIZE_PLACEMENT_CHANGED |
|
|
|
|
META_MOVE_RESIZE_CONSTRAIN),
|
2020-02-14 09:41:38 +00:00
|
|
|
META_GRAVITY_NORTH_WEST,
|
|
|
|
window->unconstrained_rect);
|
2020-03-06 16:24:35 +00:00
|
|
|
window->calc_placement = FALSE;
|
2020-02-14 09:41:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_update_placement_rule (MetaWindow *window,
|
|
|
|
MetaPlacementRule *placement_rule)
|
|
|
|
{
|
|
|
|
window->placement.state = META_PLACEMENT_STATE_INVALIDATED;
|
|
|
|
meta_window_place_with_placement_rule (window, placement_rule);
|
2016-02-01 10:46:11 +00:00
|
|
|
}
|
2016-04-06 12:07:08 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_wayland_set_min_size (MetaWindow *window,
|
|
|
|
int width,
|
|
|
|
int height)
|
|
|
|
{
|
|
|
|
gint64 new_width, new_height;
|
|
|
|
float scale;
|
|
|
|
|
2020-10-02 15:47:22 +00:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "Window %s sets min size %d x %d",
|
2016-04-06 12:07:08 +00:00
|
|
|
window->desc, width, height);
|
|
|
|
|
|
|
|
if (width == 0 && height == 0)
|
|
|
|
{
|
|
|
|
window->size_hints.min_width = 0;
|
|
|
|
window->size_hints.min_height = 0;
|
|
|
|
window->size_hints.flags &= ~PMinSize;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-24 09:05:01 +00:00
|
|
|
scale = (float) meta_window_wayland_get_geometry_scale (window);
|
2016-04-06 12:07:08 +00:00
|
|
|
scale_size (&width, &height, scale);
|
|
|
|
|
|
|
|
new_width = width + (window->custom_frame_extents.left +
|
|
|
|
window->custom_frame_extents.right);
|
|
|
|
new_height = height + (window->custom_frame_extents.top +
|
|
|
|
window->custom_frame_extents.bottom);
|
|
|
|
|
|
|
|
window->size_hints.min_width = (int) MIN (new_width, G_MAXINT);
|
|
|
|
window->size_hints.min_height = (int) MIN (new_height, G_MAXINT);
|
|
|
|
window->size_hints.flags |= PMinSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_wayland_set_max_size (MetaWindow *window,
|
|
|
|
int width,
|
|
|
|
int height)
|
|
|
|
|
|
|
|
{
|
|
|
|
gint64 new_width, new_height;
|
|
|
|
float scale;
|
|
|
|
|
2020-10-02 15:47:22 +00:00
|
|
|
meta_topic (META_DEBUG_GEOMETRY, "Window %s sets max size %d x %d",
|
2016-04-06 12:07:08 +00:00
|
|
|
window->desc, width, height);
|
|
|
|
|
|
|
|
if (width == 0 && height == 0)
|
|
|
|
{
|
|
|
|
window->size_hints.max_width = G_MAXINT;
|
|
|
|
window->size_hints.max_height = G_MAXINT;
|
|
|
|
window->size_hints.flags &= ~PMaxSize;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-24 09:05:01 +00:00
|
|
|
scale = (float) meta_window_wayland_get_geometry_scale (window);
|
2016-04-06 12:07:08 +00:00
|
|
|
scale_size (&width, &height, scale);
|
|
|
|
|
|
|
|
new_width = width + (window->custom_frame_extents.left +
|
|
|
|
window->custom_frame_extents.right);
|
|
|
|
new_height = height + (window->custom_frame_extents.top +
|
|
|
|
window->custom_frame_extents.bottom);
|
|
|
|
|
|
|
|
window->size_hints.max_width = (int) ((new_width > 0 && new_width < G_MAXINT) ?
|
|
|
|
new_width : G_MAXINT);
|
|
|
|
window->size_hints.max_height = (int) ((new_height > 0 && new_height < G_MAXINT) ?
|
|
|
|
new_height : G_MAXINT);
|
|
|
|
window->size_hints.flags |= PMaxSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_wayland_get_min_size (MetaWindow *window,
|
|
|
|
int *width,
|
|
|
|
int *height)
|
|
|
|
{
|
|
|
|
gint64 current_width, current_height;
|
|
|
|
float scale;
|
|
|
|
|
|
|
|
if (!(window->size_hints.flags & PMinSize))
|
|
|
|
{
|
|
|
|
/* Zero means unlimited */
|
|
|
|
*width = 0;
|
|
|
|
*height = 0;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
current_width = window->size_hints.min_width -
|
|
|
|
(window->custom_frame_extents.left +
|
|
|
|
window->custom_frame_extents.right);
|
|
|
|
current_height = window->size_hints.min_height -
|
|
|
|
(window->custom_frame_extents.top +
|
|
|
|
window->custom_frame_extents.bottom);
|
|
|
|
|
|
|
|
*width = MAX (current_width, 0);
|
|
|
|
*height = MAX (current_height, 0);
|
|
|
|
|
2017-02-24 09:05:01 +00:00
|
|
|
scale = 1.0 / (float) meta_window_wayland_get_geometry_scale (window);
|
2016-04-06 12:07:08 +00:00
|
|
|
scale_size (width, height, scale);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_window_wayland_get_max_size (MetaWindow *window,
|
|
|
|
int *width,
|
|
|
|
int *height)
|
|
|
|
{
|
|
|
|
gint64 current_width = 0;
|
|
|
|
gint64 current_height = 0;
|
|
|
|
float scale;
|
|
|
|
|
|
|
|
if (!(window->size_hints.flags & PMaxSize))
|
|
|
|
{
|
|
|
|
/* Zero means unlimited */
|
|
|
|
*width = 0;
|
|
|
|
*height = 0;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window->size_hints.max_width < G_MAXINT)
|
|
|
|
current_width = window->size_hints.max_width -
|
|
|
|
(window->custom_frame_extents.left +
|
|
|
|
window->custom_frame_extents.right);
|
|
|
|
|
|
|
|
if (window->size_hints.max_height < G_MAXINT)
|
|
|
|
current_height = window->size_hints.max_height -
|
|
|
|
(window->custom_frame_extents.top +
|
|
|
|
window->custom_frame_extents.bottom);
|
|
|
|
|
|
|
|
*width = CLAMP (current_width, 0, G_MAXINT);
|
|
|
|
*height = CLAMP (current_height, 0, G_MAXINT);
|
|
|
|
|
2017-02-24 09:05:01 +00:00
|
|
|
scale = 1.0 / (float) meta_window_wayland_get_geometry_scale (window);
|
2016-04-06 12:07:08 +00:00
|
|
|
scale_size (width, height, scale);
|
|
|
|
}
|
2022-05-03 16:47:57 +00:00
|
|
|
|
|
|
|
gboolean
|
|
|
|
meta_window_wayland_is_acked_fullscreen (MetaWindowWayland *wl_window)
|
|
|
|
{
|
|
|
|
return (wl_window->last_acked_configuration &&
|
|
|
|
wl_window->last_acked_configuration->is_fullscreen);
|
|
|
|
}
|