[KBM] Open Remap Shortcuts/Remap Keyboard window on the same monitor as Settings. (#8325)

This commit is contained in:
Seraphima Zykova
2020-12-10 18:28:44 +03:00
committed by GitHub
parent 709d42d3e7
commit 8a7824924a
9 changed files with 88 additions and 57 deletions

View File

@@ -2,6 +2,7 @@
#include <common/common.h>
#include <common/dpi_aware.h>
#include <common/monitor_utils.h>
#include <common/on_thread_executor.h>
#include <common/window_helpers.h>
@@ -636,7 +637,7 @@ void FancyZones::ToggleEditor() noexcept
params += std::to_wstring(spanZonesAcrossMonitors) + divider; /* Span zones */
std::vector<std::pair<HMONITOR, MONITORINFOEX>> allMonitors;
allMonitors = FancyZonesUtils::GetAllMonitorInfo<&MONITORINFOEX::rcWork>();
allMonitors = GetAllMonitorInfo<&MONITORINFOEX::rcWork>();
// device id map
std::unordered_map<std::wstring, DWORD> displayDeviceIdxMap;
@@ -1116,7 +1117,7 @@ bool FancyZones::OnSnapHotkeyBasedOnPosition(HWND window, DWORD vkCode) noexcept
current = MonitorFromWindow(window, MONITOR_DEFAULTTONULL);
}
auto allMonitors = FancyZonesUtils::GetAllMonitorRects<&MONITORINFOEX::rcWork>();
auto allMonitors = GetAllMonitorRects<&MONITORINFOEX::rcWork>();
if (current && allMonitors.size() > 1 && m_settings->GetSettings()->moveWindowAcrossMonitors)
{

View File

@@ -1,6 +1,7 @@
#pragma once
#include "gdiplus.h"
#include <common/monitor_utils.h>
#include <common/string_utils.h>
namespace FancyZonesDataTypes
@@ -114,50 +115,6 @@ namespace FancyZonesUtils
return static_cast<BYTE>(opacity * 2.55);
}
template<RECT MONITORINFO::*member>
std::vector<std::pair<HMONITOR, RECT>> GetAllMonitorRects()
{
using result_t = std::vector<std::pair<HMONITOR, RECT>>;
result_t result;
auto enumMonitors = [](HMONITOR monitor, HDC hdc, LPRECT pRect, LPARAM param) -> BOOL {
MONITORINFOEX mi;
mi.cbSize = sizeof(mi);
result_t& result = *reinterpret_cast<result_t*>(param);
if (GetMonitorInfo(monitor, &mi))
{
result.push_back({ monitor, mi.*member });
}
return TRUE;
};
EnumDisplayMonitors(NULL, NULL, enumMonitors, reinterpret_cast<LPARAM>(&result));
return result;
}
template<RECT MONITORINFO::*member>
std::vector<std::pair<HMONITOR, MONITORINFOEX>> GetAllMonitorInfo()
{
using result_t = std::vector<std::pair<HMONITOR, MONITORINFOEX>>;
result_t result;
auto enumMonitors = [](HMONITOR monitor, HDC hdc, LPRECT pRect, LPARAM param) -> BOOL {
MONITORINFOEX mi;
mi.cbSize = sizeof(mi);
result_t& result = *reinterpret_cast<result_t*>(param);
if (GetMonitorInfo(monitor, &mi))
{
result.push_back({ monitor, mi });
}
return TRUE;
};
EnumDisplayMonitors(NULL, NULL, enumMonitors, reinterpret_cast<LPARAM>(&result));
return result;
}
template<RECT MONITORINFO::*member>
RECT GetAllMonitorsCombinedRect()
{