app: make new images jump around much less

Implement a mechanism to suspend/resume GimpImageWindow's "keep canvas
pos" logic which is used to keep the image in place across widget
changed such as show/hide rulers.

gimp_display_shell_fill(): call suspend()/resume() around
gimp_display_shell_appearance_update(), and center the image after
calculating the initial scale factor, so the image jumping at least
starts at the approximately right position.
This commit is contained in:
Michael Natterer 2016-01-11 01:50:29 +01:00
parent 26ea7a3530
commit cbf2311134
3 changed files with 57 additions and 8 deletions

View File

@ -1519,9 +1519,17 @@ gimp_display_shell_fill (GimpDisplayShell *shell,
gimp_display_shell_set_unit (shell, unit);
gimp_display_shell_set_initial_scale (shell, scale, NULL, NULL);
/* center the image so subsequent stuff only moves it a little in
* the center
*/
gimp_display_shell_scroll_center_image (shell, TRUE, TRUE);
gimp_display_shell_sync_config (shell, shell->display->config);
gimp_image_window_suspend_keep_pos (window);
gimp_display_shell_appearance_update (shell);
gimp_image_window_resume_keep_pos (window);
gimp_image_window_update_tabs (window);
#if 0
gimp_help_set_help_data (shell->canvas, NULL, NULL);

View File

@ -118,6 +118,8 @@ struct _GimpImageWindowPrivate
GdkScreen *initial_screen;
gint initial_monitor;
gint suspend_keep_pos;
};
typedef struct
@ -1599,11 +1601,21 @@ gimp_image_window_get_default_dockbook (GimpImageWindow *window)
void
gimp_image_window_keep_canvas_pos (GimpImageWindow *window)
{
GimpDisplayShell *shell = gimp_image_window_get_active_shell (window);
gint canvas_x;
gint canvas_y;
gint window_x;
gint window_y;
GimpImageWindowPrivate *private;
GimpDisplayShell *shell;
gint canvas_x;
gint canvas_y;
gint window_x;
gint window_y;
g_return_if_fail (GIMP_IS_IMAGE_WINDOW (window));
private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
if (private->suspend_keep_pos > 0)
return;
shell = gimp_image_window_get_active_shell (window);
gimp_display_shell_transform_xy (shell, 0.0, 0.0, &canvas_x, &canvas_y);
@ -1626,6 +1638,31 @@ gimp_image_window_keep_canvas_pos (GimpImageWindow *window)
}
}
void
gimp_image_window_suspend_keep_pos (GimpImageWindow *window)
{
GimpImageWindowPrivate *private;
g_return_if_fail (GIMP_IS_IMAGE_WINDOW (window));
private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
private->suspend_keep_pos++;
}
void
gimp_image_window_resume_keep_pos (GimpImageWindow *window)
{
GimpImageWindowPrivate *private;
g_return_if_fail (GIMP_IS_IMAGE_WINDOW (window));
private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
g_return_if_fail (private->suspend_keep_pos > 0);
private->suspend_keep_pos--;
}
/**
* gimp_image_window_update_tabs:
@ -1803,9 +1840,11 @@ gimp_image_window_shell_size_allocate (GimpDisplayShell *shell,
data->canvas_x, data->canvas_y,
&new_window_x, &new_window_y))
{
gimp_display_shell_scroll (shell,
new_window_x - data->window_x,
new_window_y - data->window_y);
gint off_x = new_window_x - data->window_x;
gint off_y = new_window_y - data->window_y;
if (off_x || off_y)
gimp_display_shell_scroll (shell, off_x, off_y);
}
g_signal_handlers_disconnect_by_func (shell,

View File

@ -93,6 +93,8 @@ void gimp_image_window_shrink_wrap (GimpImageWindow *win
GtkWidget * gimp_image_window_get_default_dockbook (GimpImageWindow *window);
void gimp_image_window_keep_canvas_pos (GimpImageWindow *window);
void gimp_image_window_suspend_keep_pos (GimpImageWindow *window);
void gimp_image_window_resume_keep_pos (GimpImageWindow *window);
void gimp_image_window_update_tabs (GimpImageWindow *window);