dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] [SCM] DotGNU Portable.NET Class Library (pnetlib)


From: Heiko Weiss
Subject: [dotgnu-pnet-commits] [SCM] DotGNU Portable.NET Class Library (pnetlib) branch, master, updated. d30fef558a43698a9fd091fbd3c20b8d8aaa45b6
Date: Mon, 17 May 2010 10:11:01 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "DotGNU Portable.NET Class Library (pnetlib)".

The branch, master has been updated
       via  d30fef558a43698a9fd091fbd3c20b8d8aaa45b6 (commit)
      from  90aad1719f92d9dc7ddd9163d394a3c1ba7c8afe (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/pnetlib.git/commit/?id=d30fef558a43698a9fd091fbd3c20b8d8aaa45b6

commit d30fef558a43698a9fd091fbd3c20b8d8aaa45b6
Author: Heiko Weiss <address@hidden>
Date:   Mon May 17 12:09:02 2010 +0200

    Control.cs: replaced hoverTimer for each control with one static hoverTimer 
for all controls.
    Display.cs: replaced waiting for x-event endless with waiting with timeout. 
This avoids pending invokes not to be processed.

diff --git a/ChangeLog b/ChangeLog
index 7c83f36..143dc04 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-05-17  Heiko Weiss  <address@hidden>
+       
+       * Xsharp/Display.cs: replaced waiting for x-event endless with waiting 
+       with timeout. This avoids pending invokes not to be processed.
+       * System.Windows.Forms/Control.cs: replaced hoverTimer for each control
+       with one static hoverTimer for all controls.
+
 2010-04-27  Klaus Treichel  <address@hidden>
 
        * System.Drawing/Graphics.cs: Create the default graphics object in
diff --git a/System.Windows.Forms/Control.cs b/System.Windows.Forms/Control.cs
index b7e9810..a43a7a1 100644
--- a/System.Windows.Forms/Control.cs
+++ b/System.Windows.Forms/Control.cs
@@ -99,7 +99,9 @@ public class Control : IWin32Window, IDisposable
        private IToolkitWindowBuffer buffer;
        private ControlBindingsCollection controlBindingsCollection;
        private ControlCollection controlCollection;
-       private Timer hoverTimer;
+       static private Timer hoverTimer;
+       static private Control hoverControl;
+
 
 
        // Miscellaneous flags for controls.
@@ -247,10 +249,13 @@ public class Control : IWin32Window, IDisposable
                                height = initialSize.Height;
 
                                controlBindingsCollection = new 
ControlBindingsCollection(this);
-                               hoverTimer = new Timer();
-                               hoverTimer.Interval = 1000;
-                               hoverTimer.Enabled = false;
-                               hoverTimer.Tick += new 
EventHandler(this.ProcessHoverTimerEvent);
+                               if( null == hoverTimer ) 
+                               {
+                                       hoverTimer = new Timer();
+                                       hoverTimer.Interval = 1000;
+                                       hoverTimer.Enabled = false;
+                                       hoverTimer.Tick += new 
EventHandler(ProcessHoverTimerEvent);
+                               }
                                
                                updateDistances = true;
                        }
@@ -320,9 +325,12 @@ public class Control : IWin32Window, IDisposable
 
 
        // Process a hoverTimer event
-       private void ProcessHoverTimerEvent(object sender, EventArgs e)
+       static private void ProcessHoverTimerEvent(object sender, EventArgs e)
        {
-               OnMouseHover(e);
+               if( hoverControl != null ) 
+               {
+                       hoverControl.OnMouseHover(e);
+               }
        }
 
 #if CONFIG_COMPONENT_MODEL
@@ -2256,6 +2264,14 @@ public class Control : IWin32Window, IDisposable
 
 #endif // !CONFIG_COMPACT_FORMS
 
+       private bool IsDisposedOrDisposing
+       {
+               get 
+               {
+                       return GetControlFlag(ControlFlags.Disposed) || 
GetControlFlag(ControlFlags.Disposing);
+               }
+       }
+
        // Dispose of this control.
 #if CONFIG_COMPACT_FORMS
        public new void Dispose()
