wined3d: Move the fullscreen window setup / restore code to the device.
This commit is contained in:
parent
5955a349c6
commit
45cee64295
|
@ -1750,6 +1750,89 @@ static void destroy_dummy_textures(IWineD3DDeviceImpl *device, const struct wine
|
|||
memset(device->dummyTextureName, 0, gl_info->limits.textures * sizeof(*device->dummyTextureName));
|
||||
}
|
||||
|
||||
static LONG fullscreen_style(LONG style)
|
||||
{
|
||||
/* Make sure the window is managed, otherwise we won't get keyboard input. */
|
||||
style |= WS_POPUP | WS_SYSMENU;
|
||||
style &= ~(WS_CAPTION | WS_THICKFRAME);
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
static LONG fullscreen_exstyle(LONG exstyle)
|
||||
{
|
||||
/* Filter out window decorations. */
|
||||
exstyle &= ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE);
|
||||
|
||||
return exstyle;
|
||||
}
|
||||
|
||||
void device_setup_fullscreen_window(IWineD3DDeviceImpl *device, HWND window, UINT w, UINT h)
|
||||
{
|
||||
BOOL filter_messages;
|
||||
LONG style, exstyle;
|
||||
|
||||
TRACE("Setting up window %p for fullscreen mode.\n", window);
|
||||
|
||||
if (device->style || device->exStyle)
|
||||
{
|
||||
ERR("Changing the window style for window %p, but another style (%08x, %08x) is already stored.\n",
|
||||
window, device->style, device->exStyle);
|
||||
}
|
||||
|
||||
device->style = GetWindowLongW(window, GWL_STYLE);
|
||||
device->exStyle = GetWindowLongW(window, GWL_EXSTYLE);
|
||||
|
||||
style = fullscreen_style(device->style);
|
||||
exstyle = fullscreen_exstyle(device->exStyle);
|
||||
|
||||
TRACE("Old style was %08x, %08x, setting to %08x, %08x.\n",
|
||||
device->style, device->exStyle, style, exstyle);
|
||||
|
||||
filter_messages = device->filter_messages;
|
||||
device->filter_messages = TRUE;
|
||||
|
||||
SetWindowLongW(window, GWL_STYLE, style);
|
||||
SetWindowLongW(window, GWL_EXSTYLE, exstyle);
|
||||
SetWindowPos(window, HWND_TOP, 0, 0, w, h, SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOACTIVATE);
|
||||
|
||||
device->filter_messages = filter_messages;
|
||||
}
|
||||
|
||||
void device_restore_fullscreen_window(IWineD3DDeviceImpl *device, HWND window)
|
||||
{
|
||||
BOOL filter_messages;
|
||||
LONG style, exstyle;
|
||||
|
||||
if (!device->style && !device->exStyle) return;
|
||||
|
||||
TRACE("Restoring window style of window %p to %08x, %08x.\n",
|
||||
window, device->style, device->exStyle);
|
||||
|
||||
style = GetWindowLongW(window, GWL_STYLE);
|
||||
exstyle = GetWindowLongW(window, GWL_EXSTYLE);
|
||||
|
||||
filter_messages = device->filter_messages;
|
||||
device->filter_messages = TRUE;
|
||||
|
||||
/* Only restore the style if the application didn't modify it during the
|
||||
* fullscreen phase. Some applications change it before calling Reset()
|
||||
* when switching between windowed and fullscreen modes (HL2), some
|
||||
* depend on the original style (Eve Online). */
|
||||
if (style == fullscreen_style(device->style) && exstyle == fullscreen_exstyle(device->exStyle))
|
||||
{
|
||||
SetWindowLongW(window, GWL_STYLE, device->style);
|
||||
SetWindowLongW(window, GWL_EXSTYLE, device->exStyle);
|
||||
}
|
||||
SetWindowPos(window, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
|
||||
|
||||
device->filter_messages = filter_messages;
|
||||
|
||||
/* Delete the old values. */
|
||||
device->style = 0;
|
||||
device->exStyle = 0;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IWineD3DDeviceImpl_AcquireFocusWindow(IWineD3DDevice *iface, HWND window)
|
||||
{
|
||||
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *)iface;
|
||||
|
@ -6371,7 +6454,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
|
|||
}
|
||||
|
||||
/* switch from windowed to fs */
|
||||
swapchain_setup_fullscreen_window(swapchain, pPresentationParameters->BackBufferWidth,
|
||||
device_setup_fullscreen_window(This, swapchain->device_window,
|
||||
pPresentationParameters->BackBufferWidth,
|
||||
pPresentationParameters->BackBufferHeight);
|
||||
}
|
||||
else
|
||||
|
@ -6385,7 +6469,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
|
|||
else if (!swapchain->presentParms.Windowed)
|
||||
{
|
||||
/* Fullscreen -> windowed switch */
|
||||
swapchain_restore_fullscreen_window(swapchain);
|
||||
device_restore_fullscreen_window(This, swapchain->device_window);
|
||||
IWineD3DDevice_ReleaseFocusWindow(iface);
|
||||
}
|
||||
swapchain->presentParms.Windowed = pPresentationParameters->Windowed;
|
||||
|
@ -6401,7 +6485,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice *iface,
|
|||
*/
|
||||
This->style = 0;
|
||||
This->exStyle = 0;
|
||||
swapchain_setup_fullscreen_window(swapchain, pPresentationParameters->BackBufferWidth,
|
||||
device_setup_fullscreen_window(This, swapchain->device_window,
|
||||
pPresentationParameters->BackBufferWidth,
|
||||
pPresentationParameters->BackBufferHeight);
|
||||
This->style = style;
|
||||
This->exStyle = exStyle;
|
||||
|
|
|
@ -532,94 +532,6 @@ static const IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl =
|
|||
IWineD3DBaseSwapChainImpl_GetGammaRamp
|
||||
};
|
||||
|
||||
static LONG fullscreen_style(LONG style)
|
||||
{
|
||||
/* Make sure the window is managed, otherwise we won't get keyboard input. */
|
||||
style |= WS_POPUP | WS_SYSMENU;
|
||||
style &= ~(WS_CAPTION | WS_THICKFRAME);
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
static LONG fullscreen_exstyle(LONG exstyle)
|
||||
{
|
||||
/* Filter out window decorations. */
|
||||
exstyle &= ~(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE);
|
||||
|
||||
return exstyle;
|
||||
}
|
||||
|
||||
void swapchain_setup_fullscreen_window(IWineD3DSwapChainImpl *swapchain, UINT w, UINT h)
|
||||
{
|
||||
IWineD3DDeviceImpl *device = swapchain->device;
|
||||
HWND window = swapchain->device_window;
|
||||
BOOL filter_messages;
|
||||
LONG style, exstyle;
|
||||
|
||||
TRACE("Setting up window %p for fullscreen mode.\n", window);
|
||||
|
||||
if (device->style || device->exStyle)
|
||||
{
|
||||
ERR("Changing the window style for window %p, but another style (%08x, %08x) is already stored.\n",
|
||||
window, device->style, device->exStyle);
|
||||
}
|
||||
|
||||
device->style = GetWindowLongW(window, GWL_STYLE);
|
||||
device->exStyle = GetWindowLongW(window, GWL_EXSTYLE);
|
||||
|
||||
style = fullscreen_style(device->style);
|
||||
exstyle = fullscreen_exstyle(device->exStyle);
|
||||
|
||||
TRACE("Old style was %08x, %08x, setting to %08x, %08x.\n",
|
||||
device->style, device->exStyle, style, exstyle);
|
||||
|
||||
filter_messages = device->filter_messages;
|
||||
device->filter_messages = TRUE;
|
||||
|
||||
SetWindowLongW(window, GWL_STYLE, style);
|
||||
SetWindowLongW(window, GWL_EXSTYLE, exstyle);
|
||||
SetWindowPos(window, HWND_TOP, 0, 0, w, h, SWP_FRAMECHANGED | SWP_SHOWWINDOW | SWP_NOACTIVATE);
|
||||
|
||||
device->filter_messages = filter_messages;
|
||||
}
|
||||
|
||||
void swapchain_restore_fullscreen_window(IWineD3DSwapChainImpl *swapchain)
|
||||
{
|
||||
IWineD3DDeviceImpl *device = swapchain->device;
|
||||
HWND window = swapchain->device_window;
|
||||
BOOL filter_messages;
|
||||
LONG style, exstyle;
|
||||
|
||||
if (!device->style && !device->exStyle) return;
|
||||
|
||||
TRACE("Restoring window style of window %p to %08x, %08x.\n",
|
||||
window, device->style, device->exStyle);
|
||||
|
||||
style = GetWindowLongW(window, GWL_STYLE);
|
||||
exstyle = GetWindowLongW(window, GWL_EXSTYLE);
|
||||
|
||||
filter_messages = device->filter_messages;
|
||||
device->filter_messages = TRUE;
|
||||
|
||||
/* Only restore the style if the application didn't modify it during the
|
||||
* fullscreen phase. Some applications change it before calling Reset()
|
||||
* when switching between windowed and fullscreen modes (HL2), some
|
||||
* depend on the original style (Eve Online). */
|
||||
if (style == fullscreen_style(device->style) && exstyle == fullscreen_exstyle(device->exStyle))
|
||||
{
|
||||
SetWindowLongW(window, GWL_STYLE, device->style);
|
||||
SetWindowLongW(window, GWL_EXSTYLE, device->exStyle);
|
||||
}
|
||||
SetWindowPos(window, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
|
||||
|
||||
device->filter_messages = filter_messages;
|
||||
|
||||
/* Delete the old values. */
|
||||
device->style = 0;
|
||||
device->exStyle = 0;
|
||||
}
|
||||
|
||||
|
||||
/* Do not call while under the GL lock. */
|
||||
HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface_type,
|
||||
IWineD3DDeviceImpl *device, WINED3DPRESENT_PARAMETERS *present_parameters, void *parent)
|
||||
|
@ -671,7 +583,8 @@ HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface
|
|||
|
||||
if (!present_parameters->Windowed && window)
|
||||
{
|
||||
swapchain_setup_fullscreen_window(swapchain, present_parameters->BackBufferWidth,
|
||||
device_setup_fullscreen_window(device, window,
|
||||
present_parameters->BackBufferWidth,
|
||||
present_parameters->BackBufferHeight);
|
||||
}
|
||||
|
||||
|
|
|
@ -1773,6 +1773,8 @@ LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window, BOOL uni
|
|||
UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN;
|
||||
void device_resource_add(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;
|
||||
void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resource) DECLSPEC_HIDDEN;
|
||||
void device_restore_fullscreen_window(IWineD3DDeviceImpl *device, HWND hwnd) DECLSPEC_HIDDEN;
|
||||
void device_setup_fullscreen_window(IWineD3DDeviceImpl *device, HWND hwnd, UINT w, UINT h) DECLSPEC_HIDDEN;
|
||||
void device_stream_info_from_declaration(IWineD3DDeviceImpl *This,
|
||||
BOOL use_vshader, struct wined3d_stream_info *stream_info, BOOL *fixup) DECLSPEC_HIDDEN;
|
||||
void device_switch_onscreen_ds(IWineD3DDeviceImpl *device, struct wined3d_context *context,
|
||||
|
@ -2638,8 +2640,6 @@ HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetGammaRamp(IWineD3DSwapChain *iface,
|
|||
struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChain *iface) DECLSPEC_HIDDEN;
|
||||
HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface_type,
|
||||
IWineD3DDeviceImpl *device, WINED3DPRESENT_PARAMETERS *present_parameters, void *parent) DECLSPEC_HIDDEN;
|
||||
void swapchain_restore_fullscreen_window(IWineD3DSwapChainImpl *swapchain) DECLSPEC_HIDDEN;
|
||||
void swapchain_setup_fullscreen_window(IWineD3DSwapChainImpl *swapchain, UINT w, UINT h) DECLSPEC_HIDDEN;
|
||||
|
||||
#define DEFAULT_REFRESH_RATE 0
|
||||
|
||||
|
|
Loading…
Reference in New Issue