GNOME Bugzilla – Bug 524862
Using GTK_WIN_POS_CENTER_ALWAYS gives jerky window resizing in Win32
Last modified: 2008-03-30 02:32:51 UTC
Please describe the problem: If a Win32 app calls gtk_window_set_position() with GTK_WIN_POS_CENTER_ALWAYS, then user resizing of the main window by mouse dragging looks really bad - as the mouse moves it out or in the window jerks back and forth on the screen. Presumably this is due to trying to re-center the window while it is being resized. The Linux version does not show this at all and resizes nice and smoothly, and resizing of a Win32 that uses GTK_WIN_POS_CENTER rather than GTK_WIN_POS_CENTER_ALWAYS works nicely too. Steps to reproduce: 1. Compile and run the attached simple example under WIN32. 2. Resize it. Actual results: It jerks about over the screen as it is being resized. Expected results: It should resize nice and smoothly. Does this happen every time? Yep Other information:
Created attachment 108192 [details] Simple app that demos the problem Uploaded source for a simple program that demonstrates the problem. It will compile using the minGW compiler in Windows as follows (with GTK 12.3): gcc -g -mwindows -mms-bitfields -O -Wall -Werror -I/C/GTK/include -I/C/GTK/lib/gtk-2.0/include -I/C/GTK/include/gtk-2.0 -I/C/GTK/lib/gtk-2.0/include -I/C/GTK/include/atk-1.0 -I/C/GTK/include/pango-1.0 -I/C/GTK/include/glib-2.0 -I/C/GTK/lib/glib-2.0/include -I/C/GTK/include/cairo -c tstApp.c -o tstApp.o gcc -o tstapp.exe tstApp.o -lm -mwindows -L/C/GTK/lib -lgtk-win32-2.0 -lgdk-win32-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangowin32-1.0 -lgdi32 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lpangocairo-1.0 -lcairo
When you say "The Linux version does not show this at all and resizes nice and smoothly", how many window managers have you tested with? Reading the comments in gtkwindow.c that relate to GTK_WIN_POS_CENTER_ALWAYS, I get the impression that using it is not necessarily something a good application should do. I quote: * However, we can't implement a position constraint as * "anytime the window size changes, center the window" * because this may well end up fighting the WM or user. In * fact it gets in an infinite loop with at least one WM. [...] * For override redirect windows, this works fine; all window * sizes are from our configure requests. For managed windows, * it is at least semi-sane, though who knows what the * app author is thinking. Still, that doesn't mean that it would be impossible to fix it to work as nicely on Win32 as it apparently does with at least some window managers on X11. After all, on Win32 we don't even need to take into consideration the possibility of different window managers behaving differently. I doubt fixing this bug will have much priority, though, after all you are the first who have complained about this in all these years as far as I can recall.
Actually this comment: * Basically, applications are in no way in a position to * constrain the position of a window, with one exception: * override redirect windows. (Really the intended purpose * of CENTER_ALWAYS anyhow, I would think.) leads me to believe that the intent was that GTK_WIN_POS_CENTER_ALWAYS was to be used for "popup" style windows only, not normal ones that the user would be able to resize or move using the window manager. An "override redirect" window in X11 parlance is, I think, one that the window manager doesn't manage (and thus the user interacting with window the window manager can't manipulate). Also, this comment: * So the way we implement this "constraint" is to say that when WE * cause a move or resize, i.e. we make a configure request changing * window size, we recompute the CENTER_ALWAYS position to reflect * the new window size, and include it in our request. Also, if we * just turned on CENTER_ALWAYS we snap to center with a new * request. Otherwise, if we are just NOTIFIED of a move or resize * done by someone else e.g. the window manager, we do NOT send a * new configure request. seems to indicate that the intent of GTK+ is that GTK_WIN_POS_CENTER_ALWAYS is honored only when the *application* resizes or moves the window, not if the user does? Why it still then worked as you say on X11, I don't know. Maybe the above comment is obsolete or I understand it wrong. (And why the application then would bother to even try to move or resize the window freely if it itself has asked for it to be forcibly centered on the monitor, I don't know. Sounds like a situation where the right hand doesn't know what the left foot is doing.)
Also see http://www.mail-archive.com/glade-devel@lists.ximian.com/msg00652.html: "The GTK+ team *strongly* discourages the use of GTK_WIN_POS_CENTER_ALWAYS" and "GTK_WIN_POS_CENTER_ALWAYS is a really bad idea because repositioning windows after they have been mapped typically means fighting the user"
(In reply to comment #2) > When you say "The Linux version does not show this at all and resizes nice and > smoothly", how many window managers have you tested with? Only Gnome desktop in FC6.
If these constraints on use of this are the intention then that should really be mentioned in the documentation for it (http://library.gnome.org/devel/gtk/stable/gtk-Standard-Enumerations.html#GtkWindowPosition). Just to clarify something, I'm not trying to use this. I used GTK_WIN_POS_CENTER_ALWAYS by accident where I should have been using GTK_WIN_POS_CENTER, and noticed this problem due to doing that. If you want to simply document not to use it this way it will not affect what I am doing.
OK. Added recommendation not to use GTK_WIN_POS_CENTER_ALWAYS to the documentation. Resolving as WONTFIX.