GNOME Bugzilla – Bug 143285
Statusbar resize grip do not resize (win32)
Last modified: 2011-02-04 16:17:18 UTC
Can't resize with the resize grip of the statusbar. The mouse pointer change but no resizing occurs. A simple test program to test it : #include <gtk/gtk.h> int main(int argc,char **argv) { GtkWidget *window, *vbox; GtkWidget *button, *statusbar; gtk_init(&argc, &argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "Statusbar test"); gtk_window_set_default_size(GTK_WINDOW(window), 200, 100); vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), vbox); button = gtk_button_new_with_mnemonic("_Quit"); gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 0); statusbar = gtk_statusbar_new(); gtk_box_pack_start(GTK_BOX(vbox), statusbar, FALSE, FALSE, 0); g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_main_quit), NULL); gtk_widget_show_all(window); gtk_main(); return 0; }
Works fine here with GTK+ 2.4.7. Does it work for you?
Hmm no it still doesn't work for me. I've tried again the program given in my report, with msys/mingw on win2k and gtk+ 2.4.7 from http://www.gimp.org/~tml/gimp/win32/downloads.html Compiled with gcc `pkg-config.exe --cflags gtk+-2.0` -mms-bitfields -c statustest.c gcc -o statustest.exe statustest.o `pkg-config.exe --libs gtk+-2.0` The main window can be resized (using the edges) but not with the resize grip (it does nothing besides changing the mouse pointer). The same program does work on linux (fedora core 2)
Ah, yes, I spoke too soon. I thought I had grabbed the resize grip, but in fact I had grabbed the edge... Yes. this is still broken in 2.4.9. Please note that the resize grip on GTK status bars uses the gtk_window_begin_resize_drag() and gtk_window_begin_move_drag() functions, which are documented to not necessarily work with all window managers and/or windowing systems. They call directly to the corrsponding GDK functions, which currently are empty in gdk/win32... (When this API was added to GDK, it wasn't clear to the Win32 backend people what it was supposd to be used for, and whether it actually is needed on Win32. I have thought it is something that is used on X11 if there is no window manager, and thus haven't bothered with implementing it, as there always is a "window manager" on Win32.)
It looks like gdk_window_begin_resize_drag() can be implemented quite easily by pretending that the mouse has been clicked in the corner of the nonclient area by passing WM_NCxBUTTONDOWN to DefWindowProc. Like this: Index: gdk/win32/gdkwindow-win32.c =================================================================== RCS file: /cvs/gnome/gtk+/gdk/win32/gdkwindow-win32.c,v retrieving revision 1.116.2.4 diff -u -p -r1.116.2.4 gdkwindow-win32.c --- gdk/win32/gdkwindow-win32.c 15 Sep 2004 18:33:16 -0000 1.116.2.4 +++ gdk/win32/gdkwindow-win32.c 24 Oct 2004 19:07:10 -0000 @@ -3203,7 +3203,14 @@ gdk_window_begin_resize_drag (GdkWindow if (GDK_WINDOW_DESTROYED (window)) return; - /* XXX: isn't all this default on win32 ... */ + /* Must break the automatic grab that occured when the button was pressed, + * otherwise it won't work */ + gdk_display_pointer_ungrab (gdk_display_get_default (), 0); + + /* TODO: use correct button? */ + /* TODO: use correct edge */ + DefWindowProc (GDK_WINDOW_HWND (window), WM_NCLBUTTONDOWN, HTBOTTOMRIGHT, + MAKELPARAM(root_x - _gdk_offset_x, root_y - _gdk_offset_y)); } If you think this looks like a reasonable solution I could try to create a more complete patch that respects the edge parameter as well. Right now it always resizes from the bottom right corner :) I have tested this on Windows XP using the test program in this bug and dia 0.94 with gtk-2-4.
Created attachment 33221 [details] [review] Suggested patch Just for fun I went ahead and created a more complete patch for gdk_window_begin_resize_drag which respects the edge parameter, and also made a simple implementation of the gdk_window_begin_move_drag function. A limitation in both functions is that they only work with button 1. It could be possible to fix this by installing a mouse hook, or even by emulating resize/move like the x11 backend can do, but it's hardly worth the effort. The most important thing as I see it is that the statusbar resize grip works and it does for me with this patch. Tested on Windows XP using the "resize grips" test in testgtk, all 8 directions work fine now :) Moving does not work in testgtk or with the statusbar as they use button 2 for that. It would be possible to change them to allow for example shift+button 1 to move instead of resize. The patch is against sources from CVS HEAD but also works on gtk-2-4.
*** Bug 155096 has been marked as a duplicate of this bug. ***
Just applied to HEAD.
Hans, do you want to keep this open for some reason ?
Maybe Tor wants to apply it to gtk-2-4 as well ?
Hmm, yeah, applied to gtk-2-4, too.