Alexandre Julliard : wineandroid: Initialize screen dimensions.
Alexandre Julliard
julliard at winehq.org
Wed May 31 16:20:17 CDT 2017
Module: wine
Branch: master
Commit: a5904bc661a809caf4f85bae64fe8f08669c54ae
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a5904bc661a809caf4f85bae64fe8f08669c54ae
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed May 31 11:15:17 2017 +0200
wineandroid: Initialize screen dimensions.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/wineandroid.drv/Makefile.in | 1 +
dlls/wineandroid.drv/android.h | 50 ++++++++++
dlls/wineandroid.drv/init.c | 156 +++++++++++++++++++++++++++++-
dlls/wineandroid.drv/wineandroid.drv.spec | 5 +
4 files changed, 208 insertions(+), 4 deletions(-)
diff --git a/dlls/wineandroid.drv/Makefile.in b/dlls/wineandroid.drv/Makefile.in
index 13ec433..dd3ad19 100644
--- a/dlls/wineandroid.drv/Makefile.in
+++ b/dlls/wineandroid.drv/Makefile.in
@@ -1,4 +1,5 @@
MODULE = wineandroid.drv
+IMPORTS = user32 gdi32
C_SRCS = \
init.c
diff --git a/dlls/wineandroid.drv/android.h b/dlls/wineandroid.drv/android.h
new file mode 100644
index 0000000..7c708f3
--- /dev/null
+++ b/dlls/wineandroid.drv/android.h
@@ -0,0 +1,50 @@
+/*
+ * Android driver definitions
+ *
+ * Copyright 2013 Alexandre Julliard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#ifndef __WINE_ANDROID_H
+#define __WINE_ANDROID_H
+
+#include <limits.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <jni.h>
+
+#include "windef.h"
+#include "winbase.h"
+#include "wingdi.h"
+#include "winuser.h"
+#include "wine/gdi_driver.h"
+
+
+/**************************************************************************
+ * USER driver
+ */
+
+extern unsigned int screen_width DECLSPEC_HIDDEN;
+extern unsigned int screen_height DECLSPEC_HIDDEN;
+extern RECT virtual_screen_rect DECLSPEC_HIDDEN;
+extern MONITORINFOEXW default_monitor DECLSPEC_HIDDEN;
+
+extern void init_monitors( int width, int height ) DECLSPEC_HIDDEN;
+
+extern JavaVM *wine_get_java_vm(void);
+extern jobject wine_get_java_object(void);
+
+#endif /* __WINE_ANDROID_H */
diff --git a/dlls/wineandroid.drv/init.c b/dlls/wineandroid.drv/init.c
index da2a168..3a3ce80 100644
--- a/dlls/wineandroid.drv/init.c
+++ b/dlls/wineandroid.drv/init.c
@@ -28,13 +28,30 @@
#include "windef.h"
#include "winbase.h"
-#include "wingdi.h"
-#include "winuser.h"
-#include "wine/gdi_driver.h"
+#include "android.h"
+#include "wine/server.h"
+#include "wine/library.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(android);
+unsigned int screen_width = 0;
+unsigned int screen_height = 0;
+RECT virtual_screen_rect = { 0, 0, 0, 0 };
+
+MONITORINFOEXW default_monitor =
+{
+ sizeof(default_monitor), /* cbSize */
+ { 0, 0, 0, 0 }, /* rcMonitor */
+ { 0, 0, 0, 0 }, /* rcWork */
+ MONITORINFOF_PRIMARY, /* dwFlags */
+ { '\\','\\','.','\\','D','I','S','P','L','A','Y','1',0 } /* szDevice */
+};
+
+static const unsigned int screen_bpp = 32; /* we don't support other modes */
+
+static int device_init_done;
+
typedef struct
{
struct gdi_physdev dev;
@@ -42,6 +59,65 @@ typedef struct
static const struct gdi_dc_funcs android_drv_funcs;
+
+/******************************************************************************
+ * init_monitors
+ */
+void init_monitors( int width, int height )
+{
+ static const WCHAR trayW[] = {'S','h','e','l','l','_','T','r','a','y','W','n','d',0};
+ RECT rect;
+ HWND hwnd = FindWindowW( trayW, NULL );
+
+ virtual_screen_rect.right = width;
+ virtual_screen_rect.bottom = height;
+ default_monitor.rcMonitor = default_monitor.rcWork = virtual_screen_rect;
+
+ if (!hwnd || !IsWindowVisible( hwnd )) return;
+ if (!GetWindowRect( hwnd, &rect )) return;
+ if (rect.top) default_monitor.rcWork.bottom = rect.top;
+ else default_monitor.rcWork.top = rect.bottom;
+ TRACE( "found tray %p %s work area %s\n", hwnd,
+ wine_dbgstr_rect( &rect ), wine_dbgstr_rect( &default_monitor.rcWork ));
+}
+
+
+/**********************************************************************
+ * fetch_display_metrics
+ */
+static void fetch_display_metrics(void)
+{
+ if (wine_get_java_vm()) return; /* for Java threads it will be set when the top view is created */
+
+ SERVER_START_REQ( get_window_rectangles )
+ {
+ req->handle = wine_server_user_handle( GetDesktopWindow() );
+ req->relative = COORDS_CLIENT;
+ if (!wine_server_call( req ))
+ {
+ screen_width = reply->window.right;
+ screen_height = reply->window.bottom;
+ }
+ }
+ SERVER_END_REQ;
+
+ init_monitors( screen_width, screen_height );
+ TRACE( "screen %ux%u\n", screen_width, screen_height );
+}
+
+
+/**********************************************************************
+ * device_init
+ *
+ * Perform initializations needed upon creation of the first device.
+ */
+static void device_init(void)
+{
+ device_init_done = TRUE;
+ fetch_display_metrics();
+}
+
+
/******************************************************************************
* create_android_physdev
*/
@@ -49,6 +125,8 @@ static ANDROID_PDEVICE *create_android_physdev(void)
{
ANDROID_PDEVICE *physdev;
+ if (!device_init_done) device_init();
+
if (!(physdev = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*physdev) ))) return NULL;
return physdev;
}
@@ -92,6 +170,76 @@ static BOOL ANDROID_DeleteDC( PHYSDEV dev )
}
+/***********************************************************************
+ * ANDROID_GetDeviceCaps
+ */
+static INT ANDROID_GetDeviceCaps( PHYSDEV dev, INT cap )
+{
+ switch(cap)
+ {
+ case HORZRES: return screen_width;
+ case VERTRES: return screen_height;
+ case DESKTOPHORZRES: return virtual_screen_rect.right - virtual_screen_rect.left;
+ case DESKTOPVERTRES: return virtual_screen_rect.bottom - virtual_screen_rect.top;
+ case BITSPIXEL: return screen_bpp;
+ default:
+ dev = GET_NEXT_PHYSDEV( dev, pGetDeviceCaps );
+ return dev->funcs->pGetDeviceCaps( dev, cap );
+ }
+}
+
+
+/***********************************************************************
+ * ANDROID_GetMonitorInfo
+ */
+BOOL CDECL ANDROID_GetMonitorInfo( HMONITOR handle, LPMONITORINFO info )
+{
+ if (handle != (HMONITOR)1)
+ {
+ SetLastError( ERROR_INVALID_HANDLE );
+ return FALSE;
+ }
+ info->rcMonitor = default_monitor.rcMonitor;
+ info->rcWork = default_monitor.rcWork;
+ info->dwFlags = default_monitor.dwFlags;
+ if (info->cbSize >= sizeof(MONITORINFOEXW))
+ lstrcpyW( ((MONITORINFOEXW *)info)->szDevice, default_monitor.szDevice );
+ return TRUE;
+}
+
+
+/***********************************************************************
+ * ANDROID_EnumDisplayMonitors
+ */
+BOOL CDECL ANDROID_EnumDisplayMonitors( HDC hdc, LPRECT rect, MONITORENUMPROC proc, LPARAM lp )
+{
+ if (hdc)
+ {
+ POINT origin;
+ RECT limit, monrect;
+
+ if (!GetDCOrgEx( hdc, &origin )) return FALSE;
+ if (GetClipBox( hdc, &limit ) == ERROR) return FALSE;
+
+ if (rect && !IntersectRect( &limit, &limit, rect )) return TRUE;
+
+ monrect = default_monitor.rcMonitor;
+ OffsetRect( &monrect, -origin.x, -origin.y );
+ if (IntersectRect( &monrect, &monrect, &limit ))
+ if (!proc( (HMONITOR)1, hdc, &monrect, lp ))
+ return FALSE;
+ }
+ else
+ {
+ RECT unused;
+ if (!rect || IntersectRect( &unused, &default_monitor.rcMonitor, rect ))
+ if (!proc( (HMONITOR)1, 0, &default_monitor.rcMonitor, lp ))
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
static const struct gdi_dc_funcs android_drv_funcs =
{
NULL, /* pAbortDoc */
@@ -131,7 +279,7 @@ static const struct gdi_dc_funcs android_drv_funcs =
NULL, /* pGetCharABCWidths */
NULL, /* pGetCharABCWidthsI */
NULL, /* pGetCharWidth */
- NULL, /* pGetDeviceCaps */
+ ANDROID_GetDeviceCaps, /* pGetDeviceCaps */
NULL, /* pGetDeviceGammaRamp */
NULL, /* pGetFontData */
NULL, /* pGetFontRealizationInfo */
diff --git a/dlls/wineandroid.drv/wineandroid.drv.spec b/dlls/wineandroid.drv/wineandroid.drv.spec
index 9e94320..1723bd4 100644
--- a/dlls/wineandroid.drv/wineandroid.drv.spec
+++ b/dlls/wineandroid.drv/wineandroid.drv.spec
@@ -1,3 +1,8 @@
# GDI driver
@ cdecl wine_get_gdi_driver(long) ANDROID_get_gdi_driver
+
+# USER driver
+
+@ cdecl EnumDisplayMonitors(long ptr ptr long) ANDROID_EnumDisplayMonitors
+@ cdecl GetMonitorInfo(long ptr) ANDROID_GetMonitorInfo
More information about the wine-cvs
mailing list