[idd] ensure the only active monitor is the IDD
Some checks failed
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Has been cancelled
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Has been cancelled
build / module (push) Has been cancelled
build / host-linux (push) Has been cancelled
build / host-windows-cross (push) Has been cancelled
build / host-windows-native (push) Has been cancelled
build / idd (push) Has been cancelled
build / obs (clang) (push) Has been cancelled
build / obs (gcc) (push) Has been cancelled
build / docs (push) Has been cancelled

This commit is contained in:
Geoffrey McRae
2026-07-18 22:20:36 +10:00
parent 83209fd3a9
commit ab96c7ea81
5 changed files with 256 additions and 7 deletions

View File

@@ -32,6 +32,11 @@
#define ID_MENU_SHOW_LOG 3000
#define ID_MENU_SHOW_CONFIG 3001
#define ID_DISPLAY_CHECK_TIMER 1
#define DISPLAY_SETTLE_DELAY 250
#define DISPLAY_RETRY_DELAY 1000
#define DISPLAY_CHECK_INTERVAL 5000
ATOM CNotifyWindow::s_atom = 0;
UINT CNotifyWindow::s_taskbarCreated = 0;
@@ -86,6 +91,20 @@ LRESULT CNotifyWindow::handleMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
handleGPUNotification((bool)wParam);
return 0;
case WM_DISPLAYCHANGE:
scheduleDisplayCheck(DISPLAY_SETTLE_DELAY);
return 0;
case WM_TIMER:
if (wParam == ID_DISPLAY_CHECK_TIMER)
{
KillTimer(m_hwnd, ID_DISPLAY_CHECK_TIMER);
const bool success = m_onDisplayChange && m_onDisplayChange();
scheduleDisplayCheck(success ? DISPLAY_CHECK_INTERVAL : DISPLAY_RETRY_DELAY);
return 0;
}
return CWindow::handleMessage(uMsg, wParam, lParam);
default:
if (s_taskbarCreated && uMsg == s_taskbarCreated)
{
@@ -114,6 +133,7 @@ LRESULT CNotifyWindow::onClose()
LRESULT CNotifyWindow::onDestroy()
{
KillTimer(m_hwnd, ID_DISPLAY_CHECK_TIMER);
Shell_NotifyIcon(NIM_DELETE, &m_iconData);
return 0;
}
@@ -239,3 +259,19 @@ void CNotifyWindow::close()
closeRequested = true;
PostMessage(m_hwnd, WM_CLOSE, 0, 0);
}
void CNotifyWindow::scheduleDisplayCheck(UINT delay)
{
if (!m_onDisplayChange)
return;
KillTimer(m_hwnd, ID_DISPLAY_CHECK_TIMER);
if (!SetTimer(m_hwnd, ID_DISPLAY_CHECK_TIMER, delay, NULL))
DEBUG_ERROR_HR(GetLastError(), "Failed to schedule primary display check");
}
void CNotifyWindow::onDisplayChange(std::function<bool()> func)
{
m_onDisplayChange = std::move(func);
scheduleDisplayCheck(DISPLAY_SETTLE_DELAY);
}