[PATCH] user32: Keep toplevel minimized windows offscreen if they're already.

Zhiyi Zhang zzhang at codeweavers.com
Thu Feb 4 09:26:41 CST 2021


Hi Gabriel,

The patch seems okay to me. It would be better if you put the tests in a separate patch.

Thanks,
Zhiyi

On 8/25/20 11:05 PM, Gabriel Ivăncescu wrote:
> Some applications (e.g. Lego Worlds) use (-32000,-32000) to determine
> whether a window is minimized.
>
> Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
> ---
>  dlls/user32/tests/win.c | 52 +++++++++++++++++++++++++++++++++++++++++
>  dlls/user32/winpos.c    |  8 +++++++
>  2 files changed, 60 insertions(+)
>
> diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
> index 843da89..19a0db2 100644
> --- a/dlls/user32/tests/win.c
> +++ b/dlls/user32/tests/win.c
> @@ -11593,6 +11593,58 @@ todo_wine
>      ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
>          wine_dbgstr_rect(&wp.rcNormalPosition));
>  
> +    wp.flags = WPF_SETMINPOSITION;
> +    wp.showCmd = SW_NORMAL;
> +    wp.ptMinPosition.x = wp.ptMinPosition.y = 100;
> +    wp.ptMaxPosition.x = wp.ptMaxPosition.y = 100;
> +    wp.rcNormalPosition = orig;
> +    ret = SetWindowPlacement(hwnd, &wp);
> +    ok(ret, "failed to set window placement, error %u\n", GetLastError());
> +
> +    ShowWindow(hwnd, SW_MINIMIZE);
> +
> +    ret = GetWindowPlacement(hwnd, &wp);
> +    ok(ret, "failed to get window placement, error %u\n", GetLastError());
> +    ok(wp.showCmd == SW_SHOWMINIMIZED, "got show cmd %u\n", wp.showCmd);
> +    ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
> +        "got minimized pos (%d,%d)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
> +todo_wine
> +    ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
> +        "got maximized pos (%d,%d)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
> +    ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
> +        wine_dbgstr_rect(&wp.rcNormalPosition));
> +
> +    ret = SetWindowPos(hwnd, NULL, 100, 100, 151, 151, SWP_NOACTIVATE | SWP_NOZORDER);
> +    ok(ret, "failed to set window pos, error %u\n", GetLastError());
> +
> +    ret = GetWindowPlacement(hwnd, &wp);
> +    ok(ret, "failed to get window placement, error %u\n", GetLastError());
> +    ok(wp.showCmd == SW_SHOWMINIMIZED, "got show cmd %u\n", wp.showCmd);
> +    ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
> +        "got minimized pos (%d,%d)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
> +todo_wine
> +    ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
> +        "got maximized pos (%d,%d)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
> +    ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
> +        wine_dbgstr_rect(&wp.rcNormalPosition));
> +    GetWindowRect(hwnd, &rect);
> +    ok(rect.left == -32000 && rect.top == -32000, "got window rect %s\n", wine_dbgstr_rect(&rect));
> +
> +    ShowWindow(hwnd, SW_SHOWNORMAL);
> +
> +    ret = GetWindowPlacement(hwnd, &wp);
> +    ok(ret, "failed to get window placement, error %u\n", GetLastError());
> +    ok(wp.showCmd == SW_NORMAL, "got show cmd %u\n", wp.showCmd);
> +    ok(wp.ptMinPosition.x == -32000 && wp.ptMinPosition.y == -32000,
> +        "got minimized pos (%d,%d)\n", wp.ptMinPosition.x, wp.ptMinPosition.y);
> +todo_wine
> +    ok(wp.ptMaxPosition.x == -1 && wp.ptMaxPosition.y == -1,
> +        "got maximized pos (%d,%d)\n", wp.ptMaxPosition.x, wp.ptMaxPosition.y);
> +    ok(EqualRect(&wp.rcNormalPosition, &orig), "got normal pos %s\n",
> +        wine_dbgstr_rect(&wp.rcNormalPosition));
> +    GetWindowRect(hwnd, &rect);
> +    ok(EqualRect(&rect, &orig), "got window rect %s\n", wine_dbgstr_rect(&rect));
> +
>      DestroyWindow(hwnd);
>  }
>  
> diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c
> index b45b74c..3ccd939 100644
> --- a/dlls/user32/winpos.c
> +++ b/dlls/user32/winpos.c
> @@ -1688,6 +1688,14 @@ static BOOL SWP_DoWinPosChanging( WINDOWPOS *pWinpos, RECT *old_window_rect, REC
>      }
>      if (!(pWinpos->flags & SWP_NOMOVE))
>      {
> +        /* If the window is toplevel minimized off-screen, force keep it there */
> +        if ((wndPtr->dwStyle & WS_MINIMIZE) &&
> +             wndPtr->window_rect.left <= -32000 && wndPtr->window_rect.top <= -32000 &&
> +            (!wndPtr->parent || wndPtr->parent == GetDesktopWindow()))
> +        {
> +            pWinpos->x = -32000;
> +            pWinpos->y = -32000;
> +        }
>          new_window_rect->left    = pWinpos->x;
>          new_window_rect->top     = pWinpos->y;
>          new_window_rect->right  += pWinpos->x - old_window_rect->left;





More information about the wine-devel mailing list