mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 11:11:08 +00:00
d3d11videosink: Fix toggling between fullscreen and maximized
Use GetWindowPlacement() and SetWindowPlacement() APIs to remember and restore window status, such as maximized, position, restore position, etc. Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/3016 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5462>
This commit is contained in:
parent
0563a25494
commit
15248d8b84
1 changed files with 7 additions and 13 deletions
|
@ -89,8 +89,8 @@ struct _GstD3D11WindowWin32
|
||||||
gint pending_move_window;
|
gint pending_move_window;
|
||||||
|
|
||||||
/* fullscreen related */
|
/* fullscreen related */
|
||||||
RECT restore_rect;
|
|
||||||
LONG restore_style;
|
LONG restore_style;
|
||||||
|
WINDOWPLACEMENT restore_placement;
|
||||||
|
|
||||||
/* Handle set_render_rectangle */
|
/* Handle set_render_rectangle */
|
||||||
GstVideoRectangle render_rect;
|
GstVideoRectangle render_rect;
|
||||||
|
@ -176,6 +176,7 @@ static void
|
||||||
gst_d3d11_window_win32_init (GstD3D11WindowWin32 * self)
|
gst_d3d11_window_win32_init (GstD3D11WindowWin32 * self)
|
||||||
{
|
{
|
||||||
self->main_context = g_main_context_new ();
|
self->main_context = g_main_context_new ();
|
||||||
|
self->restore_placement.length = sizeof (WINDOWPLACEMENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -645,32 +646,25 @@ gst_d3d11_window_win32_change_fullscreen_mode_internal (GstD3D11WindowWin32 *
|
||||||
/* Restore the window's attributes and size */
|
/* Restore the window's attributes and size */
|
||||||
SetWindowLongA (hwnd, GWL_STYLE, self->restore_style);
|
SetWindowLongA (hwnd, GWL_STYLE, self->restore_style);
|
||||||
|
|
||||||
SetWindowPos (hwnd, HWND_NOTOPMOST,
|
SetWindowPlacement (hwnd, &self->restore_placement);
|
||||||
self->restore_rect.left,
|
|
||||||
self->restore_rect.top,
|
|
||||||
self->restore_rect.right - self->restore_rect.left,
|
|
||||||
self->restore_rect.bottom - self->restore_rect.top,
|
|
||||||
SWP_FRAMECHANGED | SWP_NOACTIVATE);
|
|
||||||
|
|
||||||
ShowWindow (hwnd, SW_NORMAL);
|
|
||||||
} else {
|
} else {
|
||||||
ComPtr < IDXGIOutput > output;
|
ComPtr < IDXGIOutput > output;
|
||||||
DXGI_OUTPUT_DESC output_desc;
|
DXGI_OUTPUT_DESC output_desc;
|
||||||
IDXGISwapChain *swap_chain = window->swap_chain;
|
IDXGISwapChain *swap_chain = window->swap_chain;
|
||||||
|
|
||||||
|
/* remember current placement to restore window later */
|
||||||
|
GetWindowPlacement (hwnd, &self->restore_placement);
|
||||||
|
|
||||||
/* show window before change style */
|
/* show window before change style */
|
||||||
ShowWindow (hwnd, SW_SHOW);
|
ShowWindow (hwnd, SW_SHOW);
|
||||||
|
|
||||||
/* Save the old window rect so we can restore it when exiting
|
|
||||||
* fullscreen mode */
|
|
||||||
GetWindowRect (hwnd, &self->restore_rect);
|
|
||||||
self->restore_style = GetWindowLong (hwnd, GWL_STYLE);
|
self->restore_style = GetWindowLong (hwnd, GWL_STYLE);
|
||||||
|
|
||||||
/* Make the window borderless so that the client area can fill the screen */
|
/* Make the window borderless so that the client area can fill the screen */
|
||||||
SetWindowLongA (hwnd, GWL_STYLE,
|
SetWindowLongA (hwnd, GWL_STYLE,
|
||||||
self->restore_style &
|
self->restore_style &
|
||||||
~(WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU |
|
~(WS_CAPTION | WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_SYSMENU |
|
||||||
WS_THICKFRAME));
|
WS_THICKFRAME | WS_MAXIMIZE));
|
||||||
|
|
||||||
swap_chain->GetContainingOutput (&output);
|
swap_chain->GetContainingOutput (&output);
|
||||||
output->GetDesc (&output_desc);
|
output->GetDesc (&output_desc);
|
||||||
|
|
Loading…
Reference in a new issue