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

Modified Files:
        AudacityApp.cpp Project.cpp Project.h 
Log Message:
Ed Musgrove's patch for window positioning.

Index: Project.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Project.h,v
retrieving revision 1.168
retrieving revision 1.169
diff -u -d -r1.168 -r1.169
--- Project.h   31 Oct 2009 15:24:22 -0000      1.168
+++ Project.h   1 Nov 2009 19:29:40 -0000       1.169
@@ -84,7 +84,7 @@
 AUDACITY_DLL_API void CloseAllProjects();
 
 void GetDefaultWindowRect(wxRect *defRect);
-void GetNextWindowPlacement(wxRect *nextRect, bool *bMaximized);
+void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool 
*pIconized);
 
 WX_DEFINE_ARRAY(AudacityProject *, AProjectArray);
 
@@ -146,7 +146,6 @@
    void SetSel0(double);        //Added by STM 
    void SetSel1(double);        //Added by STM 
 
-
    bool Clipboard() { return msClipLen > 0.0; }
 
    wxString GetName();
@@ -216,6 +215,7 @@
    void OnMouseEvent(wxMouseEvent & event);
    void OnIconize(wxIconizeEvent &event);
    void OnSize(wxSizeEvent & event);
+   void OnMove(wxMoveEvent & event);
    void OnScroll(wxScrollEvent & event);
    void OnCloseWindow(wxCloseEvent & event);
    void OnTimer(wxTimerEvent & event);
@@ -262,7 +262,6 @@
    // alternate == true, which causes the opposite behavior.
    void HandleTrackSolo(Track *t, const bool alternate);
 
-
    // Snap To
 
    void SetSnapTo(bool state);
@@ -322,8 +321,6 @@
       MixerBoard* GetMixerBoard() { return mMixerBoard; };
    #endif
 
- public:
-
    // SelectionBar callback methods
 
    virtual void AS_SetRate(double rate);
@@ -473,7 +470,14 @@
    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;   }
+
  private:
+
    int  mAudioIOToken;
 
    bool mIsDeleting;
@@ -516,7 +520,6 @@
    // Dependencies have been imported and a warning should be shown on save
    bool mImportedDependencies;
 
-
    bool mWantSaveCompressed;
    wxArrayString mStrOtherNamesArray; // used to make sure compressed file 
names are unique
    
@@ -525,11 +528,15 @@
    int mLastEffectType;
    wxString mLastEffectDesc;
 
- private:
-
    // 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:
     DECLARE_EVENT_TABLE()
 };

Index: Project.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Project.cpp,v
retrieving revision 1.465
retrieving revision 1.466
diff -u -d -r1.465 -r1.466
--- Project.cpp 31 Oct 2009 15:24:22 -0000      1.465
+++ Project.cpp 1 Nov 2009 19:29:40 -0000       1.466
@@ -80,6 +80,7 @@
 #include <wx/textfile.h>
 #include <wx/timer.h>
 #include <wx/generic/filedlgg.h>
+#include <wx/display.h>
 
 #include <wx/arrimpl.cpp>       // this allows for creation of wxObjArray
 
