From 412bc1713a697337cc2e4a837f94b3a015b7b1c7 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Wed, 21 Jun 2023 15:19:05 +0200 Subject: [PATCH] GdkWin32: Keep track of the last cursor position in move / resize contexts ...and avoid doing any work if the position hasn't changed. --- gdk/win32/gdksurface-win32.c | 9 +++++++++ gdk/win32/gdksurface-win32.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c index 9a37969944..ecae5e7d6d 100644 --- a/gdk/win32/gdksurface-win32.c +++ b/gdk/win32/gdksurface-win32.c @@ -3535,6 +3535,8 @@ setup_drag_move_resize_context (GdkSurface *surface, context->button = button; context->start_root_x = root_x; context->start_root_y = root_y; + context->current_root_x = root_x; + context->current_root_y = root_y; context->timestamp = timestamp; context->start_rect = rect; @@ -3650,6 +3652,13 @@ gdk_win32_surface_do_move_resize_drag (GdkSurface *window, if (!_gdk_win32_get_window_rect (window, &rect)) return; + if (context->current_root_x == x && + context->current_root_y == y) + return; + + context->current_root_x = x; + context->current_root_y = y; + new_rect = context->start_rect; diffx = (x - context->start_root_x) * impl->surface_scale; diffy = (y - context->start_root_y) * impl->surface_scale; diff --git a/gdk/win32/gdksurface-win32.h b/gdk/win32/gdksurface-win32.h index afe8d42010..e4b3e837ba 100644 --- a/gdk/win32/gdksurface-win32.h +++ b/gdk/win32/gdksurface-win32.h @@ -137,6 +137,12 @@ struct _GdkW32DragMoveResizeContext int start_root_x; int start_root_y; + /* Last processed cursor position. Values are divided by the window + * scale. + */ + int current_root_x; + int current_root_y; + /* Initial window rectangle (position and size). * The window is resized/moved relative to this (see start_root_*). */