Fix for lots of window size events during window drag
authorMaarten Gribnau <mail@maartengribnau.com>
Wed, 1 Jan 2003 21:31:36 +0000 (21:31 +0000)
committerMaarten Gribnau <mail@maartengribnau.com>
Wed, 1 Jan 2003 21:31:36 +0000 (21:31 +0000)
Maarten

intern/ghost/intern/GHOST_SystemCarbon.cpp
intern/ghost/intern/GHOST_SystemCarbon.h

index 1b44a83..de57607 100644 (file)
@@ -195,6 +195,7 @@ GHOST_SystemCarbon::GHOST_SystemCarbon() :
        UnsignedWide micros;
        ::Microseconds(&micros);
        m_start_time = UnsignedWideToUInt64(micros)/1000;
+       m_ignoreWindowSizedMessages = false;
 }
 
 GHOST_SystemCarbon::~GHOST_SystemCarbon()
@@ -501,8 +502,11 @@ OSStatus GHOST_SystemCarbon::handleWindowEvent(EventRef event)
                                        pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) );
                                        break;
                                case kEventWindowBoundsChanged:
-                                       window->updateDrawingContext();
-                                       pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window) );
+                                       if (!m_ignoreWindowSizedMessages)
+                                       {
+                                               window->updateDrawingContext();
+                                               pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window) );
+                                       }
                                        break;
                        }
                }
@@ -636,7 +640,15 @@ bool GHOST_SystemCarbon::handleMouseDown(EventRef event)
                        break;
                        
                case inDrag:
+                       /*
+                        * The DragWindow() routine creates a lot of kEventWindowBoundsChanged
+                        * events. By setting m_ignoreWindowSizedMessages these are suppressed.
+                        * @see GHOST_SystemCarbon::handleWindowEvent(EventRef event)
+                        */
+                       GHOST_ASSERT(validWindow(ghostWindow), "GHOST_SystemCarbon::handleMouseDown: invalid window");
+                       m_ignoreWindowSizedMessages = true;
                        ::DragWindow(window, mousePos, &GetQDGlobalsScreenBits(&screenBits)->bounds);
+                       m_ignoreWindowSizedMessages = false;
                        break;
                
                case inContent:
index ec1ff33..a08a070 100644 (file)
@@ -241,6 +241,9 @@ protected:
        
     /** State of the modifiers. */
     UInt32 m_modifierMask;
+
+    /** Ignores window size messages (when window is dragged). */
+    bool m_ignoreWindowSizedMessages;    
 };
 
 #endif // _GHOST_SYSTEM_CARBON_H_