[mutter] wayland: Factor out some parts of meta_surface_actor_wayland_get_scale
- From: Jonas Ådahl <jadahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] wayland: Factor out some parts of meta_surface_actor_wayland_get_scale
- Date: Thu, 16 Jul 2015 03:47:41 +0000 (UTC)
commit 117f57f74c885c34a788275863fc2b14274388ba
Author: Jonas Ådahl <jadahl gmail com>
Date: Mon Mar 23 21:10:20 2015 +0800
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
src/compositor/meta-surface-actor-wayland.c | 37 +++------------------------
src/wayland/meta-wayland-surface.c | 14 ++++++++++
src/wayland/meta-wayland-surface.h | 2 +
src/wayland/meta-window-wayland.c | 22 ++++++++++++++++
src/wayland/meta-window-wayland.h | 1 +
5 files changed, 43 insertions(+), 33 deletions(-)
---
diff --git a/src/compositor/meta-surface-actor-wayland.c b/src/compositor/meta-surface-actor-wayland.c
index 2786a5a..7c354d6 100644
--- a/src/compositor/meta-surface-actor-wayland.c
+++ b/src/compositor/meta-surface-actor-wayland.c
@@ -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;
}
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 2817ba6..8f0ae95 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -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;
+}
diff --git a/src/wayland/meta-wayland-surface.h b/src/wayland/meta-wayland-surface.h
index e29cf93..a1d4c7e 100644
--- a/src/wayland/meta-wayland-surface.h
+++ b/src/wayland/meta-wayland-surface.h
@@ -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
diff --git a/src/wayland/meta-window-wayland.c b/src/wayland/meta-window-wayland.c
index 8c6ca58..248cb92 100644
--- a/src/wayland/meta-window-wayland.c
+++ b/src/wayland/meta-window-wayland.c
@@ -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:
*
diff --git a/src/wayland/meta-window-wayland.h b/src/wayland/meta-window-wayland.h
index eb2e8de..c57b45d 100644
--- a/src/wayland/meta-window-wayland.h
+++ b/src/wayland/meta-window-wayland.h
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]