Merge branch 'wip/otte/for-master' into 'master'

Wip/otte/for master

See merge request GNOME/gtk!3297
This commit is contained in:
Benjamin Otte 2021-03-15 02:31:45 +00:00
commit a1c1ad317b
7 changed files with 48 additions and 106 deletions

View File

@ -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`

View File

@ -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);

View File

@ -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;
}

View File

@ -335,8 +335,6 @@ struct _GdkWin32Surface
/* scale of window on HiDPI */
int surface_scale;
int unscaled_width;
int unscaled_height;
GdkToplevelLayout *toplevel_layout;
struct {

View File

@ -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)
GdkSurface *surface = GDK_SURFACE (self);
if (surface->width == width &&
surface->height == height &&
self->surface_scale == scale)
return FALSE;
surface->width = width;
surface->height = height;
self->surface_scale = scale;
_gdk_surface_update_size (surface);
if (self->cairo_surface)
{
cairo_xlib_surface_set_size (impl->cairo_surface,
impl->unscaled_width, impl->unscaled_height);
cairo_xlib_surface_set_size (self->cairo_surface,
self->unscaled_width, self->unscaled_height);
cairo_surface_set_device_scale (self->cairo_surface, scale, scale);
}
}
static void
gdk_x11_surface_get_unscaled_size (GdkSurface *surface,
int *unscaled_width,
int *unscaled_height)
{
GdkX11Surface *impl = GDK_X11_SURFACE (surface);
if (unscaled_width)
*unscaled_width = impl->unscaled_width;
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;
}

View File

@ -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);

View File

@ -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;