Moved scrollbar tracking code to scroll.c.

Avoid unnecessary coordinates conversion in NC_HandleSysCommand.
This commit is contained in:
Alexandre Julliard 2001-10-16 21:52:26 +00:00
parent 2895e7f4fa
commit b662e11a00
6 changed files with 82 additions and 93 deletions

View File

@ -2944,6 +2944,10 @@ void MENU_TrackMouseMenuBar( HWND hWnd, INT ht, POINT pt )
if (IsMenu(hMenu)) if (IsMenu(hMenu))
{ {
/* map point to parent client coordinates */
HWND parent = GetAncestor( hWnd, GA_PARENT );
if (parent != GetDesktopWindow()) ScreenToClient( parent, &pt );
MENU_InitTracking( hWnd, hMenu, FALSE, wFlags ); MENU_InitTracking( hWnd, hMenu, FALSE, wFlags );
MENU_TrackMenu( hMenu, wFlags, pt.x, pt.y, hWnd, NULL ); MENU_TrackMenu( hMenu, wFlags, pt.x, pt.y, hWnd, NULL );
MENU_ExitTracking(hWnd); MENU_ExitTracking(hWnd);

View File

@ -895,7 +895,7 @@ static void SCROLL_HandleKbdEvent( HWND hwnd, WPARAM wParam )
* 'pt' is the location of the mouse event in client (for SB_CTL) or * 'pt' is the location of the mouse event in client (for SB_CTL) or
* windows coordinates. * windows coordinates.
*/ */
void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt) static void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt)
{ {
/* Previous mouse position for timer events */ /* Previous mouse position for timer events */
static POINT prevPt; static POINT prevPt;
@ -1109,6 +1109,58 @@ void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt)
} }
/***********************************************************************
* SCROLL_TrackScrollBar
*
* Track a mouse button press on a scroll-bar.
* pt is in screen-coordinates for non-client scroll bars.
*/
void SCROLL_TrackScrollBar( HWND hwnd, INT scrollbar, POINT pt )
{
MSG msg;
INT xoffset = 0, yoffset = 0;
if (scrollbar != SB_CTL)
{
WND *wndPtr = WIN_GetPtr( hwnd );
if (!wndPtr || wndPtr == WND_OTHER_PROCESS) return;
xoffset = wndPtr->rectClient.left - wndPtr->rectWindow.left;
yoffset = wndPtr->rectClient.top - wndPtr->rectWindow.top;
WIN_ReleasePtr( wndPtr );
ScreenToClient( hwnd, &pt );
pt.x += xoffset;
pt.y += yoffset;
}
SCROLL_HandleScrollEvent( hwnd, scrollbar, WM_LBUTTONDOWN, pt );
do
{
if (!GetMessageW( &msg, 0, 0, 0 )) break;
if (CallMsgFilterW( &msg, MSGF_SCROLLBAR )) continue;
switch(msg.message)
{
case WM_LBUTTONUP:
case WM_MOUSEMOVE:
case WM_SYSTIMER:
pt.x = LOWORD(msg.lParam) + xoffset;
pt.y = HIWORD(msg.lParam) + yoffset;
SCROLL_HandleScrollEvent( hwnd, scrollbar, msg.message, pt );
break;
default:
TranslateMessage( &msg );
DispatchMessageW( &msg );
break;
}
if (!IsWindow( hwnd ))
{
ReleaseCapture();
break;
}
} while (msg.message != WM_LBUTTONUP);
}
/*********************************************************************** /***********************************************************************
* ScrollBarWndProc * ScrollBarWndProc
*/ */
@ -1156,38 +1208,9 @@ static LRESULT WINAPI ScrollBarWndProc( HWND hwnd, UINT message, WPARAM wParam,
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
{ {
POINT pt; POINT pt;
MSG msg;
pt.x = SLOWORD(lParam); pt.x = SLOWORD(lParam);
pt.y = SHIWORD(lParam); pt.y = SHIWORD(lParam);
SetCapture( hwnd ); SCROLL_TrackScrollBar( hwnd, SB_CTL, pt );
SCROLL_HandleScrollEvent( hwnd, SB_CTL, message, pt );
TRACE("Doing LBUTTONDOWN loop hwnd=%08x\n", hwnd);
do {
if (!GetMessageW( &msg, 0, 0, 0 )) break;
if (CallMsgFilterW( &msg, MSGF_SCROLLBAR )) continue;
switch(msg.message)
{
case WM_LBUTTONUP:
case WM_MOUSEMOVE:
case WM_SYSTIMER:
pt.x = LOWORD(msg.lParam);
pt.y = HIWORD(msg.lParam);
SCROLL_HandleScrollEvent( hwnd, SB_CTL, msg.message, pt );
break;
default:
TranslateMessage( &msg );
DispatchMessageW( &msg );
break;
}
if (!IsWindow( hwnd ))
{
ReleaseCapture();
break;
}
} while (msg.message != WM_LBUTTONUP);
TRACE("Out ofLBUTTON loop hwnd=%08x\n", hwnd);
} }
break; break;
case WM_LBUTTONUP: case WM_LBUTTONUP:

View File

@ -50,7 +50,7 @@ extern UINT MENU_FindSubMenu( HMENU *hmenu, HMENU hSubTarget );
/* scrollbar */ /* scrollbar */
extern void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT nBar, BOOL arrows, BOOL interior ); extern void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT nBar, BOOL arrows, BOOL interior );
extern void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt ); extern void SCROLL_TrackScrollBar( HWND hwnd, INT scrollbar, POINT pt );
extern INT SCROLL_SetNCSbState( HWND hwnd, int vMin, int vMax, int vPos, extern INT SCROLL_SetNCSbState( HWND hwnd, int vMin, int vMax, int vPos,
int hMin, int hMax, int hPos ); int hMin, int hMax, int hPos );

