Partial fix: Unable to control position of first window on Windows with multiple screens (#1432)
Build and Test / build-linux (push) Has been cancelled
Build and Test / build-wayland (push) Has been cancelled
Build and Test / build-macos (push) Has been cancelled
Build and Test / build-windows (push) Has been cancelled

Screen configurations mixing screens with distinct scale factors may need additional support.
This commit is contained in:
ManoloFLTK
2026-05-11 08:45:17 +02:00
parent 1cafc6a0d2
commit cbcceb2996
2 changed files with 8 additions and 3 deletions
+4 -2
View File
@@ -2229,8 +2229,10 @@ void Fl_WinAPI_Window_Driver::makeWindow() {
int nscreen = 0;
if (w->parent()) {
nscreen = Fl_Window_Driver::driver(w->top_window())->screen_num();
} else if (Fl_Window_Driver::driver(w)->force_position() && Fl_WinAPI_Window_Driver::driver(w)->screen_num_ >= 0) {
nscreen = Fl_Window_Driver::driver(w)->screen_num();
} else if (Fl_Window_Driver::driver(w)->force_position()) {
if (Fl_WinAPI_Window_Driver::driver(w)->screen_num_ >= 0)
nscreen = Fl_WinAPI_Window_Driver::driver(w)->screen_num_;
else nscreen = Fl::screen_num(w->x(), w->y());
} else {
Fl_Window *hint = Fl::first_window();
if (hint) {
@@ -111,7 +111,7 @@ void Fl_WinAPI_Screen_Driver::init()
// we do a run-time check for the required functions...
HMODULE hMod = GetModuleHandle("USER32.DLL");
if (hMod) {
if (hMod && num_screens < 0) {
// check that EnumDisplayMonitors is available
fl_edm_func fl_edm = (fl_edm_func)GetProcAddress(hMod, "EnumDisplayMonitors");
@@ -125,6 +125,9 @@ void Fl_WinAPI_Screen_Driver::init()
// NOTE: num_screens is incremented in screen_cb so we must first reset it here...
num_screens = 0;
fl_edm(0, 0, screen_cb, (LPARAM)this);
/*fprintf(stderr,"Screen coordinates as seen by Windows: num_screens=%d\n",num_screens);
for(int i=0; i<num_screens;i++)
fprintf(stderr,"screen_cb: n=%d left=%d right=%d top=%d bottom=%d\n",i,screens[i].left, screens[i].right,screens[i].top, screens[i].bottom);*/
return;
}
}