Update of /cvsroot/audacity/audacity-src/src
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv6677

Modified Files:
        AudacityApp.cpp AudacityApp.h Project.cpp Project.h 
Log Message:
Commit Ed's final/cleanup patch.  More confirmation is needed, but I believe
this may also correct:

P2 (Mac) Hang when scanning for VST effects on fresh install.


Index: Project.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Project.h,v
retrieving revision 1.171
retrieving revision 1.172
diff -u -d -r1.171 -r1.172
--- Project.h   5 Nov 2009 00:32:03 -0000       1.171
+++ Project.h   8 Nov 2009 04:18:53 -0000       1.172
@@ -85,6 +85,7 @@
 
 void GetDefaultWindowRect(wxRect *defRect);
 void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool 
*pIconized);
+bool IsWindowAccessible(wxRect *requestedRect);
 
 WX_DEFINE_ARRAY(AudacityProject *, AProjectArray);
 
@@ -383,7 +384,7 @@
    void DeleteCurrentAutoSaveFile();
    
    static bool GetCacheBlockFiles();
-   
+
  public:
    bool IsSoloSimple() { return mSoloPref == wxT("Simple"); };
    bool IsSoloNone() { return mSoloPref == wxT("None"); };
@@ -462,9 +463,6 @@
    wxString mHelpPref;
    wxString mSoloPref;
 
-   // public accessors for the private data
-   // Ed Musgrove
-   // 19 October 2009
    void SetNormalizedWindowState(wxRect & pSizeAndLocation) {  
mNormalizedWindowState = pSizeAndLocation;   }
    wxRect GetNormalizedWindowState() const { return mNormalizedWindowState;   }
 
@@ -523,10 +521,6 @@
    // The screenshot class needs to access internals
    friend class ScreenshotCommand;
 
-   //Maximized project windows store their "normal"
-   // size and location in this wxRect
-   // Ed Musgrove
-   // 19 October 2009
    wxRect mNormalizedWindowState;
 
  public:

Index: Project.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Project.cpp,v
retrieving revision 1.470
retrieving revision 1.471
diff -u -d -r1.470 -r1.471
--- Project.cpp 5 Nov 2009 00:32:03 -0000       1.470
+++ Project.cpp 8 Nov 2009 04:18:53 -0000       1.471
@@ -157,8 +157,6 @@
 
 #include "CaptureEvents.h"
 
-using std::cout;
-
 TrackList *AudacityProject::msClipboard = new TrackList();
 double AudacityProject::msClipLen = 0.0;
 AudacityProject *AudacityProject::msClipProject = NULL;
@@ -552,14 +550,31 @@
 #endif
 }
 
+bool IsWindowAccessible(wxRect *requestedRect)
+{
+   wxDisplay display;
+   wxRect targetTitleRect(requestedRect->GetLeftTop(), 
requestedRect->GetBottomRight());
+   targetTitleRect.x += 15;
+   targetTitleRect.width -= 100;
+   if (targetTitleRect.width <  165) targetTitleRect.width = 165;
+   targetTitleRect.height = 15;
+   int targetBottom = targetTitleRect.GetBottom();
+   int targetRight = targetTitleRect.GetRight();
+   for (int i =  targetTitleRect.GetLeft(); i < targetRight; i++) {
+      for (int j = targetTitleRect.GetTop(); j < targetBottom; j++) {
+         int monitor = display.GetFromPoint(wxPoint(i, j));
+         if (monitor != wxNOT_FOUND) {
+            return TRUE;
+         }
+      }
+   }
+   return FALSE;
+}
+
 // BG: Calculate where to place the next window (could be the first window)
 // BG: Does not store X and Y in prefs. This is intentional.
 void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool 
