From: Jacek Caban jacek@codeweavers.com
Signed-off-by: Jacek Caban jacek@codeweavers.com --- dlls/wineandroid.drv/device.c | 10 ++-- dlls/wineandroid.drv/init.c | 12 +++-- dlls/wineandroid.drv/opengl.c | 18 ++++---- dlls/wineandroid.drv/window.c | 87 ++++++++++++++++++++++------------- 4 files changed, 78 insertions(+), 49 deletions(-)
diff --git a/dlls/wineandroid.drv/device.c b/dlls/wineandroid.drv/device.c index 30bc474ae19..45009d61a79 100644 --- a/dlls/wineandroid.drv/device.c +++ b/dlls/wineandroid.drv/device.c @@ -312,7 +312,7 @@ static struct native_win_data *get_ioctl_native_win_data( const struct ioctl_hea
static int get_ioctl_win_parent( HWND parent ) { - if (parent != GetDesktopWindow() && !GetAncestor( parent, GA_PARENT )) + if (parent != NtUserGetDesktopWindow() && !NtUserGetAncestor( parent, GA_PARENT )) return HandleToLong( HWND_MESSAGE ); return HandleToLong( parent ); } @@ -522,7 +522,7 @@ static void CALLBACK register_native_window_callback( ULONG_PTR arg1, ULONG_PTR if (!data || data->parent == win) { pANativeWindow_release( win ); - if (data) PostMessageW( hwnd, WM_ANDROID_REFRESH, opengl, 0 ); + if (data) NtUserPostMessage( hwnd, WM_ANDROID_REFRESH, opengl, 0 ); TRACE( "%p -> %p win %p (unchanged)\n", hwnd, data, win ); return; } @@ -535,7 +535,7 @@ static void CALLBACK register_native_window_callback( ULONG_PTR arg1, ULONG_PTR win->perform( win, NATIVE_WINDOW_SET_BUFFERS_FORMAT, data->buffer_format ); win->setSwapInterval( win, data->swap_interval ); unwrap_java_call(); - PostMessageW( hwnd, WM_ANDROID_REFRESH, opengl, 0 ); + NtUserPostMessage( hwnd, WM_ANDROID_REFRESH, opengl, 0 ); TRACE( "%p -> %p win %p\n", hwnd, data, win ); }
@@ -1169,7 +1169,7 @@ static DWORD CALLBACK device_thread( void *arg )
init_java_thread( java_vm );
- create_desktop_window( GetDesktopWindow() ); + create_desktop_window( NtUserGetDesktopWindow() );
RtlInitUnicodeString( &nameW, driver_nameW ); if ((status = IoCreateDriver( &nameW, init_android_driver ))) @@ -1559,7 +1559,7 @@ struct ANativeWindow *create_ioctl_window( HWND hwnd, BOOL opengl, float scale )
req.hdr.hwnd = HandleToLong( win->hwnd ); req.hdr.opengl = win->opengl; - req.parent = get_ioctl_win_parent( GetAncestor( hwnd, GA_PARENT )); + req.parent = get_ioctl_win_parent( NtUserGetAncestor( hwnd, GA_PARENT )); req.scale = scale; android_ioctl( IOCTL_CREATE_WINDOW, &req, sizeof(req), NULL, NULL );
diff --git a/dlls/wineandroid.drv/init.c b/dlls/wineandroid.drv/init.c index 694ec1bae9c..f06eb6471c5 100644 --- a/dlls/wineandroid.drv/init.c +++ b/dlls/wineandroid.drv/init.c @@ -62,15 +62,19 @@ static const struct user_driver_funcs android_drv_funcs; void init_monitors( int width, int height ) { static const WCHAR trayW[] = {'S','h','e','l','l','_','T','r','a','y','W','n','d',0}; + UNICODE_STRING name; RECT rect; - HWND hwnd = FindWindowW( trayW, NULL ); + HWND hwnd; + + RtlInitUnicodeString( &name, trayW ); + hwnd = NtUserFindWindowEx( 0, 0, &name, NULL, 0 );
virtual_screen_rect.right = width; virtual_screen_rect.bottom = height; monitor_rc_work = virtual_screen_rect;
- if (!hwnd || !IsWindowVisible( hwnd )) return; - if (!GetWindowRect( hwnd, &rect )) return; + if (!hwnd || !NtUserIsWindowVisible( hwnd )) return; + if (!NtUserGetWindowRect( hwnd, &rect )) return; if (rect.top) monitor_rc_work.bottom = rect.top; else monitor_rc_work.top = rect.bottom; TRACE( "found tray %p %s work area %s\n", hwnd, @@ -170,7 +174,7 @@ static void fetch_display_metrics(void)
SERVER_START_REQ( get_window_rectangles ) { - req->handle = wine_server_user_handle( GetDesktopWindow() ); + req->handle = wine_server_user_handle( NtUserGetDesktopWindow() ); req->relative = COORDS_CLIENT; if (!wine_server_call( req )) { diff --git a/dlls/wineandroid.drv/opengl.c b/dlls/wineandroid.drv/opengl.c index 9f20e51b8da..afd1ef3f7a5 100644 --- a/dlls/wineandroid.drv/opengl.c +++ b/dlls/wineandroid.drv/opengl.c @@ -180,7 +180,7 @@ static BOOL refresh_context( struct wgl_context *ctx ) { TRACE( "refreshing hwnd %p context %p surface %p\n", ctx->hwnd, ctx->context, ctx->surface ); p_eglMakeCurrent( display, ctx->surface, ctx->surface, ctx->context ); - RedrawWindow( ctx->hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE ); + NtUserRedrawWindow( ctx->hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE ); } return ret; } @@ -207,17 +207,17 @@ void update_gl_drawable( HWND hwnd ) } } release_gl_drawable( gl ); - RedrawWindow( hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE ); + NtUserRedrawWindow( hwnd, NULL, 0, RDW_INVALIDATE | RDW_ERASE ); } }
static BOOL set_pixel_format( HDC hdc, int format, BOOL allow_change ) { struct gl_drawable *gl; - HWND hwnd = WindowFromDC( hdc ); + HWND hwnd = NtUserWindowFromDC( hdc ); int prev = 0;
- if (!hwnd || hwnd == GetDesktopWindow()) + if (!hwnd || hwnd == NtUserGetDesktopWindow()) { WARN( "not a proper window DC %p/%p\n", hdc, hwnd ); return FALSE; @@ -255,7 +255,7 @@ static struct wgl_context *create_context( HDC hdc, struct wgl_context *share, c struct gl_drawable *gl; struct wgl_context *ctx;
- if (!(gl = get_gl_drawable( WindowFromDC( hdc ), hdc ))) return NULL; + if (!(gl = get_gl_drawable( NtUserWindowFromDC( hdc ), hdc ))) return NULL;
ctx = HeapAlloc( GetProcessHeap(), 0, sizeof(*ctx) );
@@ -348,10 +348,10 @@ static BOOL android_wglMakeContextCurrentARB( HDC draw_hdc, HDC read_hdc, struct return TRUE; }
- draw_hwnd = WindowFromDC( draw_hdc ); + draw_hwnd = NtUserWindowFromDC( draw_hdc ); if ((draw_gl = get_gl_drawable( draw_hwnd, draw_hdc ))) { - read_gl = get_gl_drawable( WindowFromDC( read_hdc ), read_hdc ); + read_gl = get_gl_drawable( NtUserWindowFromDC( read_hdc ), read_hdc ); draw_surface = draw_gl->surface ? draw_gl->surface : draw_gl->pbuffer; read_surface = read_gl->surface ? read_gl->surface : read_gl->pbuffer; TRACE( "%p/%p context %p surface %p/%p\n", @@ -500,7 +500,7 @@ static int WINAPI android_wglGetPixelFormat( HDC hdc ) struct gl_drawable *gl; int ret = 0;
- if ((gl = get_gl_drawable( WindowFromDC( hdc ), hdc ))) + if ((gl = get_gl_drawable( NtUserWindowFromDC( hdc ), hdc ))) { ret = gl->format; /* offscreen formats can't be used with traditional WGL calls */ @@ -540,7 +540,7 @@ static BOOL WINAPI android_wglMakeCurrent( HDC hdc, struct wgl_context *ctx ) return TRUE; }
- hwnd = WindowFromDC( hdc ); + hwnd = NtUserWindowFromDC( hdc ); if ((gl = get_gl_drawable( hwnd, hdc ))) { EGLSurface surface = gl->surface ? gl->surface : gl->pbuffer; diff --git a/dlls/wineandroid.drv/window.c b/dlls/wineandroid.drv/window.c index 4b9fe5cb3ce..6b019445805 100644 --- a/dlls/wineandroid.drv/window.c +++ b/dlls/wineandroid.drv/window.c @@ -99,19 +99,22 @@ static inline int get_dib_image_size( const BITMAPINFO *info ) * abs( info->bmiHeader.biHeight ); }
+static BOOL intersect_rect( RECT *dst, const RECT *src1, const RECT *src2 ) +{ + dst->left = max(src1->left, src2->left); + dst->top = max(src1->top, src2->top); + dst->right = min(src1->right, src2->right); + dst->bottom = min(src1->bottom, src2->bottom); + return !IsRectEmpty( dst ); +} +
/********************************************************************** * get_win_monitor_dpi */ static UINT get_win_monitor_dpi( HWND hwnd ) { - DPI_AWARENESS_CONTEXT context; - UINT ret; - - context = SetThreadDpiAwarenessContext( DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE ); - ret = GetDpiForSystem(); /* FIXME: get monitor dpi */ - SetThreadDpiAwarenessContext( context ); - return ret; + return NtUserGetSystemDpiForProcess( NULL ); /* FIXME: get monitor dpi */ }
@@ -126,7 +129,7 @@ static struct android_win_data *alloc_win_data( HWND hwnd ) { data->hwnd = hwnd; data->window = create_ioctl_window( hwnd, FALSE, - (float)get_win_monitor_dpi( hwnd ) / GetDpiForWindow( hwnd )); + (float)get_win_monitor_dpi( hwnd ) / NtUserGetDpiForWindow( hwnd )); EnterCriticalSection( &win_data_section ); win_data_context[context_idx(hwnd)] = data; } @@ -466,8 +469,8 @@ static int process_events( DWORD mask ) screen_width = event->data.desktop.width; screen_height = event->data.desktop.height; init_monitors( screen_width, screen_height ); - SetWindowPos( GetDesktopWindow(), 0, 0, 0, screen_width, screen_height, - SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW ); + NtUserSetWindowPos( NtUserGetDesktopWindow(), 0, 0, 0, screen_width, screen_height, + SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW ); SetThreadDpiAwarenessContext( context ); break;
@@ -728,7 +731,7 @@ static void android_surface_flush( struct window_surface *window_surface ) window_surface->funcs->lock( window_surface ); SetRect( &rect, 0, 0, surface->header.rect.right - surface->header.rect.left, surface->header.rect.bottom - surface->header.rect.top ); - needs_flush = IntersectRect( &rect, &rect, &surface->bounds ); + needs_flush = intersect_rect( &rect, &rect, &surface->bounds ); reset_bounds( &surface->bounds ); window_surface->funcs->unlock( window_surface ); if (!needs_flush) return; @@ -753,7 +756,7 @@ static void android_surface_flush( struct window_surface *window_surface ) rect.top = rc.top; rect.right = rc.right; rect.bottom = rc.bottom; - IntersectRect( &rect, &rect, &surface->header.rect ); + intersect_rect( &rect, &rect, &surface->header.rect );
if (surface->region_data) { @@ -874,7 +877,7 @@ static void set_surface_region( struct window_surface *window_surface, HRGN win_ { region = NtGdiCreateRectRgn( 0, 0, win_data->window_rect.right - win_data->window_rect.left, win_data->window_rect.bottom - win_data->window_rect.top ); - if (GetWindowRgn( surface->hwnd, region ) == ERROR && !surface->region) goto done; + if (NtUserGetWindowRgnEx( surface->hwnd, region, 0 ) == ERROR && !surface->region) goto done; }
NtGdiOffsetRgn( region, offset_x, offset_y ); @@ -1222,7 +1225,7 @@ BOOL ANDROID_CreateWindow( HWND hwnd ) { TRACE( "%p\n", hwnd );
- if (hwnd == GetDesktopWindow()) + if (hwnd == NtUserGetDesktopWindow()) { struct android_win_data *data;
@@ -1262,11 +1265,11 @@ static struct android_win_data *create_win_data( HWND hwnd, const RECT *window_r struct android_win_data *data; HWND parent;
- if (!(parent = GetAncestor( hwnd, GA_PARENT ))) return NULL; /* desktop or HWND_MESSAGE */ + if (!(parent = NtUserGetAncestor( hwnd, GA_PARENT ))) return NULL; /* desktop or HWND_MESSAGE */
if (!(data = alloc_win_data( hwnd ))) return NULL;
- data->parent = (parent == GetDesktopWindow()) ? 0 : parent; + data->parent = (parent == NtUserGetDesktopWindow()) ? 0 : parent; data->whole_rect = data->window_rect = *window_rect; data->client_rect = *client_rect; return data; @@ -1275,7 +1278,7 @@ static struct android_win_data *create_win_data( HWND hwnd, const RECT *window_r
static inline BOOL get_surface_rect( const RECT *visible_rect, RECT *surface_rect ) { - if (!IntersectRect( surface_rect, visible_rect, &virtual_screen_rect )) return FALSE; + if (!intersect_rect( surface_rect, visible_rect, &virtual_screen_rect )) return FALSE; OffsetRect( surface_rect, -visible_rect->left, -visible_rect->top ); surface_rect->left &= ~31; surface_rect->top &= ~31; @@ -1297,11 +1300,11 @@ BOOL ANDROID_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags, DWORD flags; COLORREF key; BYTE alpha; - BOOL layered = GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED; + BOOL layered = NtUserGetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED;
TRACE( "win %p window %s client %s style %08x flags %08x\n", hwnd, wine_dbgstr_rect(window_rect), wine_dbgstr_rect(client_rect), - GetWindowLongW( hwnd, GWL_STYLE ), swp_flags ); + NtUserGetWindowLongW( hwnd, GWL_STYLE ), swp_flags );
if (!data && !(data = create_win_data( hwnd, window_rect, client_rect ))) return TRUE;
@@ -1325,9 +1328,10 @@ BOOL ANDROID_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags, goto done; } } - if (!(swp_flags & SWP_SHOWWINDOW) && !(GetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) goto done; + if (!(swp_flags & SWP_SHOWWINDOW) && !(NtUserGetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) + goto done;
- if (!layered || !GetLayeredWindowAttributes( hwnd, &key, &alpha, &flags )) flags = 0; + if (!layered || !NtUserGetLayeredWindowAttributes( hwnd, &key, &alpha, &flags )) flags = 0; if (!(flags & LWA_ALPHA)) alpha = 255; if (!(flags & LWA_COLORKEY)) key = CLR_INVALID;
@@ -1349,7 +1353,7 @@ void ANDROID_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags, struct window_surface *surface ) { struct android_win_data *data; - DWORD new_style = GetWindowLongW( hwnd, GWL_STYLE ); + DWORD new_style = NtUserGetWindowLongW( hwnd, GWL_STYLE ); HWND owner = 0;
if (!(data = get_win_data( hwnd ))) return; @@ -1364,10 +1368,10 @@ void ANDROID_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags, if (data->surface) window_surface_release( data->surface ); data->surface = surface; } - if (!data->parent) owner = GetWindow( hwnd, GW_OWNER ); + if (!data->parent) owner = NtUserGetWindowRelative( hwnd, GW_OWNER ); release_win_data( data );
- if (!(swp_flags & SWP_NOZORDER)) insert_after = GetWindow( hwnd, GW_HWNDPREV ); + if (!(swp_flags & SWP_NOZORDER)) insert_after = NtUserGetWindowRelative( hwnd, GW_HWNDPREV );
TRACE( "win %p window %s client %s style %08x owner %p after %p flags %08x\n", hwnd, wine_dbgstr_rect(window_rect), wine_dbgstr_rect(client_rect), @@ -1383,7 +1387,7 @@ void ANDROID_WindowPosChanged( HWND hwnd, HWND insert_after, UINT swp_flags, */ UINT ANDROID_ShowWindow( HWND hwnd, INT cmd, RECT *rect, UINT swp ) { - if (!IsIconic( hwnd )) return swp; + if (!(NtUserGetWindowLongW( hwnd, GWL_STYLE ) & WS_MINIMIZE)) return swp; /* always hide icons off-screen */ if (rect->left != -32000 || rect->top != -32000) { @@ -1406,8 +1410,8 @@ void ANDROID_SetParent( HWND hwnd, HWND parent, HWND old_parent )
TRACE( "win %p parent %p -> %p\n", hwnd, old_parent, parent );
- data->parent = (parent == GetDesktopWindow()) ? 0 : parent; - ioctl_set_window_parent( hwnd, parent, (float)get_win_monitor_dpi( hwnd ) / GetDpiForWindow( hwnd )); + data->parent = (parent == NtUserGetDesktopWindow()) ? 0 : parent; + ioctl_set_window_parent( hwnd, parent, (float)get_win_monitor_dpi( hwnd ) / NtUserGetDpiForWindow( hwnd )); release_win_data( data ); }
@@ -1422,6 +1426,28 @@ void ANDROID_SetCapture( HWND hwnd, UINT flags ) }
+static BOOL get_icon_info( HICON handle, ICONINFOEXW *ret ) +{ + UNICODE_STRING module, res_name; + ICONINFO info; + + module.Buffer = ret->szModName; + module.MaximumLength = sizeof(ret->szModName) - sizeof(WCHAR); + res_name.Buffer = ret->szResName; + res_name.MaximumLength = sizeof(ret->szResName) - sizeof(WCHAR); + if (!NtUserGetIconInfo( handle, &info, &module, &res_name, NULL, 0 )) return FALSE; + ret->fIcon = info.fIcon; + ret->xHotspot = info.xHotspot; + ret->yHotspot = info.yHotspot; + ret->hbmColor = info.hbmColor; + ret->hbmMask = info.hbmMask; + ret->wResID = res_name.Length ? 0 : LOWORD(res_name.Buffer); + ret->szModName[module.Length] = 0; + ret->szResName[res_name.Length] = 0; + return TRUE; +} + + /*********************************************************************** * ANDROID_SetCursor */ @@ -1441,8 +1467,7 @@ void ANDROID_SetCursor( HCURSOR handle ) ICONINFOEXW info; int id;
- info.cbSize = sizeof(info); - if (!GetIconInfoExW( handle, &info )) return; + if (!get_icon_info( handle, &info )) return;
if (!(id = get_cursor_system_id( &info ))) { @@ -1475,7 +1500,7 @@ void ANDROID_SetWindowStyle( HWND hwnd, INT offset, STYLESTRUCT *style ) struct android_win_data *data; DWORD changed = style->styleNew ^ style->styleOld;
- if (hwnd == GetDesktopWindow()) return; + if (hwnd == NtUserGetDesktopWindow()) return; if (!(data = get_win_data( hwnd ))) return;
if (offset == GWL_EXSTYLE && (changed & WS_EX_LAYERED)) /* changing WS_EX_LAYERED resets attributes */ @@ -1585,7 +1610,7 @@ BOOL ANDROID_UpdateLayeredWindow( HWND hwnd, const UPDATELAYEREDWINDOWINFO *info
if (info->prcDirty) { - IntersectRect( &rect, &rect, info->prcDirty ); + intersect_rect( &rect, &rect, info->prcDirty ); memcpy( src_bits, dst_bits, bmi->bmiHeader.biSizeImage ); NtGdiPatBlt( hdc, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, BLACKNESS ); }