2010-02-03 Carlos Alberto Cortez <calberto.cortez@gmail.com>
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>
Thu, 4 Feb 2010 06:06:45 +0000 (06:06 -0000)
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>
Thu, 4 Feb 2010 06:06:45 +0000 (06:06 -0000)
* StatusStrip.cs:
* XplatX11.cs:
* X11Structs: Implement the new BeginMoveResize method, designed to
instruct the window manager to init a resize operation on a top level
form. This is used by StatusStrip.
* XplatUI.cs:
* XplatUIDriver.cs:
* XplatUIWin32.cs:
* XplatUICarbon.cs: Fill the gaps by creating stubs and updating the
method calls.
Fixes #573299.

svn path=/trunk/mcs/; revision=150833

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusStrip.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Structs.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUI.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUICarbon.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIDriver.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIWin32.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs

index a641e9f30be23c466cb192d9c0f69722442a9c1e..846fa3fd7077285cfc1ddede5809cbc5ba18c266 100644 (file)
@@ -1,3 +1,17 @@
+2010-02-03  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * StatusStrip.cs:
+       * XplatX11.cs:
+       * X11Structs: Implement the new BeginMoveResize method, designed to
+       instruct the window manager to init a resize operation on a top level
+       form. This is used by StatusStrip.
+       * XplatUI.cs:
+       * XplatUIDriver.cs:
+       * XplatUIWin32.cs:
+       * XplatUICarbon.cs: Fill the gaps by creating stubs and updating the
+       method calls.
+       Fixes #573299.
+
 2010-02-01  Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
        * ComboBox.cs: When creating DrawItemEventArgs pass the fore color and
