wineandroid: Store the actual screen DPI on startup.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2017-06-12 19:12:30 +02:00
parent 3179a5da93
commit f254aec449
5 changed files with 51 additions and 1 deletions

View File

@ -1,5 +1,5 @@
MODULE = wineandroid.drv
IMPORTS = user32 gdi32 ntoskrnl
IMPORTS = user32 gdi32 advapi32 ntoskrnl
C_SRCS = \
device.c \

View File

@ -53,6 +53,7 @@ public class WineActivity extends Activity
{
private native String wine_init( String[] cmdline, String[] env );
public native void wine_desktop_changed( int width, int height );
public native void wine_config_changed( int dpi );
public native void wine_surface_changed( int hwnd, Surface surface );
public native boolean wine_motion_event( int hwnd, int action, int x, int y, int state, int vscroll );
public native boolean wine_keyboard_event( int hwnd, int action, int keycode, int state );
@ -508,6 +509,7 @@ public class WineActivity extends Activity
top_view = new TopView( this, hwnd );
setContentView( top_view );
progress_dialog.dismiss();
wine_config_changed( getResources().getConfiguration().densityDpi );
}
public void create_window( int hwnd, int parent, int pid )

View File

@ -81,10 +81,12 @@ enum android_window_messages
extern HWND get_capture_window(void) DECLSPEC_HIDDEN;
extern void init_monitors( int width, int height ) DECLSPEC_HIDDEN;
extern void set_screen_dpi( DWORD dpi ) DECLSPEC_HIDDEN;
extern void update_keyboard_lock_state( WORD vkey, UINT state ) DECLSPEC_HIDDEN;
/* JNI entry points */
extern void desktop_changed( JNIEnv *env, jobject obj, jint width, jint height ) DECLSPEC_HIDDEN;
extern void config_changed( JNIEnv *env, jobject obj, jint dpi ) DECLSPEC_HIDDEN;
extern void surface_changed( JNIEnv *env, jobject obj, jint win, jobject surface ) DECLSPEC_HIDDEN;
extern jboolean motion_event( JNIEnv *env, jobject obj, jint win, jint action,
jint x, jint y, jint state, jint vscroll ) DECLSPEC_HIDDEN;
@ -94,6 +96,7 @@ extern jboolean keyboard_event( JNIEnv *env, jobject obj, jint win, jint action,
enum event_type
{
DESKTOP_CHANGED,
CONFIG_CHANGED,
SURFACE_CHANGED,
MOTION_EVENT,
KEYBOARD_EVENT,
@ -109,6 +112,11 @@ union event_data
unsigned int height;
} desktop;
struct
{
enum event_type type;
unsigned int dpi;
} cfg;
struct
{
enum event_type type;
HWND hwnd;

View File

@ -28,6 +28,7 @@
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "android.h"
#include "wine/server.h"
#include "wine/library.h"
@ -82,6 +83,22 @@ void init_monitors( int width, int height )
}
/******************************************************************************
* set_screen_dpi
*/
void set_screen_dpi( DWORD dpi )
{
static const WCHAR dpi_key_name[] = {'S','o','f','t','w','a','r','e','\\','F','o','n','t','s',0};
static const WCHAR dpi_value_name[] = {'L','o','g','P','i','x','e','l','s',0};
HKEY hkey;
if (!RegCreateKeyW( HKEY_CURRENT_CONFIG, dpi_key_name, &hkey ))
{
RegSetValueExW( hkey, dpi_value_name, 0, REG_DWORD, (void *)&dpi, sizeof(DWORD) );
RegCloseKey( hkey );
}
}
/**********************************************************************
* fetch_display_metrics
*/
@ -390,6 +407,7 @@ const struct gdi_dc_funcs * CDECL ANDROID_get_gdi_driver( unsigned int version )
static const JNINativeMethod methods[] =
{
{ "wine_desktop_changed", "(II)V", desktop_changed },
{ "wine_config_changed", "(I)V", config_changed },
{ "wine_surface_changed", "(ILandroid/view/Surface;)V", surface_changed },
{ "wine_motion_event", "(IIIIII)Z", motion_event },
{ "wine_keyboard_event", "(IIII)Z", keyboard_event },

View File

@ -223,6 +223,23 @@ void desktop_changed( JNIEnv *env, jobject obj, jint width, jint height )
}
/***********************************************************************
* config_changed
*
* JNI callback, runs in the context of the Java thread.
*/
void config_changed( JNIEnv *env, jobject obj, jint dpi )
{
union event_data data;
memset( &data, 0, sizeof(data) );
data.type = CONFIG_CHANGED;
data.cfg.dpi = dpi;
p__android_log_print( ANDROID_LOG_INFO, "wine", "config_changed: %u dpi", dpi );
send_event( &data );
}
/***********************************************************************
* surface_changed
*
@ -428,6 +445,11 @@ static int process_events( DWORD mask )
SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOREDRAW );
break;
case CONFIG_CHANGED:
TRACE( "CONFIG_CHANGED dpi %u\n", event->data.cfg.dpi );
set_screen_dpi( event->data.cfg.dpi );
break;
case SURFACE_CHANGED:
TRACE("SURFACE_CHANGED %p %p size %ux%u\n", event->data.surface.hwnd,
event->data.surface.window, event->data.surface.width, event->data.surface.height );