|
@@ -70,6 +70,12 @@ __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
|
|
#define GetProcAddress (void *)GetProcAddress
|
|
#define GetProcAddress (void *)GetProcAddress
|
|
#endif
|
|
#endif
|
|
|
|
|
|
|
|
+typedef struct {
|
|
|
|
+ int count;
|
|
|
|
+ int screen;
|
|
|
|
+ HMONITOR monitor;
|
|
|
|
+} EnumScreenData;
|
|
|
|
+
|
|
typedef struct {
|
|
typedef struct {
|
|
int count;
|
|
int count;
|
|
int screen;
|
|
int screen;
|
|
@@ -82,6 +88,16 @@ typedef struct {
|
|
Point2 pos;
|
|
Point2 pos;
|
|
} EnumPosData;
|
|
} EnumPosData;
|
|
|
|
|
|
|
|
+static BOOL CALLBACK _MonitorEnumProcScreen(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
|
|
|
|
+ EnumScreenData *data = (EnumScreenData *)dwData;
|
|
|
|
+ if (data->monitor == hMonitor) {
|
|
|
|
+ data->screen = data->count;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ data->count++;
|
|
|
|
+ return TRUE;
|
|
|
|
+}
|
|
|
|
+
|
|
static BOOL CALLBACK _MonitorEnumProcSize(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
|
|
static BOOL CALLBACK _MonitorEnumProcSize(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
|
|
EnumSizeData *data = (EnumSizeData *)dwData;
|
|
EnumSizeData *data = (EnumSizeData *)dwData;
|
|
if (data->count == data->screen) {
|
|
if (data->count == data->screen) {
|
|
@@ -1354,7 +1370,13 @@ Error OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int
|
|
|
|
|
|
*/
|
|
*/
|
|
|
|
|
|
- EnumSizeData data = { 0, 0, Size2() };
|
|
|
|
|
|
+ // Get the primary monitor without providing hwnd
|
|
|
|
+ // Solution from https://devblogs.microsoft.com/oldnewthing/20070809-00/?p=25643
|
|
|
|
+ const POINT ptZero = { 0, 0 };
|
|
|
|
+ EnumScreenData primary_data = { 0, 0, MonitorFromPoint(ptZero, MONITOR_DEFAULTTOPRIMARY) };
|
|
|
|
+ EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcScreen, (LPARAM)&primary_data);
|
|
|
|
+
|
|
|
|
+ EnumSizeData data = { 0, primary_data.screen, Size2() };
|
|
EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcSize, (LPARAM)&data);
|
|
EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcSize, (LPARAM)&data);
|
|
|
|
|
|
WindowRect.right = data.size.width;
|
|
WindowRect.right = data.size.width;
|
|
@@ -1898,22 +1920,6 @@ int OS_Windows::get_screen_count() const {
|
|
return data;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
|
|
-typedef struct {
|
|
|
|
- int count;
|
|
|
|
- int screen;
|
|
|
|
- HMONITOR monitor;
|
|
|
|
-} EnumScreenData;
|
|
|
|
-
|
|
|
|
-static BOOL CALLBACK _MonitorEnumProcScreen(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) {
|
|
|
|
- EnumScreenData *data = (EnumScreenData *)dwData;
|
|
|
|
- if (data->monitor == hMonitor) {
|
|
|
|
- data->screen = data->count;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- data->count++;
|
|
|
|
- return TRUE;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
int OS_Windows::get_current_screen() const {
|
|
int OS_Windows::get_current_screen() const {
|
|
EnumScreenData data = { 0, 0, MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST) };
|
|
EnumScreenData data = { 0, 0, MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST) };
|
|
EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcScreen, (LPARAM)&data);
|
|
EnumDisplayMonitors(NULL, NULL, _MonitorEnumProcScreen, (LPARAM)&data);
|