window: Use the MetaWindowConfig

This is a fairly large refactoring to replace the window rect and
fullscreen flag with the new MetaWindowConfig object.

No functional change intended at this point.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4076>
This commit is contained in:
Olivier Fourdan 2024-10-21 11:11:32 +02:00
parent a7ef0b137e
commit 4c20584b11
15 changed files with 181 additions and 127 deletions

View File

@ -1375,11 +1375,13 @@ meta_compositor_flash_window (MetaCompositor *compositor,
CLUTTER_ACTOR (meta_window_actor_from_window (window));
ClutterActor *flash;
ClutterTransition *transition;
int width, height;
flash = clutter_actor_new ();
clutter_actor_set_accessible_name (flash, "Flash actor");
clutter_actor_set_background_color (flash, &COGL_COLOR_INIT (0, 0, 0, 255));
clutter_actor_set_size (flash, window->rect.width, window->rect.height);
meta_window_config_get_size (window->config, &width, &height);
clutter_actor_set_size (flash, width, height);
clutter_actor_set_position (flash,
window->custom_frame_extents.left,
window->custom_frame_extents.top);

View File

@ -548,6 +548,7 @@ maybe_configure_black_background (MetaWindowActorWayland *self,
ClutterActorIter iter;
float max_width = 0;
float max_height = 0;
int width, height;
if (!meta_window_wayland_is_acked_fullscreen (META_WINDOW_WAYLAND (window)))
return FALSE;
@ -584,8 +585,9 @@ maybe_configure_black_background (MetaWindowActorWayland *self,
*surfaces_width = max_width;
*surfaces_height = max_height;
*background_width = window->rect.width / geometry_scale;
*background_height = window->rect.height / geometry_scale;
meta_window_config_get_size (window->config, &width, &height);
*background_width = width / geometry_scale;
*background_height = height / geometry_scale;
return TRUE;
}

View File

@ -891,9 +891,6 @@ process_keyboard_resize_grab (MetaWindowDrag *window_drag,
if (process_keyboard_resize_grab_op_change (window_drag, window, event))
return TRUE;
width = window->rect.width;
height = window->rect.height;
meta_window_get_frame_rect (window, &frame_rect);
width = frame_rect.width;
height = frame_rect.height;
@ -1599,6 +1596,7 @@ maybe_maximize_tiled_window (MetaWindow *window)
{
MtkRectangle work_area;
gint shake_threshold;
int width;
if (!meta_window_is_tiled_side_by_side (window))
return;
@ -1608,7 +1606,8 @@ maybe_maximize_tiled_window (MetaWindow *window)
meta_window_get_work_area_for_monitor (window,
window->tile_monitor_number,
&work_area);
if (window->rect.width >= work_area.width - shake_threshold)
meta_window_config_get_size (window->config, &width, NULL);
if (width >= work_area.width - shake_threshold)
meta_window_maximize (window, META_MAXIMIZE_BOTH);
}

View File

@ -560,10 +560,12 @@ place_window_if_needed (MetaWindow *window,
MtkRectangle placed_rect;
MetaWorkspace *cur_workspace;
MetaLogicalMonitor *logical_monitor;
int x, y;
meta_window_config_get_position (window->config, &x, &y);
placed_rect = (MtkRectangle) {
.x = window->rect.x,
.y = window->rect.y,
.x = x,
.y = y,
.width = info->current.width,
.height = info->current.height
};
@ -897,6 +899,7 @@ constrain_custom_rule (MetaWindow *window,
gboolean constraint_satisfied;
MtkRectangle temporary_rect;
MtkRectangle adjusted_unconstrained;
MtkRectangle parent_rect;
int adjusted_rel_x;
int adjusted_rel_y;
MetaPlacementRule current_rule;
@ -911,10 +914,11 @@ constrain_custom_rule (MetaWindow *window,
return TRUE;
parent = meta_window_get_transient_for (window);
parent_rect = meta_window_config_get_rect (parent->config);
if (window->placement.state == META_PLACEMENT_STATE_CONSTRAINED_FINISHED)
{
placement_rule->parent_rect.x = parent->rect.x;
placement_rule->parent_rect.y = parent->rect.y;
placement_rule->parent_rect.x = parent_rect.x;
placement_rule->parent_rect.y = parent_rect.y;
}
parent_x = placement_rule->parent_rect.x;
parent_y = placement_rule->parent_rect.y;
@ -938,8 +942,8 @@ constrain_custom_rule (MetaWindow *window,
case META_PLACEMENT_STATE_CONSTRAINED_FINISHED:
case META_PLACEMENT_STATE_INVALIDATED:
temporary_rect = (MtkRectangle) {
.x = parent->rect.x + window->placement.current.rel_x,
.y = parent->rect.y + window->placement.current.rel_y,
.x = parent_rect.x + window->placement.current.rel_x,
.y = parent_rect.y + window->placement.current.rel_y,
.width = info->current.width,
.height = info->current.height,
};

View File

@ -38,6 +38,7 @@
#include "meta/meta-close-dialog.h"
#include "meta/util.h"
#include "meta/window.h"
#include "meta/meta-window-config.h"
#include "wayland/meta-wayland-types.h"
typedef struct _MetaWindowQueue MetaWindowQueue;
@ -311,8 +312,8 @@ struct _MetaWindow
* comment at the top of meta_window_move_resize_internal() for more
* information. */
/* The current window geometry of the window. */
MtkRectangle rect;
/* The current configuration of the window. */
MetaWindowConfig *config;
/* The geometry to restore when we unmaximize. */
MtkRectangle saved_rect;
@ -401,9 +402,6 @@ struct _MetaWindow
* that to toggle between normal/tiled or maximized/tiled states. */
guint saved_maximize : 1;
/* Whether we're fullscreen */
guint fullscreen : 1;
/* Whether the window is marked as urgent */
guint urgent : 1;

View File

@ -331,6 +331,8 @@ meta_window_finalize (GObject *object)
g_clear_pointer (&window->preferred_logical_monitor,
meta_logical_monitor_id_free);
g_clear_object (&window->config);
g_free (window->startup_id);
g_free (window->role);
g_free (window->res_class);
@ -1021,6 +1023,7 @@ meta_window_constructed (GObject *object)
MetaContext *context = meta_display_get_context (display);
MetaBackend *backend = meta_context_get_backend (context);
MetaWorkspaceManager *workspace_manager = display->workspace_manager;
MtkRectangle frame_rect;
COGL_TRACE_BEGIN_SCOPED (MetaWindowSharedInit,
"Meta::Window::constructed()");
@ -1041,9 +1044,10 @@ meta_window_constructed (GObject *object)
meta_window_set_normal_hints (window, NULL);
/* And this is our unmaximized size */
window->saved_rect = window->rect;
window->saved_rect_fullscreen = window->rect;
window->unconstrained_rect = window->rect;
frame_rect = meta_window_config_get_rect (window->config);
window->saved_rect = frame_rect;
window->saved_rect_fullscreen = frame_rect;
window->unconstrained_rect = frame_rect;
window->title = NULL;
@ -1055,7 +1059,7 @@ meta_window_constructed (GObject *object)
window->maximize_horizontally_after_placement = FALSE;
window->maximize_vertically_after_placement = FALSE;
window->minimize_after_placement = FALSE;
window->fullscreen = FALSE;
meta_window_config_set_is_fullscreen (window->config, FALSE);
window->require_fully_onscreen = TRUE;
window->require_on_single_monitor = TRUE;
window->require_titlebar_visible = TRUE;
@ -1133,7 +1137,7 @@ meta_window_constructed (GObject *object)
window->compositor_private = NULL;
if (window->rect.width > 0 && window->rect.height > 0)
if (frame_rect.width > 0 && frame_rect.height > 0)
{
window->monitor = meta_window_find_monitor_from_frame_rect (window);
window->highest_scale_monitor =
@ -2076,6 +2080,7 @@ window_would_mostly_be_covered_by_always_above_window (MetaWindow *window)
GList *l;
g_autoptr (MtkRegion) region = NULL;
int window_area, intersection_area, visible_area;
MtkRectangle frame_rect;
region = mtk_region_create ();
windows = meta_workspace_list_windows (workspace);
@ -2083,13 +2088,15 @@ window_would_mostly_be_covered_by_always_above_window (MetaWindow *window)
{
MetaWindow *other_window = l->data;
frame_rect = meta_window_config_get_rect (other_window->config);
if (other_window->wm_state_above && other_window != window)
mtk_region_union_rectangle (region, &other_window->rect);
mtk_region_union_rectangle (region, &frame_rect);
}
window_area = window->rect.width * window->rect.height;
frame_rect = meta_window_config_get_rect (window->config);
window_area = frame_rect.width * frame_rect.height;
mtk_region_intersect_rectangle (region, &window->rect);
mtk_region_intersect_rectangle (region, &frame_rect);
intersection_area = calculate_region_area (region);
visible_area = window_area - intersection_area;
@ -2330,10 +2337,12 @@ meta_window_show (MetaWindow *window)
window->has_maximize_func)
{
MtkRectangle work_area;
MtkRectangle frame_rect;
int window_area;
int work_area_area;
window_area = window->rect.width * window->rect.height;
frame_rect = meta_window_config_get_rect (window->config);
window_area = frame_rect.width * frame_rect.height;
meta_window_get_work_area_current_monitor (window, &work_area);
work_area_area = work_area.width * work_area.height;
@ -2696,16 +2705,19 @@ meta_window_save_rect (MetaWindow *window)
meta_window_is_tiled_side_by_side (window) ||
meta_window_is_fullscreen (window)))
{
MtkRectangle frame_rect;
frame_rect = meta_window_config_get_rect (window->config);
/* save size/pos as appropriate args for move_resize */
if (!window->maximized_horizontally)
{
window->saved_rect.x = window->rect.x;
window->saved_rect.width = window->rect.width;
window->saved_rect.x = frame_rect.x;
window->saved_rect.width = frame_rect.width;
}
if (!window->maximized_vertically)
{
window->saved_rect.y = window->rect.y;
window->saved_rect.height = window->rect.height;
window->saved_rect.y = frame_rect.y;
window->saved_rect.height = frame_rect.height;
}
}
}
@ -2857,7 +2869,7 @@ meta_window_is_maximized (MetaWindow *window)
gboolean
meta_window_is_fullscreen (MetaWindow *window)
{
return window->fullscreen;
return meta_window_config_get_is_fullscreen (window->config);
}
/**
@ -3189,7 +3201,7 @@ unmaximize_window_before_freeing (MetaWindow *window)
if (window->withdrawn) /* See bug #137185 */
{
window->rect = window->saved_rect;
meta_window_config_set_rect (window->config, window->saved_rect);
set_net_wm_state (window);
}
#ifdef HAVE_WAYLAND
@ -3400,9 +3412,9 @@ meta_window_make_fullscreen_internal (MetaWindow *window)
meta_topic (META_DEBUG_WINDOW_OPS,
"Fullscreening %s", window->desc);
window->saved_rect_fullscreen = window->rect;
window->saved_rect_fullscreen = meta_window_config_get_rect (window->config);
window->fullscreen = TRUE;
meta_window_config_set_is_fullscreen (window->config, TRUE);
meta_stack_freeze (window->display->stack);
@ -3460,7 +3472,7 @@ meta_window_unmake_fullscreen (MetaWindow *window)
meta_topic (META_DEBUG_WINDOW_OPS,
"Unfullscreening %s", window->desc);
window->fullscreen = FALSE;
meta_window_config_set_is_fullscreen (window->config, FALSE);
target_rect = window->saved_rect_fullscreen;
meta_window_frame_size_changed (window);
@ -3690,11 +3702,14 @@ meta_window_updates_are_frozen (MetaWindow *window)
static void
meta_window_reposition (MetaWindow *window)
{
MtkRectangle frame_rect;
frame_rect = meta_window_config_get_rect (window->config);
meta_window_move_resize (window,
(META_MOVE_RESIZE_MOVE_ACTION |
META_MOVE_RESIZE_RESIZE_ACTION |
META_MOVE_RESIZE_CONSTRAIN),
window->rect);
frame_rect);
}
static gboolean
@ -3860,6 +3875,7 @@ meta_window_update_monitor (MetaWindow *window,
{
MetaWorkspaceManager *workspace_manager = window->display->workspace_manager;
const MetaLogicalMonitor *old, *old_highest_scale;
int frame_width, frame_height;
old = window->monitor;
META_WINDOW_GET_CLASS (window)->update_main_monitor (window, flags);
@ -3892,8 +3908,9 @@ meta_window_update_monitor (MetaWindow *window,
}
old_highest_scale = window->highest_scale_monitor;
meta_window_config_get_size (window->config, &frame_width, &frame_height);
window->highest_scale_monitor = window->rect.width > 0 && window->rect.height > 0
window->highest_scale_monitor = frame_width > 0 && frame_height > 0
? meta_window_find_highest_scale_monitor_from_frame_rect (window)
: window->monitor;
@ -3932,6 +3949,7 @@ meta_window_move_resize_internal (MetaWindow *window,
MtkRectangle unconstrained_rect;
MtkRectangle constrained_rect;
MtkRectangle temporary_rect;
MtkRectangle rect;
int rel_x = 0;
int rel_y = 0;
MetaMoveResizeResultFlags result = 0;
@ -3951,6 +3969,7 @@ meta_window_move_resize_internal (MetaWindow *window,
/* We don't need it in the idle queue anymore. */
meta_window_unqueue (window, META_QUEUE_MOVE_RESIZE);
rect = meta_window_config_get_rect (window->config);
if ((flags & META_MOVE_RESIZE_RESIZE_ACTION) && (flags & META_MOVE_RESIZE_MOVE_ACTION))
{
@ -3962,7 +3981,7 @@ meta_window_move_resize_internal (MetaWindow *window,
/* If this is only a resize, then ignore the position given in
* the parameters and instead calculate the new position from
* resizing the old rectangle with the given gravity. */
meta_rectangle_resize_with_gravity (&window->rect,
meta_rectangle_resize_with_gravity (&rect,
&unconstrained_rect,
gravity,
frame_rect.width,
@ -3974,21 +3993,21 @@ meta_window_move_resize_internal (MetaWindow *window,
* just use the existing size of the window. */
unconstrained_rect.x = frame_rect.x;
unconstrained_rect.y = frame_rect.y;
unconstrained_rect.width = window->rect.width;
unconstrained_rect.height = window->rect.height;
unconstrained_rect.width = rect.width;
unconstrained_rect.height = rect.height;
}
else if ((flags & META_MOVE_RESIZE_WAYLAND_FINISH_MOVE_RESIZE))
{
/* This is a Wayland buffer acking our size. The new rect is
* just the existing one we have. Ignore the passed-in rect
* completely. */
unconstrained_rect = window->rect;
unconstrained_rect = rect;
}
else
g_assert_not_reached ();
constrained_rect = unconstrained_rect;
temporary_rect = window->rect;
temporary_rect = rect;
if (flags & META_MOVE_RESIZE_CONSTRAIN && window->monitor)
{
MtkRectangle old_rect;
@ -4375,8 +4394,9 @@ gboolean
meta_window_geometry_contains_rect (MetaWindow *window,
MtkRectangle *rect)
{
return mtk_rectangle_contains_rect (&window->rect,
rect);
MtkRectangle frame_rect = meta_window_config_get_rect (window->config);
return mtk_rectangle_contains_rect (&frame_rect, rect);
}
/**
@ -4510,7 +4530,7 @@ void
meta_window_get_frame_rect (const MetaWindow *window,
MtkRectangle *rect)
{
*rect = window->rect;
*rect = meta_window_config_get_rect (window->config);
}
/**

View File

@ -691,6 +691,7 @@ toplevel_bounds_struts (void)
MetaWindow *window;
MtkRectangle logical_monitor_layout;
MtkRectangle work_area;
MtkRectangle frame_rect;
/*
* This test case makes sure that setting and changing struts result in the
@ -719,8 +720,9 @@ toplevel_bounds_struts (void)
g_assert_cmpint (work_area.width, ==, logical_monitor_layout.width);
g_assert_cmpint (work_area.height, ==, logical_monitor_layout.height - 10);
g_assert_cmpint (window->rect.width, ==, work_area.width - 10);
g_assert_cmpint (window->rect.height, ==, work_area.height - 10);
frame_rect = meta_window_config_get_rect (window->config);
g_assert_cmpint (frame_rect.width, ==, work_area.width - 10);
g_assert_cmpint (frame_rect.height, ==, work_area.height - 10);
meta_wayland_test_driver_emit_sync_event (test_driver, 0);
meta_wayland_test_client_finish (wayland_test_client);
@ -739,8 +741,9 @@ toplevel_bounds_struts (void)
g_assert_cmpint (work_area.width, ==, logical_monitor_layout.width);
g_assert_cmpint (work_area.height, ==, logical_monitor_layout.height);
g_assert_cmpint (window->rect.width, ==, work_area.width - 10);
g_assert_cmpint (window->rect.height, ==, work_area.height - 10);
frame_rect = meta_window_config_get_rect (window->config);
g_assert_cmpint (frame_rect.width, ==, work_area.width - 10);
g_assert_cmpint (frame_rect.height, ==, work_area.height - 10);
meta_wayland_test_driver_emit_sync_event (test_driver, 0);
meta_wayland_test_client_finish (wayland_test_client);
@ -774,6 +777,7 @@ toplevel_bounds_monitors (void)
MetaWaylandTestClient *wayland_test_client;
MtkRectangle logical_monitor_layout;
MtkRectangle work_area;
MtkRectangle frame_rect;
MetaWindow *window;
/*
@ -811,8 +815,9 @@ toplevel_bounds_monitors (void)
g_assert_cmpint (work_area.width, ==, logical_monitor_layout.width);
g_assert_cmpint (work_area.height, ==, logical_monitor_layout.height - 10);
g_assert_cmpint (window->rect.width, ==, work_area.width - 10);
g_assert_cmpint (window->rect.height, ==, work_area.height - 10);
frame_rect = meta_window_config_get_rect (window->config);
g_assert_cmpint (frame_rect.width, ==, work_area.width - 10);
g_assert_cmpint (frame_rect.height, ==, work_area.height - 10);
meta_wayland_test_driver_emit_sync_event (test_driver, 0);
meta_wayland_test_client_finish (wayland_test_client);
@ -835,8 +840,9 @@ toplevel_bounds_monitors (void)
g_assert_cmpint (work_area.width, ==, 300);
g_assert_cmpint (work_area.height, ==, 200);
g_assert_cmpint (window->rect.width, ==, 300 - 10);
g_assert_cmpint (window->rect.height, ==, 200 - 10);
frame_rect = meta_window_config_get_rect (window->config);
g_assert_cmpint (frame_rect.width, ==, 300 - 10);
g_assert_cmpint (frame_rect.height, ==, 200 - 10);
meta_wayland_test_driver_emit_sync_event (test_driver, 0);
meta_wayland_test_client_finish (wayland_test_client);

View File

@ -34,6 +34,7 @@ meta_wayland_window_configuration_new (MetaWindow *window,
{
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
MetaWaylandWindowConfiguration *configuration;
int x, y;
configuration = g_new0 (MetaWaylandWindowConfiguration, 1);
*configuration = (MetaWaylandWindowConfiguration) {
@ -50,9 +51,10 @@ meta_wayland_window_configuration_new (MetaWindow *window,
.is_suspended = meta_window_is_suspended (window),
};
meta_window_config_get_position (window->config, &x, &y);
if (flags & META_MOVE_RESIZE_MOVE_ACTION ||
window->rect.x != rect.x ||
window->rect.y != rect.y)
x != rect.x ||
y != rect.y)
{
configuration->has_position = TRUE;
configuration->x = rect.x;

View File

@ -320,10 +320,12 @@ meta_wayland_xdg_session_state_save_window (MetaSessionState *state,
MetaWaylandXdgSessionState *xdg_session_state =
META_WAYLAND_XDG_SESSION_STATE (state);
MetaWaylandXdgToplevelState *toplevel_state;
MtkRectangle rect;
toplevel_state =
meta_wayland_xdg_session_state_ensure_toplevel (xdg_session_state,
name);
rect = meta_window_config_get_rect (window->config);
g_object_get (window,
"minimized", &toplevel_state->is_minimized,
@ -334,7 +336,7 @@ meta_wayland_xdg_session_state_save_window (MetaSessionState *state,
{
toplevel_state->window_state = WINDOW_STATE_MAXIMIZED;
toplevel_state->tiled.rect = window->rect;
toplevel_state->tiled.rect = rect;
}
else if (window->tile_mode == META_TILE_LEFT ||
window->tile_mode == META_TILE_RIGHT)
@ -344,13 +346,13 @@ meta_wayland_xdg_session_state_save_window (MetaSessionState *state,
else if (window->tile_mode == META_TILE_RIGHT)
toplevel_state->window_state = WINDOW_STATE_TILED_RIGHT;
toplevel_state->tiled.rect = window->rect;
toplevel_state->tiled.rect = rect;
}
else
{
toplevel_state->window_state = WINDOW_STATE_FLOATING;
toplevel_state->floating.rect = window->rect;
toplevel_state->floating.rect = rect;
}
toplevel_state->workspace_idx = meta_workspace_index (window->workspace);

View File

@ -878,8 +878,10 @@ meta_wayland_xdg_toplevel_apply_state (MetaWaylandSurfaceRole *surface_role,
{
MetaWaylandWindowConfiguration *configuration;
int bounds_width, bounds_height, geometry_scale;
MtkRectangle rect;
geometry_scale = meta_window_wayland_get_geometry_scale (window);
rect = meta_window_config_get_rect (window->config);
if (!meta_window_calculate_bounds (window, &bounds_width, &bounds_height))
{
@ -891,7 +893,7 @@ meta_wayland_xdg_toplevel_apply_state (MetaWaylandSurfaceRole *surface_role,
{
configuration =
meta_wayland_window_configuration_new (window,
window->rect,
rect,
bounds_width,
bounds_height,
geometry_scale,

View File

@ -263,6 +263,7 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
gboolean can_move_now = FALSE;
MtkRectangle configured_rect;
MtkRectangle frame_rect;
int geometry_scale;
int new_x;
int new_y;
@ -281,6 +282,7 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
* coordinate space so that we can have a scale independent size to pass
* to the Wayland surface. */
geometry_scale = meta_window_wayland_get_geometry_scale (window);
frame_rect = meta_window_config_get_rect (window->config);
configured_rect.width = constrained_rect.width;
configured_rect.height = constrained_rect.height;
@ -314,20 +316,21 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
new_width = unconstrained_rect.width;
new_height = unconstrained_rect.height;
}
if (window->rect.width != new_width ||
window->rect.height != new_height)
if (frame_rect.width != new_width ||
frame_rect.height != new_height)
{
*result |= META_MOVE_RESIZE_RESULT_RESIZED;
window->rect.width = new_width;
window->rect.height = new_height;
meta_window_config_set_size (window->config,
new_width, new_height);
}
frame_rect = meta_window_config_get_rect (window->config);
window->buffer_rect.width =
window->rect.width +
frame_rect.width +
window->custom_frame_extents.left +
window->custom_frame_extents.right;
window->buffer_rect.height =
window->rect.height +
frame_rect.height +
window->custom_frame_extents.top +
window->custom_frame_extents.bottom;
@ -353,8 +356,8 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
if (flags & META_MOVE_RESIZE_PLACEMENT_CHANGED ||
rel_x != wl_window->last_sent_rel_x ||
rel_y != wl_window->last_sent_rel_y ||
constrained_rect.width != window->rect.width ||
constrained_rect.height != window->rect.height)
constrained_rect.width != frame_rect.width ||
constrained_rect.height != frame_rect.height)
{
MetaWaylandWindowConfiguration *configuration;
@ -388,8 +391,8 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
break;
}
}
else if (constrained_rect.width != window->rect.width ||
constrained_rect.height != window->rect.height ||
else if (constrained_rect.width != frame_rect.width ||
constrained_rect.height != frame_rect.height ||
flags & META_MOVE_RESIZE_STATE_CHANGED)
{
MetaWaylandWindowConfiguration *configuration;
@ -445,11 +448,10 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
!!(flags & META_MOVE_RESIZE_STATE_CHANGED);
}
if (new_x != window->rect.x || new_y != window->rect.y)
if (new_x != frame_rect.x || new_y != frame_rect.y)
{
*result |= META_MOVE_RESIZE_RESULT_MOVED;
window->rect.x = new_x;
window->rect.y = new_y;
meta_window_config_set_position (window->config, new_x, new_y);
}
if (window->placement.rule &&
@ -526,7 +528,7 @@ meta_window_wayland_update_main_monitor (MetaWindow *window,
MetaLogicalMonitor *scaled_new;
float from_scale, to_scale;
float scale;
MtkRectangle rect;
MtkRectangle frame_rect;
from = window->monitor;
@ -540,7 +542,8 @@ meta_window_wayland_update_main_monitor (MetaWindow *window,
return;
}
if (window->rect.width == 0 || window->rect.height == 0)
frame_rect = meta_window_config_get_rect (window->config);
if (frame_rect.width == 0 || frame_rect.height == 0)
{
window->monitor = meta_window_find_monitor_from_id (window);
return;
@ -587,10 +590,9 @@ meta_window_wayland_update_main_monitor (MetaWindow *window,
* changes the main monitor, wait until both the current and the new scale
* will result in the same main monitor. */
scale = to_scale / from_scale;
rect = window->rect;
scale_rect_size (&rect, scale);
scale_rect_size (&frame_rect, scale);
scaled_new =
meta_monitor_manager_get_logical_monitor_from_rect (monitor_manager, &rect);
meta_monitor_manager_get_logical_monitor_from_rect (monitor_manager, &frame_rect);
if (to != scaled_new)
return;
@ -606,6 +608,7 @@ meta_window_wayland_main_monitor_changed (MetaWindow *window,
int geometry_scale;
float scale_factor;
MetaWaylandSurface *surface;
MtkRectangle frame_rect;
if (!window->monitor)
return;
@ -629,7 +632,8 @@ meta_window_wayland_main_monitor_changed (MetaWindow *window,
scale_factor = (float) geometry_scale / old_geometry_scale;
/* Window size. */
scale_rect_size (&window->rect, scale_factor);
frame_rect = meta_window_config_get_rect (window->config);
scale_rect_size (&frame_rect, scale_factor);
scale_rect_size (&window->unconstrained_rect, scale_factor);
scale_rect_size (&window->saved_rect, scale_factor);
scale_size (&window->size_hints.min_width, &window->size_hints.min_height, scale_factor);
@ -649,9 +653,9 @@ meta_window_wayland_main_monitor_changed (MetaWindow *window,
/* Buffer rect. */
scale_rect_size (&window->buffer_rect, scale_factor);
window->buffer_rect.x =
window->rect.x - window->custom_frame_extents.left;
frame_rect.x - window->custom_frame_extents.left;
window->buffer_rect.y =
window->rect.y - window->custom_frame_extents.top;
frame_rect.y - window->custom_frame_extents.top;
meta_compositor_sync_window_geometry (window->display->compositor,
window,
@ -861,10 +865,6 @@ meta_window_wayland_constructed (GObject *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;
@ -878,6 +878,8 @@ meta_window_wayland_constructed (GObject *object)
window->decorated = FALSE;
window->hidden = TRUE;
window->config = meta_window_config_new ();
G_OBJECT_CLASS (meta_window_wayland_parent_class)->constructed (object);
}
@ -1105,9 +1107,7 @@ meta_window_wayland_is_resize (MetaWindowWayland *wl_window,
else
{
MetaWindow *window = META_WINDOW (wl_window);
old_width = window->rect.width;
old_height = window->rect.height;
meta_window_config_get_size (window->config, &old_width, &old_height);
}
return !wl_window->has_last_sent_configuration ||
@ -1178,6 +1178,7 @@ meta_window_wayland_finish_move_resize (MetaWindow *window,
gboolean is_window_being_resized;
gboolean is_client_resize;
MetaWindowDrag *window_drag;
MtkRectangle frame_rect;
/* 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
@ -1225,9 +1226,10 @@ meta_window_wayland_finish_move_resize (MetaWindow *window,
meta_grab_op_is_resizing (meta_window_drag_get_grab_op (window_drag)) &&
meta_window_drag_get_window (window_drag) == window);
frame_rect = meta_window_config_get_rect (window->config);
rect = (MtkRectangle) {
.x = window->rect.x,
.y = window->rect.y,
.x = frame_rect.x,
.y = frame_rect.y,
.width = new_geom.width,
.height = new_geom.height
};
@ -1239,10 +1241,12 @@ meta_window_wayland_finish_move_resize (MetaWindow *window,
if (window->placement.rule)
{
MetaWindow *parent;
MtkRectangle parent_rect;
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;
parent_rect = meta_window_config_get_rect (parent->config);
rect.x = parent_rect.x + acked_configuration->rel_x;
rect.y = parent_rect.y + acked_configuration->rel_y;
}
else
{
@ -1262,7 +1266,7 @@ meta_window_wayland_finish_move_resize (MetaWindow *window,
rect.x += dx;
rect.y += dy;
if (rect.x != window->rect.x || rect.y != window->rect.y)
if (rect.x != frame_rect.x || rect.y != frame_rect.y)
flags |= META_MOVE_RESIZE_MOVE_ACTION;
if (wl_window->has_pending_state_change && acked_configuration)
@ -1271,7 +1275,7 @@ meta_window_wayland_finish_move_resize (MetaWindow *window,
wl_window->has_pending_state_change = FALSE;
}
if (rect.width != window->rect.width || rect.height != window->rect.height)
if (rect.width != frame_rect.width || rect.height != frame_rect.height)
{
flags |= META_MOVE_RESIZE_RESIZE_ACTION;
@ -1310,8 +1314,9 @@ meta_window_place_with_placement_rule (MetaWindow *window,
window->placement.rule = g_new0 (MetaPlacementRule, 1);
*window->placement.rule = *placement_rule;
window->unconstrained_rect.x = window->rect.x;
window->unconstrained_rect.y = window->rect.y;
meta_window_config_get_position (window->config,
&window->unconstrained_rect.x,
&window->unconstrained_rect.y);
window->unconstrained_rect.width = placement_rule->width;
window->unconstrained_rect.height = placement_rule->height;

View File

@ -804,6 +804,7 @@ repick_drop_surface (MetaWaylandCompositor *compositor,
Display *xdisplay = meta_x11_display_get_xdisplay (x11_display);
MetaWaylandSurface *focus = NULL;
MetaWindow *focus_window;
MtkRectangle frame_rect;
focus = pick_drop_surface (compositor, event);
if (dnd->focus_surface == focus)
@ -825,11 +826,12 @@ repick_drop_surface (MetaWaylandCompositor *compositor,
dnd_window = next_dnd_window (dnd);
XMapRaised (xdisplay, dnd_window);
frame_rect = meta_window_config_get_rect (focus_window->config);
XMoveResizeWindow (xdisplay, dnd_window,
focus_window->rect.x,
focus_window->rect.y,
focus_window->rect.width,
focus_window->rect.height);
frame_rect.x,
frame_rect.y,
frame_rect.width,
frame_rect.height);
}
else
{

View File

@ -88,7 +88,7 @@ meta_window_x11_set_frame_xwindow (MetaWindow *window,
frame->window = window;
frame->xwindow = xframe;
frame->rect = window->rect;
frame->rect = meta_window_config_get_rect (window->config);
frame->child_x = 0;
frame->child_y = 0;
frame->bottom_height = 0;

View File

@ -344,7 +344,11 @@ meta_window_set_custom_frame_extents (MetaWindow *window,
*/
if (is_initial)
{
meta_window_client_rect_to_frame_rect (window, &window->rect, &window->rect);
MtkRectangle frame_rect;
frame_rect = meta_window_config_get_rect (window->config);
meta_window_client_rect_to_frame_rect (window, &frame_rect, &frame_rect);
meta_window_config_set_rect (window->config, frame_rect);
meta_window_client_rect_to_frame_rect (window, &window->unconstrained_rect, &window->unconstrained_rect);
}
}
@ -791,7 +795,7 @@ reload_net_wm_state (MetaWindow *window,
window->maximized_horizontally = FALSE;
window->maximized_vertically = FALSE;
window->fullscreen = FALSE;
meta_window_config_set_is_fullscreen (window->config, FALSE);
priv->wm_state_modal = FALSE;
priv->wm_state_skip_taskbar = FALSE;
priv->wm_state_skip_pager = FALSE;
@ -819,7 +823,7 @@ reload_net_wm_state (MetaWindow *window,
priv->wm_state_skip_pager = TRUE;
else if (value->v.atom_list.atoms[i] == x11_display->atom__NET_WM_STATE_FULLSCREEN)
{
window->fullscreen = TRUE;
meta_window_config_set_is_fullscreen (window->config, TRUE);
g_object_notify (G_OBJECT (window), "fullscreen");
}
else if (value->v.atom_list.atoms[i] == x11_display->atom__NET_WM_STATE_ABOVE)

View File

@ -671,14 +671,14 @@ meta_window_x11_initialize_state (MetaWindow *window)
}
/* For override-redirect windows, save the client rect
* directly. window->rect was assigned from the XWindowAttributes
* directly. window->config->rect was assigned from the XWindowAttributes
* in the main meta_window_shared_new.
*
* For normal windows, do a full ConfigureRequest based on the
* window hints, as that's what the ICCCM says to do.
*/
priv->client_rect = window->rect;
window->buffer_rect = window->rect;
priv->client_rect = meta_window_config_get_rect (window->config);
window->buffer_rect = meta_window_config_get_rect (window->config);
if (!window->override_redirect)
{
@ -1408,15 +1408,18 @@ meta_window_x11_move_resize_internal (MetaWindow *window,
gboolean configure_frame_first;
gboolean is_configure_request;
MetaWindowDrag *window_drag;
MtkRectangle frame_rect;
is_configure_request = (flags & META_MOVE_RESIZE_CONFIGURE_REQUEST) != 0;
meta_frame_calc_borders (priv->frame, &borders);
size_dx = constrained_rect.width - window->rect.width;
size_dy = constrained_rect.height - window->rect.height;
frame_rect = meta_window_config_get_rect (window->config);
size_dx = constrained_rect.width - frame_rect.width;
size_dy = constrained_rect.height - frame_rect.height;
window->rect = constrained_rect;
meta_window_config_set_rect (window->config, constrained_rect);
frame_rect = meta_window_config_get_rect (window->config);
if (priv->frame)
{
@ -1424,8 +1427,8 @@ meta_window_x11_move_resize_internal (MetaWindow *window,
int new_x, new_y;
/* Compute new frame size */
new_w = window->rect.width + borders.invisible.left + borders.invisible.right;
new_h = window->rect.height + borders.invisible.top + borders.invisible.bottom;
new_w = frame_rect.width + borders.invisible.left + borders.invisible.right;
new_h = frame_rect.height + borders.invisible.top + borders.invisible.bottom;
if (new_w != priv->frame->rect.width ||
new_h != priv->frame->rect.height)
@ -1436,8 +1439,8 @@ meta_window_x11_move_resize_internal (MetaWindow *window,
}
/* Compute new frame coords */
new_x = window->rect.x - borders.invisible.left;
new_y = window->rect.y - borders.invisible.top;
new_x = frame_rect.x - borders.invisible.left;
new_y = frame_rect.y - borders.invisible.top;
if (new_x != priv->frame->rect.x ||
new_y != priv->frame->rect.y)
@ -2174,7 +2177,8 @@ meta_window_x11_constructed (GObject *object)
rect = MTK_RECTANGLE_INIT (attrs.x, attrs.y, attrs.width, attrs.height);
meta_window_protocol_to_stage_rect (window, &rect, &rect);
window->rect = rect;
window->config = meta_window_config_new ();
meta_window_config_set_rect (window->config, rect);
/* size_hints are the "request" */
window->size_hints.x = rect.x;
@ -2727,12 +2731,11 @@ meta_window_x11_get_gravity_position (MetaWindow *window,
int w, h;
int x, y;
w = window->rect.width;
h = window->rect.height;
meta_window_config_get_size (window->config, &w, &h);
if (gravity == META_GRAVITY_STATIC)
{
frame_extents = window->rect;
frame_extents = meta_window_config_get_rect (window->config);
if (priv->frame)
{
frame_extents.x = priv->frame->rect.x + priv->frame->child_x;
@ -2742,7 +2745,7 @@ meta_window_x11_get_gravity_position (MetaWindow *window,
else
{
if (priv->frame == NULL)
frame_extents = window->rect;
frame_extents = meta_window_config_get_rect (window->config);
else
frame_extents = priv->frame->rect;
}
@ -2815,10 +2818,11 @@ meta_window_x11_get_session_geometry (MetaWindow *window,
window->size_hints.win_gravity,
x, y);
*width = (window->rect.width - window->size_hints.base_width) /
window->size_hints.width_inc;
*height = (window->rect.height - window->size_hints.base_height) /
window->size_hints.height_inc;
meta_window_config_get_position (window->config, width, height);
*width -= window->size_hints.base_width;
*width /= window->size_hints.width_inc;
*height -= window->size_hints.base_height;
*height /= window->size_hints.height_inc;
}
static void
@ -2857,7 +2861,7 @@ meta_window_move_resize_request (MetaWindow *window,
* and otherwise use our current up-to-date position.
*
* Otherwise you get spurious position changes when the app changes
* size, for example, if window->rect is not in sync with the
* size, for example, if window->config->rect is not in sync with the
* server-side position in effect when the configure request was
* generated.
*/
@ -4345,6 +4349,7 @@ meta_window_x11_configure_notify (MetaWindow *window,
{
MetaWindowX11 *window_x11 = META_WINDOW_X11 (window);
MetaWindowX11Private *priv = meta_window_x11_get_instance_private (window_x11);
MtkRectangle rect;
g_assert (window->override_redirect);
g_assert (priv->frame == NULL);
@ -4354,10 +4359,11 @@ meta_window_x11_configure_notify (MetaWindow *window,
event->y,
event->width,
event->height),
&window->rect);
&rect);
meta_window_config_set_rect (window->config, rect);
priv->client_rect = window->rect;
window->buffer_rect = window->rect;
priv->client_rect = rect;
window->buffer_rect = rect;
meta_window_update_monitor (window, META_WINDOW_UPDATE_MONITOR_FLAGS_NONE);