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 143285 - Statusbar resize grip do not resize (win32)
Statusbar resize grip do not resize (win32)
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Win32
2.4.x
Other Windows
: Normal normal
: ---
Assigned To: gtk-win32 maintainers
gtk-bugs
: 155096 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2004-05-27 12:56 UTC by Mael
Modified: 2011-02-04 16:17 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Suggested patch (3.56 KB, patch)
2004-10-29 20:58 UTC, Robert Ögren
none Details | Review

Description Mael 2004-05-27 12:56:42 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;
}
Comment 1 Tor Lillqvist 2004-08-31 19:31:16 UTC
Works fine here with GTK+ 2.4.7. Does it work for you?
Comment 2 Mael 2004-09-01 07:37:05 UTC
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)
Comment 3 Tor Lillqvist 2004-09-02 02:02:45 UTC
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.)
Comment 4 Robert Ögren 2004-10-24 19:15:28 UTC
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.
Comment 5 Robert Ögren 2004-10-29 20:58:06 UTC
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.
Comment 6 Hans Breuer 2004-10-30 18:05:28 UTC
*** Bug 155096 has been marked as a duplicate of this bug. ***
Comment 7 Hans Breuer 2004-10-30 18:10:02 UTC
Just applied to HEAD.
Comment 8 Matthias Clasen 2004-10-31 17:11:07 UTC
Hans, do you want to keep this open for some reason ?
Comment 9 Hans Breuer 2004-10-31 17:39:49 UTC
Maybe Tor wants to apply it to gtk-2-4 as well ?
Comment 10 Tor Lillqvist 2004-10-31 19:02:04 UTC
Hmm, yeah, applied to gtk-2-4, too.