Module: wine Branch: master Commit: b66478dfbcc57e2f9cde12c1e0ae34ffcff12714 URL: http://source.winehq.org/git/wine.git/?a=commit;h=b66478dfbcc57e2f9cde12c1e0...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Tue Nov 2 12:02:47 2010 +0100
wined3d: Set an A window proc on non-unicode windows.
---
dlls/wined3d/device.c | 12 +++++++++--- dlls/wined3d/wined3d_main.c | 26 ++++++++++++++++++++++---- dlls/wined3d/wined3d_private.h | 2 +- 3 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 1416e59..6e78f04 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -6916,14 +6916,17 @@ void get_drawable_size_backbuffer(struct wined3d_context *context, UINT *width, *height = swapchain->presentParms.BackBufferHeight; }
-LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window, +LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window, BOOL unicode, 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 (unicode) + return DefWindowProcW(window, message, wparam, lparam); + else + return DefWindowProcA(window, message, wparam, lparam); }
if (message == WM_DESTROY) @@ -6935,5 +6938,8 @@ LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window, else ERR("Window %p is not the focus window for device %p.\n", window, device); }
- return CallWindowProcW(proc, window, message, wparam, lparam); + if (unicode) + return CallWindowProcW(proc, window, message, wparam, lparam); + else + return CallWindowProcA(proc, window, message, wparam, lparam); } diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c index 26945ef..0932351 100644 --- a/dlls/wined3d/wined3d_main.c +++ b/dlls/wined3d/wined3d_main.c @@ -32,6 +32,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d); struct wined3d_wndproc { HWND window; + BOOL unicode; WNDPROC proc; IWineD3DDeviceImpl *device; }; @@ -394,6 +395,7 @@ static LRESULT CALLBACK wined3d_wndproc(HWND window, UINT message, WPARAM wparam { struct wined3d_wndproc *entry; IWineD3DDeviceImpl *device; + BOOL unicode; WNDPROC proc;
wined3d_mutex_lock(); @@ -407,10 +409,11 @@ static LRESULT CALLBACK wined3d_wndproc(HWND window, UINT message, WPARAM wparam }
device = entry->device; + unicode = entry->unicode; proc = entry->proc; wined3d_mutex_unlock();
- return device_process_message(device, window, message, wparam, lparam, proc); + return device_process_message(device, window, unicode, message, wparam, lparam, proc); }
BOOL wined3d_register_window(HWND window, IWineD3DDeviceImpl *device) @@ -440,7 +443,14 @@ BOOL wined3d_register_window(HWND window, IWineD3DDeviceImpl *device)
entry = &wndproc_table.entries[wndproc_table.count++]; entry->window = window; - entry->proc = (WNDPROC)SetWindowLongPtrW(window, GWLP_WNDPROC, (LONG_PTR)wined3d_wndproc); + entry->unicode = IsWindowUnicode(window); + /* Set a window proc that matches the window. Some applications (e.g. NoX) + * replace the window proc after we've set ours, and expect to be able to + * call the previous one (ours) directly, without using CallWindowProc(). */ + if (entry->unicode) + entry->proc = (WNDPROC)SetWindowLongPtrW(window, GWLP_WNDPROC, (LONG_PTR)wined3d_wndproc); + else + entry->proc = (WNDPROC)SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)wined3d_wndproc); entry->device = device;
wined3d_mutex_unlock(); @@ -460,8 +470,16 @@ void wined3d_unregister_window(HWND window) struct wined3d_wndproc *entry = &wndproc_table.entries[i]; struct wined3d_wndproc *last = &wndproc_table.entries[--wndproc_table.count];
- if (GetWindowLongPtrW(window, GWLP_WNDPROC) == (LONG_PTR)wined3d_wndproc) - SetWindowLongPtrW(window, GWLP_WNDPROC, (LONG_PTR)entry->proc); + if (entry->unicode) + { + if (GetWindowLongPtrW(window, GWLP_WNDPROC) == (LONG_PTR)wined3d_wndproc) + SetWindowLongPtrW(window, GWLP_WNDPROC, (LONG_PTR)entry->proc); + } + else + { + if (GetWindowLongPtrA(window, GWLP_WNDPROC) == (LONG_PTR)wined3d_wndproc) + SetWindowLongPtrA(window, GWLP_WNDPROC, (LONG_PTR)entry->proc); + } if (entry != last) *entry = *last; wined3d_mutex_unlock();
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 18da56a..f710d0a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1769,7 +1769,7 @@ HRESULT device_init(IWineD3DDeviceImpl *device, IWineD3DImpl *wined3d, UINT adapter_idx, WINED3DDEVTYPE device_type, HWND focus_window, DWORD flags, IWineD3DDeviceParent *device_parent) DECLSPEC_HIDDEN; void device_preload_textures(IWineD3DDeviceImpl *device) DECLSPEC_HIDDEN; -LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window, +LRESULT device_process_message(IWineD3DDeviceImpl *device, HWND window, BOOL unicode, 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;