Commit cb076db8 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Move IWineD3DDeviceImpl_RestoreWindow() to swapchain.c.

parent 542590cf
......@@ -919,73 +919,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINE
return WINED3D_OK;
}
static LONG fullscreen_style(LONG orig_style) {
LONG style = orig_style;
style &= ~WS_CAPTION;
style &= ~WS_THICKFRAME;
/* Make sure the window is managed, otherwise we won't get keyboard input */
style |= WS_POPUP | WS_SYSMENU;
return style;
}
static LONG fullscreen_exStyle(LONG orig_exStyle) {
LONG exStyle = orig_exStyle;
/* Filter out window decorations */
exStyle &= ~WS_EX_WINDOWEDGE;
exStyle &= ~WS_EX_CLIENTEDGE;
return exStyle;
}
/*****************************************************************************
* IWineD3DDeviceImpl_RestoreWindow
*
* Helper function that restores a windows' properties when taking it out
* of fullscreen mode
*
* Params:
* iface: Pointer to the IWineD3DDevice interface
* window: Window to setup
*
*****************************************************************************/
static void IWineD3DDeviceImpl_RestoreWindow(IWineD3DDevice *iface, HWND window) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
LONG style, exStyle;
/* This could be a DDSCL_NORMAL -> DDSCL_NORMAL
* switch, do nothing
*/
if (!This->style && !This->exStyle) return;
TRACE("(%p): Restoring window settings of window %p to %08x, %08x\n",
This, window, This->style, This->exStyle);
style = GetWindowLongW(window, GWL_STYLE);
exStyle = GetWindowLongW(window, GWL_EXSTYLE);
/* 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(This->style) && exStyle == fullscreen_exStyle(This->exStyle))
{
SetWindowLongW(window, GWL_STYLE, This->style);
SetWindowLongW(window, GWL_EXSTYLE, This->exStyle);
}
/* Delete the old values */
This->style = 0;
This->exStyle = 0;
/* Inform the window about the update */
SetWindowPos(window, 0 /* InsertAfter, ignored */,
0, 0, 0, 0, /* Pos, Size, ignored */
SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
}
static HRESULT WINAPI IWineD3DDeviceImpl_CreateSwapChain(IWineD3DDevice *iface,
WINED3DPRESENT_PARAMETERS *present_parameters, IWineD3DSwapChain **swapchain,
IUnknown *parent, WINED3DSURFTYPE surface_type)
......@@ -6568,7 +6501,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Reset(IWineD3DDevice* iface, WINED3DPRE
}
} else if(swapchain->win_handle && !swapchain->presentParms.Windowed) {
/* Fullscreen -> windowed switch */
IWineD3DDeviceImpl_RestoreWindow(iface, swapchain->win_handle);
swapchain_restore_fullscreen_window(swapchain);
}
swapchain->presentParms.Windowed = pPresentationParameters->Windowed;
} else if(!pPresentationParameters->Windowed) {
......
......@@ -602,6 +602,38 @@ void swapchain_setup_fullscreen_window(IWineD3DSwapChainImpl *swapchain, UINT w,
SetWindowPos(window, HWND_TOP, 0, 0, w, h, SWP_FRAMECHANGED | SWP_SHOWWINDOW);
}
void swapchain_restore_fullscreen_window(IWineD3DSwapChainImpl *swapchain)
{
IWineD3DDeviceImpl *device = swapchain->device;
HWND window = swapchain->win_handle;
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);
/* 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);
}
/* Delete the old values. */
device->style = 0;
device->exStyle = 0;
SetWindowPos(window, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
}
HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface_type,
IWineD3DDeviceImpl *device, WINED3DPRESENT_PARAMETERS *present_parameters, IUnknown *parent)
{
......
......@@ -2453,6 +2453,7 @@ struct wined3d_context *swapchain_create_context_for_thread(IWineD3DSwapChain *i
HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface_type,
IWineD3DDeviceImpl *device, WINED3DPRESENT_PARAMETERS *present_parameters, IUnknown *parent) DECLSPEC_HIDDEN;
void swapchain_setup_fullscreen_window(IWineD3DSwapChainImpl *swapchain, UINT w, UINT h) DECLSPEC_HIDDEN;
void swapchain_restore_fullscreen_window(IWineD3DSwapChainImpl *swapchain) DECLSPEC_HIDDEN;
#define DEFAULT_REFRESH_RATE 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment