Fixes: 05d727a935b9009f188cc74ca77e14afc44aef30 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57160
From: Rémi Bernon rbernon@codeweavers.com
Fixes: 05d727a935b9009f188cc74ca77e14afc44aef30 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=57160 --- dlls/win32u/window.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c index 77471213431..ab58cabb40e 100644 --- a/dlls/win32u/window.c +++ b/dlls/win32u/window.c @@ -1949,14 +1949,14 @@ static struct window_surface *get_window_surface( HWND hwnd, UINT swp_flags, BOO
if (new_surface && !is_layered) { - DWORD lwa_flags = 0; + DWORD lwa_flags = 0, alpha_bits = -1; COLORREF key; BYTE alpha;
if (!NtUserGetLayeredWindowAttributes( hwnd, &key, &alpha, &lwa_flags )) lwa_flags = 0; - if (!(lwa_flags & LWA_ALPHA)) alpha = 255; + if (lwa_flags & LWA_ALPHA) alpha_bits = alpha << 24; if (!(lwa_flags & LWA_COLORKEY)) key = CLR_INVALID; - window_surface_set_layered( new_surface, key, alpha << 24, 0 ); + window_surface_set_layered( new_surface, key, alpha_bits, 0 ); }
return new_surface;
Dmitry Timoshkov (@dmitry) commented about dlls/win32u/window.c:
if (new_surface && !is_layered) {
DWORD lwa_flags = 0;
DWORD lwa_flags = 0, alpha_bits = -1;
This either shouldn't be a DWORD or -1. What about using ~0?
On Thu Sep 12 08:15:18 2024 +0000, Dmitry Timoshkov wrote:
This either shouldn't be a DWORD or -1. What about using ~0?
It does the same thing, I don't think it matters and alpha_bits is initialized with -1 everywhere else it's used.
Using ~0 makes it very tempting to use ~0u, which is wrong in various cases (`UINT64 bla = ~0u`, isn't the same value as `UINT64 bla = ~0` / `UINT64 bla = -1` which both are equal).
On Thu Sep 12 08:23:17 2024 +0000, Rémi Bernon wrote:
It does the same thing, I don't think it matters and alpha_bits is initialized with -1 everywhere else it's used. Using ~0 makes it very tempting to use ~0u, which is wrong in various cases (`UINT64 bla = ~0u`, isn't the same value as `UINT64 bla = ~0` / `UINT64 bla = -1` which both are equal).
Of course it's the same thing, hence the suggestion. It's clearly wrong to assign a signed value to a variable of an unsigned type.
On Thu Sep 12 08:31:57 2024 +0000, Dmitry Timoshkov wrote:
Of course it's the same thing, hence the suggestion. It's clearly wrong to assign a signed value to a variable of an unsigned type.
Well, if you want to be absolutely strict, ~0 is still signed, so you have to use ~0u (which is inconvenient because then you have to use the exactly right suffix for the variable type).