wined3d: Filter messages for the device's focus window instead of the swapchain's device window.

Usually these will be the same window, but they don't have to be.
oldstable
Henri Verbeet 2009-12-22 18:32:13 +01:00 committed by Alexandre Julliard
parent ed96e740e9
commit a0aa10eb5c
5 changed files with 48 additions and 49 deletions

View File

@ -1395,7 +1395,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface,
if(This->d3d_initialized) return WINED3DERR_INVALIDCALL;
if(!This->adapter->opengl) return WINED3DERR_INVALIDCALL;
/* TODO: Test if OpenGL is compiled in and loaded */
This-> focus_window = This->createParms.hFocusWindow;
if (!This->focus_window) This->focus_window = pPresentationParameters->hDeviceWindow;
if (!wined3d_register_window(This->focus_window, This))
{
ERR("Failed to register window %p.\n", This->focus_window);
return E_FAIL;
}
TRACE("(%p) : Creating stateblock\n", This);
/* Creating the startup stateBlock - Note Special Case: 0 => Don't fill in yet! */
@ -1584,6 +1590,7 @@ err_out:
if (This->shader_priv) {
This->shader_backend->shader_free_private(iface);
}
wined3d_unregister_window(This->focus_window);
return hr;
}
@ -1773,6 +1780,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface,
This->draw_buffers = NULL;
This->d3d_initialized = FALSE;
wined3d_unregister_window(This->focus_window);
return WINED3D_OK;
}
@ -7051,3 +7061,22 @@ void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width,
*width = surface->currentDesc.Width;
*height = surface->currentDesc.Height;
}
LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window,
UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc)
{
if (device->filter_messages)
{
TRACE("Filtering message: window %p, message %#x, wparam %#lx, lparam %#lx.\n",
window, message, wparam, lparam);
return DefWindowProcW(window, message, wparam, lparam);
}
if (message == WM_DESTROY)
{
TRACE("unregister window %p.\n", window);
wined3d_unregister_window(window);
}
return CallWindowProcW(proc, window, message, wparam, lparam);
}

View File

@ -91,8 +91,6 @@ static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface)
IWineD3DDevice_SetDisplayMode((IWineD3DDevice *)This->device, 0, &mode);
}
wined3d_unregister_window(This->win_handle);
HeapFree(GetProcessHeap(), 0, This->context);
HeapFree(GetProcessHeap(), 0, This);
}
@ -600,14 +598,14 @@ void swapchain_setup_fullscreen_window(IWineD3DSwapChainImpl *swapchain, UINT w,
TRACE("Old style was %08x, %08x, setting to %08x, %08x.\n",
device->style, device->exStyle, style, exstyle);
filter_messages = swapchain->filter_messages;
swapchain->filter_messages = TRUE;
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);
swapchain->filter_messages = filter_messages;
device->filter_messages = filter_messages;
}
void swapchain_restore_fullscreen_window(IWineD3DSwapChainImpl *swapchain)
@ -625,8 +623,8 @@ void swapchain_restore_fullscreen_window(IWineD3DSwapChainImpl *swapchain)
style = GetWindowLongW(window, GWL_STYLE);
exstyle = GetWindowLongW(window, GWL_EXSTYLE);
filter_messages = swapchain->filter_messages;
swapchain->filter_messages = TRUE;
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()
@ -639,7 +637,7 @@ void swapchain_restore_fullscreen_window(IWineD3DSwapChainImpl *swapchain)
}
SetWindowPos(window, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
swapchain->filter_messages = filter_messages;
device->filter_messages = filter_messages;
/* Delete the old values. */
device->style = 0;
@ -689,12 +687,6 @@ HRESULT swapchain_init(IWineD3DSwapChainImpl *swapchain, WINED3DSURFTYPE surface
window = present_parameters->hDeviceWindow ? present_parameters->hDeviceWindow : device->createParms.hFocusWindow;
if (!wined3d_register_window(window, swapchain))
{
ERR("Failed to register window %p.\n", window);
return E_FAIL;
}
swapchain->device = device;
swapchain->parent = parent;
swapchain->ref = 1;
@ -905,8 +897,6 @@ err:
if (swapchain->frontBuffer) IWineD3DSurface_Release(swapchain->frontBuffer);
wined3d_unregister_window(window);
return hr;
}
@ -951,22 +941,3 @@ void get_drawable_size_swapchain(struct wined3d_context *context, UINT *width, U
*width = surface->currentDesc.Width;
*height = surface->currentDesc.Height;
}
LRESULT swapchain_process_message(IWineD3DSwapChainImpl *swapchain, HWND window,
UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc)
{
if (swapchain->filter_messages)
{
TRACE("Filtering message: window %p, message %#x, wparam %#lx, lparam %#lx.\n",
window, message, wparam, lparam);
return DefWindowProcW(window, message, wparam, lparam);
}
if (message == WM_DESTROY)
{
TRACE("unregister window %p.\n", window);
wined3d_unregister_window(window);
}
return CallWindowProcW(proc, window, message, wparam, lparam);
}

View File

@ -70,8 +70,6 @@ static void WINAPI IWineGDISwapChainImpl_Destroy(IWineD3DSwapChain *iface)
IWineD3DDevice_SetDisplayMode((IWineD3DDevice *)This->device, 0, &mode);
}
wined3d_unregister_window(This->win_handle);
HeapFree(GetProcessHeap(), 0, This->context);
HeapFree(GetProcessHeap(), 0, This);
}

