app: make sure the image stays in place when showing/hiding docks

also when it's rotated or flipped.
This commit is contained in:
Michael Natterer
2015-11-14 00:05:23 +01:00
parent c6b6031f31
commit 4656ead4b3

View File

@ -121,8 +121,10 @@ struct _GimpImageWindowPrivate
typedef struct typedef struct
{ {
gint x; gint canvas_x;
gint y; gint canvas_y;
gint window_x;
gint window_y;
} PosCorrectionData; } PosCorrectionData;
@ -1596,28 +1598,25 @@ gimp_image_window_get_default_dockbook (GimpImageWindow *window)
void void
gimp_image_window_keep_canvas_pos (GimpImageWindow *window) gimp_image_window_keep_canvas_pos (GimpImageWindow *window)
{ {
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window); GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
gint image_origin_shell_x = -1; gint canvas_x;
gint image_origin_shell_y = -1; gint canvas_y;
gint image_origin_window_x = -1; gint window_x;
gint image_origin_window_y = -1; gint window_y;
gimp_display_shell_transform_xy (shell, gimp_display_shell_transform_xy (shell, 0.0, 0.0, &canvas_x, &canvas_y);
0.0, 0.0,
&image_origin_shell_x,
&image_origin_shell_y);
if (gtk_widget_translate_coordinates (GTK_WIDGET (shell->canvas), if (gtk_widget_translate_coordinates (GTK_WIDGET (shell->canvas),
GTK_WIDGET (window), GTK_WIDGET (window),
image_origin_shell_x, canvas_x, canvas_y,
image_origin_shell_y, &window_x, &window_y))
&image_origin_window_x,
&image_origin_window_y))
{ {
PosCorrectionData *data = g_new0 (PosCorrectionData, 1); PosCorrectionData *data = g_new0 (PosCorrectionData, 1);
data->x = image_origin_window_x; data->canvas_x = canvas_x;
data->y = image_origin_window_y; data->canvas_y = canvas_y;
data->window_x = window_x;
data->window_y = window_y;
g_signal_connect_data (shell, "size-allocate", g_signal_connect_data (shell, "size-allocate",
G_CALLBACK (gimp_image_window_shell_size_allocate), G_CALLBACK (gimp_image_window_shell_size_allocate),
@ -1794,23 +1793,18 @@ gimp_image_window_shell_size_allocate (GimpDisplayShell *shell,
GtkAllocation *allocation, GtkAllocation *allocation,
PosCorrectionData *data) PosCorrectionData *data)
{ {
GimpImageWindow *window = gimp_display_shell_get_window (shell); GimpImageWindow *window = gimp_display_shell_get_window (shell);
gint image_origin_shell_x = -1; gint new_window_x;
gint image_origin_shell_y = -1; gint new_window_y;
if (gtk_widget_translate_coordinates (GTK_WIDGET (window), if (gtk_widget_translate_coordinates (GTK_WIDGET (shell->canvas),
GTK_WIDGET (shell->canvas), GTK_WIDGET (window),
data->x, data->y, data->canvas_x, data->canvas_y,
&image_origin_shell_x, &new_window_x, &new_window_y))
&image_origin_shell_y))
{ {
/* Note that the shell offset isn't the offset of the image into the gimp_display_shell_scroll (shell,
* shell, but the offset of the shell relative to the image, new_window_x - data->window_x,
* therefore we need to negate new_window_y - data->window_y);
*/
gimp_display_shell_scroll_set_offset (shell,
-image_origin_shell_x,
-image_origin_shell_y);
} }
g_signal_handlers_disconnect_by_func (shell, g_signal_handlers_disconnect_by_func (shell,