From 3f026cafa5d2fa76d31e379ca1cd3e7809907594 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 22 Sep 2010 20:28:11 +0200 Subject: [PATCH] user32: Add support for RTL window layouts in WIN_GetRectangles. --- dlls/user32/win.c | 28 ++++++++++++++++++++++++++++ server/window.c | 26 ++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/dlls/user32/win.c b/dlls/user32/win.c index d6916767f6f..17925e9f1e2 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -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) diff --git a/server/window.c b/server/window.c index 81299128c06..ebcb5bf6ebe 100644 --- a/server/window.c +++ b/server/window.c @@ -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 ); -- 2.11.4.GIT