Windows: Fix flicker/animation when transitioning from fullscreen to maximized

This commit is contained in:
dannye 2024-11-09 17:11:16 -06:00 committed by ManoloFLTK
parent 2337214e4e
commit 29531fa421

View File

@ -577,13 +577,6 @@ void Fl_WinAPI_Window_Driver::fullscreen_on() {
}
static void delayed_maximize(Fl_Window *win){
Fl::remove_check((Fl_Timeout_Handler)delayed_maximize, win);
win->un_maximize();
win->maximize();
}
void Fl_WinAPI_Window_Driver::fullscreen_off(int X, int Y, int W, int H) {
pWindow->_clear_fullscreen();
DWORD style = GetWindowLong(fl_xid(pWindow), GWL_STYLE);
@ -606,6 +599,8 @@ void Fl_WinAPI_Window_Driver::fullscreen_off(int X, int Y, int W, int H) {
break;
}
Fl_X::flx(pWindow)->xid = (fl_uintptr_t)xid;
SetWindowLong(fl_xid(pWindow), GWL_STYLE, style);
if (!pWindow->maximize_active()) {
// compute window position and size in scaled units
float s = Fl::screen_driver()->scale(screen_num());
int scaledX = int(ceil(X*s)), scaledY= int(ceil(Y*s)), scaledW = int(ceil(W*s)), scaledH = int(ceil(H*s));
@ -617,11 +612,15 @@ void Fl_WinAPI_Window_Driver::fullscreen_off(int X, int Y, int W, int H) {
}
scaledW += bx*2;
scaledH += by*2+bt;
SetWindowLong(fl_xid(pWindow), GWL_STYLE, style);
SetWindowPos(fl_xid(pWindow), 0, scaledX, scaledY, scaledW, scaledH,
SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED);
} else {
int WX, WY, WW, WH;
((Fl_WinAPI_Screen_Driver*)Fl::screen_driver())->screen_xywh_unscaled(WX, WY, WW, WH, screen_num());
SetWindowPos(fl_xid(pWindow), 0, WX, WY, WW, WH,
SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED);
}
Fl::handle(FL_FULLSCREEN, pWindow);
if (pWindow->maximize_active()) Fl::add_check((Fl_Timeout_Handler)delayed_maximize, pWindow);
}