After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 630069 - In single-window mode, canvas badly positioned in all successive tabs
In single-window mode, canvas badly positioned in all successive tabs
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: User Interface
2.7.1
Other Mac OS
: Normal minor
: 2.8
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks: 643533
 
 
Reported: 2010-09-19 14:46 UTC by Tom H
Modified: 2011-03-09 06:31 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed patch (2.22 KB, patch)
2011-02-05 13:12 UTC, Massimo
none Details | Review

Description Tom H 2010-09-19 14:46:47 UTC
In single-window mode, any documents opened or created appear with the canvas positioned so that the top left (0,0) is at the top left of the window, except for the first document to be opened (when the tab bar is not there), which is correctly centred in the workspace.

All documents should behave as the first one does, centring in the workspace (especially if the entire image can be visible when centred)
Comment 1 Martin Nordholts 2010-09-19 14:48:49 UTC
This will be fixed
Comment 2 Ulysses Levy 2011-02-03 11:33:31 UTC
I do not think this is limited to single-window-mode. 

looks like something to do with app/display/gimpdisplayshell.c where at the end of gimp_display_shell_constructed, we are setup to center after a resize(?) event.

If we resize the new viz, gimp does the right thing and centers our canvas.

My guess is gimp_display_shell_scale_changed isn't doing the right thing (as far as programmatic resizing)?


Some Code of interest from app/display/gimpdisplayshell.c pasted below:

if (image)
    {
      gimp_display_shell_connect (shell);

      /* After connecting to the image we want to center it. Since we
       * not even finnished creating the display shell, we can safely
       * assume we will get a size-allocate later.
       */
      gimp_display_shell_scroll_center_image_on_next_size_allocate (shell,
                                                                    TRUE,
                                                                    TRUE);
    }
  else
    {
      ...
    }

  /* make sure the information is up-to-date */
  gimp_display_shell_scale_changed (shell);
Comment 3 Massimo 2011-02-05 13:12:16 UTC
Created attachment 180169 [details] [review]
Proposed patch

Here one problem is that 'gimp_image_window_keep_canvas_pos' in file
'app/display/gimpimagewindow.c' connects a signal handler too early, 
with data not yet valid, the handler is executed after the canvas 
position is computed correctly and so invalid data overrides the 
valid.

The attached patch checks the return value of 
'gtk_widget_translate_coordinates' to avoid connecting handlers 
when their execution is considered harmful.
Comment 4 Ulysses Levy 2011-02-05 21:01:18 UTC
Works like a champ! Nothing like a well positioned if statement.
Comment 5 Martin Nordholts 2011-03-09 06:31:37 UTC
Thanks Massimo, good job as usual

commit 166c76b62d543487285a63a6d657a226240fd176
Author: Massimo Valentini <sixtysix@inwind.it>
Date:   Wed Mar 9 07:30:15 2011 +0100

    Bug 630069 - In single-window mode, canvas badly positioned in all successive tabs
    
    The problem is that gimp_image_window_keep_canvas_pos() connects a
    signal handler too early, with data not yet valid, the handler is
    executed after the canvas position is computed correctly and so
    invalid data overrides the valid.
    
    Checks the return value of gtk_widget_translate_coordinates() to avoid
    connecting handlers when their execution is considered harmful.