Commit fc940d58 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Move WM_CONTEXTMENU and WM_POPUPSYSTEMMENU implementation from user32.

parent b9d8a842
......@@ -119,7 +119,6 @@ extern void MENU_EndMenu(HWND) DECLSPEC_HIDDEN;
extern HMENU MENU_GetSysMenu( HWND hWnd, HMENU hPopupMenu ) DECLSPEC_HIDDEN;
/* nonclient area */
extern LRESULT NC_HandleNCHitTest( HWND hwnd, POINT pt ) DECLSPEC_HIDDEN;
extern LRESULT NC_HandleNCMouseMove( HWND hwnd, WPARAM wParam, LPARAM lParam ) DECLSPEC_HIDDEN;
extern LRESULT NC_HandleNCMouseLeave( HWND hwnd ) DECLSPEC_HIDDEN;
extern LRESULT NC_HandleNCLButtonDblClk( HWND hwnd, WPARAM wParam, LPARAM lParam) DECLSPEC_HIDDEN;
......
......@@ -209,32 +209,6 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
}
break;
case WM_CONTEXTMENU:
if (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
SendMessageW( GetParent(hwnd), msg, (WPARAM)hwnd, lParam );
else
{
LONG hitcode;
POINT pt;
pt.x = (short)LOWORD(lParam);
pt.y = (short)HIWORD(lParam);
hitcode = NC_HandleNCHitTest(hwnd, pt);
/* Track system popup if click was in the caption area. */
if (hitcode==HTCAPTION || hitcode==HTSYSMENU)
TrackPopupMenu( NtUserGetSystemMenu(hwnd, FALSE),
TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
pt.x, pt.y, 0, hwnd, NULL );
}
break;
case WM_POPUPSYSTEMMENU:
/* This is an undocumented message used by the windows taskbar to
display the system menu of windows that belong to other processes. */
TrackPopupMenu( NtUserGetSystemMenu(hwnd, FALSE), TPM_LEFTBUTTON|TPM_RIGHTBUTTON,
(short)LOWORD(lParam), (short)HIWORD(lParam), 0, hwnd, NULL );
return 0;
case WM_PRINT:
DEFWND_Print(hwnd, (HDC)wParam, lParam);
return 0;
......
......@@ -377,188 +377,6 @@ static void NC_GetInsideRect( HWND hwnd, enum coords_relative relative, RECT *re
}
}
/***********************************************************************
* NC_HandleNCHitTest
*
* Handle a WM_NCHITTEST message. Called from DefWindowProc().
*/
LRESULT NC_HandleNCHitTest( HWND hwnd, POINT pt )
{
RECT rect, rcClient;
DWORD style, ex_style;
TRACE("hwnd=%p pt=%ld,%ld\n", hwnd, pt.x, pt.y );
WIN_GetRectangles( hwnd, COORDS_SCREEN, &rect, &rcClient );
if (!PtInRect( &rect, pt )) return HTNOWHERE;
style = GetWindowLongW( hwnd, GWL_STYLE );
ex_style = GetWindowLongW( hwnd, GWL_EXSTYLE );
if (PtInRect( &rcClient, pt )) return HTCLIENT;
/* Check borders */
if (HAS_THICKFRAME( style, ex_style ))
{
InflateRect( &rect, -GetSystemMetrics(SM_CXFRAME), -GetSystemMetrics(SM_CYFRAME) );
if (!PtInRect( &rect, pt ))
{
/* Check top sizing border */
if (pt.y < rect.top)
{
if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTTOPLEFT;
if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTTOPRIGHT;
return HTTOP;
}
/* Check bottom sizing border */
if (pt.y >= rect.bottom)
{
if (pt.x < rect.left+GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMLEFT;
if (pt.x >= rect.right-GetSystemMetrics(SM_CXSIZE)) return HTBOTTOMRIGHT;
return HTBOTTOM;
}
/* Check left sizing border */
if (pt.x < rect.left)
{
if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPLEFT;
if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMLEFT;
return HTLEFT;
}
/* Check right sizing border */
if (pt.x >= rect.right)
{
if (pt.y < rect.top+GetSystemMetrics(SM_CYSIZE)) return HTTOPRIGHT;
if (pt.y >= rect.bottom-GetSystemMetrics(SM_CYSIZE)) return HTBOTTOMRIGHT;
return HTRIGHT;
}
}
}
else /* No thick frame */
{
if (HAS_DLGFRAME( style, ex_style ))
InflateRect(&rect, -GetSystemMetrics(SM_CXDLGFRAME), -GetSystemMetrics(SM_CYDLGFRAME));
else if (HAS_THINFRAME( style ))
InflateRect(&rect, -GetSystemMetrics(SM_CXBORDER), -GetSystemMetrics(SM_CYBORDER));
if (!PtInRect( &rect, pt )) return HTBORDER;
}
/* Check caption */
if ((style & WS_CAPTION) == WS_CAPTION)
{
if (ex_style & WS_EX_TOOLWINDOW)
rect.top += GetSystemMetrics(SM_CYSMCAPTION) - 1;
else
rect.top += GetSystemMetrics(SM_CYCAPTION) - 1;
if (!PtInRect( &rect, pt ))
{
BOOL min_or_max_box = (style & WS_SYSMENU) && (style & (WS_MINIMIZEBOX|WS_MAXIMIZEBOX));
if (ex_style & WS_EX_LAYOUTRTL)
{
/* Check system menu */
if ((style & WS_SYSMENU) && !(ex_style & WS_EX_TOOLWINDOW) && NC_IconForWindow(hwnd))
{
rect.right -= GetSystemMetrics(SM_CYCAPTION) - 1;
if (pt.x > rect.right) return HTSYSMENU;
}
/* Check close button */
if (style & WS_SYSMENU)
{
rect.left += GetSystemMetrics(SM_CYCAPTION);
if (pt.x < rect.left) return HTCLOSE;
}
/* Check maximize box */
/* In win95 there is automatically a Maximize button when there is a minimize one*/
if (min_or_max_box && !(ex_style & WS_EX_TOOLWINDOW))
{
rect.left += GetSystemMetrics(SM_CXSIZE);
if (pt.x < rect.left) return HTMAXBUTTON;
}
/* Check minimize box */
if (min_or_max_box && !(ex_style & WS_EX_TOOLWINDOW))
{
rect.left += GetSystemMetrics(SM_CXSIZE);
if (pt.x < rect.left) return HTMINBUTTON;
}
}
else
{
/* Check system menu */
if ((style & WS_SYSMENU) && !(ex_style & WS_EX_TOOLWINDOW) && NC_IconForWindow(hwnd))
{
rect.left += GetSystemMetrics(SM_CYCAPTION) - 1;
if (pt.x < rect.left) return HTSYSMENU;
}
/* Check close button */
if (style & WS_SYSMENU)
{
rect.right -= GetSystemMetrics(SM_CYCAPTION);
if (pt.x > rect.right) return HTCLOSE;
}
/* Check maximize box */
/* In win95 there is automatically a Maximize button when there is a minimize one*/
if (min_or_max_box && !(ex_style & WS_EX_TOOLWINDOW))
{
rect.right -= GetSystemMetrics(SM_CXSIZE);
if (pt.x > rect.right) return HTMAXBUTTON;
}
/* Check minimize box */
if (min_or_max_box && !(ex_style & WS_EX_TOOLWINDOW))
{
rect.right -= GetSystemMetrics(SM_CXSIZE);
if (pt.x > rect.right) return HTMINBUTTON;
}
}
return HTCAPTION;
}
}
/* Check menu bar */
if (HAS_MENU( hwnd, style ) && (pt.y < rcClient.top) &&
(pt.x >= rcClient.left) && (pt.x < rcClient.right))
return HTMENU;
/* Check vertical scroll bar */
if (ex_style & WS_EX_LAYOUTRTL) ex_style ^= WS_EX_LEFTSCROLLBAR;
if (style & WS_VSCROLL)
{
if((ex_style & WS_EX_LEFTSCROLLBAR) != 0)
rcClient.left -= GetSystemMetrics(SM_CXVSCROLL);
else
rcClient.right += GetSystemMetrics(SM_CXVSCROLL);
if (PtInRect( &rcClient, pt )) return HTVSCROLL;
}
/* Check horizontal scroll bar */
if (style & WS_HSCROLL)
{
rcClient.bottom += GetSystemMetrics(SM_CYHSCROLL);
if (PtInRect( &rcClient, pt ))
{
/* Check size box */
if ((style & WS_VSCROLL) &&
((((ex_style & WS_EX_LEFTSCROLLBAR) != 0) && (pt.x <= rcClient.left + GetSystemMetrics(SM_CXVSCROLL))) ||
(((ex_style & WS_EX_LEFTSCROLLBAR) == 0) && (pt.x >= rcClient.right - GetSystemMetrics(SM_CXVSCROLL)))))
return HTSIZE;
return HTHSCROLL;
}
}
/* Has to return HTNOWHERE if nothing was found
Could happen when a window has a customized non client area */
return HTNOWHERE;
}
LRESULT NC_HandleNCMouseMove(HWND hwnd, WPARAM wParam, LPARAM lParam)
{
RECT rect;
......
......@@ -2063,6 +2063,32 @@ LRESULT default_window_proc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam,
case WM_NCRBUTTONDOWN:
return handle_nc_rbutton_down( hwnd, wparam, lparam );
case WM_CONTEXTMENU:
if (get_window_long( hwnd, GWL_STYLE ) & WS_CHILD)
send_message( get_parent( hwnd ), msg, (WPARAM)hwnd, lparam );
else
{
LONG hitcode;
POINT pt;
pt.x = (short)LOWORD( lparam );
pt.y = (short)HIWORD( lparam );
hitcode = handle_nc_hit_test( hwnd, pt );
/* Track system popup if click was in the caption area. */
if (hitcode == HTCAPTION || hitcode == HTSYSMENU)
NtUserTrackPopupMenuEx( NtUserGetSystemMenu( hwnd, FALSE ),
TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
pt.x, pt.y, hwnd, NULL );
}
break;
case WM_POPUPSYSTEMMENU:
/* This is an undocumented message used by the windows taskbar to
* display the system menu of windows that belong to other processes. */
NtUserTrackPopupMenuEx( NtUserGetSystemMenu( hwnd, FALSE ), TPM_LEFTBUTTON | TPM_RIGHTBUTTON,
(short)LOWORD(lparam), (short)HIWORD(lparam), hwnd, NULL );
return 0;
case WM_WINDOWPOSCHANGING:
return handle_window_pos_changing( hwnd, (WINDOWPOS *)lparam );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment