user32: Add support for RTL window layouts in WIN_GetRectangles.

This commit is contained in:
Alexandre Julliard 2010-09-22 20:28:11 +02:00
parent 5702324b37
commit 3f026cafa5
2 changed files with 54 additions and 0 deletions

View File

@ -44,6 +44,14 @@ static DWORD process_layout;
/**********************************************************************/
static inline void mirror_rect( const RECT *window_rect, RECT *rect )
{
int width = window_rect->right - window_rect->left;
int tmp = rect->left;
rect->left = width - rect->right;
rect->right = width - tmp;
}
/* helper for Get/SetWindowLong */
static inline LONG_PTR get_win_data( const void *ptr, UINT size )
{
@ -689,12 +697,32 @@ BOOL WIN_GetRectangles( HWND hwnd, enum coords_relative relative, RECT *rectWind
case COORDS_CLIENT:
OffsetRect( &window_rect, -win->rectClient.left, -win->rectClient.top );
OffsetRect( &client_rect, -win->rectClient.left, -win->rectClient.top );
if (win->dwExStyle & WS_EX_LAYOUTRTL)
mirror_rect( &win->rectClient, &window_rect );
break;
case COORDS_WINDOW:
OffsetRect( &window_rect, -win->rectWindow.left, -win->rectWindow.top );
OffsetRect( &client_rect, -win->rectWindow.left, -win->rectWindow.top );
if (win->dwExStyle & WS_EX_LAYOUTRTL)
mirror_rect( &win->rectWindow, &client_rect );
break;
case COORDS_PARENT:
if (win->parent)
{
WND *parent = WIN_GetPtr( win->parent );
if (parent == WND_DESKTOP) break;
if (!parent || parent == WND_OTHER_PROCESS)
{
WIN_ReleasePtr( win );
goto other_process;
}
if (parent->dwExStyle & WS_EX_LAYOUTRTL)
{
mirror_rect( &parent->rectClient, &window_rect );
mirror_rect( &parent->rectClient, &client_rect );
}
WIN_ReleasePtr( parent );
}
break;
case COORDS_SCREEN:
while (win->parent)

View File

@ -905,6 +905,16 @@ static inline void offset_rect( rectangle_t *rect, int offset_x, int offset_y )
}
/* mirror a rectangle respective to the window client area */
static inline void mirror_rect( const rectangle_t *window_rect, rectangle_t *rect )
{
int width = window_rect->right - window_rect->left;
int tmp = rect->left;
rect->left = width - rect->right;
rect->right = width - tmp;
}
/* set the region to the client rect clipped by the window rect, in parent-relative coordinates */
static void set_region_client_rect( struct region *region, struct window *win )
{
@ -2134,13 +2144,29 @@ DECL_HANDLER(get_window_rectangles)
offset_rect( &reply->window, -win->client_rect.left, -win->client_rect.top );
offset_rect( &reply->visible, -win->client_rect.left, -win->client_rect.top );
offset_rect( &reply->client, -win->client_rect.left, -win->client_rect.top );
if (win->ex_style & WS_EX_LAYOUTRTL)
{
mirror_rect( &win->client_rect, &reply->window );
mirror_rect( &win->client_rect, &reply->visible );
}
break;
case COORDS_WINDOW:
offset_rect( &reply->window, -win->window_rect.left, -win->window_rect.top );
offset_rect( &reply->visible, -win->window_rect.left, -win->window_rect.top );
offset_rect( &reply->client, -win->window_rect.left, -win->window_rect.top );
if (win->ex_style & WS_EX_LAYOUTRTL)
{
mirror_rect( &win->window_rect, &reply->visible );
mirror_rect( &win->window_rect, &reply->client );
}
break;
case COORDS_PARENT:
if (win->parent && win->parent->ex_style & WS_EX_LAYOUTRTL)
{
mirror_rect( &win->parent->client_rect, &reply->window );
mirror_rect( &win->parent->client_rect, &reply->visible );
mirror_rect( &win->parent->client_rect, &reply->client );
}
break;
case COORDS_SCREEN:
client_to_screen_rect( win->parent, &reply->window );