@@ -2277,7 +2293,7 @@ public class Control : IWin32Window, IDisposable
        protected virtual void Dispose(bool disposing)
 #endif
                        {
-                               if( GetControlFlag(ControlFlags.Disposed) || 
GetControlFlag(ControlFlags.Disposing) ) {
+                               if( this.IsDisposedOrDisposing ) {
                                        return;// do nothing if already 
disposing or disposed
                                }
                                
@@ -2321,13 +2337,8 @@ public class Control : IWin32Window, IDisposable
                                                }
                                                numChildren = 0;
                                                children = null;
-                                               
-                                               if( null != hoverTimer ) {
-                                                       hoverTimer.Enabled = 
false;
-                                                       hoverTimer.Tick -= new 
EventHandler(this.ProcessHoverTimerEvent);
-                                                       hoverTimer.Dispose();
-                                                       hoverTimer = null;
-                                               }
+
+                                               StopHover();
                                        }
                                        finally
                                        {
@@ -5063,9 +5074,11 @@ public class Control : IWin32Window, IDisposable
 #endif
        protected virtual void OnMouseDown(MouseEventArgs e)
                        {
-                               if( null == hoverTimer ) return; // we are 
disposed
-                               hoverTimer.Enabled = false;
-                               hoverTimer.Stop();
+                               if( this.IsDisposedOrDisposing ) {
+                                       return;// do nothing if already 
disposing or disposed
+                               }
+
+                               StopHover();
 
                                MouseEventHandler handler;
                                handler = 
(MouseEventHandler)(GetHandler(EventId.MouseDown));
@@ -5083,9 +5096,11 @@ public class Control : IWin32Window, IDisposable
 #endif
        protected virtual void OnMouseEnter(EventArgs e)
                        {
-                               if( null == hoverTimer ) return; // we are 
disposed
-                               hoverTimer.Enabled = true;
-                               hoverTimer.Start();
+                               if( this.IsDisposedOrDisposing ) {
+                                       return;// do nothing if already 
disposing or disposed
+                               }
+
+                               StartHover();
 
                                EventHandler handler;
                                handler = 
(EventHandler)(GetHandler(EventId.MouseEnter));
@@ -5094,14 +5109,34 @@ public class Control : IWin32Window, IDisposable
                                        handler(this, e);
                                }
                        }
+
+       private void StartHover() 
+       {
+               hoverTimer.Stop();
+               hoverControl = this;
+               hoverTimer.Start();
+       }
+
+       private void StopHover() 
+       {
+               if( hoverControl == this ) 
+               {
+                       hoverControl = null;
+                       hoverTimer.Stop();
+               }
+       }
+
 #if CONFIG_COMPONENT_MODEL
        [EditorBrowsable(EditorBrowsableState.Advanced)]
 #endif
        protected virtual void OnMouseHover(EventArgs e)
                        {
-                               if( null == hoverTimer ) return; // we are 
disposed
-                               hoverTimer.Stop();
+                               StopHover();
 
+                               if( this.IsDisposedOrDisposing ) {
+                                       return;// do nothing if already 
disposing or disposed
+                               }
+                               
                                EventHandler handler;
                                handler = 
(EventHandler)(GetHandler(EventId.MouseHover));
                                if(handler != null)
@@ -5114,9 +5149,10 @@ public class Control : IWin32Window, IDisposable
 #endif
        protected virtual void OnMouseLeave(EventArgs e)
                        {
-                               if( null == hoverTimer ) return; // we are 
disposed
-                               hoverTimer.Enabled = false;
-                               hoverTimer.Stop();
+                               if( this.IsDisposedOrDisposing ) {
+                                       return;// do nothing if already 
disposing or disposed
+                               }
+                               StopHover();
 
                                EventHandler handler;
                                handler = 
(EventHandler)(GetHandler(EventId.MouseLeave));
@@ -5142,9 +5178,10 @@ public class Control : IWin32Window, IDisposable
 #endif
        protected virtual void OnMouseUp(MouseEventArgs e)
                        {
-                               if( null == hoverTimer ) return; // we are 
disposed
-                               hoverTimer.Enabled = false;
-                               hoverTimer.Stop();
+                               if( this.IsDisposedOrDisposing ) {
+                                       return;// do nothing if already 
disposing or disposed
+                               }
+                               StopHover();
 
                                MouseEventHandler handler;
                                handler = 
(MouseEventHandler)(GetHandler(EventId.MouseUp));
@@ -5162,9 +5199,10 @@ public class Control : IWin32Window, IDisposable
 #endif
        protected virtual void OnMouseWheel(MouseEventArgs e)
                        {
-                               if( null == hoverTimer ) return; // we are 
disposed
-                               hoverTimer.Enabled = false;
-                               hoverTimer.Stop();
+                               if( this.IsDisposedOrDisposing ) {
+                                       return;// do nothing if already 
disposing or disposed
+                               }
+                               StopHover();
 
                                MouseEventHandler handler;
                                handler = 
(MouseEventHandler)(GetHandler(EventId.MouseWheel));
diff --git a/Xsharp/Display.cs b/Xsharp/Display.cs
index 89a64b9..a2654a0 100644
--- a/Xsharp/Display.cs
+++ b/Xsharp/Display.cs
@@ -607,8 +607,12 @@ public sealed class Display : IDisposable
                                                        Unlock();
                                                        try
                                                        {
-                                                               
Xlib.XNextEvent(dpy, out xevent);
-                                                               
DispatchEvent(ref xevent);
+                                                               timeout = 100;
+                                                               
if(Xlib.XNextEventWithTimeout
+                                                                       (dpy, 
out xevent, timeout) > 0)
+                                                               {
+                                                                       
DispatchEvent(ref xevent);
+                                                               }
                                                        }
                                                        finally
                                                        {

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                       |    7 +++
 System.Windows.Forms/Control.cs |  102 ++++++++++++++++++++++++++------------
 Xsharp/Display.cs               |    8 ++-
 3 files changed, 83 insertions(+), 34 deletions(-)


hooks/post-receive
-- 
DotGNU Portable.NET Class Library (pnetlib)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]