index dcd08616752bfb0e85f4ecbef2c1d35176a0e2de..1dc3e978179007547f4793a228fb00decaed710e 100644 (file)
@@ -276,9 +276,15 @@ namespace System.Windows.Forms
                                // send the WM a message to begin a window resize operation
                                case Msg.WM_LBUTTONDOWN: {
                                        Point p = new Point (LowOrder ((int)m.LParam.ToInt32 ()), HighOrder ((int)m.LParam.ToInt32 ()));
+                                       Form form = FindForm ();
 
                                        if (this.SizingGrip && this.SizeGripBounds.Contains (p)) {
-                                               XplatUI.SendMessage (this.FindForm().Handle, Msg.WM_NCLBUTTONDOWN, (IntPtr) HitTest.HTBOTTOMRIGHT, IntPtr.Zero);
+                                               // For top level forms it's not enoug to send a NCLBUTTONDOWN message, so
+                                               // we make a direct call to our XplatUI engine.
+                                               if (!form.IsMdiChild)
+                                                       XplatUI.BeginMoveResize (form.Handle);
+
+                                               XplatUI.SendMessage (form.Handle, Msg.WM_NCLBUTTONDOWN, (IntPtr) HitTest.HTBOTTOMRIGHT, IntPtr.Zero);
                                                return;
                                        }
                                        
index 7b154d83fbfe98d450dbcf789a4ae5f1c5196b24..abb0fee5a545f220ef756c699d65ab644a996b8b 100644 (file)
@@ -1359,6 +1359,21 @@ namespace System.Windows.Forms {
                _NET_WM_STATE_TOGGLE            = 2
        }
 
+       internal enum NetWmMoveResize {
+               _NET_WM_MOVERESIZE_SIZE_TOPLEFT =       0,
+               _NET_WM_MOVERESIZE_SIZE_TOP =           1,
+               _NET_WM_MOVERESIZE_SIZE_TOPRIGHT =      2,
+               _NET_WM_MOVERESIZE_SIZE_RIGHT =         3,
+               _NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT =   4,
+               _NET_WM_MOVERESIZE_SIZE_BOTTOM =        5,
+               _NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT =    6,
+               _NET_WM_MOVERESIZE_SIZE_LEFT =          7,
+               _NET_WM_MOVERESIZE_MOVE =               8,
+               _NET_WM_MOVERESIZE_SIZE_KEYBOARD =      9,
+               _NET_WM_MOVERESIZE_MOVE_KEYBOARD =      10,
+               _NET_WM_MOVERESIZE_CANCEL =             11
+       }
+
        [Flags]
        internal enum XSizeHintsFlags  {
                USPosition                      = (1 << 0),
index 9728486e64e21ba14d88ef78ca4d8c24428b0986..8d3facf72efbe613102a789c632c1fae4b4017cb 100644 (file)
@@ -471,6 +471,11 @@ namespace System.Windows.Forms {
                        driver.AudibleAlert(alert);
                }
 
+               internal static void BeginMoveResize (IntPtr handle)
+               {
+                       driver.BeginMoveResize (handle);
+               }
+
                internal static bool CalculateWindowRect(ref Rectangle ClientRect, CreateParams cp, Menu menu, out Rectangle WindowRect) {
                        #if DriverDebug
                                Console.WriteLine("CalculateWindowRect({0}, {1}, {2}): Called", ClientRect, cp, menu);
index 897fff46028eb2189fd7e5189450045b4dbe136a..010f73099dc7982b271da13af5ad57906ad5f130 100644 (file)
@@ -795,6 +795,9 @@ namespace System.Windows.Forms {
                        AlertSoundPlay ();
                }
 
+               internal override void BeginMoveResize (IntPtr handle) {
+               }
+
                internal override void CaretVisible (IntPtr hwnd, bool visible) {
                        if (Caret.Hwnd == hwnd) {
                                if (visible) {
index d32659714df380885cb452154f2a283baa56ec75..4ea795d5bf0157c03f9a1f299d744d011542742e 100644 (file)
@@ -276,6 +276,8 @@ namespace System.Windows.Forms {
                #region XplatUI Driver Methods
                internal abstract void AudibleAlert(AlertType alert);
 
+               internal abstract void BeginMoveResize (IntPtr handle); // init a window manager driven resize event
+
                internal abstract void EnableThemes();
 
                internal abstract void GetDisplaySize(out Size size);
index f3d7ca3294bf98e67d40a6495092aa41dbb8bd6d..aceae31489f92e54aed96b81ae30cc3014805628 100644 (file)
@@ -1588,6 +1588,9 @@ namespace System.Windows.Forms {
                        Win32PlaySound(GetSoundAlias (alert), IntPtr.Zero, SndFlags.SND_ALIAS_ID | SndFlags.SND_ASYNC | SndFlags.SND_NOSTOP | SndFlags.SND_NOWAIT);
                }
 
+               internal override void BeginMoveResize (IntPtr handle) {
+               }
+
                internal override void GetDisplaySize(out Size size) {
                        RECT    rect;
 
index b64febd4cea0c45fd1e3f8481d1847187fd6c46d..4b085346c10f3e0edf79a8c67b6a2f64728da6fd 100644 (file)
@@ -160,7 +160,7 @@ namespace System.Windows.Forms {
                //private static IntPtr _NET_SHOWING_DESKTOP;
                //private static IntPtr _NET_CLOSE_WINDOW;
                //private static IntPtr _NET_MOVERESIZE_WINDOW;
-               //private static IntPtr _NET_WM_MOVERESIZE;
+               private static IntPtr _NET_WM_MOVERESIZE;
                //private static IntPtr _NET_RESTACK_WINDOW;
                //private static IntPtr _NET_REQUEST_FRAME_EXTENTS;
                private static IntPtr _NET_WM_NAME;
@@ -577,7 +577,7 @@ namespace System.Windows.Forms {
                                //"_NET_SHOWING_DESKTOP",
                                //"_NET_CLOSE_WINDOW",
                                //"_NET_MOVERESIZE_WINDOW",
-                               //"_NET_WM_MOVERESIZE",
+                               "_NET_WM_MOVERESIZE",
                                //"_NET_RESTACK_WINDOW",
                                //"_NET_REQUEST_FRAME_EXTENTS",
                                "_NET_WM_NAME",
@@ -653,7 +653,7 @@ namespace System.Windows.Forms {
                        //_NET_SHOWING_DESKTOP = atoms [off++];
                        //_NET_CLOSE_WINDOW = atoms [off++];
                        //_NET_MOVERESIZE_WINDOW = atoms [off++];
-                       //_NET_WM_MOVERESIZE = atoms [off++];
+                       _NET_WM_MOVERESIZE = atoms [off++];
                        //_NET_RESTACK_WINDOW = atoms [off++];
                        //_NET_REQUEST_FRAME_EXTENTS = atoms [off++];
                        _NET_WM_NAME = atoms [off++];
@@ -718,6 +718,10 @@ namespace System.Windows.Forms {
                }
 
                private void SendNetWMMessage(IntPtr window, IntPtr message_type, IntPtr l0, IntPtr l1, IntPtr l2) {
+                       SendNetWMMessage (window, message_type, l0, l1, l2, IntPtr.Zero);
+               }
+
+               private void SendNetWMMessage(IntPtr window, IntPtr message_type, IntPtr l0, IntPtr l1, IntPtr l2, IntPtr l3) {
                        XEvent  xev;
 
                        xev = new XEvent();
@@ -729,6 +733,7 @@ namespace System.Windows.Forms {
                        xev.ClientMessageEvent.ptr1 = l0;
                        xev.ClientMessageEvent.ptr2 = l1;
                        xev.ClientMessageEvent.ptr3 = l2;
+                       xev.ClientMessageEvent.ptr4 = l3;
                        XSendEvent(DisplayHandle, RootWindow, false, new IntPtr ((int) (EventMask.SubstructureRedirectMask | EventMask.SubstructureNotifyMask)), ref xev);
                }
 
@@ -4613,6 +4618,22 @@ namespace System.Windows.Forms {
                                                               (IntPtr) (screen_y << 16 | screen_x & 0xFFFF));
                }
 
+               // Our very basic implementation of MoveResize - we can extend it later
+               // *if* needed
+               internal override void BeginMoveResize (IntPtr handle)
+               {
+                       // We *need* to ungrab the pointer in the current display
+                       XplatUI.UngrabWindow (Grab.Hwnd);
+
+                       int x_root, y_root;
+                       GetCursorPos (IntPtr.Zero, out x_root, out y_root);
+
+                       Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+                       SendNetWMMessage (hwnd.whole_window, _NET_WM_MOVERESIZE, (IntPtr) x_root, (IntPtr) y_root,
+                                       (IntPtr) NetWmMoveResize._NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT, 
+                                       (IntPtr) 1); // left button
+               }
+
                internal override bool GetText(IntPtr handle, out string text) {
 
                        lock (XlibLock) {