Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/apps/mplayerc/MainFrm.cpp')
-rw-r--r--src/apps/mplayerc/MainFrm.cpp230
1 files changed, 108 insertions, 122 deletions
diff --git a/src/apps/mplayerc/MainFrm.cpp b/src/apps/mplayerc/MainFrm.cpp
index 7b0e93309..4aad24334 100644
--- a/src/apps/mplayerc/MainFrm.cpp
+++ b/src/apps/mplayerc/MainFrm.cpp
@@ -4505,8 +4505,6 @@ void CMainFrame::OnFileReopen()
OpenCurPlaylistItem();
}
-void RecurseAddDir(CString path, CAtlList<CString>* sl);
-
void CMainFrame::OnDropFiles(HDROP hDropInfo)
{
SetForegroundWindow();
@@ -9225,10 +9223,19 @@ static BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, LPRECT l
void CMainFrame::SetDefaultWindowRect(int iMonitor)
{
AppSettings& s = AfxGetAppSettings();
+ int w, h, x, y;
+ if(s.HasFixedWindowSize())
{
- boolean m_center = true;
-
+ w = s.fixedWindowSize.cx;
+ h = s.fixedWindowSize.cy;
+ }
+ else if(s.fRememberWindowSize)
+ {
+ w = s.rcLastWindowPos.Width();
+ h = s.rcLastWindowPos.Height();
+ }
+ else {
CRect r1, r2;
GetClientRect(&r1);
m_wndView.GetClientRect(&r2);
@@ -9242,32 +9249,24 @@ void CMainFrame::SetDefaultWindowRect(int iMonitor)
DWORD style = GetStyle();
- MENUBARINFO mbi;
- memset(&mbi, 0, sizeof(mbi));
- mbi.cbSize = sizeof(mbi);
- ::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
-
- int w = _DEFCLIENTW + ((style&WS_THICKFRAME) ? GetSystemMetrics(SM_CXSIZEFRAME)*2 : 0)
- + r1.Width() - r2.Width();
- int h = _DEFCLIENTH + ((style&WS_THICKFRAME) ? GetSystemMetrics(SM_CYSIZEFRAME)*2 : 0)
- + (mbi.rcBar.bottom - mbi.rcBar.top)
- + r1.Height() - r2.Height()
- + 1; // ???
-// + 2; // ???
- if(style&WS_CAPTION) h += GetSystemMetrics(SM_CYCAPTION);
+ w = _DEFCLIENTW + ((style&WS_THICKFRAME) ? GetSystemMetrics(SM_CXSIZEFRAME)*2 : 0)
+ + r1.Width() - r2.Width();
+ h = _DEFCLIENTH + ((style&WS_THICKFRAME) ? GetSystemMetrics(SM_CYSIZEFRAME)*2 : 0)
+ + r1.Height() - r2.Height();
- if(s.HasFixedWindowSize())
- {
- w = s.fixedWindowSize.cx;
- h = s.fixedWindowSize.cy;
- }
- else if(s.fRememberWindowSize)
- {
- w = s.rcLastWindowPos.Width();
- h = s.rcLastWindowPos.Height();
- m_center = false;
+ if(style&WS_CAPTION) {
+ h += GetSystemMetrics(SM_CYCAPTION); // if we have caption then we have menu too
+ h += GetSystemMetrics(SM_CYMENU);
}
+ }
+ if(s.fRememberWindowPos)
+ {
+ x = s.rcLastWindowPos.TopLeft().x;
+ y = s.rcLastWindowPos.TopLeft().y;
+ }
+ else
+ {
HMONITOR hMonitor = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
if(iMonitor > 0)
@@ -9282,48 +9281,31 @@ void CMainFrame::SetDefaultWindowRect(int iMonitor)
mi.cbSize = sizeof(MONITORINFO);
GetMonitorInfo(hMonitor, &mi);
- int x = (mi.rcWork.left+mi.rcWork.right-w)/2;
- int y = (mi.rcWork.top+mi.rcWork.bottom-h)/2;
-
- if(s.fRememberWindowPos)
- {
- CRect r = s.rcLastWindowPos;
-// x = r.CenterPoint().x - w/2;
-// y = r.CenterPoint().y - h/2;
- x = r.TopLeft().x;
- y = r.TopLeft().y;
- m_center = false;
- }
-
- UINT lastWindowType = s.lastWindowType;
-
- MoveWindow(x, y, w, h);
+ x = (mi.rcWork.left+mi.rcWork.right-w)/2; // Center main window
+ y = (mi.rcWork.top+mi.rcWork.bottom-h)/2; // no need to call CenterWindow()
+ }
- // Center main window ...
- if(m_center) CenterWindow();
+ UINT lastWindowType = s.lastWindowType;
+ MoveWindow(x, y, w, h);
- // Waffs : fullscreen command line
- if(!(s.nCLSwitches&CLSW_ADD) && (s.nCLSwitches&CLSW_FULLSCREEN) && !s.slFiles.IsEmpty())
- {
- ToggleFullscreen(true, true);
- SetCursor(NULL);
- AfxGetAppSettings().nCLSwitches &= ~CLSW_FULLSCREEN;
- m_fFirstFSAfterLaunchOnFS = true;
- }
+ // Waffs : fullscreen command line
+ if(!(s.nCLSwitches&CLSW_ADD) && (s.nCLSwitches&CLSW_FULLSCREEN) && !s.slFiles.IsEmpty())
+ {
+ ToggleFullscreen(true, true);
+ SetCursor(NULL);
+ AfxGetAppSettings().nCLSwitches &= ~CLSW_FULLSCREEN;
+ m_fFirstFSAfterLaunchOnFS = true;
+ }
- if(s.fRememberWindowSize && s.fRememberWindowPos)
- {
- WINDOWPLACEMENT wp;
- memset(&wp, 0, sizeof(wp));
- wp.length = sizeof(WINDOWPLACEMENT);
- if(lastWindowType == SIZE_MAXIMIZED)
- ShowWindow(SW_MAXIMIZE);
- else if(lastWindowType == SIZE_MINIMIZED)
- ShowWindow(SW_MINIMIZE);
+ if(s.fRememberWindowSize && s.fRememberWindowPos)
+ {
+ if(lastWindowType == SIZE_MAXIMIZED)
+ ShowWindow(SW_MAXIMIZE);
+ else if(lastWindowType == SIZE_MINIMIZED)
+ ShowWindow(SW_MINIMIZE);
- // Casimir666 : if fullscreen was on, put it on back
- if (!m_fFullScreen && s.fLastFullScreen) ToggleFullscreen(true, true);
- }
+ // Casimir666 : if fullscreen was on, put it on back
+ if (!m_fFullScreen && s.fLastFullScreen) ToggleFullscreen(true, true);
}
if(s.fHideCaptionMenu)
@@ -9344,53 +9326,51 @@ void CMainFrame::RestoreDefaultWindowRect()
// && (GetExStyle()&WS_EX_APPWINDOW)
&& !s.fRememberWindowSize)
{
- CRect r1, r2;
- GetClientRect(&r1);
- m_wndView.GetClientRect(&r2);
-
- CSize logosize = m_wndView.GetLogoSize();
- int _DEFCLIENTW = max(logosize.cx, DEFCLIENTW);
- int _DEFCLIENTH = max(logosize.cy, DEFCLIENTH);
-
- DWORD style = GetStyle();
-
- MENUBARINFO mbi;
- memset(&mbi, 0, sizeof(mbi));
- mbi.cbSize = sizeof(mbi);
- ::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
-
- int w = _DEFCLIENTW + ((style&WS_THICKFRAME) ? GetSystemMetrics(SM_CXSIZEFRAME)*2 : 0)
- + r1.Width() - r2.Width();
- int h = _DEFCLIENTH + ((style&WS_THICKFRAME) ? GetSystemMetrics(SM_CYSIZEFRAME)*2 : 0)
- + (mbi.rcBar.bottom - mbi.rcBar.top)
- + r1.Height() - r2.Height()
- + 1; // ???
-// + 2; // ???
- if(style&WS_CAPTION) h += GetSystemMetrics(SM_CYCAPTION);
+ int x, y, w, h;
if(s.HasFixedWindowSize())
{
w = s.fixedWindowSize.cx;
h = s.fixedWindowSize.cy;
}
+ else
+ {
+ CRect r1, r2;
+ GetClientRect(&r1);
+ m_wndView.GetClientRect(&r2);
- CRect r;
- GetWindowRect(r);
+ CSize logosize = m_wndView.GetLogoSize();
+ int _DEFCLIENTW = max(logosize.cx, DEFCLIENTW);
+ int _DEFCLIENTH = max(logosize.cy, DEFCLIENTH);
- int x = r.CenterPoint().x - w/2;
- int y = r.CenterPoint().y - h/2;
+ DWORD style = GetStyle();
+ w = _DEFCLIENTW + ((style&WS_THICKFRAME) ? GetSystemMetrics(SM_CXSIZEFRAME)*2 : 0)
+ + r1.Width() - r2.Width();
+ h = _DEFCLIENTH + ((style&WS_THICKFRAME) ? GetSystemMetrics(SM_CYSIZEFRAME)*2 : 0)
+ + r1.Height() - r2.Height();
+
+ if(style&WS_CAPTION)
+ {
+ h += GetSystemMetrics(SM_CYCAPTION);
+ h += GetSystemMetrics(SM_CYMENU);
+ }
+ }
if(s.fRememberWindowPos)
{
- CRect r = s.rcLastWindowPos;
+ x = s.rcLastWindowPos.TopLeft().x;
+ y = s.rcLastWindowPos.TopLeft().y;
+ }
+ else
+ {
+ CRect r;
+ GetWindowRect(r);
- x = r.TopLeft().x;
- y = r.TopLeft().y;
+ x = r.CenterPoint().x - w/2; // Center window here
+ y = r.CenterPoint().y - h/2; // no need to call CenterWindow()
}
MoveWindow(x, y, w, h);
-
- if(!s.fRememberWindowPos) CenterWindow();
}
}
@@ -9407,6 +9387,7 @@ void CMainFrame::SetPlaybackMode(int iNewStatus)
if (m_wndNavigationBar.IsWindowVisible() && GetPlaybackMode() != PM_CAPTURE)
ShowControlBar(&m_wndNavigationBar, !m_wndNavigationBar.IsWindowVisible(), TRUE);
}
+
CSize CMainFrame::GetVideoSize()
{
bool fKeepAspectRatio = AfxGetAppSettings().fKeepAspectRatio;
@@ -9493,7 +9474,7 @@ void CMainFrame::ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasT
HMONITOR hm_cur = MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST);
CMonitors monitors;
- bool m_PlayListBarVisible = false;
+ static bool m_PlayListBarVisible = false;
if(!m_fFullScreen)
{
@@ -9557,7 +9538,7 @@ void CMainFrame::ToggleFullscreen(bool fToNearest, bool fSwitchScreenResWhenHasT
ModifyStyleEx(dwRemoveEx, dwAddEx, SWP_NOZORDER);
::SetMenu(m_hWnd, hMenu);
- bool m_Change_Monitor = false;
+ static bool m_Change_Monitor = false;
// try disable shader when move from one monitor to other ...
if(m_fFullScreen)
{
@@ -9931,6 +9912,7 @@ void CMainFrame::ZoomVideoWindow(double scale)
OnGetMinMaxInfo(&mmi);
CRect r;
+ GetWindowRect(r);
int w = 0, h = 0;
if(!m_fAudioOnly)
@@ -9950,14 +9932,7 @@ void CMainFrame::ZoomVideoWindow(double scale)
+ r1.Width() - r2.Width()
+ lWidth;
- // This doesn't give correct menu pixel size
- //MENUBARINFO mbi;
- //memset(&mbi, 0, sizeof(mbi));
- //mbi.cbSize = sizeof(mbi);
- //::GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi);
-
h = ((style&WS_THICKFRAME) ? GetSystemMetrics(SM_CYSIZEFRAME)*2 : 0)
- //+ (mbi.rcBar.bottom - mbi.rcBar.top)
+ r1.Height() - r2.Height()
+ lHeight;
@@ -9966,20 +9941,13 @@ void CMainFrame::ZoomVideoWindow(double scale)
h += GetSystemMetrics( SM_CYCAPTION );
// If we have a caption then we have a menu bar
h += GetSystemMetrics( SM_CYMENU );
- // Do not use magic values please !
- //w += 2; h += 2; // for the 1 pixel wide sunken frame
- //w += 2; h += 3; // for the inner black border
}
- GetWindowRect(r);
-
w = max(w, mmi.ptMinTrackSize.x);
h = max(h, mmi.ptMinTrackSize.y);
}
else
{
- GetWindowRect(r);
-
w = r.Width(); // mmi.ptMinTrackSize.x;
h = mmi.ptMinTrackSize.y;
}
@@ -9991,22 +9959,40 @@ void CMainFrame::ZoomVideoWindow(double scale)
w = min(w, (mi.rcWork.right - mi.rcWork.left));
h = min(h, (mi.rcWork.bottom - mi.rcWork.top));
- // center window
if(!s.fRememberWindowPos)
{
- CPoint cp = r.CenterPoint();
- r.left = cp.x - w/2;
- r.top = cp.y - h/2;
+ bool isSnapped = false;
+
+ if(s.fSnapToDesktopEdges) { // check if snapped to edges
+ isSnapped = (r.left == mi.rcWork.left) || (r.top == mi.rcWork.top)
+ || (r.right == mi.rcWork.right) || (r.bottom == mi.rcWork.bottom);
+ }
+
+ if(isSnapped) // prefer left, top snap to right, bottom snap
+ {
+ if(r.left == mi.rcWork.left) {}
+ else if(r.right == mi.rcWork.right)
+ {
+ r.left = r.right - w;
+ }
+
+ if(r.top == mi.rcWork.top) {}
+ else if(r.bottom == mi.rcWork.bottom)
+ {
+ r.top = r.bottom - h;
+ }
+ }
+ else // center window
+ {
+ CPoint cp = r.CenterPoint();
+ r.left = cp.x - w/2;
+ r.top = cp.y - h/2;
+ }
}
r.right = r.left + w;
r.bottom = r.top + h;
- /*
- MONITORINFO mi;
- mi.cbSize = sizeof(MONITORINFO);
- GetMonitorInfo(MonitorFromWindow(m_hWnd, MONITOR_DEFAULTTONEAREST), &mi);
- */
if(r.right > mi.rcWork.right) r.OffsetRect(mi.rcWork.right-r.right, 0);
if(r.left < mi.rcWork.left) r.OffsetRect(mi.rcWork.left-r.left, 0);
if(r.bottom > mi.rcWork.bottom) r.OffsetRect(0, mi.rcWork.bottom-r.bottom);