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))
{
/* 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_TrackMenu( hMenu, wFlags, pt.x, pt.y, hWnd, NULL );
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
* 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 */
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
*/
@ -1156,38 +1208,9 @@ static LRESULT WINAPI ScrollBarWndProc( HWND hwnd, UINT message, WPARAM wParam,
case WM_LBUTTONDOWN:
{
POINT pt;
MSG msg;
pt.x = SLOWORD(lParam);
pt.y = SHIWORD(lParam);
SetCapture( hwnd );
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);
SCROLL_TrackScrollBar( hwnd, SB_CTL, pt );
}
break;
case WM_LBUTTONUP:

View File

@ -50,7 +50,7 @@ extern UINT MENU_FindSubMenu( HMENU *hmenu, HMENU hSubTarget );
/* scrollbar */
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,
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_HandleNCLButtonDown( 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 void NC_DrawSysButton( 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 );
case WM_SYSCOMMAND:
{
POINT pt;
pt.x = SLOWORD(lParam);
pt.y = SHIWORD(lParam);
return NC_HandleSysCommand( hwnd, wParam, pt );
}
return NC_HandleSysCommand( hwnd, wParam, lParam );
case WM_KEYDOWN:
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 )
{
MSG msg;
INT scrollbar;
WND *wndPtr = WIN_FindWndPtr( hwnd );
if ((wParam & 0xfff0) == SC_HSCROLL)
{
if ((wParam & 0x0f) != HTHSCROLL) goto END;
if ((wParam & 0x0f) != HTHSCROLL) return;
scrollbar = SB_HORZ;
}
else /* SC_VSCROLL */
{
if ((wParam & 0x0f) != HTVSCROLL) goto END;
if ((wParam & 0x0f) != HTVSCROLL) return;
scrollbar = SB_VERT;
}
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);
SCROLL_TrackScrollBar( hwnd, scrollbar, pt );
}
/***********************************************************************
* NC_HandleNCLButtonDown
*
@ -2130,20 +2098,11 @@ LONG NC_HandleNCLButtonDblClk( HWND hwnd, WPARAM wParam, LPARAM lParam )
*
* 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 );
UINT16 uCommand = wParam & 0xFFF0;
TRACE("Handling WM_SYSCOMMAND %x %lx\n", wParam, lParam );
TRACE("Handling WM_SYSCOMMAND %x %ld,%ld\n", wParam, pt.x, pt.y );
if (uCommand != SC_KEYMENU)
{
HWND parent = GetAncestor( hwnd, GA_PARENT );
if (parent != GetDesktopWindow()) ScreenToClient( parent, &pt );
}
switch (uCommand)
switch (wParam & 0xfff0)
{
case SC_SIZE:
case SC_MOVE:
@ -2170,22 +2129,31 @@ LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt )
break;
case SC_CLOSE:
WIN_ReleaseWndPtr(wndPtr);
return SendMessageA( hwnd, WM_CLOSE, 0, 0 );
case SC_VSCROLL:
case SC_HSCROLL:
NC_TrackScrollBar( hwnd, wParam, pt );
{
POINT pt;
pt.x = SLOWORD(lParam);
pt.y = SHIWORD(lParam);
NC_TrackScrollBar( hwnd, wParam, pt );
}
break;
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;
case SC_KEYMENU:
MENU_TrackKbdMenuBar( hwnd, wParam , pt.x );
MENU_TrackKbdMenuBar( hwnd, wParam, LOWORD(lParam) );
break;
case SC_TASKLIST:
WinExec( "taskman.exe", SW_SHOWNORMAL );
break;
@ -2213,7 +2181,6 @@ LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, POINT pt )
FIXME("unimplemented!\n");
break;
}
WIN_ReleaseWndPtr(wndPtr);
return 0;
}