summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte.benjamin@googlemail.com>2021-03-15 02:31:45 +0000
committerBenjamin Otte <otte.benjamin@googlemail.com>2021-03-15 02:31:45 +0000
commita1c1ad317ba428f460563dbcd8d4ba816984a69c (patch)
tree0267574b1f0f36bfb60c237a0a7916b79e654a48
parentcbda61d3fb22659fccb09e1d536a02670af2bb01 (diff)
parentdbd19bf27ada039f83acb6924173e0491ceae43e (diff)
downloadgtk+-a1c1ad317ba428f460563dbcd8d4ba816984a69c.tar.gz
Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master See merge request GNOME/gtk!3297
-rw-r--r--gdk/gdksurface.c31
-rw-r--r--gdk/gdksurfaceprivate.h6
-rw-r--r--gdk/win32/gdksurface-win32.c30
-rw-r--r--gdk/win32/gdksurface-win32.h2
-rw-r--r--gdk/x11/gdksurface-x11.c79
-rw-r--r--gdk/x11/gdksurface-x11.h1
-rw-r--r--gsk/ngl/gsknglrenderer.c5
7 files changed, 48 insertions, 106 deletions
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 7a4bf47962..6ad438093a 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -2610,37 +2610,6 @@ gdk_surface_get_scale_factor (GdkSurface *surface)
return 1;
}
-/* Returns the *real* unscaled size, which may be a fractional size
- in surface scale coordinates. We need this to properly handle GL
- coordinates which are y-flipped in the real coordinates. */
-void
-gdk_surface_get_unscaled_size (GdkSurface *surface,
- int *unscaled_width,
- int *unscaled_height)
-{
- GdkSurfaceClass *class;
- int scale;
-
- g_return_if_fail (GDK_IS_SURFACE (surface));
-
- class = GDK_SURFACE_GET_CLASS (surface);
-
- if (class->get_unscaled_size)
- {
- class->get_unscaled_size (surface, unscaled_width, unscaled_height);
- return;
- }
-
- scale = gdk_surface_get_scale_factor (surface);
-
- if (unscaled_width)
- *unscaled_width = surface->width * scale;
-
- if (unscaled_height)
- *unscaled_height = surface->height * scale;
-}
-
-
/**
* gdk_surface_set_opaque_region:
* @surface: a top-level `GdkSurface`
diff --git a/gdk/gdksurfaceprivate.h b/gdk/gdksurfaceprivate.h
index 2126371853..90f5bcba2d 100644
--- a/gdk/gdksurfaceprivate.h
+++ b/gdk/gdksurfaceprivate.h
@@ -157,9 +157,6 @@ struct _GdkSurfaceClass
double dy);
int (* get_scale_factor) (GdkSurface *surface);
- void (* get_unscaled_size) (GdkSurface *surface,
- int *unscaled_width,
- int *unscaled_height);
void (* set_opaque_region) (GdkSurface *surface,
cairo_region_t *region);
@@ -271,9 +268,6 @@ GdkGLContext * gdk_surface_get_paint_gl_context (GdkSurface *surface,
GError **error);
GdkGLContext * gdk_surface_get_shared_data_gl_context (GdkSurface *surface);
-void gdk_surface_get_unscaled_size (GdkSurface *surface,
- int *unscaled_width,
- int *unscaled_height);
gboolean gdk_surface_handle_event (GdkEvent *event);
GdkSeat * gdk_surface_get_seat_from_event (GdkSurface *surface,
GdkEvent *event);
diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c
index d600996fe2..03250491d4 100644
--- a/gdk/win32/gdksurface-win32.c
+++ b/gdk/win32/gdksurface-win32.c
@@ -520,8 +520,6 @@ _gdk_win32_display_create_surface (GdkDisplay *display,
surface->height = height;
impl->surface_scale = _gdk_win32_display_get_monitor_scale_factor (display_win32, NULL, NULL, NULL);
- impl->unscaled_width = width * impl->surface_scale;
- impl->unscaled_height = height * impl->surface_scale;
dwExStyle = 0;
owner = NULL;
@@ -3969,12 +3967,9 @@ gdk_win32_surface_do_move_resize_drag (GdkSurface *window,
{
int scale = impl->surface_scale;
- impl->unscaled_width = new_rect.right - new_rect.left;
- impl->unscaled_height = new_rect.bottom - new_rect.top;
-
impl->next_layout.configured_rect = new_rect;
- impl->next_layout.configured_width = (impl->unscaled_width + scale - 1) / scale;
- impl->next_layout.configured_height = (impl->unscaled_height + scale - 1) / scale;
+ impl->next_layout.configured_width = (new_rect.right - new_rect.left + scale - 1) / scale;
+ impl->next_layout.configured_height = (new_rect.bottom - new_rect.top + scale - 1) / scale;
}
context->native_move_resize_pending = TRUE;
@@ -4476,19 +4471,6 @@ _gdk_win32_surface_get_scale_factor (GdkSurface *window)
}
}
-void
-_gdk_win32_surface_get_unscaled_size (GdkSurface *window,
- int *unscaled_width,
- int *unscaled_height)
-{
- GdkWin32Surface *impl = GDK_WIN32_SURFACE (window);
-
- if (unscaled_width)
- *unscaled_width = impl->unscaled_width;
- if (unscaled_height)
- *unscaled_height = impl->unscaled_height;
-}
-
static void
gdk_win32_surface_set_input_region (GdkSurface *window,
cairo_region_t *input_region)
@@ -4580,11 +4562,8 @@ _gdk_win32_surface_request_layout (GdkSurface *surface)
{
_gdk_win32_get_window_rect (surface, &rect);
- impl->unscaled_width = rect.right - rect.left;
- impl->unscaled_height = rect.bottom - rect.top;
-
- impl->next_layout.configured_width = (impl->unscaled_width + scale - 1) / scale;
- impl->next_layout.configured_height = (impl->unscaled_height + scale - 1) / scale;
+ impl->next_layout.configured_width = (rect.right - rect.left + scale - 1) / scale;
+ impl->next_layout.configured_height = (rect.bottom - rect.top + scale - 1) / scale;
surface->x = rect.left / scale;
surface->y = rect.top / scale;
}
@@ -4635,7 +4614,6 @@ gdk_win32_surface_class_init (GdkWin32SurfaceClass *klass)
impl_class->drag_begin = _gdk_win32_surface_drag_begin;
impl_class->create_gl_context = _gdk_win32_surface_create_gl_context;
impl_class->get_scale_factor = _gdk_win32_surface_get_scale_factor;
- impl_class->get_unscaled_size = _gdk_win32_surface_get_unscaled_size;
impl_class->request_layout = _gdk_win32_surface_request_layout;
impl_class->compute_size = _gdk_win32_surface_compute_size;
}
diff --git a/gdk/win32/gdksurface-win32.h b/gdk/win32/gdksurface-win32.h
index 6be358338b..5f85c50373 100644
--- a/gdk/win32/gdksurface-win32.h
+++ b/gdk/win32/gdksurface-win32.h
@@ -335,8 +335,6 @@ struct _GdkWin32Surface
/* scale of window on HiDPI */
int surface_scale;
- int unscaled_width;
- int unscaled_height;
GdkToplevelLayout *toplevel_layout;
struct {
diff --git a/gdk/x11/gdksurface-x11.c b/gdk/x11/gdksurface-x11.c
index 92a0a23d6c..210f584d64 100644
--- a/gdk/x11/gdksurface-x11.c
+++ b/gdk/x11/gdksurface-x11.c
@@ -177,35 +177,46 @@ _gdk_x11_surface_get_toplevel (GdkSurface *surface)
return impl->toplevel;
}
-/**
- * _gdk_x11_surface_update_size:
- * @impl: a #GdkX11Surface.
+/*
+ * gdk_x11_surface_update_size:
+ * @self: a #GdkX11Surface
+ * @width: the new width of the surface
+ * @height: the new height of the surface
+ * @scale: the new scale of the surface
*
* Updates the state of the surface (in particular the drawable's
* cairo surface) when its size has changed.
+ *
+ * Returns: %TRUE if the surface was updated, %FALSE if no updates
+ * where necessary
**/
-void
-_gdk_x11_surface_update_size (GdkX11Surface *impl)
+static gboolean
+gdk_x11_surface_update_size (GdkX11Surface *self,
+ int width,
+ int height,
+ int scale)
{
- if (impl->cairo_surface)
- {
- cairo_xlib_surface_set_size (impl->cairo_surface,
- impl->unscaled_width, impl->unscaled_height);
- }
-}
+ GdkSurface *surface = GDK_SURFACE (self);
-static void
-gdk_x11_surface_get_unscaled_size (GdkSurface *surface,
- int *unscaled_width,
- int *unscaled_height)
-{
- GdkX11Surface *impl = GDK_X11_SURFACE (surface);
+ if (surface->width == width &&
+ surface->height == height &&
+ self->surface_scale == scale)
+ return FALSE;
- if (unscaled_width)
- *unscaled_width = impl->unscaled_width;
+ surface->width = width;
+ surface->height = height;
+ self->surface_scale = scale;
+
+ _gdk_surface_update_size (surface);
+
+ if (self->cairo_surface)
+ {
+ cairo_xlib_surface_set_size (self->cairo_surface,
+ self->unscaled_width, self->unscaled_height);
+ cairo_surface_set_device_scale (self->cairo_surface, scale, scale);
+ }
- if (unscaled_height)
- *unscaled_height = impl->unscaled_height;
+ return TRUE;
}
static void
@@ -385,10 +396,10 @@ gdk_x11_surface_compute_size (GdkSurface *surface)
if (surface->resize_count == 0)
{
- surface->width = impl->next_layout.configured_width;
- surface->height = impl->next_layout.configured_height;
- _gdk_surface_update_size (surface);
- _gdk_x11_surface_update_size (impl);
+ gdk_x11_surface_update_size (impl,
+ impl->next_layout.configured_width,
+ impl->next_layout.configured_height,
+ impl->surface_scale);
}
impl->next_layout.surface_geometry_dirty = FALSE;
@@ -396,11 +407,10 @@ gdk_x11_surface_compute_size (GdkSurface *surface)
}
else
{
- surface->width = impl->next_layout.configured_width;
- surface->height = impl->next_layout.configured_height;
-
- _gdk_surface_update_size (surface);
- _gdk_x11_surface_update_size (impl);
+ gdk_x11_surface_update_size (impl,
+ impl->next_layout.configured_width,
+ impl->next_layout.configured_height,
+ impl->surface_scale);
impl->next_layout.surface_geometry_dirty = FALSE;
}
@@ -1983,7 +1993,7 @@ gdk_x11_surface_enter_leave_monitors (GdkSurface *surface)
void
_gdk_x11_surface_set_surface_scale (GdkSurface *surface,
- int scale)
+ int scale)
{
GdkX11Surface *impl;
GdkToplevelX11 *toplevel;
@@ -1991,10 +2001,8 @@ _gdk_x11_surface_set_surface_scale (GdkSurface *surface,
impl = GDK_X11_SURFACE (surface);
- impl->surface_scale = scale;
- if (impl->cairo_surface)
- cairo_surface_set_device_scale (impl->cairo_surface, impl->surface_scale, impl->surface_scale);
- _gdk_surface_update_size (surface);
+ if (!gdk_x11_surface_update_size (impl, surface->width, surface->height, scale))
+ return;
toplevel = _gdk_x11_surface_get_toplevel (surface);
if (toplevel)
@@ -4802,7 +4810,6 @@ gdk_x11_surface_class_init (GdkX11SurfaceClass *klass)
impl_class->get_scale_factor = gdk_x11_surface_get_scale_factor;
impl_class->set_opaque_region = gdk_x11_surface_set_opaque_region;
impl_class->create_gl_context = gdk_x11_surface_create_gl_context;
- impl_class->get_unscaled_size = gdk_x11_surface_get_unscaled_size;
impl_class->request_layout = gdk_x11_surface_request_layout;
impl_class->compute_size = gdk_x11_surface_compute_size;
}
diff --git a/gdk/x11/gdksurface-x11.h b/gdk/x11/gdksurface-x11.h
index 0830407dd0..89f4b12845 100644
--- a/gdk/x11/gdksurface-x11.h
+++ b/gdk/x11/gdksurface-x11.h
@@ -195,7 +195,6 @@ GdkToplevelX11 *_gdk_x11_surface_get_toplevel (GdkSurface *window);
GdkCursor *_gdk_x11_surface_get_cursor (GdkSurface *window);
-void _gdk_x11_surface_update_size (GdkX11Surface *impl);
void _gdk_x11_surface_set_surface_scale (GdkSurface *window,
int scale);
gboolean _gdk_x11_surface_syncs_frames (GdkSurface *surface);
diff --git a/gsk/ngl/gsknglrenderer.c b/gsk/ngl/gsknglrenderer.c
index 66edc98d5d..4c6a077ab3 100644
--- a/gsk/ngl/gsknglrenderer.c
+++ b/gsk/ngl/gsknglrenderer.c
@@ -173,10 +173,7 @@ get_render_region (GdkSurface *surface,
*/
damage = gdk_draw_context_get_frame_region (GDK_DRAW_CONTEXT (context));
- if (cairo_region_contains_rectangle (damage, &whole_surface) == CAIRO_REGION_OVERLAP_IN)
- return NULL;
-
- /* If the extents match the full-scene, do the same as above */
+ /* If the extents match the full-scene, return NULL */
cairo_region_get_extents (damage, &extents);
if (gdk_rectangle_equal (&extents, &whole_surface))
return NULL;