*pIconized)
 {
-   // This code was heavily modified to deal with iconized 
-   // and maximized project windows
-   // Ed Musgrove
-   // 28 September 2009 -- 21 October 2009
    int inc = 25;
    *pMaximized = FALSE;
    *pIconized = FALSE;
@@ -585,83 +600,7 @@
          nextRect->SetWidth(gPrefs->Read(wxT("/Window/Width"), 
defaultWindowRect.GetWidth()));
          nextRect->SetHeight(gPrefs->Read(wxT("/Window/Height"), 
defaultWindowRect.GetHeight()));
       }
-      // define a rectangular region of the window's title bar and determine 
if any portion 
-      //    of it is in the desktopand is  therefor available to be dragged by 
the use
-      //    this will insure that the new window is always accessible to the 
user
-      wxDisplay display;
-      wxRect targetTitleRect(nextRect->GetLeftTop(), 
nextRect->GetBottomRight());
-      targetTitleRect.x += 15;   // ignore title bar icon region
-      targetTitleRect.width -= 100; // ignore min max & close icons
-      if (targetTitleRect.width <  150) targetTitleRect.width = 165;
-      targetTitleRect.height = 15; //  fifteen pixels of display to grab a 
hold of
-      int targetTop = targetTitleRect.GetTop();
-      int targetBottom = targetTitleRect.GetBottom();
-      int targetLeft = targetTitleRect.GetLeft();
-      int targetRight = targetTitleRect.GetRight();
-      bool isAccessible =  FALSE;
-      if (targetLeft < 0) {
-         if (targetTop < 0) {// --
-            for (int i =  targetLeft; i < targetRight; i++) {
-               for (int j = targetTop; j < targetBottom; j++) {
-                  bool goodI =  FALSE;
-                  bool goodJ =  FALSE;
-                  int monitor = display.GetFromPoint(wxPoint(i, j));
-                  if (monitor != wxNOT_FOUND) {
-                     isAccessible = TRUE;
-                     break;
-                  }
-               }
-               if (isAccessible) break;
-            }
-         }
-         else { // -+
-            for (int i =  targetLeft; i < targetRight; i++) {
-               for (int j = targetTop; j < targetBottom; j++) {
-                  bool goodI =  FALSE;
-                  bool goodJ =  FALSE;
-                  int monitor = display.GetFromPoint(wxPoint(i, j));
-                  if (monitor != wxNOT_FOUND) {
-                     isAccessible = TRUE;
-                     break;
-                  }
-               }
-               if (isAccessible) break;
-            }
-         }
-      }
-      else {
-         if (targetTop < 0) { //+-
-            for (int i =  targetLeft; i < targetRight; i++) {
-               for (int j = targetTop; j < targetBottom; j--) {
-                  bool goodI =  FALSE;
-                  bool goodJ =  FALSE;
-                  int monitor = display.GetFromPoint(wxPoint(i, j));
-                  if (monitor != wxNOT_FOUND) {
-                     isAccessible = TRUE;
-                     break;
-                  }
-               }
-               if (isAccessible) break;
-            }
-         }
-         else { // ++
-            for (int i =  targetLeft; i < targetRight; i++) {
-               for (int j = targetTop; j < targetBottom; j++) {
-                  bool goodI =  FALSE;
-                  bool goodJ =  FALSE;
-                  int monitor = display.GetFromPoint(wxPoint(i, j));
-                  if (monitor != wxNOT_FOUND) {
-                     isAccessible = TRUE;
-                     break;
-                  }
-               }
-               if (isAccessible) break;
-            }
-         }
-      }
-      if (!isAccessible) {
-         // the default values are guaranteed to be on the main monitor
-         //    completely visible and accessible
+      if (!IsWindowAccessible(nextRect)) {
          nextRect->SetX(defaultWindowRect.GetX());
          nextRect->SetY(defaultWindowRect.GetY());
          nextRect->SetWidth(defaultWindowRect.GetWidth());
@@ -673,7 +612,6 @@
       AudacityProject * validProject = NULL;
       size_t numProjects = gAudacityProjects.Count();
       for (int i = numProjects; i > 0 ; i--)
-      //   read these backwards so that new project locations will increment 
off the newest project window
       {
          if (!gAudacityProjects[i-1]->IsIconized()) {
              validWindowSize = TRUE;
@@ -699,26 +637,16 @@
 
       //Placement depends on the increments
       nextRect->SetX(nextRect->GetX() + inc);
-      //nextRect->x += inc;
       nextRect->SetY(nextRect->GetY() + inc);
-      //nextRect->y += inc;
    }
 
-   //Make sure that the Window will be completely visible
-   //Get the size of the screen
    wxRect screenRect = wxGetClientDisplayRect();
 
-   // We do not want to reset the increments unless the top left corner of the 
new window
-   //    gets too near the bottom right hand corner of the screen -- also, 
make sure the 
-   //    window fits on the screen
-   // Ed Musgrove
-   // 16 October 2009
-         //Have we hit the right side of the screen?
+   //Have we hit the right side of the screen?
    wxPoint bottomRight = nextRect->GetBottomRight();
    if (bottomRight.x > screenRect.GetRight()) {
       int newWidth = screenRect.GetWidth() - nextRect->GetLeft();
       if (newWidth < defaultWindowRect.GetWidth()) {
-         // try to use as much of the user's preferred Project window state as 
possible
          nextRect->SetX(gPrefs->Read(wxT("/Window/X"), 
defaultWindowRect.GetX()));
          nextRect->SetY(gPrefs->Read(wxT("/Window/Y"), 
defaultWindowRect.GetY()));
          nextRect->SetWidth(gPrefs->Read(wxT("/Window/Width"), 
defaultWindowRect.GetWidth()));
@@ -727,16 +655,22 @@
          nextRect->SetWidth(newWidth);
       }
    }
-      //Have we hit the bottom of the screen?
+   bottomRight = nextRect->GetBottomRight();
+   //Have we hit the bottom of the screen?
    if (bottomRight.y > screenRect.GetBottom()) {
       nextRect->y  -= inc;
-      //we will need to test again since we have moved the window down
       bottomRight = nextRect->GetBottomRight();
       if (bottomRight.y > screenRect.GetBottom()) {
          int newheight = screenRect.GetHeight() - nextRect->GetBottom();
          nextRect->SetBottom(screenRect.GetBottom());
       }
    }
+   if (!IsWindowAccessible(nextRect)) {
+      nextRect->SetX(defaultWindowRect.GetX());
+      nextRect->SetY(defaultWindowRect.GetY());
+      nextRect->SetWidth(defaultWindowRect.GetWidth());
+      nextRect->SetHeight(defaultWindowRect.GetHeight());
+   }
 }
 
 wxString CreateUniqueName()
@@ -1090,9 +1024,6 @@
 
    gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"), &mRate, 
AudioIO::GetOptimalSupportedSampleRate());
    mDefaultFormat = (sampleFormat) 
gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleFormat"), floatSample);
-   // remember the "normalized" window size and location
-   // Ed Musgrove
-   // 19 October 2009
    wxRect normalRect;
    gPrefs->Read(wxT("/Window/Normal_X"), &normalRect.x);
    gPrefs->Read(wxT("/Window/Normal_Y"), &normalRect.y);
@@ -1611,9 +1542,6 @@
 
 void AudacityProject::OnMove(wxMoveEvent & event)
 {
-   // remember where the window is for .cfg
-   // Ed Musgrove
-   // 19 October 2009
    wxRect rect(this->GetRect());
    if (!this->IsMaximized() && !this->IsIconized())
       SetNormalizedWindowState(rect);
@@ -1623,9 +1551,6 @@
 void AudacityProject::OnSize(wxSizeEvent & event)
 {
    HandleResize();
-   // remember where the window is for .cfg
-   // Ed Musgrove
-   // 19 October 2009
    wxRect rect(this->GetRect());
    if (!this->IsMaximized() && !this->IsIconized())
       SetNormalizedWindowState(rect);
@@ -1963,11 +1888,6 @@
    //
    // LL: Save before doing anything else to the window that might make
    //     its size change.
-   //This is to repair the potential situation in which Audacity opens with
-   //     the initial opening window invisible.
-   //This SaveWindowSize call was modified to deal with iconized project 
windows
-   // Ed Musgrove
-   // 28 September 2009
       SaveWindowSize();
 
    mLastFocusedWindow = NULL;
@@ -2085,9 +2005,6 @@
          QuitAudacity();
       else {
 #if !defined(__WXMAC__)
-      // we want to use this new Audacity project from which to gather 
preference data
-      // Ed Musgrove
-      // 11 October 2009
       wxGetApp().SetWindowRectAlreadySaved(FALSE);
       CreateNewAudacityProject();
 #endif

Index: AudacityApp.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/AudacityApp.h,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- AudacityApp.h       31 Oct 2009 15:24:21 -0000      1.60
+++ AudacityApp.h       8 Nov 2009 04:18:53 -0000       1.61
@@ -165,9 +165,6 @@
 
    FileHistory *GetRecentFiles() {return mRecentFiles;}
    void AddFileToHistory(const wxString & name);
-   // Use these to access the new mmWindowRectAlreadySaved Boolean .
-   // Ed Musgrove
-   // 11 October 2009
    bool GetWindowRectAlreadySaved()const {return mWindowRectAlreadySaved;}
    void SetWindowRectAlreadySaved(bool alreadySaved) {mWindowRectAlreadySaved 
= alreadySaved;}
 
@@ -205,10 +202,6 @@
 //      ....      depends on whether [AudacityDir]\presets can be written
    wxString mAppHomeDir;
    wxString mPresetsDir;
-   // Use this new Boolean to determine if the project window
-   //   location and size have already been written to preferences.
-   // Ed Musgrove
-   // 11 October 2009
    bool mWindowRectAlreadySaved;
 
 #if defined(__WXMSW__)

Index: AudacityApp.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/AudacityApp.cpp,v
retrieving revision 1.252
retrieving revision 1.253
diff -u -d -r1.252 -r1.253
--- AudacityApp.cpp     1 Nov 2009 19:29:39 -0000       1.252
+++ AudacityApp.cpp     8 Nov 2009 04:18:53 -0000       1.253
@@ -244,9 +244,6 @@
    else
 /*end+*/
    {
-      // This SaveWindowSize call was heavily modified to deal with iconized 
project windows
-      // Ed Musgrove
-      // 28 September 2009
       SaveWindowSize();
       while (gAudacityProjects.Count())
       {
@@ -305,9 +302,6 @@
 }
 
 void SaveWindowSize()
-   // This code was heavily modified to deal with iconized project windows.
-   // Ed Musgrove
-   // 28 September 2009
 {
    if (wxGetApp().GetWindowRectAlreadySaved())
    {
@@ -338,9 +332,6 @@
       gPrefs->Write(wxT("/Window/Width"), windowRect.GetWidth());
       gPrefs->Write(wxT("/Window/Height"), windowRect.GetHeight());
       gPrefs->Write(wxT("/Window/Maximized"), wndMaximized);
-      // remember the "normalized" window size and location
-      // Ed Musgrove
-      // 19 October 2009
       gPrefs->Write(wxT("/Window/Normal_X"), normalRect.GetX());
       gPrefs->Write(wxT("/Window/Normal_Y"), normalRect.GetY());
       gPrefs->Write(wxT("/Window/Normal_Width"), normalRect.GetWidth());
@@ -1275,9 +1266,6 @@
    
    ModuleManager::Dispatch(AppInitialized);
 
-   // initialize mWindowRectAlreadySaved
-   // Ed Musgrove
-   // 11 October 2009
    mWindowRectAlreadySaved = FALSE;
 
    return TRUE;


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Audacity-cvs mailing list
Audacity-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to