[prev in list] [next in list] [prev in thread] [next in thread]
List: wine-devel
Subject: Re: [PATCH] avicap32: Partially implement capCreateCaptureWindowW.
From: "Zebediah Figura (she/her)" <zfigura () codeweavers ! com>
Date: 2021-08-31 17:10:12
Message-ID: f027dd9f-23b0-6a20-36a1-d228acb2878f () codeweavers ! com
[Download RAW message or body]
On 8/31/21 8:59 AM, Gijs Vermeulen wrote:
> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=38011
> Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
> ---
> dlls/avicap32/Makefile.in | 1 +
> dlls/avicap32/avicap32_main.c | 72 ++++++++++++++++++++++++++---------
> 2 files changed, 56 insertions(+), 17 deletions(-)
>
> diff --git a/dlls/avicap32/Makefile.in b/dlls/avicap32/Makefile.in
> index 8f5a1089d5c..f320a58f04b 100644
> --- a/dlls/avicap32/Makefile.in
> +++ b/dlls/avicap32/Makefile.in
> @@ -1,4 +1,5 @@
> MODULE = avicap32.dll
> IMPORTLIB = avicap32
> +IMPORTS = user32
>
> C_SRCS = avicap32_main.c
> diff --git a/dlls/avicap32/avicap32_main.c b/dlls/avicap32/avicap32_main.c
> index 9e2a99d4c7c..6ed8db1d552 100644
> --- a/dlls/avicap32/avicap32_main.c
> +++ b/dlls/avicap32/avicap32_main.c
> @@ -56,36 +56,74 @@
>
> WINE_DEFAULT_DEBUG_CHANNEL(avicap);
>
> +static ATOM registered_class = 0;
> +static WCHAR class_nameW[] = {'W','i','n','e','A','v','i','C','a','p','C','l','a','s','s',0};
> +
> +static LRESULT CALLBACK avicap_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
> +{
> + switch(msg)
> + {
> + /* FIXME: handle WM_CAP_* messages */
Could we maybe have a FIXME for these?
> + default:
> + return DefWindowProcW(hwnd, msg, wparam, lparam);
> + }
> +}
> +
> +static ATOM register_class(void)
> +{
> + WNDCLASSEXW class;
> +
> + class.cbSize = sizeof(WNDCLASSEXW);
> + class.style = 0;
> + class.lpfnWndProc = avicap_wndproc;
> + class.cbClsExtra = 0;
> + class.cbWndExtra = 0;
> + class.hInstance = GetModuleHandleW(NULL);
> + class.hIcon = NULL;
> + class.hCursor = LoadCursorW(NULL, (LPWSTR)IDC_ARROW);
> + class.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
> + class.lpszMenuName = NULL;
> + class.lpszClassName = class_nameW;
> + class.hIconSm = NULL;
> +
> + return RegisterClassExW(&class);
> +}
>
> /***********************************************************************
> * capCreateCaptureWindowW (AVICAP32.@)
> */
> -HWND VFWAPI capCreateCaptureWindowW(LPCWSTR lpszWindowName, DWORD dwStyle, INT x,
> - INT y, INT nWidth, INT nHeight, HWND hWnd,
> - INT nID)
> +HWND VFWAPI capCreateCaptureWindowW(const WCHAR *window_name, DWORD style, INT x,
> + INT y, INT width, INT height, HWND hWnd, INT id)
> {
> - FIXME("(%s, %08x, %08x, %08x, %08x, %08x, %p, %08x): stub\n",
> - debugstr_w(lpszWindowName), dwStyle, x, y, nWidth, nHeight, hWnd, nID);
> - return 0;
> + FIXME("(%s, %08x, %08x, %08x, %08x, %08x, %p, %08x): semi-stub\n",
> + debugstr_w(window_name), style, x, y, width, height, hWnd, id);
> +
> + if (!registered_class && !(registered_class = register_class()))
> + {
> + ERR("Failed to register class!\n");
> + return NULL;
> + }
> +
> + return CreateWindowExW(style, class_nameW, window_name, style, x, y, width, height,
> + hWnd, NULL, GetModuleHandleW(NULL), NULL);
> }
>
This is thread-safe, but it really doesn't look like it. I'm honestly
inclined to advocate for just not caching "registered_class" at all.
Also, can you please unregister the window class on DLL unload?
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic