From 651ec0474417eecbb94f2ef732e4f397d6c8f7a1 Mon Sep 17 00:00:00 2001 From: Gabriele Barbero Date: Tue, 16 Dec 2025 16:06:34 +0100 Subject: [PATCH] display, tools: use gimp_display_shell_untransform_xy_f... ... to get limits in image coordinates instead of gimp_ruler_get_range. Rulers return values in the active unit (e.g. mm, inches), while the overlay logic works in pixels. This unit mismatch caused incorrect clamping of the text overlay position, making it jump when dragging if the unit wasn't set to pixels. --- app/display/gimpdisplayshell.c | 21 +++++++++++++++------ app/tools/gimptexttool-editor.c | 11 +++++++---- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index 5e3476c298..4ce100f67c 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -1281,13 +1281,22 @@ gimp_display_shell_overlay_allocate (GtkWidget *child, GtkAllocation *allocation, GimpDisplayShellOverlay *overlay) { - gdouble tlx, tly, brx, bry; - gdouble llimit, rlimit, ulimit, blimit; + gdouble tlx; + gdouble tly; + gdouble brx; + gdouble bry; + gdouble llimit; + gdouble rlimit; + gdouble ulimit; + gdouble blimit; - gimp_ruler_get_range ((GimpRuler *) overlay->shell->hrule, - &llimit, &rlimit, NULL); - gimp_ruler_get_range ((GimpRuler *) overlay->shell->vrule, - &ulimit, &blimit, NULL); + gimp_display_shell_untransform_xy_f (overlay->shell, + 0.0, 0.0, + &llimit, &ulimit); + gimp_display_shell_untransform_xy_f (overlay->shell, + (gdouble) overlay->shell->disp_width, + (gdouble) overlay->shell->disp_height, + &rlimit, &blimit); gimp_display_shell_get_overlay_corners (overlay->shell, child, diff --git a/app/tools/gimptexttool-editor.c b/app/tools/gimptexttool-editor.c index a7519ab2cb..3ae30ccaac 100644 --- a/app/tools/gimptexttool-editor.c +++ b/app/tools/gimptexttool-editor.c @@ -2091,10 +2091,13 @@ gimp_text_tool_style_overlay_button_motion (GtkWidget *widget, x, y, &x, &y); - gimp_ruler_get_range ((GimpRuler *) shell->hrule, - &llimit, &rlimit, NULL); - gimp_ruler_get_range ((GimpRuler *) shell->vrule, - &ulimit, &blimit, NULL); + gimp_display_shell_untransform_xy_f (shell, + 0.0, 0.0, + &llimit, &ulimit); + gimp_display_shell_untransform_xy_f (shell, + (gdouble) shell->disp_width, + (gdouble) shell->disp_height, + &rlimit, &blimit); gimp_display_shell_get_overlay_corners (shell, text_tool->style_overlay, x, y,