View File

@ -15,7 +15,7 @@ extern LONG NC_HandleNCCalcSize( HWND hwnd, RECT *winRect );
extern LONG NC_HandleNCHitTest( HWND hwnd, POINT pt ); extern LONG NC_HandleNCHitTest( HWND hwnd, POINT pt );
extern LONG NC_HandleNCLButtonDown( HWND hwnd, WPARAM wParam, LPARAM lParam ); extern LONG NC_HandleNCLButtonDown( HWND hwnd, WPARAM wParam, LPARAM lParam );
extern LONG NC_HandleNCLButtonDblClk( HWND hwnd, WPARAM wParam, LPARAM lParam); extern LONG NC_HandleNCLButtonDblClk( HWND hwnd, WPARAM wParam, LPARAM lParam);
extern LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt ); extern LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, LPARAM lParam );
extern LONG NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam ); extern LONG NC_HandleSetCursor( HWND hwnd, WPARAM wParam, LPARAM lParam );
extern void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down ); extern void NC_DrawSysButton( HWND hwnd, HDC hdc, BOOL down );
extern BOOL NC_DrawSysButton95( HWND hwnd, HDC hdc, BOOL down ); extern BOOL NC_DrawSysButton95( HWND hwnd, HDC hdc, BOOL down );

View File

@ -500,12 +500,7 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
return NC_HandleSetCursor( hwnd, wParam, lParam ); return NC_HandleSetCursor( hwnd, wParam, lParam );
case WM_SYSCOMMAND: case WM_SYSCOMMAND:
{ return NC_HandleSysCommand( hwnd, wParam, lParam );
POINT pt;
pt.x = SLOWORD(lParam);
pt.y = SHIWORD(lParam);
return NC_HandleSysCommand( hwnd, wParam, pt );
}
case WM_KEYDOWN: case WM_KEYDOWN:
if(wParam == VK_F10) iF10Key = VK_F10; if(wParam == VK_F10) iF10Key = VK_F10;

View File

