Update of /cvsroot/audacity/audacity-src/src/toolbars
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv3235

Modified Files:
        ToolManager.cpp ToolManager.h 
Log Message:

Switch to using a timer for SHIFT key monitoring
Correct indicator movement under KDE

Index: ToolManager.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/toolbars/ToolManager.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ToolManager.h       22 Oct 2006 19:47:16 -0000      1.6
+++ ToolManager.h       23 Oct 2006 04:47:22 -0000      1.7
@@ -66,7 +66,7 @@
 
    ToolBar *Float( ToolBar *t, wxPoint & pos );
 
-   void OnKey( wxKeyEvent & event );
+   void OnTimer( wxTimerEvent & event );
    void OnMouse( wxMouseEvent & event );
    void OnGrabber( GrabberEvent & event );
 
@@ -93,6 +93,9 @@
    wxRegion *mDown;
    wxRegion *mCurrent;
 
+   wxTimer mTimer;
+   bool mLastState;
+
 #if defined(__WXMAC__)
    bool mTransition;
 #endif

Index: ToolManager.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/toolbars/ToolManager.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- ToolManager.cpp     22 Oct 2006 19:47:16 -0000      1.9
+++ ToolManager.cpp     23 Oct 2006 04:47:22 -0000      1.10
@@ -40,6 +40,7 @@
 #include <wx/settings.h>
 #include <wx/sysopt.h>
 #include <wx/timer.h>
+#include <wx/utils.h>
 #include <wx/window.h>
 #endif  /*  */
 
@@ -285,6 +286,7 @@
 
 BEGIN_EVENT_TABLE( ToolManager, wxEvtHandler )
    EVT_GRABBER( wxID_ANY, ToolManager::OnGrabber )
+   EVT_TIMER( wxID_ANY, ToolManager::OnTimer )
 END_EVENT_TABLE()
 
 //
@@ -382,6 +384,9 @@
    mBars[ SelectionBarID ]     = new SelectionBar();
    mBars[ DeviceBarID ]        = new DeviceToolBar();
 
+   // We own the timer
+   mTimer.SetOwner( this );
+
    // Process the toolbar config settings
    ReadConfig();
 } 
@@ -770,17 +775,6 @@
          mParent->ReleaseMouse();
       }
 
-      // Need to watch for the shift key
-      wxTheApp->Disconnect( wxEVT_KEY_DOWN,
-                            wxKeyEventHandler( ToolManager::OnKey ),
-                            NULL,
-                            this );
-
-      wxTheApp->Disconnect( wxEVT_KEY_UP,
-                            wxKeyEventHandler( ToolManager::OnKey ),
-                            NULL,
-                            this );
-
       // Hide the indicator
       mIndicator->Hide();
 
@@ -806,6 +800,7 @@
       mDragBar = NULL;
       mLastPos.x = mBarPos.x = -1;
       mLastPos.y = mBarPos.y = -1;
+      mTimer.Stop();
    }
    else if( event.Dragging() && pos != mLastPos )
    {
@@ -869,15 +864,19 @@
                mCurrent = mLeft;
             }
 
-            // Move it into position and put it on stage
+            // Change the shape while hidden and then show it if okay
             mIndicator->SetShape( *mCurrent );
-            mIndicator->Move( dock->GetParent()->ClientToScreen( p ) );
             if( !event.ShiftDown() )
             {
                mIndicator->Show();
                mIndicator->Update();
             }
 
+            // Move it into position
+            // LL:  Do this after the Show() since KDE doesn't move the window
+            //      if it's not shown.  (Do it outside if the previous IF as 
well)
+            mIndicator->Move( dock->GetParent()->ClientToScreen( p ) );
+
             // Remember for next go round
             mBarPos = r;
          }
@@ -907,7 +906,7 @@
 //
 // Watch for shift key changes
 //
-void ToolManager::OnKey( wxKeyEvent & event )
+void ToolManager::OnTimer( wxTimerEvent & event )
 {
    // Go ahead and set the event to propagate
    event.Skip();
@@ -920,20 +919,25 @@
       return;
    }
 
-   if( event.GetKeyCode() == WXK_SHIFT )
+   bool state = wxGetKeyState( WXK_SHIFT );
+   if( mLastState != state )
    {
+      mLastState = state;
+
 #if defined(__WXMAC__)
       // Disable window animation
       wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, 1 );
 #endif
 
-      mIndicator->Show( event.GetEventType() == wxEVT_KEY_UP );
+      mIndicator->Show( !state );
 
 #if defined(__WXMAC__)
       // Disable window animation
       wxSystemOptions::SetOption( wxMAC_WINDOW_PLAIN_TRANSITION, mTransition );
 #endif
    }
+
+   return;
 }
 
 //
@@ -1016,19 +1020,12 @@
       mDragWindow = (ToolFrame *) mDragBar->GetParent();
    }
 
-   // Need to watch for the shift key
-   wxTheApp->Connect( wxEVT_KEY_DOWN,
-                     wxKeyEventHandler( ToolManager::OnKey ),
-                     NULL,
-                     this );
-
-   wxTheApp->Connect( wxEVT_KEY_UP,
-                     wxKeyEventHandler( ToolManager::OnKey ),
-                     NULL,
-                     this );
-
    // We want all mouse events from this point on
    mParent->CaptureMouse();
+
+   // Start monitoring shift key changes
+   mLastState = wxGetKeyState( WXK_SHIFT );
+   mTimer.Start( 100 );
 }
 
 // Indentation settings for Vim and Emacs and unique identifier for Arch, a


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to