@@ -473,7 +474,8 @@
 {
    bool bMaximized;
    wxRect wndRect;
-   GetNextWindowPlacement(&wndRect, &bMaximized);
+   bool bIconized;
+   GetNextWindowPlacement(&wndRect, &bMaximized, &bIconized);
 
    //Create and show a new project
    AudacityProject *p = new AudacityProject(NULL, -1,
@@ -482,8 +484,13 @@
 
    gAudacityProjects.Add(p);
    
-   if(bMaximized)
+   if(bMaximized) {
       p->Maximize(true);
+   }
+   else if (bIconized) {
+      // if the user close down and iconized state we could start back up and 
iconized state
+      // p->Iconize(TRUE);
+   }
 
    //Initialise the Listener
    gAudioIO->SetListener(p);
@@ -540,29 +547,128 @@
 #ifdef __WXMSW__
    defRect->height += 40;
 #endif
+#ifdef __WXMAC__
+   defRect->height += 55;
+#endif
 }
 
 // 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 *bMaximized)
+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;
-   *bMaximized = false;
-   wxRect defWndRect;
+   *pMaximized = FALSE;
+   *pIconized = FALSE;
+   wxRect defaultWindowRect;
+   GetDefaultWindowRect(&defaultWindowRect);
 
    if (gAudacityProjects.IsEmpty()) {
       //Read the values from the registry, or use the defaults
-      GetDefaultWindowRect(&defWndRect);
-      nextRect->SetX(gPrefs->Read(wxT("/Window/X"), defWndRect.GetX()));
-      nextRect->SetY(gPrefs->Read(wxT("/Window/Y"), defWndRect.GetY()));
-      nextRect->SetWidth(gPrefs->Read(wxT("/Window/Width"), 
defWndRect.GetWidth()));
-      nextRect->SetHeight(gPrefs->Read(wxT("/Window/Height"), 
defWndRect.GetHeight()));
-
-      gPrefs->Read(wxT("/Window/Maximized"), bMaximized);
+      // In version 1.3 and above, using the registry has been replaced
+      //    by a configuration file -- audacity.cfg. Different OSes store
+      //    this file in different locations.
+      gPrefs->Read(wxT("/Window/Maximized"), pMaximized);
+      gPrefs->Read(wxT("/Window/Iconized"), pIconized);
+      if (pMaximized || pIconized) {
+         nextRect->SetX(gPrefs->Read(wxT("/Window/Normal_X"), 
defaultWindowRect.GetX()));
+         nextRect->SetY(gPrefs->Read(wxT("/Window/Normal_Y"), 
defaultWindowRect.GetY()));
+         nextRect->SetWidth(gPrefs->Read(wxT("/Window/Normal_Width"), 
defaultWindowRect.GetWidth()));
+         nextRect->SetHeight(gPrefs->Read(wxT("/Window/Normal_Height"), 
defaultWindowRect.GetHeight()));
+      }
+      else {
+         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()));
+         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
+         nextRect->SetX(defaultWindowRect.GetX());
+         nextRect->SetY(defaultWindowRect.GetY());
+         nextRect->SetWidth(defaultWindowRect.GetWidth());
+         nextRect->SetHeight(defaultWindowRect.GetHeight());
+      }
    }
    else {
-      //This code was heavily modified to deal with iconized project windows
-      //Ed Musgrove 28 September 2009
       bool validWindowSize = FALSE;
       AudacityProject * validProject = NULL;
       size_t numProjects = gAudacityProjects.Count();
@@ -578,58 +684,58 @@
       if (validWindowSize)
       {
          *nextRect = validProject->GetRect();
-         *bMaximized = validProject->IsMaximized();
+         *pMaximized = validProject->IsMaximized();
+         *pIconized = validProject->IsIconized();
       }
       else 
       {
-          GetDefaultWindowRect(&defWndRect);
-          nextRect->SetX(gPrefs->Read(wxT("/Window/X"), defWndRect.GetX()));
-          nextRect->SetY(gPrefs->Read(wxT("/Window/Y"), defWndRect.GetY()));
-          nextRect->SetWidth(gPrefs->Read(wxT("/Window/Width"), 
defWndRect.GetWidth()));
-          nextRect->SetHeight(gPrefs->Read(wxT("/Window/Height"), 
defWndRect.GetHeight()));
-          gPrefs->Read(wxT("/Window/Maximized"), bMaximized);
+          nextRect->SetX(gPrefs->Read(wxT("/Window/Normal_X"), 
defaultWindowRect.GetX()));
+          nextRect->SetY(gPrefs->Read(wxT("/Window/Normal_Y"), 
defaultWindowRect.GetY()));
+          nextRect->SetWidth(gPrefs->Read(wxT("/Window/Normal_Width"), 
defaultWindowRect.GetWidth()));
+          nextRect->SetHeight(gPrefs->Read(wxT("/Window/Normal_Height"), 
defaultWindowRect.GetHeight()));
+          gPrefs->Read(wxT("/Window/Maximized"), pMaximized);
+          gPrefs->Read(wxT("/Window/Iconized"), pIconized);
       }
 
       //Placement depends on the increments
-      nextRect->x += inc;
-      nextRect->y += inc;
+      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();
 
-   //First check if we need to reset the increments
-
-   //Have we hit the bottom of the screen?
-   if (nextRect->GetBottom() > screenRect.GetBottom()) {
-      //Recalculate the position on the screen
-      nextRect->x = defWndRect.x + gAudacityOffsetInc;
-      nextRect->y = defWndRect.y;
-
-      //Increment Offset increment
-      gAudacityOffsetInc += inc;
-   }
-
-   //Have we hit the right side of the screen?
-   if (nextRect->GetRight() > screenRect.GetRight()) {
-      //Reset Offset increments
-      gAudacityOffsetInc = 0;
-
-      //Recalculate the position on the screen
-      nextRect->x = defWndRect.x;
-      nextRect->y = defWndRect.y;
-      //No need to compute the offset, just use the default
+   // 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?
+   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()));
+      }
+      else {
+         nextRect->SetWidth(newWidth);
+      }
    }