@ -1954,54 +1954,22 @@ NC_TrackCloseButton95 (HWND hwnd, WORD wParam)
*/ */
static void NC_TrackScrollBar( HWND hwnd, WPARAM wParam, POINT pt ) static void NC_TrackScrollBar( HWND hwnd, WPARAM wParam, POINT pt )
{ {
MSG msg;
INT scrollbar; INT scrollbar;
WND *wndPtr = WIN_FindWndPtr( hwnd );
if ((wParam & 0xfff0) == SC_HSCROLL) if ((wParam & 0xfff0) == SC_HSCROLL)
{ {
if ((wParam & 0x0f) != HTHSCROLL) goto END; if ((wParam & 0x0f) != HTHSCROLL) return;
scrollbar = SB_HORZ; scrollbar = SB_HORZ;
} }
else /* SC_VSCROLL */ else /* SC_VSCROLL */
{ {
if ((wParam & 0x0f) != HTVSCROLL) goto END; if ((wParam & 0x0f) != HTVSCROLL) return;
scrollbar = SB_VERT; scrollbar = SB_VERT;
} }
SCROLL_TrackScrollBar( hwnd, scrollbar, pt );
pt.x -= wndPtr->rectWindow.left;
pt.y -= wndPtr->rectWindow.top;
SetCapture( hwnd );
SCROLL_HandleScrollEvent( hwnd, scrollbar, WM_LBUTTONDOWN, pt );
do
{
if (!GetMessageW( &msg, 0, 0, 0 )) break;
if (CallMsgFilterW( &msg, MSGF_SCROLLBAR )) continue;
switch(msg.message)
{
case WM_LBUTTONUP:
case WM_MOUSEMOVE:
case WM_SYSTIMER:
pt.x = LOWORD(msg.lParam) + wndPtr->rectClient.left - wndPtr->rectWindow.left;
pt.y = HIWORD(msg.lParam) + wndPtr->rectClient.top - wndPtr->rectWindow.top;
SCROLL_HandleScrollEvent( hwnd, scrollbar, msg.message, pt );
break;
default:
TranslateMessage( &msg );
DispatchMessageW( &msg );
break;
}
if (!IsWindow( hwnd ))
{
ReleaseCapture();
break;
}
} while (msg.message != WM_LBUTTONUP);
END:
WIN_ReleaseWndPtr(wndPtr);
} }
/*********************************************************************** /***********************************************************************
* NC_HandleNCLButtonDown * NC_HandleNCLButtonDown
* *
@ -2130,20 +2098,11 @@ LONG NC_HandleNCLButtonDblClk( HWND hwnd, WPARAM wParam, LPARAM lParam )
* *
* Handle a WM_SYSCOMMAND message. Called from DefWindowProc(). * Handle a WM_SYSCOMMAND message. Called from DefWindowProc().
*/ */
LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt ) LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, LPARAM lParam )
{ {
WND *wndPtr = WIN_FindWndPtr( hwnd ); TRACE("Handling WM_SYSCOMMAND %x %lx\n", wParam, lParam );
UINT16 uCommand = wParam & 0xFFF0;
TRACE("Handling WM_SYSCOMMAND %x %ld,%ld\n", wParam, pt.x, pt.y ); switch (wParam & 0xfff0)
if (uCommand != SC_KEYMENU)
{
HWND parent = GetAncestor( hwnd, GA_PARENT );
if (parent != GetDesktopWindow()) ScreenToClient( parent, &pt );
}
switch (uCommand)
{ {
case SC_SIZE: case SC_SIZE:
case SC_MOVE: case SC_MOVE:
@ -2170,22 +2129,31 @@ LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt )
break; break;
case SC_CLOSE: case SC_CLOSE:
WIN_ReleaseWndPtr(wndPtr);
return SendMessageA( hwnd, WM_CLOSE, 0, 0 ); return SendMessageA( hwnd, WM_CLOSE, 0, 0 );
case SC_VSCROLL: case SC_VSCROLL:
case SC_HSCROLL: case SC_HSCROLL:
NC_TrackScrollBar( hwnd, wParam, pt ); {
POINT pt;
pt.x = SLOWORD(lParam);
pt.y = SHIWORD(lParam);
NC_TrackScrollBar( hwnd, wParam, pt );
}
break; break;
case SC_MOUSEMENU: case SC_MOUSEMENU:
MENU_TrackMouseMenuBar( hwnd, wParam & 0x000F, pt ); {
POINT pt;
pt.x = SLOWORD(lParam);
pt.y = SHIWORD(lParam);
MENU_TrackMouseMenuBar( hwnd, wParam & 0x000F, pt );
}
break; break;
case SC_KEYMENU: case SC_KEYMENU:
MENU_TrackKbdMenuBar( hwnd, wParam , pt.x ); MENU_TrackKbdMenuBar( hwnd, wParam, LOWORD(lParam) );
break; break;
case SC_TASKLIST: case SC_TASKLIST:
WinExec( "taskman.exe", SW_SHOWNORMAL ); WinExec( "taskman.exe", SW_SHOWNORMAL );
break; break;
@ -2213,7 +2181,6 @@ LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt )
FIXME("unimplemented!\n"); FIXME("unimplemented!\n");
break; break;
} }
WIN_ReleaseWndPtr(wndPtr);
return 0; return 0;
} }