- Fixed Refresh and Invalidate
authorPeter Dennis Bartok <pbartok@mono-cvs.ximian.com>
Fri, 6 Aug 2004 23:17:44 +0000 (23:17 -0000)
committerPeter Dennis Bartok <pbartok@mono-cvs.ximian.com>
Fri, 6 Aug 2004 23:17:44 +0000 (23:17 -0000)
svn path=/trunk/mcs/; revision=32004

mcs/class/Managed.Windows.Forms/System.Windows.Forms/X11Structs.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/XplatUIX11.cs

index 98b958472c4055df4ac1f6b54fabfd2d5a6cc47b..bd559fa48e14b2b6366a2911067c4135a4602116 100644 (file)
 //     Peter Bartok    pbartok@novell.com
 //
 //
-// $Revision: 1.4 $
+// $Revision: 1.5 $
 // $Modtime: $
 // $Log: X11Structs.cs,v $
+// Revision 1.5  2004/08/06 23:17:44  pbartok
+// - Fixed Refresh and Invalidate
+//
 // Revision 1.4  2004/08/06 21:30:56  pbartok
 // - Fixed recursive loop when resizing
 // - Improved/fixed redrawing on expose messages
@@ -683,7 +686,36 @@ namespace System.Windows.Forms {
                XK_Super_R      = 0xFFEC,
                XK_Hyper_L      = 0xFFED,
                XK_Hyper_R      = 0xFFEE,
+       }
 
+       [Flags]
+       internal enum EventMask {
+               NoEventMask             = 0,
+               KeyPressMask            = 1<<0,
+               KeyReleaseMask          = 1<<1,
+               ButtonPressMask         = 1<<2,
+               ButtonReleaseMask       = 1<<3,
+               EnterWindowMask         = 1<<4,
+               LeaveWindowMask         = 1<<5,
+               PointerMotionMask       = 1<<6,
+               PointerMotionHintMask   = 1<<7,
+               Button1MotionMask       = 1<<8,
+               Button2MotionMask       = 1<<9,
+               Button3MotionMask       = 1<<10,
+               Button4MotionMask       = 1<<11,
+               Button5MotionMask       = 1<<12,
+               ButtonMotionMask        = 1<<13,
+               KeymapStateMask         = 1<<14,
+               ExposureMask            = 1<<15,
+               VisibilityChangeMask    = 1<<16,
+               StructureNotifyMask     = 1<<17,
+               ResizeRedirectMask      = 1<<18,
+               SubstructureNotifyMask  = 1<<19,
+               SubstructureRedirectMask= 1<<20,
+               FocusChangeMask         = 1<<21,
+               PropertyChangeMask      = 1<<22,
+               ColormapChangeMask      = 1<<23,
+               OwnerGrabButtonMask     = 1<<24
        }
        #endregion
 }
index 7ce325a0c8ac10de99f0f5697e142a8ce06701a1..854a4b08c4ca1841fc427c56e4b94f9f7c86a881 100644 (file)
 //     Peter Bartok    pbartok@novell.com
 //
 //
-// $Revision: 1.6 $
+// $Revision: 1.7 $
 // $Modtime: $
 // $Log: XplatUIX11.cs,v $
+// Revision 1.7  2004/08/06 23:17:44  pbartok
+// - Fixed Refresh and Invalidate
+//
 // Revision 1.6  2004/08/06 21:30:56  pbartok
 // - Fixed recursive loop when resizing
 // - Improved/fixed redrawing on expose messages
@@ -257,8 +260,22 @@ namespace System.Windows.Forms {
                }
 
                internal override void RefreshWindow(IntPtr handle) {
+                       XWindowAttributes       attributes=new XWindowAttributes();
+                       XEvent                  xevent = new XEvent();
+
+                       // We need info about our window to generate the expose
+                       XGetWindowAttributes(DisplayHandle, handle, ref attributes);
+
+                       xevent.type=XEventName.Expose;
+                       xevent.ExposeEvent.display=DisplayHandle;
+                       xevent.ExposeEvent.window=handle;
+                       xevent.ExposeEvent.x=0;
+                       xevent.ExposeEvent.y=0;
+                       xevent.ExposeEvent.width=attributes.width;
+                       xevent.ExposeEvent.height=attributes.height;
+
+                       XSendEvent(DisplayHandle, handle, false, EventMask.ExposureMask, ref xevent);
                        XFlush(DisplayHandle);
-                       Console.WriteLine("XplatUIX11.RefreshWindow");
                }
 
                [MonoTODO("Add support for internal table of windows/DCs for looking up paint area and cleanup")]
@@ -301,7 +318,35 @@ Where();
                }
 
                internal override void Invalidate(IntPtr handle, Rectangle rc, bool clear) {
-                       Console.WriteLine("XplatUIX11.Invalidate");
+                       XEvent                  xevent = new XEvent();
+
+                       xevent.type=XEventName.Expose;
+                       xevent.ExposeEvent.display=DisplayHandle;
+                       xevent.ExposeEvent.window=handle;
+                       xevent.ExposeEvent.count=0;
+
+Console.WriteLine("Invalidating, rc={0}, clear={1}", rc, clear);
+                       if (clear) {
+                               // Need to clear the whole window, so we force a redraw for the whole window
+                               XWindowAttributes       attributes=new XWindowAttributes();
+
+                               // We need info about our window to generate the expose
+                               XGetWindowAttributes(DisplayHandle, handle, ref attributes);
+
+                               xevent.ExposeEvent.x=0;
+                               xevent.ExposeEvent.y=0;
+                               xevent.ExposeEvent.width=attributes.width;
+                               xevent.ExposeEvent.height=attributes.height;
+                       } else {
+                               xevent.ExposeEvent.x=rc.Left;
+                               xevent.ExposeEvent.y=rc.Top;
+                               xevent.ExposeEvent.width=rc.Width;
+                               xevent.ExposeEvent.height=rc.Height;
+                       }
+
+                       XSendEvent(DisplayHandle, handle, false, EventMask.ExposureMask, ref xevent);
+                       // Flush is not needed, invalidate does not guarantee an immediate effect
+                       //XFlush(DisplayHandle);
                        return;
                }
 
@@ -628,6 +673,9 @@ Console.WriteLine("Setting parent for window {0} to {1}, border width of window:
                [DllImport ("libX11.so", EntryPoint="XStoreName")]
                internal extern static int XStoreName(IntPtr display, IntPtr window, string window_name);
 
+               [DllImport ("libX11.so", EntryPoint="XSendEvent")]
+               internal extern static int XSendEvent(IntPtr display, IntPtr window, bool propagate, EventMask event_mask, ref XEvent send_event);
+
                // Drawing
                [DllImport ("libX11.so", EntryPoint="XCreateGC")]
                internal extern static IntPtr XCreateGC(IntPtr display, IntPtr window, int valuemask, IntPtr values);