-
-   //Next check if the screen is too small for the default Audacity width and 
height
-   //Uses both comparisons from above
-   if ((nextRect->GetRight() > screenRect.GetRight()) ||
-      (nextRect->GetBottom() > screenRect.GetBottom())) {
-      //Resize the Audacity window to fit in the screen
-      nextRect->width = screenRect.width-nextRect->x;
-      nextRect->height = screenRect.height-nextRect->y;
+      //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());
+      }
    }
 }
 
@@ -652,28 +758,29 @@
 
 
 BEGIN_EVENT_TABLE(AudacityProject, wxFrame)
-    EVT_MENU_OPEN(AudacityProject::OnMenuEvent)
-    EVT_MENU_CLOSE(AudacityProject::OnMenuEvent)
-    EVT_MENU(wxID_ANY, AudacityProject::OnMenu)
-    EVT_MOUSE_EVENTS(AudacityProject::OnMouseEvent)
-    EVT_CLOSE(AudacityProject::OnCloseWindow)
-    EVT_SIZE(AudacityProject::OnSize)
-    EVT_ACTIVATE(AudacityProject::OnActivate)
-    EVT_COMMAND_SCROLL_LINEUP(HSBarID, AudacityProject::OnScrollLeftButton)
-    EVT_COMMAND_SCROLL_LINEDOWN(HSBarID, AudacityProject::OnScrollRightButton)
-    EVT_COMMAND_SCROLL(HSBarID, AudacityProject::OnScroll)
-    EVT_COMMAND_SCROLL(VSBarID, AudacityProject::OnScroll)
-    EVT_TIMER(AudacityProjectTimerID, AudacityProject::OnTimer)
-    // Fires for menu with ID #1...first menu defined
-    EVT_UPDATE_UI(1, AudacityProject::OnUpdateUI)
-    EVT_ICONIZE(AudacityProject::OnIconize)
-    EVT_COMMAND(wxID_ANY, EVT_OPEN_AUDIO_FILE, 
AudacityProject::OnOpenAudioFile)
-    EVT_COMMAND(wxID_ANY, EVT_TOOLBAR_UPDATED, 
AudacityProject::OnToolBarUpdate)
-    EVT_COMMAND(wxID_ANY, EVT_CAPTURE_KEYBOARD, 
AudacityProject::OnCaptureKeyboard)
-    EVT_COMMAND(wxID_ANY, EVT_RELEASE_KEYBOARD, 
AudacityProject::OnReleaseKeyboard)
-    //mchinen:multithreaded calls - may not be threadsafe with CommandEvent: 
may have to change.
-    EVT_COMMAND(wxID_ANY, EVT_ODTASK_UPDATE, AudacityProject::OnODTaskUpdate)
-    EVT_COMMAND(wxID_ANY, EVT_ODTASK_COMPLETE, 
AudacityProject::OnODTaskComplete)
+   EVT_MENU_OPEN(AudacityProject::OnMenuEvent)
+   EVT_MENU_CLOSE(AudacityProject::OnMenuEvent)
+   EVT_MENU(wxID_ANY, AudacityProject::OnMenu)
+   EVT_MOUSE_EVENTS(AudacityProject::OnMouseEvent)
+   EVT_CLOSE(AudacityProject::OnCloseWindow)
+   EVT_SIZE(AudacityProject::OnSize)
+   EVT_MOVE(AudacityProject::OnMove)
+   EVT_ACTIVATE(AudacityProject::OnActivate)
+   EVT_COMMAND_SCROLL_LINEUP(HSBarID, AudacityProject::OnScrollLeftButton)
+   EVT_COMMAND_SCROLL_LINEDOWN(HSBarID, AudacityProject::OnScrollRightButton)
+   EVT_COMMAND_SCROLL(HSBarID, AudacityProject::OnScroll)
+   EVT_COMMAND_SCROLL(VSBarID, AudacityProject::OnScroll)
+   EVT_TIMER(AudacityProjectTimerID, AudacityProject::OnTimer)
+   // Fires for menu with ID #1...first menu defined
+   EVT_UPDATE_UI(1, AudacityProject::OnUpdateUI)
+   EVT_ICONIZE(AudacityProject::OnIconize)
+   EVT_COMMAND(wxID_ANY, EVT_OPEN_AUDIO_FILE, AudacityProject::OnOpenAudioFile)
+   EVT_COMMAND(wxID_ANY, EVT_TOOLBAR_UPDATED, AudacityProject::OnToolBarUpdate)
+   EVT_COMMAND(wxID_ANY, EVT_CAPTURE_KEYBOARD, 
AudacityProject::OnCaptureKeyboard)
+   EVT_COMMAND(wxID_ANY, EVT_RELEASE_KEYBOARD, 
AudacityProject::OnReleaseKeyboard)
+   //mchinen:multithreaded calls - may not be threadsafe with CommandEvent: 
may have to change.
+   EVT_COMMAND(wxID_ANY, EVT_ODTASK_UPDATE, AudacityProject::OnODTaskUpdate)
+   EVT_COMMAND(wxID_ANY, EVT_ODTASK_COMPLETE, 
AudacityProject::OnODTaskComplete)
 END_EVENT_TABLE()
 
 AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
