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:
Jonas Ådahl 2015-03-23 21:10:20 +08:00
parent b97ebc4124
commit 117f57f74c
5 changed files with 43 additions and 33 deletions

View File

@ -31,6 +31,7 @@
#include "meta-shaped-texture-private.h"
#include "wayland/meta-wayland-private.h"
#include "wayland/meta-window-wayland.h"
#include "compositor/region-utils.h"
@ -81,52 +82,22 @@ meta_surface_actor_wayland_is_unredirected (MetaSurfaceActor *actor)
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
meta_surface_actor_wayland_get_scale (MetaSurfaceActorWayland *actor)
{
MetaSurfaceActorWaylandPrivate *priv = meta_surface_actor_wayland_get_instance_private (actor);
MetaWaylandSurface *surface = priv->surface;
MetaWindow *window = NULL;
MetaWindow *window;
int output_scale = 1;
if (!surface)
return 1;
while (surface)
{
if (surface->window)
{
window = surface->window;
break;
}
surface = surface->sub.parent;
}
window = meta_wayland_surface_get_toplevel_window (surface);
/* XXX: We do not handle x11 clients yet */
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;
}

View File

@ -2229,3 +2229,17 @@ meta_wayland_surface_drag_dest_drop (MetaWaylandSurface *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;
}

View File

@ -190,4 +190,6 @@ void meta_wayland_surface_drag_dest_drop (MetaWaylandSurface
void meta_wayland_surface_update_outputs (MetaWaylandSurface *surface);
MetaWindow * meta_wayland_surface_get_toplevel_window (MetaWaylandSurface *surface);
#endif

View File

@ -412,6 +412,28 @@ should_do_pending_move (MetaWindowWayland *wl_window,
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:
*

View File

@ -50,5 +50,6 @@ 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);
#endif