GdkWin32: Keep track of the last cursor position in move / resize contexts
authorLuca Bacci <luca.bacci982@gmail.com>
Wed, 21 Jun 2023 13:19:05 +0000 (15:19 +0200)
committerLuca Bacci <luca.bacci982@gmail.com>
Wed, 21 Jun 2023 13:31:48 +0000 (15:31 +0200)
...and avoid doing any work if the position hasn't changed.

gdk/win32/gdksurface-win32.c
gdk/win32/gdksurface-win32.h

index 9a3796994402413cbccb4bb17f1ecf5bb7b4e7e1..ecae5e7d6dc865baf720ece0fce9b3852c6b757a 100644 (file)
@@ -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;
index afe8d42010140b1c5cb3fa0ae684c94da472ac33..e4b3e837bab8fbcf721c6a072e8c3588e6a25b18 100644 (file)
@@ -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_*).
    */