From a51bb8151d15f02725536e3043a1912020c51449 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 12 Jan 2004 21:15:16 +0000 Subject: [PATCH] ScrollDC doesn't need to be in the graphics driver. --- dlls/user/user_main.c | 1 - dlls/x11drv/scroll.c | 90 +-------------------- dlls/x11drv/x11drv.spec | 1 - include/user.h | 1 - {dlls/x11drv => windows}/scroll.c | 161 ++++++++++++++++++-------------------- 5 files changed, 77 insertions(+), 177 deletions(-) copy {dlls/x11drv => windows}/scroll.c (57%) diff --git a/dlls/user/user_main.c b/dlls/user/user_main.c index aebce243dca..d3add4713bb 100644 --- a/dlls/user/user_main.c +++ b/dlls/user/user_main.c @@ -111,7 +111,6 @@ static BOOL load_driver(void) GET_USER_FUNC(ForceWindowRaise); GET_USER_FUNC(MsgWaitForMultipleObjectsEx); GET_USER_FUNC(ReleaseDC); - GET_USER_FUNC(ScrollDC); GET_USER_FUNC(ScrollWindowEx); GET_USER_FUNC(SetFocus); GET_USER_FUNC(SetParent); diff --git a/dlls/x11drv/scroll.c b/dlls/x11drv/scroll.c index 6d826e819d8..7bec346ea35 100644 --- a/dlls/x11drv/scroll.c +++ b/dlls/x11drv/scroll.c @@ -38,94 +38,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(scroll); /************************************************************************* - * ScrollDC (X11DRV.@) - * - * dx, dy, lprcScroll and lprcClip are all in logical coordinates (msdn is wrong) - * hrgnUpdate is returned in device coordinates with rcUpdate in logical coordinates. - * - */ -BOOL X11DRV_ScrollDC( HDC hdc, INT dx, INT dy, const RECT *lprcScroll, - const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate ) -{ - RECT rSrc, rClipped_src, rClip, rDst, offset; - - TRACE( "%p %d,%d hrgnUpdate=%p lprcUpdate = %p\n", hdc, dx, dy, hrgnUpdate, lprcUpdate ); - if (lprcClip) TRACE( "lprcClip = %s\n", wine_dbgstr_rect(lprcClip)); - if (lprcScroll) TRACE( "lprcScroll = %s\n", wine_dbgstr_rect(lprcScroll)); - - /* compute device clipping region (in device coordinates) */ - - if (lprcScroll) rSrc = *lprcScroll; - else GetClipBox( hdc, &rSrc ); - LPtoDP(hdc, (LPPOINT)&rSrc, 2); - - if (lprcClip) rClip = *lprcClip; - else GetClipBox( hdc, &rClip ); - LPtoDP(hdc, (LPPOINT)&rClip, 2); - - IntersectRect( &rClipped_src, &rSrc, &rClip ); - TRACE("rSrc %s rClip %s clipped rSrc %s\n", wine_dbgstr_rect(&rSrc), - wine_dbgstr_rect(&rClip), wine_dbgstr_rect(&rClipped_src)); - - rDst = rClipped_src; - SetRect(&offset, 0, 0, dx, dy); - LPtoDP(hdc, (LPPOINT)&offset, 2); - OffsetRect( &rDst, offset.right - offset.left, offset.bottom - offset.top ); - TRACE("rDst before clipping %s\n", wine_dbgstr_rect(&rDst)); - IntersectRect( &rDst, &rDst, &rClip ); - TRACE("rDst after clipping %s\n", wine_dbgstr_rect(&rDst)); - - if (!IsRectEmpty(&rDst)) - { - /* copy bits */ - RECT rDst_lp = rDst, rSrc_lp = rDst; - - OffsetRect( &rSrc_lp, offset.left - offset.right, offset.top - offset.bottom ); - DPtoLP(hdc, (LPPOINT)&rDst_lp, 2); - DPtoLP(hdc, (LPPOINT)&rSrc_lp, 2); - - if (!BitBlt( hdc, rDst_lp.left, rDst_lp.top, - rDst_lp.right - rDst_lp.left, rDst_lp.bottom - rDst_lp.top, - hdc, rSrc_lp.left, rSrc_lp.top, SRCCOPY)) - return FALSE; - } - - /* compute update areas. This is the clipped source or'ed with the unclipped source translated minus the - clipped src translated (rDst) all clipped to rClip */ - - if (hrgnUpdate || lprcUpdate) - { - HRGN hrgn = hrgnUpdate, hrgn2; - - if (hrgn) SetRectRgn( hrgn, rClipped_src.left, rClipped_src.top, rClipped_src.right, rClipped_src.bottom ); - else hrgn = CreateRectRgn( rClipped_src.left, rClipped_src.top, rClipped_src.right, rClipped_src.bottom ); - - hrgn2 = CreateRectRgnIndirect( &rSrc ); - OffsetRgn(hrgn2, offset.right - offset.left, offset.bottom - offset.top ); - CombineRgn(hrgn, hrgn, hrgn2, RGN_OR); - - SetRectRgn( hrgn2, rDst.left, rDst.top, rDst.right, rDst.bottom ); - CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF ); - - SetRectRgn( hrgn2, rClip.left, rClip.top, rClip.right, rClip.bottom ); - CombineRgn( hrgn, hrgn, hrgn2, RGN_AND ); - - if( lprcUpdate ) - { - GetRgnBox( hrgn, lprcUpdate ); - - /* Put the lprcUpdate in logical coordinate */ - DPtoLP( hdc, (LPPOINT)lprcUpdate, 2 ); - TRACE("returning lprcUpdate %s\n", wine_dbgstr_rect(lprcUpdate)); - } - if (!hrgnUpdate) DeleteObject( hrgn ); - DeleteObject( hrgn2 ); - } - return TRUE; -} - - -/************************************************************************* * ScrollWindowEx (X11DRV.@) * * Note: contrary to what the doc says, pixels that are scrolled from the @@ -165,7 +77,7 @@ INT X11DRV_ScrollWindowEx( HWND hwnd, INT dx, INT dy, { HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 ); X11DRV_StartGraphicsExposures( hDC ); - X11DRV_ScrollDC( hDC, dx, dy, &rc, &cliprc, hrgnUpdate, rcUpdate ); + ScrollDC( hDC, dx, dy, &rc, &cliprc, hrgnUpdate, rcUpdate ); X11DRV_EndGraphicsExposures( hDC, hrgn ); ReleaseDC( hwnd, hDC ); if (bUpdate) CombineRgn( hrgnUpdate, hrgnUpdate, hrgn, RGN_OR ); diff --git a/dlls/x11drv/x11drv.spec b/dlls/x11drv/x11drv.spec index 3a22b0d54be..3becd0ec74b 100644 --- a/dlls/x11drv/x11drv.spec +++ b/dlls/x11drv/x11drv.spec @@ -98,7 +98,6 @@ @ cdecl RegisterClipboardFormat(str) X11DRV_RegisterClipboardFormat @ cdecl ReleaseDC(long long) X11DRV_ReleaseDC @ cdecl ResetSelectionOwner(long long) X11DRV_ResetSelectionOwner -@ cdecl ScrollDC(long long long ptr ptr long ptr) X11DRV_ScrollDC @ cdecl ScrollWindowEx(long long long ptr ptr long ptr long) X11DRV_ScrollWindowEx @ cdecl SetClipboardData(long long long) X11DRV_SetClipboardData @ cdecl SetFocus(long) X11DRV_SetFocus diff --git a/include/user.h b/include/user.h index 46756b27825..d31be8c8258 100644 --- a/include/user.h +++ b/include/user.h @@ -113,7 +113,6 @@ typedef struct tagUSER_DRIVER { void (*pForceWindowRaise)(HWND); DWORD (*pMsgWaitForMultipleObjectsEx)(DWORD,const HANDLE*,DWORD,DWORD,DWORD); void (*pReleaseDC)(HWND,HDC); - BOOL (*pScrollDC)(HDC,INT,INT,const RECT*,const RECT*,HRGN,LPRECT); INT (*pScrollWindowEx)(HWND,INT,INT,const RECT*,const RECT*,HRGN,LPRECT,UINT); void (*pSetFocus)(HWND); HWND (*pSetParent)(HWND,HWND); diff --git a/dlls/x11drv/scroll.c b/windows/scroll.c similarity index 57% copy from dlls/x11drv/scroll.c copy to windows/scroll.c index 6d826e819d8..6d26caf9a74 100644 --- a/dlls/x11drv/scroll.c +++ b/windows/scroll.c @@ -1,9 +1,8 @@ /* * Scroll windows and DCs * - * Copyright 1993 David W. Metcalfe - * Copyright 1995, 1996 Alex Korobka - * Copyright 2001 Alexandre Julliard + * Copyright David W. Metcalfe, 1993 + * Alex Korobka 1995,1996 * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,32 +19,70 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "config.h" - #include -#include +#include #include "windef.h" #include "winbase.h" #include "wingdi.h" +#include "wine/winuser16.h" #include "winuser.h" - -#include "x11drv.h" +#include "user.h" #include "win.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(scroll); +/************************************************************************* + * fix_caret + */ +static HWND fix_caret(HWND hWnd, LPRECT lprc, UINT flags) +{ + GUITHREADINFO info; + + if (!GetGUIThreadInfo( GetCurrentThreadId(), &info )) return 0; + if (!info.hwndCaret) return 0; + if (info.hwndCaret == hWnd || + ((flags & SW_SCROLLCHILDREN) && IsChild(hWnd, info.hwndCaret))) + { + POINT pt; + pt.x = info.rcCaret.left; + pt.y = info.rcCaret.top; + MapWindowPoints( info.hwndCaret, hWnd, (LPPOINT)&info.rcCaret, 2 ); + if( IntersectRect(lprc, lprc, &info.rcCaret) ) + { + HideCaret(0); + lprc->left = pt.x; + lprc->top = pt.y; + return info.hwndCaret; + } + } + return 0; +} + /************************************************************************* - * ScrollDC (X11DRV.@) + * ScrollWindow (USER32.@) + * + */ +BOOL WINAPI ScrollWindow( HWND hwnd, INT dx, INT dy, + const RECT *rect, const RECT *clipRect ) +{ + return + (ERROR != ScrollWindowEx( hwnd, dx, dy, rect, clipRect, 0, NULL, + (rect ? 0 : SW_SCROLLCHILDREN) | + SW_INVALIDATE )); +} + +/************************************************************************* + * ScrollDC (USER32.@) * * dx, dy, lprcScroll and lprcClip are all in logical coordinates (msdn is wrong) * hrgnUpdate is returned in device coordinates with rcUpdate in logical coordinates. - * */ -BOOL X11DRV_ScrollDC( HDC hdc, INT dx, INT dy, const RECT *lprcScroll, +BOOL WINAPI ScrollDC( HDC hdc, INT dx, INT dy, const RECT *lprcScroll, const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate ) + { RECT rSrc, rClipped_src, rClip, rDst, offset; @@ -106,7 +143,7 @@ BOOL X11DRV_ScrollDC( HDC hdc, INT dx, INT dy, const RECT *lprcScroll, SetRectRgn( hrgn2, rDst.left, rDst.top, rDst.right, rDst.bottom ); CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF ); - + SetRectRgn( hrgn2, rClip.left, rClip.top, rClip.right, rClip.bottom ); CombineRgn( hrgn, hrgn, hrgn2, RGN_AND ); @@ -126,30 +163,20 @@ BOOL X11DRV_ScrollDC( HDC hdc, INT dx, INT dy, const RECT *lprcScroll, /************************************************************************* - * ScrollWindowEx (X11DRV.@) + * ScrollWindowEx (USER32.@) * - * Note: contrary to what the doc says, pixels that are scrolled from the - * outside of clipRect to the inside are NOT painted. - * - * Parameter are the same as in ScrollWindowEx, with the additional - * requirement that rect and clipRect are _valid_ pointers, to - * rectangles _within_ the client are. Moreover, there is something - * to scroll. + * NOTE: Use this function instead of ScrollWindow32 */ -INT X11DRV_ScrollWindowEx( HWND hwnd, INT dx, INT dy, - const RECT *rect, const RECT *clipRect, - HRGN hrgnUpdate, LPRECT rcUpdate, UINT flags ) +INT WINAPI ScrollWindowEx( HWND hwnd, INT dx, INT dy, + const RECT *rect, const RECT *clipRect, + HRGN hrgnUpdate, LPRECT rcUpdate, + UINT flags ) { - INT retVal; - BOOL bOwnRgn = TRUE; - BOOL bUpdate = (rcUpdate || hrgnUpdate || flags & (SW_INVALIDATE | SW_ERASE)); - HRGN hrgnTemp; - HDC hDC; - RECT rc, cliprc; - - TRACE( "%p, %d,%d hrgnUpdate=%p rcUpdate = %p %s %04x\n", - hwnd, dx, dy, hrgnUpdate, rcUpdate, wine_dbgstr_rect(rect), flags ); - TRACE( "clipRect = %s\n", wine_dbgstr_rect(clipRect)); + RECT rc, cliprc; + INT result; + + if (!WIN_IsWindowDrawable( hwnd, TRUE )) return ERROR; + hwnd = WIN_GetFullHandle( hwnd ); GetClientRect(hwnd, &rc); if (rect) IntersectRect(&rc, &rc, rect); @@ -157,61 +184,25 @@ INT X11DRV_ScrollWindowEx( HWND hwnd, INT dx, INT dy, if (clipRect) IntersectRect(&cliprc,&rc,clipRect); else cliprc = rc; - if( hrgnUpdate ) bOwnRgn = FALSE; - else if( bUpdate ) hrgnUpdate = CreateRectRgn( 0, 0, 0, 0 ); - - hDC = GetDCEx( hwnd, 0, DCX_CACHE | DCX_USESTYLE ); - if (hDC) + if (!IsRectEmpty(&cliprc) && (dx || dy)) { - HRGN hrgn = CreateRectRgn( 0, 0, 0, 0 ); - X11DRV_StartGraphicsExposures( hDC ); - X11DRV_ScrollDC( hDC, dx, dy, &rc, &cliprc, hrgnUpdate, rcUpdate ); - X11DRV_EndGraphicsExposures( hDC, hrgn ); - ReleaseDC( hwnd, hDC ); - if (bUpdate) CombineRgn( hrgnUpdate, hrgnUpdate, hrgn, RGN_OR ); - else RedrawWindow( hwnd, NULL, hrgn, RDW_INVALIDATE | RDW_ERASE ); - DeleteObject( hrgn ); - } - - /* Take into account the fact that some damage may have occurred during the scroll */ - hrgnTemp = CreateRectRgn( 0, 0, 0, 0 ); - retVal = GetUpdateRgn( hwnd, hrgnTemp, FALSE ); - if (retVal != NULLREGION) - { - HRGN hrgnClip = CreateRectRgnIndirect(&cliprc); - OffsetRgn( hrgnTemp, dx, dy ); - CombineRgn( hrgnTemp, hrgnTemp, hrgnClip, RGN_AND ); - RedrawWindow( hwnd, NULL, hrgnTemp, RDW_INVALIDATE | RDW_ERASE ); - DeleteObject( hrgnClip ); - } - DeleteObject( hrgnTemp ); - - if( flags & SW_SCROLLCHILDREN ) - { - HWND *list = WIN_ListChildren( hwnd ); - if (list) + RECT caretrc = rc; + HWND hwndCaret = fix_caret(hwnd, &caretrc, flags); + + if (USER_Driver.pScrollWindowEx) + result = USER_Driver.pScrollWindowEx( hwnd, dx, dy, rect, clipRect, + hrgnUpdate, rcUpdate, flags ); + else + result = ERROR; /* FIXME: we should have a fallback implementation */ + + if( hwndCaret ) { - int i; - RECT r, dummy; - for (i = 0; list[i]; i++) - { - GetWindowRect( list[i], &r ); - MapWindowPoints( 0, hwnd, (POINT *)&r, 2 ); - if (!rect || IntersectRect(&dummy, &r, &rc)) - SetWindowPos( list[i], 0, r.left + dx, r.top + dy, 0, 0, - SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE | - SWP_NOREDRAW | SWP_DEFERERASE ); - } - HeapFree( GetProcessHeap(), 0, list ); + SetCaretPos( caretrc.left + dx, caretrc.top + dy ); + ShowCaret(hwndCaret); } } - - if( flags & (SW_INVALIDATE | SW_ERASE) ) - RedrawWindow( hwnd, NULL, hrgnUpdate, RDW_INVALIDATE | RDW_ERASE | - ((flags & SW_ERASE) ? RDW_ERASENOW : 0) | - ((flags & SW_SCROLLCHILDREN) ? RDW_ALLCHILDREN : 0 ) ); - - if( bOwnRgn && hrgnUpdate ) DeleteObject( hrgnUpdate ); + else + result = NULLREGION; - return retVal; + return result; } -- 2.11.4.GIT