Commit 1eb3b34b authored by Alexander Larsson's avatar Alexander Larsson

Add gdk_window_get_unscaled_size

This is required for the X backend GL integration. If the
window has a height that is not a multiple of the window scale
we can't properly do the y coordinate flipping that GL needs.
Other backends can ignore this and use the default implementation.

https://bugzilla.gnome.org/show_bug.cgi?id=739750
parent 788478df
......@@ -375,7 +375,9 @@ void _gdk_window_update_size (GdkWindow *window);
gboolean _gdk_window_update_viewable (GdkWindow *window);
GdkGLContext * gdk_window_get_paint_gl_context (GdkWindow *window,
GError **error);
void gdk_window_get_unscaled_size (GdkWindow *window,
int *unscaled_width,
int *unscaled_height);
void _gdk_window_process_updates_recurse (GdkWindow *window,
cairo_region_t *expose_region);
......
......@@ -11045,6 +11045,37 @@ gdk_window_get_scale_factor (GdkWindow *window)
return 1;
}
/* Returns the *real* unscaled size, which may be a fractional size
in window scale coordinates. We need this to properly handle GL
coordinates which are y-flipped in the real coordinates. */
void
gdk_window_get_unscaled_size (GdkWindow *window,
int *unscaled_width,
int *unscaled_height)
{
GdkWindowImplClass *impl_class;
gint scale;
g_return_if_fail (GDK_IS_WINDOW (window));
if (window->impl_window == window)
{
impl_class = GDK_WINDOW_IMPL_GET_CLASS (window->impl);
if (impl_class->get_unscaled_size)
return impl_class->get_unscaled_size (window, unscaled_width, unscaled_height);
}
scale = gdk_window_get_scale_factor (window);
if (unscaled_width)
*unscaled_width = window->width * scale;
if (unscaled_height)
*unscaled_height = window->height * scale;
}
/**
* gdk_window_set_opaque_region:
* @window: a top-level or non-native #GdkWindow
......
......@@ -279,6 +279,9 @@ struct _GdkWindowImplClass
GdkAtom property);
gint (* get_scale_factor) (GdkWindow *window);
void (* get_unscaled_size) (GdkWindow *window,
int *unscaled_width,
int *unscaled_height);
void (* set_opaque_region) (GdkWindow *window,
cairo_region_t *region);
......
......@@ -198,6 +198,20 @@ _gdk_x11_window_update_size (GdkWindowImplX11 *impl)
}
}
void
gdk_x11_window_get_unscaled_size (GdkWindow *window,
int *unscaled_width,
int *unscaled_height)
{
GdkWindowImplX11 *impl = GDK_WINDOW_IMPL_X11 (window->impl);
if (unscaled_width)
*unscaled_width = impl->unscaled_width;
if (unscaled_height)
*unscaled_height = impl->unscaled_height;
}
static void
set_sync_counter(Display *display,
XSyncCounter counter,
......@@ -5758,4 +5772,5 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
impl_class->show_window_menu = gdk_x11_window_show_window_menu;
impl_class->create_gl_context = gdk_x11_window_create_gl_context;
impl_class->invalidate_for_new_frame = gdk_x11_window_invalidate_for_new_frame;
impl_class->get_unscaled_size = gdk_x11_window_get_unscaled_size;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment