mirror of
https://github.com/brl/mutter.git
synced 2024-11-26 01:50:42 -05:00
window: Replace monitor scale getter with geometry scale
All places that get the 'main monitor scale' of a window really just wants the window geometry scale, so call it that. https://bugzilla.gnome.org/show_bug.cgi?id=777732
This commit is contained in:
parent
f25f14351c
commit
1c54c7a1bb
@ -98,7 +98,7 @@ meta_surface_actor_wayland_get_scale (MetaSurfaceActorWayland *self)
|
||||
{
|
||||
MetaWaylandSurface *surface = meta_surface_actor_wayland_get_surface (self);
|
||||
MetaWindow *window;
|
||||
int output_scale = 1;
|
||||
int geometry_scale = 1;
|
||||
|
||||
g_assert (surface);
|
||||
|
||||
@ -106,9 +106,9 @@ meta_surface_actor_wayland_get_scale (MetaSurfaceActorWayland *self)
|
||||
|
||||
/* XXX: We do not handle x11 clients yet */
|
||||
if (window && window->client_type != META_WINDOW_CLIENT_TYPE_X11)
|
||||
output_scale = meta_window_wayland_get_main_monitor_scale (window);
|
||||
geometry_scale = meta_window_wayland_get_geometry_scale (window);
|
||||
|
||||
return (double) output_scale / (double) surface->scale;
|
||||
return (double) geometry_scale / (double) surface->scale;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -118,16 +118,16 @@ logical_to_actor_position (MetaSurfaceActorWayland *self,
|
||||
{
|
||||
MetaWaylandSurface *surface = meta_surface_actor_wayland_get_surface (self);
|
||||
MetaWindow *toplevel_window;
|
||||
int monitor_scale = 1;
|
||||
int geometry_scale = 1;
|
||||
|
||||
g_assert (surface);
|
||||
|
||||
toplevel_window = meta_wayland_surface_get_toplevel_window (surface);
|
||||
if (toplevel_window)
|
||||
monitor_scale = meta_window_wayland_get_main_monitor_scale (toplevel_window);
|
||||
geometry_scale = meta_window_wayland_get_geometry_scale (toplevel_window);
|
||||
|
||||
*x = *x * monitor_scale;
|
||||
*y = *y * monitor_scale;
|
||||
*x = *x * geometry_scale;
|
||||
*y = *y * geometry_scale;
|
||||
}
|
||||
|
||||
/* Convert the current actor state to the corresponding subsurface rectangle
|
||||
@ -140,19 +140,19 @@ meta_surface_actor_wayland_get_subsurface_rect (MetaSurfaceActorWayland *self,
|
||||
MetaWaylandBuffer *buffer = meta_wayland_surface_get_buffer (surface);
|
||||
CoglTexture *texture;
|
||||
MetaWindow *toplevel_window;
|
||||
int monitor_scale;
|
||||
int geometry_scale;
|
||||
float x, y;
|
||||
|
||||
g_assert (surface);
|
||||
|
||||
texture = buffer->texture;
|
||||
toplevel_window = meta_wayland_surface_get_toplevel_window (surface);
|
||||
monitor_scale = meta_window_wayland_get_main_monitor_scale (toplevel_window);
|
||||
geometry_scale = meta_window_wayland_get_geometry_scale (toplevel_window);
|
||||
|
||||
clutter_actor_get_position (CLUTTER_ACTOR (self), &x, &y);
|
||||
*rect = (MetaRectangle) {
|
||||
.x = x / monitor_scale,
|
||||
.y = y / monitor_scale,
|
||||
.x = x / geometry_scale,
|
||||
.y = y / geometry_scale,
|
||||
.width = cogl_texture_get_width (texture) / surface->scale,
|
||||
.height = cogl_texture_get_height (texture) / surface->scale,
|
||||
};
|
||||
|
@ -778,16 +778,18 @@ static void
|
||||
scale_placement_rule (MetaPlacementRule *placement_rule,
|
||||
MetaWaylandSurface *surface)
|
||||
{
|
||||
int monitor_scale = surface->window->monitor->scale;
|
||||
int geometry_scale;
|
||||
|
||||
placement_rule->anchor_rect.x *= monitor_scale;
|
||||
placement_rule->anchor_rect.y *= monitor_scale;
|
||||
placement_rule->anchor_rect.width *= monitor_scale;
|
||||
placement_rule->anchor_rect.height *= monitor_scale;
|
||||
placement_rule->offset_x *= monitor_scale;
|
||||
placement_rule->offset_y *= monitor_scale;
|
||||
placement_rule->width *= monitor_scale;
|
||||
placement_rule->height *= monitor_scale;
|
||||
geometry_scale = meta_window_wayland_get_geometry_scale (surface->window);
|
||||
|
||||
placement_rule->anchor_rect.x *= geometry_scale;
|
||||
placement_rule->anchor_rect.y *= geometry_scale;
|
||||
placement_rule->anchor_rect.width *= geometry_scale;
|
||||
placement_rule->anchor_rect.height *= geometry_scale;
|
||||
placement_rule->offset_x *= geometry_scale;
|
||||
placement_rule->offset_y *= geometry_scale;
|
||||
placement_rule->width *= geometry_scale;
|
||||
placement_rule->height *= geometry_scale;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -920,7 +922,7 @@ xdg_popup_role_configure (MetaWaylandSurfaceRoleShellSurface *shell_surface_role
|
||||
MetaWaylandXdgPopup *xdg_popup = META_WAYLAND_XDG_POPUP (shell_surface_role);
|
||||
MetaWaylandXdgSurface *xdg_surface = META_WAYLAND_XDG_SURFACE (xdg_popup);
|
||||
MetaWindow *parent_window = xdg_popup->parent_surface->window;
|
||||
int monitor_scale;
|
||||
int geometry_scale;
|
||||
int x, y;
|
||||
|
||||
/* If the parent surface was destroyed, its window will be destroyed
|
||||
@ -934,9 +936,9 @@ xdg_popup_role_configure (MetaWaylandSurfaceRoleShellSurface *shell_surface_role
|
||||
if (!parent_window)
|
||||
return;
|
||||
|
||||
monitor_scale = meta_window_wayland_get_main_monitor_scale (parent_window);
|
||||
x = (new_x - parent_window->rect.x) / monitor_scale;
|
||||
y = (new_y - parent_window->rect.y) / monitor_scale;
|
||||
geometry_scale = meta_window_wayland_get_geometry_scale (parent_window);
|
||||
x = (new_x - parent_window->rect.x) / geometry_scale;
|
||||
y = (new_y - parent_window->rect.y) / geometry_scale;
|
||||
zxdg_popup_v6_send_configure (xdg_popup->resource,
|
||||
x, y, new_width, new_height);
|
||||
meta_wayland_xdg_surface_send_configure (xdg_surface);
|
||||
|
@ -177,7 +177,7 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
|
||||
int configured_y;
|
||||
int configured_width;
|
||||
int configured_height;
|
||||
int monitor_scale;
|
||||
int geometry_scale;
|
||||
|
||||
g_assert (window->frame == NULL);
|
||||
|
||||
@ -192,9 +192,9 @@ meta_window_wayland_move_resize_internal (MetaWindow *window,
|
||||
* 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. */
|
||||
monitor_scale = meta_window_wayland_get_main_monitor_scale (window);
|
||||
configured_width = constrained_rect.width / monitor_scale;
|
||||
configured_height = constrained_rect.height / monitor_scale;
|
||||
geometry_scale = meta_window_wayland_get_geometry_scale (window);
|
||||
configured_width = constrained_rect.width / geometry_scale;
|
||||
configured_height = constrained_rect.height / geometry_scale;
|
||||
|
||||
/* For wayland clients, the size is completely determined by the client,
|
||||
* and while this allows to avoid some trickery with frames and the resulting
|
||||
@ -569,7 +569,7 @@ should_do_pending_move (MetaWindowWayland *wl_window,
|
||||
}
|
||||
|
||||
int
|
||||
meta_window_wayland_get_main_monitor_scale (MetaWindow *window)
|
||||
meta_window_wayland_get_geometry_scale (MetaWindow *window)
|
||||
{
|
||||
return window->monitor->scale;
|
||||
}
|
||||
@ -587,25 +587,26 @@ meta_window_wayland_move_resize (MetaWindow *window,
|
||||
int dy)
|
||||
{
|
||||
MetaWindowWayland *wl_window = META_WINDOW_WAYLAND (window);
|
||||
int geometry_scale;
|
||||
int gravity;
|
||||
MetaRectangle rect;
|
||||
MetaMoveResizeFlags flags;
|
||||
int monitor_scale;
|
||||
|
||||
/* 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. */
|
||||
monitor_scale = meta_window_wayland_get_main_monitor_scale (window);
|
||||
new_geom.x *= monitor_scale;
|
||||
new_geom.y *= monitor_scale;
|
||||
new_geom.width *= monitor_scale;
|
||||
new_geom.height *= monitor_scale;
|
||||
|
||||
geometry_scale = meta_window_wayland_get_geometry_scale (window);
|
||||
new_geom.x *= geometry_scale;
|
||||
new_geom.y *= geometry_scale;
|
||||
new_geom.width *= geometry_scale;
|
||||
new_geom.height *= geometry_scale;
|
||||
|
||||
/* The (dx, dy) offset is also in logical pixel coordinate space and needs
|
||||
* to be scaled in the same way as new_geom. */
|
||||
dx *= monitor_scale;
|
||||
dy *= monitor_scale;
|
||||
dx *= geometry_scale;
|
||||
dy *= geometry_scale;
|
||||
|
||||
/* XXX: Find a better place to store the window geometry offsets. */
|
||||
window->custom_frame_extents.left = new_geom.x;
|
||||
@ -655,18 +656,16 @@ meta_window_wayland_place_relative_to (MetaWindow *window,
|
||||
int x,
|
||||
int y)
|
||||
{
|
||||
int monitor_scale;
|
||||
int geometry_scale;
|
||||
|
||||
/* If there is no monitor, we can't position the window reliably. */
|
||||
if (!other->monitor)
|
||||
return;
|
||||
|
||||
/* Scale the relative coordinate (x, y) from logical pixels to physical
|
||||
* pixels. */
|
||||
monitor_scale = other->monitor->scale;
|
||||
geometry_scale = meta_window_wayland_get_geometry_scale (other);
|
||||
meta_window_move_frame (window, FALSE,
|
||||
other->buffer_rect.x + (x * monitor_scale),
|
||||
other->buffer_rect.y + (y * monitor_scale));
|
||||
other->buffer_rect.x + (x * geometry_scale),
|
||||
other->buffer_rect.y + (y * geometry_scale));
|
||||
window->placed = TRUE;
|
||||
}
|
||||
|
||||
@ -703,7 +702,7 @@ meta_window_wayland_set_min_size (MetaWindow *window,
|
||||
return;
|
||||
}
|
||||
|
||||
scale = (float) meta_window_wayland_get_main_monitor_scale (window);
|
||||
scale = (float) meta_window_wayland_get_geometry_scale (window);
|
||||
scale_size (&width, &height, scale);
|
||||
|
||||
new_width = width + (window->custom_frame_extents.left +
|
||||
@ -737,7 +736,7 @@ meta_window_wayland_set_max_size (MetaWindow *window,
|
||||
return;
|
||||
}
|
||||
|
||||
scale = (float) meta_window_wayland_get_main_monitor_scale (window);
|
||||
scale = (float) meta_window_wayland_get_geometry_scale (window);
|
||||
scale_size (&width, &height, scale);
|
||||
|
||||
new_width = width + (window->custom_frame_extents.left +
|
||||
@ -779,7 +778,7 @@ meta_window_wayland_get_min_size (MetaWindow *window,
|
||||
*width = MAX (current_width, 0);
|
||||
*height = MAX (current_height, 0);
|
||||
|
||||
scale = 1.0 / (float) meta_window_wayland_get_main_monitor_scale (window);
|
||||
scale = 1.0 / (float) meta_window_wayland_get_geometry_scale (window);
|
||||
scale_size (width, height, scale);
|
||||
}
|
||||
|
||||
@ -814,7 +813,7 @@ meta_window_wayland_get_max_size (MetaWindow *window,
|
||||
*width = CLAMP (current_width, 0, G_MAXINT);
|
||||
*height = CLAMP (current_height, 0, G_MAXINT);
|
||||
|
||||
scale = 1.0 / (float) meta_window_wayland_get_main_monitor_scale (window);
|
||||
scale = 1.0 / (float) meta_window_wayland_get_geometry_scale (window);
|
||||
scale_size (width, height, scale);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ void meta_window_wayland_move_resize (MetaWindow *window,
|
||||
MetaRectangle new_geom,
|
||||
int dx,
|
||||
int dy);
|
||||
int meta_window_wayland_get_main_monitor_scale (MetaWindow *window);
|
||||
int meta_window_wayland_get_geometry_scale (MetaWindow *window);
|
||||
|
||||
void meta_window_wayland_place_relative_to (MetaWindow *window,
|
||||
MetaWindow *other,
|
||||
|
Loading…
Reference in New Issue
Block a user