Jacek Caban : win32u: Move more default window messages implementation from user32.
Alexandre Julliard
julliard at winehq.org
Mon Jun 20 16:56:08 CDT 2022
Module: wine
Branch: master
Commit: 04716457559706e7b406f08546e86b9d6765cbc2
URL: https://source.winehq.org/git/wine.git/?a=commit;h=04716457559706e7b406f08546e86b9d6765cbc2
Author: Jacek Caban <jacek at codeweavers.com>
Date: Mon Jun 20 13:58:48 2022 +0200
win32u: Move more default window messages implementation from user32.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
---
dlls/user32/defwnd.c | 98 --------------------------------------
dlls/win32u/defwnd.c | 109 +++++++++++++++++++++++++++++++++++++++++++
dlls/win32u/win32u_private.h | 1 +
dlls/win32u/window.c | 2 +-
4 files changed, 111 insertions(+), 99 deletions(-)
diff --git a/dlls/user32/defwnd.c b/dlls/user32/defwnd.c
index dcc0f4d2138..96dd2e873fa 100644
--- a/dlls/user32/defwnd.c
+++ b/dlls/user32/defwnd.c
@@ -36,8 +36,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(win);
-#define DRAG_FILE 0x454C4946
-
/***********************************************************************
* DEFWND_ControlColor
*
@@ -90,34 +88,6 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
case WM_NCMOUSELEAVE:
return NC_HandleNCMouseLeave( hwnd );
- case WM_RBUTTONUP:
- {
- POINT pt;
- pt.x = (short)LOWORD(lParam);
- pt.y = (short)HIWORD(lParam);
- ClientToScreen(hwnd, &pt);
- SendMessageW( hwnd, WM_CONTEXTMENU, (WPARAM)hwnd, MAKELPARAM(pt.x, pt.y) );
- }
- break;
-
- case WM_NCRBUTTONUP:
- /*
- * FIXME : we must NOT send WM_CONTEXTMENU on a WM_NCRBUTTONUP (checked
- * in Windows), but what _should_ we do? According to MSDN :
- * "If it is appropriate to do so, the system sends the WM_SYSCOMMAND
- * message to the window". When is it appropriate?
- */
- break;
-
- case WM_XBUTTONUP:
- case WM_NCXBUTTONUP:
- if (HIWORD(wParam) == XBUTTON1 || HIWORD(wParam) == XBUTTON2)
- {
- SendMessageW(hwnd, WM_APPCOMMAND, (WPARAM)hwnd,
- MAKELPARAM(LOWORD(wParam), FAPPCOMMAND_MOUSE | HIWORD(wParam)));
- }
- break;
-
case WM_SYSCOMMAND:
return NC_HandleSysCommand( hwnd, wParam, lParam );
@@ -146,74 +116,6 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
break;
}
- case WM_VKEYTOITEM:
- case WM_CHARTOITEM:
- return -1;
-
- case WM_DROPOBJECT:
- return DRAG_FILE;
-
- case WM_QUERYDROPOBJECT:
- return (GetWindowLongA( hwnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES) != 0;
-
- case WM_QUERYDRAGICON:
- {
- UINT len;
-
- HICON hIcon = (HICON)GetClassLongPtrW( hwnd, GCLP_HICON );
- HINSTANCE instance = (HINSTANCE)GetWindowLongPtrW( hwnd, GWLP_HINSTANCE );
- if (hIcon) return (LRESULT)hIcon;
- for(len=1; len<64; len++)
- if((hIcon = LoadIconW(instance, MAKEINTRESOURCEW(len))))
- return (LRESULT)hIcon;
- return (LRESULT)LoadIconW(0, (LPWSTR)IDI_APPLICATION);
- }
- break;
-
- case WM_ISACTIVEICON:
- return (win_get_flags( hwnd ) & WIN_NCACTIVATED) != 0;
-
- case WM_NOTIFYFORMAT:
- if (IsWindowUnicode(hwnd)) return NFR_UNICODE;
- else return NFR_ANSI;
-
- case WM_QUERYOPEN:
- case WM_QUERYENDSESSION:
- return 1;
-
- case WM_HELP:
- SendMessageW( GetParent(hwnd), msg, wParam, lParam );
- break;
-
- case WM_STYLECHANGED:
- if (wParam == GWL_STYLE && (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED))
- {
- STYLESTRUCT *style = (STYLESTRUCT *)lParam;
- if ((style->styleOld ^ style->styleNew) & (WS_CAPTION|WS_THICKFRAME|WS_VSCROLL|WS_HSCROLL))
- NtUserSetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER |
- SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE );
- }
- break;
-
- case WM_INPUTLANGCHANGEREQUEST:
- NtUserActivateKeyboardLayout( (HKL)lParam, 0 );
- break;
-
- case WM_INPUTLANGCHANGE:
- {
- struct user_thread_info *info = get_user_thread_info();
- int count = 0;
- HWND *win_array = WIN_ListChildren( hwnd );
- info->kbd_layout = (HKL)lParam;
-
- if (!win_array)
- break;
- while (win_array[count])
- SendMessageW( win_array[count++], WM_INPUTLANGCHANGE, wParam, lParam);
- HeapFree(GetProcessHeap(),0,win_array);
- break;
- }
-
default:
return NtUserMessageCall( hwnd, msg, wParam, lParam, 0, NtUserDefWindowProc, FALSE );
diff --git a/dlls/win32u/defwnd.c b/dlls/win32u/defwnd.c
index 0470ed77eac..5625f15d42a 100644
--- a/dlls/win32u/defwnd.c
+++ b/dlls/win32u/defwnd.c
@@ -31,6 +31,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(win);
+#define DRAG_FILE 0x454c4946
+
/* bits in the dwKeyData */
#define KEYDATA_ALT 0x2000
#define KEYDATA_PREVSTATE 0x4000
@@ -2350,6 +2352,28 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
case WM_NCLBUTTONDBLCLK:
return handle_nc_button_dbl_click( hwnd, wparam, lparam );
+ case WM_RBUTTONUP:
+ {
+ POINT pt;
+ pt.x = (short)LOWORD( lparam );
+ pt.y = (short)HIWORD( lparam );
+ client_to_screen( hwnd, &pt );
+ send_message( hwnd, WM_CONTEXTMENU, (WPARAM)hwnd, MAKELPARAM( pt.x, pt.y ));
+ }
+ break;
+
+ case WM_NCRBUTTONUP:
+ break;
+
+ case WM_XBUTTONUP:
+ case WM_NCXBUTTONUP:
+ if (HIWORD(wparam) == XBUTTON1 || HIWORD(wparam) == XBUTTON2)
+ {
+ send_message( hwnd, WM_APPCOMMAND, (WPARAM)hwnd,
+ MAKELPARAM( LOWORD( wparam ), FAPPCOMMAND_MOUSE | HIWORD( wparam )));
+ }
+ break;
+
case WM_CONTEXTMENU:
if (get_window_long( hwnd, GWL_STYLE ) & WS_CHILD)
send_message( get_parent( hwnd ), msg, (WPARAM)hwnd, lparam );
@@ -2640,6 +2664,91 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
send_message( parent, msg, wparam, lparam );
break;
}
+
+ case WM_VKEYTOITEM:
+ case WM_CHARTOITEM:
+ result = -1;
+ break;
+
+ case WM_DROPOBJECT:
+ result = DRAG_FILE;
+ break;
+
+ case WM_QUERYDROPOBJECT:
+ result = (get_window_long( hwnd, GWL_EXSTYLE ) & WS_EX_ACCEPTFILES) != 0;
+ break;
+
+ case WM_QUERYDRAGICON:
+ {
+ UINT len;
+ HICON icon = (HICON)get_class_long_ptr( hwnd, GCLP_HICON, FALSE );
+ HINSTANCE instance = (HINSTANCE)get_window_long_ptr( hwnd, GWLP_HINSTANCE, FALSE );
+
+ if (icon)
+ {
+ result = (LRESULT)icon;
+ break;
+ }
+
+ for (len = 1; len < 64; len++)
+ {
+ if((icon = LoadImageW( instance, MAKEINTRESOURCEW( len ), IMAGE_ICON, 0, 0,
+ LR_SHARED | LR_DEFAULTSIZE )))
+ {
+ result = (LRESULT)icon;
+ break;
+ }
+ }
+ if (!result) result = (LRESULT)LoadImageW( 0, (WCHAR *)IDI_APPLICATION, IMAGE_ICON,
+ 0, 0, LR_SHARED | LR_DEFAULTSIZE );
+ break;
+ }
+
+ case WM_ISACTIVEICON:
+ result = (win_get_flags( hwnd ) & WIN_NCACTIVATED) != 0;
+ break;
+
+ case WM_NOTIFYFORMAT:
+ result = is_window_unicode(hwnd) ? NFR_UNICODE : NFR_ANSI;
+ break;
+
+ case WM_QUERYOPEN:
+ case WM_QUERYENDSESSION:
+ result = 1;
+ break;
+
+ case WM_HELP:
+ send_message( get_parent( hwnd ), msg, wparam, lparam );
+ break;
+
+ case WM_STYLECHANGED:
+ if (wparam == GWL_STYLE && (get_window_long( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED))
+ {
+ STYLESTRUCT *style = (STYLESTRUCT *)lparam;
+ if ((style->styleOld ^ style->styleNew) & (WS_CAPTION|WS_THICKFRAME|WS_VSCROLL|WS_HSCROLL))
+ NtUserSetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOZORDER |
+ SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE );
+ }
+ break;
+
+ case WM_INPUTLANGCHANGEREQUEST:
+ NtUserActivateKeyboardLayout( (HKL)lparam, 0 );
+ break;
+
+ case WM_INPUTLANGCHANGE:
+ {
+ struct user_thread_info *info = get_user_thread_info();
+ HWND *win_array = list_window_children( 0, hwnd, NULL, 0 );
+ int count = 0;
+ info->kbd_layout = (HKL)lparam;
+
+ if (!win_array)
+ break;
+ while (win_array[count])
+ send_message( win_array[count++], WM_INPUTLANGCHANGE, wparam, lparam );
+ free( win_array );
+ break;
+ }
}
return result;
diff --git a/dlls/win32u/win32u_private.h b/dlls/win32u/win32u_private.h
index b2d16b07d8e..808d3f83e37 100644
--- a/dlls/win32u/win32u_private.h
+++ b/dlls/win32u/win32u_private.h
@@ -473,6 +473,7 @@ extern void user_check_not_lock(void) DECLSPEC_HIDDEN;
/* window.c */
struct tagWND;
extern HDWP begin_defer_window_pos( INT count ) DECLSPEC_HIDDEN;
+extern BOOL client_to_screen( HWND hwnd, POINT *pt ) DECLSPEC_HIDDEN;
extern void destroy_thread_windows(void) DECLSPEC_HIDDEN;
extern LRESULT destroy_window( HWND hwnd ) DECLSPEC_HIDDEN;
extern BOOL get_client_rect( HWND hwnd, RECT *rect ) DECLSPEC_HIDDEN;
diff --git a/dlls/win32u/window.c b/dlls/win32u/window.c
index e8562f6a685..4a6b321d391 100644
--- a/dlls/win32u/window.c
+++ b/dlls/win32u/window.c
@@ -2840,7 +2840,7 @@ other_process: /* one of the parents may belong to another process, do it the h
}
/* see ClientToScreen */
-static BOOL client_to_screen( HWND hwnd, POINT *pt )
+BOOL client_to_screen( HWND hwnd, POINT *pt )
{
POINT offset;
BOOL mirrored;
More information about the wine-cvs
mailing list