mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-06 20:09:27 +00:00
win32u: Move default key messages implementation from user32.
Signed-off-by: Jacek Caban <jacek@codeweavers.com>
This commit is contained in:
parent
0395988052
commit
749e1b05d7
|
@ -36,15 +36,8 @@
|
|||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(win);
|
||||
|
||||
/* bits in the dwKeyData */
|
||||
#define KEYDATA_ALT 0x2000
|
||||
#define KEYDATA_PREVSTATE 0x4000
|
||||
|
||||
#define DRAG_FILE 0x454C4946
|
||||
|
||||
static short iF10Key = 0;
|
||||
static short iMenuSysKey = 0;
|
||||
|
||||
/***********************************************************************
|
||||
* DEFWND_HandleWindowPosChanged
|
||||
*
|
||||
|
@ -169,12 +162,6 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
|
|||
DEFWND_HandleWindowPosChanged( hwnd, (const WINDOWPOS *)lParam );
|
||||
break;
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_RBUTTONDOWN:
|
||||
case WM_MBUTTONDOWN:
|
||||
iF10Key = iMenuSysKey = 0;
|
||||
break;
|
||||
|
||||
case WM_RBUTTONUP:
|
||||
{
|
||||
POINT pt;
|
||||
|
@ -222,69 +209,6 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
|
|||
case WM_SYSCOMMAND:
|
||||
return NC_HandleSysCommand( hwnd, wParam, lParam );
|
||||
|
||||
case WM_KEYDOWN:
|
||||
if(wParam == VK_F10) iF10Key = VK_F10;
|
||||
break;
|
||||
|
||||
case WM_SYSKEYDOWN:
|
||||
if( HIWORD(lParam) & KEYDATA_ALT )
|
||||
{
|
||||
/* if( HIWORD(lParam) & ~KEYDATA_PREVSTATE ) */
|
||||
if ( (wParam == VK_MENU || wParam == VK_LMENU
|
||||
|| wParam == VK_RMENU) && !iMenuSysKey )
|
||||
iMenuSysKey = 1;
|
||||
else
|
||||
iMenuSysKey = 0;
|
||||
|
||||
iF10Key = 0;
|
||||
|
||||
if( wParam == VK_F4 ) /* try to close the window */
|
||||
{
|
||||
HWND top = NtUserGetAncestor( hwnd, GA_ROOT );
|
||||
if (!(GetClassLongW( top, GCL_STYLE ) & CS_NOCLOSE))
|
||||
PostMessageW( top, WM_SYSCOMMAND, SC_CLOSE, 0 );
|
||||
}
|
||||
}
|
||||
else if( wParam == VK_F10 )
|
||||
{
|
||||
if (NtUserGetKeyState(VK_SHIFT) & 0x8000)
|
||||
SendMessageW( hwnd, WM_CONTEXTMENU, (WPARAM)hwnd, -1 );
|
||||
iF10Key = 1;
|
||||
}
|
||||
else if (wParam == VK_ESCAPE && (NtUserGetKeyState(VK_SHIFT) & 0x8000))
|
||||
SendMessageW( hwnd, WM_SYSCOMMAND, SC_KEYMENU, ' ' );
|
||||
break;
|
||||
|
||||
case WM_KEYUP:
|
||||
case WM_SYSKEYUP:
|
||||
/* Press and release F10 or ALT */
|
||||
if (((wParam == VK_MENU || wParam == VK_LMENU || wParam == VK_RMENU)
|
||||
&& iMenuSysKey) || ((wParam == VK_F10) && iF10Key))
|
||||
SendMessageW( NtUserGetAncestor( hwnd, GA_ROOT ), WM_SYSCOMMAND, SC_KEYMENU, 0L );
|
||||
iMenuSysKey = iF10Key = 0;
|
||||
break;
|
||||
|
||||
case WM_SYSCHAR:
|
||||
{
|
||||
iMenuSysKey = 0;
|
||||
if (wParam == '\r' && IsIconic(hwnd))
|
||||
{
|
||||
PostMessageW( hwnd, WM_SYSCOMMAND, SC_RESTORE, 0L );
|
||||
break;
|
||||
}
|
||||
if ((HIWORD(lParam) & KEYDATA_ALT) && wParam)
|
||||
{
|
||||
if (wParam == '\t' || wParam == '\x1b') break;
|
||||
if (wParam == ' ' && (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD))
|
||||
SendMessageW( GetParent(hwnd), msg, wParam, lParam );
|
||||
else
|
||||
SendMessageW( hwnd, WM_SYSCOMMAND, SC_KEYMENU, wParam );
|
||||
}
|
||||
else /* check for Ctrl-Esc */
|
||||
if (wParam != '\x1b') MessageBeep(0);
|
||||
break;
|
||||
}
|
||||
|
||||
case WM_SHOWWINDOW:
|
||||
{
|
||||
LONG style = GetWindowLongW( hwnd, GWL_STYLE );
|
||||
|
@ -310,11 +234,6 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
|
|||
break;
|
||||
}
|
||||
|
||||
case WM_CANCELMODE:
|
||||
iMenuSysKey = 0;
|
||||
NtUserMessageCall( hwnd, msg, wParam, lParam, 0, NtUserDefWindowProc, FALSE );
|
||||
break;
|
||||
|
||||
case WM_VKEYTOITEM:
|
||||
case WM_CHARTOITEM:
|
||||
return -1;
|
||||
|
@ -485,6 +404,7 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
|
|||
break;
|
||||
|
||||
case WM_SETTEXT:
|
||||
case WM_SYSCHAR:
|
||||
result = NtUserMessageCall( hwnd, msg, wParam, lParam, 0, NtUserDefWindowProc, TRUE );
|
||||
break;
|
||||
|
||||
|
@ -556,14 +476,6 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
|
|||
}
|
||||
break;
|
||||
|
||||
case WM_SYSCHAR:
|
||||
{
|
||||
CHAR ch = LOWORD(wParam);
|
||||
WCHAR wch;
|
||||
MultiByteToWideChar(CP_ACP, 0, &ch, 1, &wch, 1);
|
||||
wParam = MAKEWPARAM( wch, HIWORD(wParam) );
|
||||
}
|
||||
/* fall through */
|
||||
default:
|
||||
result = DEFWND_DefWinProc( hwnd, msg, wParam, lParam );
|
||||
break;
|
||||
|
|
|
@ -31,6 +31,13 @@
|
|||
WINE_DEFAULT_DEBUG_CHANNEL(win);
|
||||
|
||||
|
||||
/* bits in the dwKeyData */
|
||||
#define KEYDATA_ALT 0x2000
|
||||
#define KEYDATA_PREVSTATE 0x4000
|
||||
|
||||
static short f10_key = 0;
|
||||
static short menu_sys_key = 0;
|
||||
|
||||
static BOOL has_dialog_frame( UINT style, UINT ex_style )
|
||||
{
|
||||
return (ex_style & WS_EX_DLGMODALFRAME) || ((style & WS_DLGFRAME) && !(style & WS_THICKFRAME));
|
||||
|
@ -2404,6 +2411,7 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
|
|||
break;
|
||||
|
||||
case WM_CANCELMODE:
|
||||
menu_sys_key = 0;
|
||||
end_menu( hwnd );
|
||||
if (get_capture() == hwnd) release_capture();
|
||||
break;
|
||||
|
@ -2443,6 +2451,78 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
|
|||
result = handle_sys_command( hwnd, wparam, lparam );
|
||||
break;
|
||||
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_RBUTTONDOWN:
|
||||
case WM_MBUTTONDOWN:
|
||||
f10_key = menu_sys_key = 0;
|
||||
break;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
if (wparam == VK_F10) f10_key = VK_F10;
|
||||
break;
|
||||
|
||||
case WM_SYSKEYDOWN:
|
||||
if (HIWORD( lparam ) & KEYDATA_ALT)
|
||||
{
|
||||
if ((wparam == VK_MENU || wparam == VK_LMENU || wparam == VK_RMENU) && !menu_sys_key)
|
||||
menu_sys_key = 1;
|
||||
else
|
||||
menu_sys_key = 0;
|
||||
|
||||
f10_key = 0;
|
||||
|
||||
if (wparam == VK_F4) /* try to close the window */
|
||||
{
|
||||
HWND top = NtUserGetAncestor( hwnd, GA_ROOT );
|
||||
if (!(get_class_long( top, GCL_STYLE, FALSE ) & CS_NOCLOSE))
|
||||
NtUserPostMessage( top, WM_SYSCOMMAND, SC_CLOSE, 0 );
|
||||
}
|
||||
}
|
||||
else if (wparam == VK_F10)
|
||||
{
|
||||
if (NtUserGetKeyState(VK_SHIFT) & 0x8000)
|
||||
send_message( hwnd, WM_CONTEXTMENU, (WPARAM)hwnd, -1 );
|
||||
f10_key = 1;
|
||||
}
|
||||
else if (wparam == VK_ESCAPE && (NtUserGetKeyState( VK_SHIFT ) & 0x8000))
|
||||
send_message( hwnd, WM_SYSCOMMAND, SC_KEYMENU, ' ' );
|
||||
break;
|
||||
|
||||
case WM_KEYUP:
|
||||
case WM_SYSKEYUP:
|
||||
/* Press and release F10 or ALT */
|
||||
if (((wparam == VK_MENU || wparam == VK_LMENU || wparam == VK_RMENU) && menu_sys_key) ||
|
||||
(wparam == VK_F10 && f10_key))
|
||||
send_message( NtUserGetAncestor( hwnd, GA_ROOT ), WM_SYSCOMMAND, SC_KEYMENU, 0 );
|
||||
menu_sys_key = f10_key = 0;
|
||||
break;
|
||||
|
||||
case WM_SYSCHAR:
|
||||
menu_sys_key = 0;
|
||||
if (wparam == '\r' && is_iconic( hwnd ))
|
||||
{
|
||||
NtUserPostMessage( hwnd, WM_SYSCOMMAND, SC_RESTORE, 0 );
|
||||
break;
|
||||
}
|
||||
if ((HIWORD( lparam ) & KEYDATA_ALT) && wparam)
|
||||
{
|
||||
WCHAR wch;
|
||||
if (ansi)
|
||||
{
|
||||
char ch = wparam;
|
||||
win32u_mbtowc( &ansi_cp, &wch, 1, &ch, 1 );
|
||||
}
|
||||
else wch = wparam;
|
||||
if (wch == '\t' || wch == '\x1b') break;
|
||||
if (wch == ' ' && (get_window_long( hwnd, GWL_STYLE ) & WS_CHILD))
|
||||
send_message( get_parent( hwnd ), msg, wch, lparam );
|
||||
else
|
||||
send_message( hwnd, WM_SYSCOMMAND, SC_KEYMENU, wch );
|
||||
}
|
||||
else if (wparam != '\x1b') /* Ctrl-Esc */
|
||||
message_beep(0);
|
||||
break;
|
||||
|
||||
case WM_KEYF1:
|
||||
{
|
||||
HELPINFO hi;
|
||||
|
|
Loading…
Reference in a new issue