windisplay: Fix recursive loop in adjust_z_order

Cherry-pick of 639497310e with alteration
to preserve ABI (replacing an unused bool field)
This commit is contained in:
rdb 2024-11-14 20:21:04 +01:00
parent c8c5ae829d
commit d020b25afe
2 changed files with 11 additions and 2 deletions

View File

@ -1308,6 +1308,11 @@ adjust_z_order() {
void WinGraphicsWindow::
adjust_z_order(WindowProperties::ZOrder last_z_order,
WindowProperties::ZOrder this_z_order) {
// Prevent calling this recursively.
if (_in_adjust_z_order) {
return;
}
HWND order;
bool do_change = false;
@ -1337,8 +1342,10 @@ adjust_z_order(WindowProperties::ZOrder last_z_order,
break;
}
if (do_change) {
_in_adjust_z_order = true;
BOOL result = SetWindowPos(_hWnd, order, 0,0,0,0,
SWP_NOMOVE | SWP_NOSENDCHANGING | SWP_NOSIZE);
_in_adjust_z_order = false;
if (!result) {
windisplay_cat.warning()
<< "SetWindowPos failed.\n";
@ -1630,7 +1637,9 @@ window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) {
if (_hWnd != nullptr) {
handle_reshape();
}
adjust_z_order();
if (!_in_adjust_z_order) {
adjust_z_order();
}
return 0;
case WM_PAINT:

View File

@ -173,7 +173,7 @@ private:
bool _ime_open;
bool _ime_active;
bool _tracking_mouse_leaving;
bool _bCursor_in_WindowClientArea;
bool _in_adjust_z_order = false;
HANDLE _input_device_handle[32];
HCURSOR _cursor;
DEVMODE _fullscreen_display_mode;