mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
wayland: Factor out some parts of meta_surface_actor_wayland_get_scale
Put a toplevel window getter in meta-wayland-surface.h and a main monitor scale getter in window-wayland.h. https://bugzilla.gnome.org/show_bug.cgi?id=745655
This commit is contained in:
parent
b97ebc4124
commit
117f57f74c
@ -31,6 +31,7 @@
|
|||||||
#include "meta-shaped-texture-private.h"
|
#include "meta-shaped-texture-private.h"
|
||||||
|
|
||||||
#include "wayland/meta-wayland-private.h"
|
#include "wayland/meta-wayland-private.h"
|
||||||
|
#include "wayland/meta-window-wayland.h"
|
||||||
|
|
||||||
#include "compositor/region-utils.h"
|
#include "compositor/region-utils.h"
|
||||||
|
|
||||||
@ -81,52 +82,22 @@ meta_surface_actor_wayland_is_unredirected (MetaSurfaceActor *actor)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
get_output_scale (int winsys_id)
|
|
||||||
{
|
|
||||||
MetaMonitorManager *monitor_manager = meta_monitor_manager_get ();
|
|
||||||
MetaOutput *outputs;
|
|
||||||
guint n_outputs, i;
|
|
||||||
int output_scale = 1;
|
|
||||||
|
|
||||||
outputs = meta_monitor_manager_get_outputs (monitor_manager, &n_outputs);
|
|
||||||
|
|
||||||
for (i = 0; i < n_outputs; i++)
|
|
||||||
{
|
|
||||||
if (outputs[i].winsys_id == winsys_id)
|
|
||||||
{
|
|
||||||
output_scale = outputs[i].scale;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return output_scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
double
|
double
|
||||||
meta_surface_actor_wayland_get_scale (MetaSurfaceActorWayland *actor)
|
meta_surface_actor_wayland_get_scale (MetaSurfaceActorWayland *actor)
|
||||||
{
|
{
|
||||||
MetaSurfaceActorWaylandPrivate *priv = meta_surface_actor_wayland_get_instance_private (actor);
|
MetaSurfaceActorWaylandPrivate *priv = meta_surface_actor_wayland_get_instance_private (actor);
|
||||||
MetaWaylandSurface *surface = priv->surface;
|
MetaWaylandSurface *surface = priv->surface;
|
||||||
MetaWindow *window = NULL;
|
MetaWindow *window;
|
||||||
int output_scale = 1;
|
int output_scale = 1;
|
||||||
|
|
||||||
if (!surface)
|
if (!surface)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
while (surface)
|
window = meta_wayland_surface_get_toplevel_window (surface);
|
||||||
{
|
|
||||||
if (surface->window)
|
|
||||||
{
|
|
||||||
window = surface->window;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
surface = surface->sub.parent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* XXX: We do not handle x11 clients yet */
|
/* XXX: We do not handle x11 clients yet */
|
||||||
if (window && window->client_type != META_WINDOW_CLIENT_TYPE_X11)
|
if (window && window->client_type != META_WINDOW_CLIENT_TYPE_X11)
|
||||||
output_scale = get_output_scale (window->monitor->winsys_id);
|
output_scale = meta_window_wayland_get_main_monitor_scale (window);
|
||||||
|
|
||||||
return (double)output_scale / (double)priv->surface->scale;
|
return (double)output_scale / (double)priv->surface->scale;
|
||||||
}
|
}
|
||||||
|
@ -2229,3 +2229,17 @@ meta_wayland_surface_drag_dest_drop (MetaWaylandSurface *surface)
|
|||||||
|
|
||||||
surface->dnd.funcs->drop (data_device, surface);
|
surface->dnd.funcs->drop (data_device, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetaWindow *
|
||||||
|
meta_wayland_surface_get_toplevel_window (MetaWaylandSurface *surface)
|
||||||
|
{
|
||||||
|
while (surface)
|
||||||
|
{
|
||||||
|
if (surface->window)
|
||||||
|
return surface->window;
|
||||||
|
|
||||||
|
surface = surface->sub.parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
@ -190,4 +190,6 @@ void meta_wayland_surface_drag_dest_drop (MetaWaylandSurface
|
|||||||
|
|
||||||
void meta_wayland_surface_update_outputs (MetaWaylandSurface *surface);
|
void meta_wayland_surface_update_outputs (MetaWaylandSurface *surface);
|
||||||
|
|
||||||
|
MetaWindow * meta_wayland_surface_get_toplevel_window (MetaWaylandSurface *surface);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -412,6 +412,28 @@ should_do_pending_move (MetaWindowWayland *wl_window,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
meta_window_wayland_get_main_monitor_scale (MetaWindow *window)
|
||||||
|
{
|
||||||
|
MetaMonitorManager *monitor_manager = meta_monitor_manager_get ();
|
||||||
|
MetaOutput *outputs;
|
||||||
|
guint n_outputs, i;
|
||||||
|
int output_scale = 1;
|
||||||
|
|
||||||
|
outputs = meta_monitor_manager_get_outputs (monitor_manager, &n_outputs);
|
||||||
|
|
||||||
|
for (i = 0; i < n_outputs; i++)
|
||||||
|
{
|
||||||
|
if (outputs[i].winsys_id == window->monitor->winsys_id)
|
||||||
|
{
|
||||||
|
output_scale = outputs[i].scale;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return output_scale;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* meta_window_move_resize_wayland:
|
* meta_window_move_resize_wayland:
|
||||||
*
|
*
|
||||||
|
@ -50,5 +50,6 @@ void meta_window_wayland_move_resize (MetaWindow *window,
|
|||||||
MetaRectangle new_geom,
|
MetaRectangle new_geom,
|
||||||
int dx,
|
int dx,
|
||||||
int dy);
|
int dy);
|
||||||
|
int meta_window_wayland_get_main_monitor_scale (MetaWindow *window);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user