@@ -983,6 +1090,15 @@
 
    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);
+   gPrefs->Read(wxT("/Window/Normal_Width"), &normalRect.width);
+   gPrefs->Read(wxT("/Window/Normal_Height"), &normalRect.height);
+   SetNormalizedWindowState(normalRect);
 }
 
 void AudacityProject::UpdatePrefs()
@@ -1493,10 +1609,26 @@
    event.Skip();
 }
 
+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);
+   event.Skip();
+}
+
 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);
    event.Skip();
 }
 
@@ -1831,7 +1963,8 @@
    //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
+   // Ed Musgrove
+   // 28 September 2009
       SaveWindowSize();
 
    mLastFocusedWindow = NULL;

Index: AudacityApp.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/AudacityApp.cpp,v
retrieving revision 1.251
retrieving revision 1.252
diff -u -d -r1.251 -r1.252
--- AudacityApp.cpp     20 Oct 2009 23:08:26 -0000      1.251
+++ AudacityApp.cpp     1 Nov 2009 19:29:39 -0000       1.252
@@ -315,6 +315,7 @@
    }
    bool validWindowForSaveWindowSize = FALSE;
    AudacityProject * validProject = NULL;
+   bool foundIconizedProject = FALSE;
    size_t numProjects = gAudacityProjects.Count();
    for (size_t i = 0; i < numProjects; i++)
    {
@@ -323,26 +324,65 @@
          validProject = gAudacityProjects[i];
          i = numProjects;
       }