View File

@ -33,7 +33,7 @@ struct wined3d_wndproc
{
HWND window;
WNDPROC proc;
IWineD3DSwapChainImpl *swapchain;
IWineD3DDeviceImpl *device;
};
struct wined3d_wndproc_table
@ -389,8 +389,8 @@ static struct wined3d_wndproc *wined3d_find_wndproc(HWND window)
static LRESULT CALLBACK wined3d_wndproc(HWND window, UINT message, WPARAM wparam, LPARAM lparam)
{
IWineD3DSwapChainImpl *swapchain;
struct wined3d_wndproc *entry;
IWineD3DDeviceImpl *device;
WNDPROC proc;
wined3d_mutex_lock();
@ -403,14 +403,14 @@ static LRESULT CALLBACK wined3d_wndproc(HWND window, UINT message, WPARAM wparam
return DefWindowProcW(window, message, wparam, lparam);
}
swapchain = entry->swapchain;
device = entry->device;
proc = entry->proc;
wined3d_mutex_unlock();
return swapchain_process_message(swapchain, window, message, wparam, lparam, proc);
return device_process_message(device, window, message, wparam, lparam, proc);
}
BOOL wined3d_register_window(HWND window, IWineD3DSwapChainImpl *swapchain)
BOOL wined3d_register_window(HWND window, IWineD3DDeviceImpl *device)
{
struct wined3d_wndproc *entry;
@ -438,7 +438,7 @@ BOOL wined3d_register_window(HWND window, IWineD3DSwapChainImpl *swapchain)
entry = &wndproc_table.entries[wndproc_table.count++];
entry->window = window;
entry->proc = (WNDPROC)SetWindowLongPtrW(window, GWLP_WNDPROC, (LONG_PTR)wined3d_wndproc);
entry->swapchain = swapchain;
entry->device = device;
wined3d_mutex_unlock();

View File

@ -1440,7 +1440,7 @@ typedef struct IWineD3DImpl
extern const IWineD3DVtbl IWineD3D_Vtbl DECLSPEC_HIDDEN;
BOOL wined3d_register_window(HWND window, struct IWineD3DSwapChainImpl *swapchain) DECLSPEC_HIDDEN;
BOOL wined3d_register_window(HWND window, struct IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN;
void wined3d_unregister_window(HWND window) DECLSPEC_HIDDEN;
BOOL InitAdapters(IWineD3DImpl *This) DECLSPEC_HIDDEN;
@ -1504,7 +1504,8 @@ struct IWineD3DDeviceImpl
WORD softwareVertexProcessing : 1; /* process vertex shaders using software or hardware */
WORD useDrawStridedSlow : 1;
WORD instancedDraw : 1;
WORD padding : 4;
WORD filter_messages : 1;
WORD padding : 3;
BYTE fixed_function_usage_map; /* MAX_TEXTURES, 8 */
@ -1519,6 +1520,7 @@ struct IWineD3DDeviceImpl
/* Internal use fields */
WINED3DDEVICE_CREATION_PARAMETERS createParms;
WINED3DDEVTYPE devType;
HWND focus_window;
IWineD3DSwapChain **swapchains;
UINT NumberOfSwapChains;
@ -1591,6 +1593,8 @@ struct IWineD3DDeviceImpl
HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d,
UINT adapter_idx, WINED3DDEVTYPE device_type, HWND focus_window, DWORD flags,
IUnknown *parent, IWineD3DDeviceParent *device_parent) DECLSPEC_HIDDEN;
LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window,
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_stream_info_from_declaration(IWineD3DDeviceImpl *This,
@ -2417,7 +2421,6 @@ struct IWineD3DSwapChainImpl
WINED3DFORMAT orig_fmt;
WINED3DGAMMARAMP orig_gamma;
BOOL render_to_fbo;
BOOL filter_messages;
long prev_time, frames; /* Performance tracking */
unsigned int vSyncCounter;
@ -2456,8 +2459,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, IUnknown *parent) DECLSPEC_HIDDEN;
LRESULT swapchain_process_message(IWineD3DSwapChainImpl *device, HWND window,
UINT message, WPARAM wparam, LPARAM lparam, WNDPROC proc) DECLSPEC_HIDDEN;
void swapchain_restore_fullscreen_window(IWineD3DSwapChainImpl *swapchain) DECLSPEC_HIDDEN;
void swapchain_setup_fullscreen_window(IWineD3DSwapChainImpl *swapchain, UINT w, UINT h) DECLSPEC_HIDDEN;