gdkoffscreenwindow: use embedder to derive surfaces & scale factor

In Gdk, a GdkOffscreenWindow parent has to be the root window. This is
problematic on Wayland because the root window doesn't necessary have the
right information with regard to scale factor.

This patch proposes to rely on the embedder, if available, to derive
surfaces as well as getting the scale factor.

https://bugzilla.gnome.org/show_bug.cgi?id=758936
This commit is contained in:
Lionel Landwerlin 2015-12-02 01:41:07 +00:00
parent 3ba11782db
commit bd332f10ab

View File

@ -143,9 +143,15 @@ _gdk_offscreen_window_create_surface (GdkWindow *offscreen,
gint width,
gint height)
{
GdkOffscreenWindow *impl;
GdkWindow *derived;
g_return_val_if_fail (GDK_IS_OFFSCREEN_WINDOW (offscreen->impl), NULL);
return gdk_window_create_similar_surface (offscreen->parent,
impl = GDK_OFFSCREEN_WINDOW (offscreen->impl);
derived = impl->embedder ? impl->embedder : offscreen->parent;
return gdk_window_create_similar_surface (derived,
CAIRO_CONTENT_COLOR_ALPHA,
width, height);
}
@ -657,10 +663,15 @@ gdk_offscreen_window_get_frame_extents (GdkWindow *window,
static gint
gdk_offscreen_window_get_scale_factor (GdkWindow *window)
{
GdkOffscreenWindow *offscreen;
if (GDK_WINDOW_DESTROYED (window))
return 1;
offscreen = GDK_OFFSCREEN_WINDOW (window->impl);
if (offscreen->embedder)
return gdk_window_get_scale_factor (offscreen->embedder);
return gdk_window_get_scale_factor (window->parent);
}