+      else
+         foundIconizedProject =  TRUE;
+
    }
    if (validWindowForSaveWindowSize)
    {
       wxRect windowRect = validProject->GetRect();
+      wxRect normalRect = validProject->GetNormalizedWindowState();
       bool wndMaximized = validProject->IsMaximized();
       gPrefs->Write(wxT("/Window/X"), windowRect.GetX());
       gPrefs->Write(wxT("/Window/Y"), windowRect.GetY());
       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());
+      gPrefs->Write(wxT("/Window/Normal_Height"), normalRect.GetHeight());
+      gPrefs->Write(wxT("/Window/Iconized"), FALSE);
    }
    else
    {
-      wxRect defWndRect;
-      GetDefaultWindowRect(&defWndRect);
-      gPrefs->Write(wxT("/Window/X"), defWndRect.GetX());
-      gPrefs->Write(wxT("/Window/Y"), defWndRect.GetY());
-      gPrefs->Write(wxT("/Window/Width"), defWndRect.GetWidth());
-      gPrefs->Write(wxT("/Window/Height"), defWndRect.GetHeight());
-      gPrefs->Write(wxT("/Window/Maximized"), FALSE);
+      if (foundIconizedProject) {
+         validProject = gAudacityProjects[0];
+         bool wndMaximized = validProject->IsMaximized();
+         wxRect normalRect = validProject->GetNormalizedWindowState();
+         // store only the normal rectangle because the itemized rectangle
+         // makes no sense for an opening project window
+         gPrefs->Write(wxT("/Window/X"), normalRect.GetX());
+         gPrefs->Write(wxT("/Window/Y"), normalRect.GetY());
+         gPrefs->Write(wxT("/Window/Width"), normalRect.GetWidth());
+         gPrefs->Write(wxT("/Window/Height"), normalRect.GetHeight());
+         gPrefs->Write(wxT("/Window/Maximized"), wndMaximized);
+         gPrefs->Write(wxT("/Window/Normal_X"), normalRect.GetX());
+         gPrefs->Write(wxT("/Window/Normal_Y"), normalRect.GetY());
+         gPrefs->Write(wxT("/Window/Normal_Width"), normalRect.GetWidth());
+         gPrefs->Write(wxT("/Window/Normal_Height"), normalRect.GetHeight());
+         gPrefs->Write(wxT("/Window/Iconized"), TRUE);
+      }
+      else {
+         // this would be a very strange case that might possibly occur on the 
Mac
+         // Audacity would have to be running with no projects open
+         // in this case we are going to write only the default values
+         wxRect defWndRect;
+         GetDefaultWindowRect(&defWndRect);
+         gPrefs->Write(wxT("/Window/X"), defWndRect.GetX());
+         gPrefs->Write(wxT("/Window/Y"), defWndRect.GetY());
+         gPrefs->Write(wxT("/Window/Width"), defWndRect.GetWidth());
+         gPrefs->Write(wxT("/Window/Height"), defWndRect.GetHeight());
+         gPrefs->Write(wxT("/Window/Maximized"), FALSE);
+         gPrefs->Write(wxT("/Window/Normal_X"), defWndRect.GetX());
+         gPrefs->Write(wxT("/Window/Normal_Y"), defWndRect.GetY());
+         gPrefs->Write(wxT("/Window/Normal_Width"), defWndRect.GetWidth());
+         gPrefs->Write(wxT("/Window/Normal_Height"), defWndRect.GetHeight());
+         gPrefs->Write(wxT("/Window/Iconized"), FALSE);
+      }
    }
    wxGetApp().SetWindowRectAlreadySaved(TRUE);
 }


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Audacity-cvs mailing list
Audacity-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to