Alexandre Julliard : user32: Add support for RTL window layouts in GetUpdateRgn and GetUpdateRect.
Alexandre Julliard
julliard at winehq.org
Thu Sep 23 12:43:49 CDT 2010
Module: wine
Branch: master
Commit: 9bbfcb5b07fa5f68c3f2fc56637c8258a1970a43
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9bbfcb5b07fa5f68c3f2fc56637c8258a1970a43
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Sep 23 15:51:10 2010 +0200
user32: Add support for RTL window layouts in GetUpdateRgn and GetUpdateRect.
---
dlls/user32/painting.c | 8 +++-----
dlls/user32/win.h | 1 +
dlls/user32/winpos.c | 35 +++++++++++++++++++++++++++++++++++
3 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/dlls/user32/painting.c b/dlls/user32/painting.c
index 94bb630..9f02a03 100644
--- a/dlls/user32/painting.c
+++ b/dlls/user32/painting.c
@@ -1289,8 +1289,6 @@ INT WINAPI GetUpdateRgn( HWND hwnd, HRGN hrgn, BOOL erase )
if ((update_rgn = send_ncpaint( hwnd, NULL, &flags )))
{
- POINT offset;
-
retval = CombineRgn( hrgn, update_rgn, 0, RGN_COPY );
if (send_erase( hwnd, flags, update_rgn, NULL, NULL ))
{
@@ -1298,9 +1296,7 @@ INT WINAPI GetUpdateRgn( HWND hwnd, HRGN hrgn, BOOL erase )
get_update_flags( hwnd, NULL, &flags );
}
/* map region to client coordinates */
- offset.x = offset.y = 0;
- ScreenToClient( hwnd, &offset );
- OffsetRgn( hrgn, offset.x, offset.y );
+ map_window_region( 0, hwnd, hrgn );
}
return retval;
}
@@ -1324,8 +1320,10 @@ BOOL WINAPI GetUpdateRect( HWND hwnd, LPRECT rect, BOOL erase )
if (GetRgnBox( update_rgn, rect ) != NULLREGION)
{
HDC hdc = GetDCEx( hwnd, 0, DCX_USESTYLE );
+ DWORD layout = SetLayout( hdc, 0 ); /* MapWindowPoints mirrors already */
MapWindowPoints( 0, hwnd, (LPPOINT)rect, 2 );
DPtoLP( hdc, (LPPOINT)rect, 2 );
+ SetLayout( hdc, layout );
ReleaseDC( hwnd, hdc );
}
}
diff --git a/dlls/user32/win.h b/dlls/user32/win.h
index 2d5ff87..6907889 100644
--- a/dlls/user32/win.h
+++ b/dlls/user32/win.h
@@ -83,6 +83,7 @@ extern HWND WIN_IsCurrentThread( HWND hwnd ) DECLSPEC_HIDDEN;
extern HWND WIN_SetOwner( HWND hwnd, HWND owner ) DECLSPEC_HIDDEN;
extern ULONG WIN_SetStyle( HWND hwnd, ULONG set_bits, ULONG clear_bits ) DECLSPEC_HIDDEN;
extern BOOL WIN_GetRectangles( HWND hwnd, enum coords_relative relative, RECT *rectWindow, RECT *rectClient ) DECLSPEC_HIDDEN;
+extern void map_window_region( HWND from, HWND to, HRGN hrgn ) DECLSPEC_HIDDEN;
extern LRESULT WIN_DestroyWindow( HWND hwnd ) DECLSPEC_HIDDEN;
extern void WIN_DestroyThreadWindows( HWND hwnd ) DECLSPEC_HIDDEN;
extern HWND WIN_CreateWindowEx( CREATESTRUCTW *cs, LPCWSTR className, HINSTANCE module, BOOL unicode ) DECLSPEC_HIDDEN;
diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c
index fbcd432..1721b34 100644
--- a/dlls/user32/winpos.c
+++ b/dlls/user32/winpos.c
@@ -501,6 +501,41 @@ static POINT WINPOS_GetWinOffset( HWND hwndFrom, HWND hwndTo, BOOL *mirrored )
return offset;
}
+/* map coordinates of a window region */
+void map_window_region( HWND from, HWND to, HRGN hrgn )
+{
+ BOOL mirrored;
+ POINT offset = WINPOS_GetWinOffset( from, to, &mirrored );
+ UINT i, size;
+ RGNDATA *data;
+ HRGN new_rgn;
+ RECT *rect;
+
+ if (!mirrored)
+ {
+ OffsetRgn( hrgn, offset.x, offset.y );
+ return;
+ }
+ if (!(size = GetRegionData( hrgn, 0, NULL ))) return;
+ if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return;
+ GetRegionData( hrgn, size, data );
+ rect = (RECT *)data->Buffer;
+ for (i = 0; i < data->rdh.nCount; i++)
+ {
+ int tmp = -(rect[i].left + offset.x);
+ rect[i].left = -(rect[i].right + offset.x);
+ rect[i].right = tmp;
+ rect[i].top += offset.y;
+ rect[i].bottom += offset.y;
+ }
+ if ((new_rgn = ExtCreateRegion( NULL, data->rdh.nCount, data )))
+ {
+ CombineRgn( hrgn, new_rgn, 0, RGN_COPY );
+ DeleteObject( new_rgn );
+ }
+ HeapFree( GetProcessHeap(), 0, data );
+}
+
/*******************************************************************
* MapWindowPoints (USER32.@)
More information about the wine-cvs
mailing list