wayland/actor-surface: Turn get_geometry_scale() into a vfunc
This allows us to implement more sophisticated logic for the different cases. For DnD surfaces, use the geometry scale of the monitor where the pointer is, instead of incorrectly assuming '1' as it was before. https://gitlab.gnome.org/GNOME/mutter/merge_requests/780
This commit is contained in:
parent
dbe9daeb76
commit
bba8f6c53e
@ -100,25 +100,10 @@ meta_wayland_actor_surface_queue_frame_callbacks (MetaWaylandActorSurface *actor
|
||||
double
|
||||
meta_wayland_actor_surface_get_geometry_scale (MetaWaylandActorSurface *actor_surface)
|
||||
{
|
||||
MetaWaylandSurfaceRole *surface_role =
|
||||
META_WAYLAND_SURFACE_ROLE (actor_surface);
|
||||
MetaWaylandSurface *surface =
|
||||
meta_wayland_surface_role_get_surface (surface_role);
|
||||
MetaWindow *toplevel_window;
|
||||
MetaWaylandActorSurfaceClass *actor_surface_class =
|
||||
META_WAYLAND_ACTOR_SURFACE_GET_CLASS (actor_surface);
|
||||
|
||||
toplevel_window = meta_wayland_surface_get_toplevel_window (surface);
|
||||
if (meta_is_stage_views_scaled ())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!toplevel_window ||
|
||||
toplevel_window->client_type == META_WINDOW_CLIENT_TYPE_X11)
|
||||
return 1;
|
||||
else
|
||||
return meta_window_wayland_get_geometry_scale (toplevel_window);
|
||||
}
|
||||
return actor_surface_class->get_geometry_scale (actor_surface);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -33,6 +33,7 @@ struct _MetaWaylandActorSurfaceClass
|
||||
{
|
||||
MetaWaylandSurfaceRoleClass parent_class;
|
||||
|
||||
double (* get_geometry_scale) (MetaWaylandActorSurface *actor_surface);
|
||||
void (* sync_actor_state) (MetaWaylandActorSurface *actor_surface);
|
||||
};
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "wayland/meta-wayland-dnd-surface.h"
|
||||
|
||||
#include "backends/meta-logical-monitor.h"
|
||||
#include "compositor/meta-feedback-actor-private.h"
|
||||
|
||||
struct _MetaWaylandSurfaceRoleDND
|
||||
@ -62,6 +63,38 @@ dnd_surface_commit (MetaWaylandSurfaceRole *surface_role,
|
||||
surface_role_class->commit (surface_role, pending);
|
||||
}
|
||||
|
||||
static MetaLogicalMonitor *
|
||||
dnd_surface_find_logical_monitor (MetaWaylandActorSurface *actor_surface)
|
||||
{
|
||||
MetaBackend *backend = meta_get_backend ();
|
||||
MetaCursorRenderer *cursor_renderer =
|
||||
meta_backend_get_cursor_renderer (backend);
|
||||
MetaMonitorManager *monitor_manager =
|
||||
meta_backend_get_monitor_manager (backend);
|
||||
ClutterPoint pointer_pos;
|
||||
|
||||
pointer_pos = meta_cursor_renderer_get_position (cursor_renderer);
|
||||
return meta_monitor_manager_get_logical_monitor_at (monitor_manager,
|
||||
pointer_pos.x,
|
||||
pointer_pos.y);
|
||||
}
|
||||
|
||||
static double
|
||||
dnd_subsurface_get_geometry_scale (MetaWaylandActorSurface *actor_surface)
|
||||
{
|
||||
if (meta_is_stage_views_scaled ())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
MetaLogicalMonitor *logical_monitor;
|
||||
|
||||
logical_monitor = dnd_surface_find_logical_monitor (actor_surface);
|
||||
return meta_logical_monitor_get_scale (logical_monitor);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
dnd_subsurface_sync_actor_state (MetaWaylandActorSurface *actor_surface)
|
||||
{
|
||||
@ -116,5 +149,6 @@ meta_wayland_surface_role_dnd_class_init (MetaWaylandSurfaceRoleDNDClass *klass)
|
||||
surface_role_class->assigned = dnd_surface_assigned;
|
||||
surface_role_class->commit = dnd_surface_commit;
|
||||
|
||||
actor_surface_class->get_geometry_scale = dnd_subsurface_get_geometry_scale;
|
||||
actor_surface_class->sync_actor_state = dnd_subsurface_sync_actor_state;
|
||||
}
|
||||
|
@ -180,6 +180,22 @@ meta_wayland_shell_surface_surface_commit (MetaWaylandSurfaceRole *surface_role
|
||||
meta_wayland_surface_get_height (surface) * geometry_scale;
|
||||
}
|
||||
|
||||
static double
|
||||
meta_wayland_shell_surface_get_geometry_scale (MetaWaylandActorSurface *actor_surface)
|
||||
{
|
||||
MetaWaylandSurfaceRole *surface_role =
|
||||
META_WAYLAND_SURFACE_ROLE (actor_surface);
|
||||
MetaWaylandSurface *surface =
|
||||
meta_wayland_surface_role_get_surface (surface_role);
|
||||
MetaWindow *toplevel_window;
|
||||
|
||||
toplevel_window = meta_wayland_surface_get_toplevel_window (surface);
|
||||
if (meta_is_stage_views_scaled () || !toplevel_window)
|
||||
return 1;
|
||||
else
|
||||
return meta_window_wayland_get_geometry_scale (toplevel_window);
|
||||
}
|
||||
|
||||
static void
|
||||
meta_wayland_shell_surface_sync_actor_state (MetaWaylandActorSurface *actor_surface)
|
||||
{
|
||||
@ -210,6 +226,9 @@ meta_wayland_shell_surface_class_init (MetaWaylandShellSurfaceClass *klass)
|
||||
META_WAYLAND_ACTOR_SURFACE_CLASS (klass);
|
||||
|
||||
surface_role_class->commit = meta_wayland_shell_surface_surface_commit;
|
||||
|
||||
actor_surface_class->get_geometry_scale =
|
||||
meta_wayland_shell_surface_get_geometry_scale;
|
||||
actor_surface_class->sync_actor_state =
|
||||
meta_wayland_shell_surface_sync_actor_state;
|
||||
}
|
||||
|
@ -240,6 +240,28 @@ meta_wayland_subsurface_get_toplevel (MetaWaylandSurfaceRole *surface_role)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static double
|
||||
meta_wayland_subsurface_get_geometry_scale (MetaWaylandActorSurface *actor_surface)
|
||||
{
|
||||
MetaWaylandSurfaceRole *surface_role =
|
||||
META_WAYLAND_SURFACE_ROLE (actor_surface);
|
||||
MetaWaylandSurface *surface =
|
||||
meta_wayland_surface_role_get_surface (surface_role);
|
||||
MetaWaylandSurface *parent = surface->sub.parent;
|
||||
|
||||
if (parent)
|
||||
{
|
||||
MetaWaylandActorSurface *parent_actor;
|
||||
|
||||
parent_actor = META_WAYLAND_ACTOR_SURFACE (surface->sub.parent->role);
|
||||
return meta_wayland_actor_surface_get_geometry_scale (parent_actor);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
meta_wayland_subsurface_sync_actor_state (MetaWaylandActorSurface *actor_surface)
|
||||
{
|
||||
@ -273,6 +295,8 @@ meta_wayland_subsurface_class_init (MetaWaylandSubsurfaceClass *klass)
|
||||
|
||||
surface_role_class->get_toplevel = meta_wayland_subsurface_get_toplevel;
|
||||
|
||||
actor_surface_class->get_geometry_scale =
|
||||
meta_wayland_subsurface_get_geometry_scale;
|
||||
actor_surface_class->sync_actor_state =
|
||||
meta_wayland_subsurface_sync_actor_state;
|
||||
}
|
||||
|
@ -907,6 +907,12 @@ xwayland_surface_get_toplevel (MetaWaylandSurfaceRole *surface_role)
|
||||
return meta_wayland_surface_role_get_surface (surface_role);
|
||||
}
|
||||
|
||||
static double
|
||||
xwayland_surface_get_geometry_scale (MetaWaylandActorSurface *actor_surface)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
xwayland_surface_sync_actor_state (MetaWaylandActorSurface *actor_surface)
|
||||
{
|
||||
@ -938,6 +944,7 @@ meta_wayland_surface_role_xwayland_class_init (MetaWaylandSurfaceRoleXWaylandCla
|
||||
surface_role_class->commit = xwayland_surface_commit;
|
||||
surface_role_class->get_toplevel = xwayland_surface_get_toplevel;
|
||||
|
||||
actor_surface_class->get_geometry_scale = xwayland_surface_get_geometry_scale;
|
||||
actor_surface_class->sync_actor_state = xwayland_surface_sync_actor_state;
|
||||
|
||||
xwayland_surface_signals[XWAYLAND_SURFACE_WINDOW_ASSOCIATED] =
|
||||
|
Loading…
Reference in New Issue
Block a user