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. LL: This should NOT need to be this complicated...FIXME
| 156 | // |
| 157 | // LL: This should NOT need to be this complicated...FIXME |
| 158 | void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized) |
| 159 | { |
| 160 | int inc = 25; |
| 161 | |
| 162 | wxRect defaultRect; |
| 163 | GetDefaultWindowRect(&defaultRect); |
| 164 | |
| 165 | *pMaximized = ProjectWindowMaximized.Read(); |
| 166 | *pIconized = ProjectWindowIconized.Read(); |
| 167 | |
| 168 | wxRect windowRect; |
| 169 | windowRect.x = ProjectWindowX.ReadWithDefault(defaultRect.x); |
| 170 | windowRect.y = ProjectWindowY.ReadWithDefault(defaultRect.y); |
| 171 | windowRect.width = ProjectWindowWidth.ReadWithDefault(defaultRect.width); |
| 172 | windowRect.height = ProjectWindowHeight.ReadWithDefault(defaultRect.height); |
| 173 | |
| 174 | wxRect normalRect; |
| 175 | normalRect.x = ProjectWindowNormalX.ReadWithDefault(defaultRect.x); |
| 176 | normalRect.y = ProjectWindowNormalY.ReadWithDefault(defaultRect.y); |
| 177 | normalRect.width = ProjectWindowNormalWidth.ReadWithDefault(defaultRect.width); |
| 178 | normalRect.height = ProjectWindowNormalHeight.ReadWithDefault(defaultRect.height); |
| 179 | |
| 180 | // Workaround 2.1.1 and earlier bug on OSX...affects only normalRect, but let's just |
| 181 | // validate for all rects and plats |
| 182 | if (normalRect.width == 0 || normalRect.height == 0) { |
| 183 | normalRect = defaultRect; |
| 184 | } |
| 185 | if (windowRect.width == 0 || windowRect.height == 0) { |
| 186 | windowRect = defaultRect; |
| 187 | } |
| 188 | |
| 189 | |
| 190 | wxRect screenRect( wxGetClientDisplayRect()); |
| 191 | #if defined(__WXMAC__) |
| 192 | |
| 193 | // On OSX, the top of the window should never be less than the menu height, |
| 194 | // so something is amiss if it is |
| 195 | if (normalRect.y < screenRect.y) { |
| 196 | normalRect = defaultRect; |
| 197 | } |
| 198 | if (windowRect.y < screenRect.y) { |
| 199 | windowRect = defaultRect; |
| 200 | } |
| 201 | #endif |
| 202 | |
| 203 | // IF projects empty, THEN it's the first window. |
| 204 | // It lands where the config says it should, and can straddle screen. |
| 205 | if (AllProjects{}.empty()) { |
| 206 | if (*pMaximized || *pIconized) { |
| 207 | *nextRect = normalRect; |
| 208 | } |
| 209 | else { |
| 210 | *nextRect = windowRect; |
| 211 | } |
| 212 | // Resize, for example if one monitor that was on is now off. |
| 213 | if (!CornersOnScreen( wxRect(*nextRect).Deflate( 32, 32 ))) { |
| 214 | *nextRect = defaultRect; |
| 215 | } |
no test coverage detected