wineandroid: Add infrastructure to support a separate TextureView for the window client area.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
95c4516b65
commit
f77bbd45d6
|
@ -54,7 +54,7 @@ public class WineActivity extends Activity
|
||||||
private native String wine_init( String[] cmdline, String[] env );
|
private native String wine_init( String[] cmdline, String[] env );
|
||||||
public native void wine_desktop_changed( int width, int height );
|
public native void wine_desktop_changed( int width, int height );
|
||||||
public native void wine_config_changed( int dpi );
|
public native void wine_config_changed( int dpi );
|
||||||
public native void wine_surface_changed( int hwnd, Surface surface );
|
public native void wine_surface_changed( int hwnd, Surface surface, boolean opengl );
|
||||||
public native boolean wine_motion_event( int hwnd, int action, int x, int y, int state, int vscroll );
|
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 );
|
public native boolean wine_keyboard_event( int hwnd, int action, int keycode, int state );
|
||||||
|
|
||||||
|
@ -299,6 +299,7 @@ protected class WineWindow extends Object
|
||||||
protected WineWindow parent;
|
protected WineWindow parent;
|
||||||
protected WineView window_view;
|
protected WineView window_view;
|
||||||
protected Surface window_surface;
|
protected Surface window_surface;
|
||||||
|
protected Surface client_surface;
|
||||||
|
|
||||||
public WineWindow( int w, WineWindow parent )
|
public WineWindow( int w, WineWindow parent )
|
||||||
{
|
{
|
||||||
|
@ -312,7 +313,7 @@ public WineWindow( int w, WineWindow parent )
|
||||||
win_map.put( w, this );
|
win_map.put( w, this );
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
{
|
{
|
||||||
window_view = new WineView( WineActivity.this, this );
|
window_view = new WineView( WineActivity.this, this, false );
|
||||||
window_view.layout( 0, 0, 1, 1 ); // make sure the surface gets created
|
window_view.layout( 0, 0, 1, 1 ); // make sure the surface gets created
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -353,7 +354,7 @@ public void set_parent( WineWindow new_parent )
|
||||||
parent = new_parent;
|
parent = new_parent;
|
||||||
if (new_parent == null)
|
if (new_parent == null)
|
||||||
{
|
{
|
||||||
window_view = new WineView( WineActivity.this, this );
|
window_view = new WineView( WineActivity.this, this, false );
|
||||||
window_view.layout( 0, 0, 1, 1 ); // make sure the surface gets created
|
window_view.layout( 0, 0, 1, 1 ); // make sure the surface gets created
|
||||||
}
|
}
|
||||||
else window_view = null;
|
else window_view = null;
|
||||||
|
@ -364,12 +365,22 @@ public int get_hwnd()
|
||||||
return hwnd;
|
return hwnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void set_surface( SurfaceTexture surftex )
|
public void set_surface( SurfaceTexture surftex, boolean is_client )
|
||||||
{
|
{
|
||||||
if (surftex == null) window_surface = null;
|
if (is_client)
|
||||||
else if (window_surface == null) window_surface = new Surface( surftex );
|
{
|
||||||
Log.i( LOGTAG, String.format( "set window surface hwnd %08x %s", hwnd, window_surface ));
|
if (surftex == null) client_surface = null;
|
||||||
wine_surface_changed( hwnd, window_surface );
|
else if (client_surface == null) client_surface = new Surface( surftex );
|
||||||
|
Log.i( LOGTAG, String.format( "set client surface hwnd %08x %s", hwnd, client_surface ));
|
||||||
|
wine_surface_changed( hwnd, client_surface, true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (surftex == null) window_surface = null;
|
||||||
|
else if (window_surface == null) window_surface = new Surface( surftex );
|
||||||
|
Log.i( LOGTAG, String.format( "set window surface hwnd %08x %s", hwnd, window_surface ));
|
||||||
|
wine_surface_changed( hwnd, window_surface, false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void get_event_pos( MotionEvent event, int[] pos )
|
public void get_event_pos( MotionEvent event, int[] pos )
|
||||||
|
@ -384,11 +395,13 @@ public void get_event_pos( MotionEvent event, int[] pos )
|
||||||
protected class WineView extends TextureView implements TextureView.SurfaceTextureListener
|
protected class WineView extends TextureView implements TextureView.SurfaceTextureListener
|
||||||
{
|
{
|
||||||
private WineWindow window;
|
private WineWindow window;
|
||||||
|
private boolean is_client;
|
||||||
|
|
||||||
public WineView( Context c, WineWindow win )
|
public WineView( Context c, WineWindow win, boolean client )
|
||||||
{
|
{
|
||||||
super( c );
|
super( c );
|
||||||
window = win;
|
window = win;
|
||||||
|
is_client = client;
|
||||||
setSurfaceTextureListener( this );
|
setSurfaceTextureListener( this );
|
||||||
setVisibility( VISIBLE );
|
setVisibility( VISIBLE );
|
||||||
setOpaque( false );
|
setOpaque( false );
|
||||||
|
@ -403,22 +416,23 @@ public WineWindow get_window()
|
||||||
|
|
||||||
public void onSurfaceTextureAvailable( SurfaceTexture surftex, int width, int height )
|
public void onSurfaceTextureAvailable( SurfaceTexture surftex, int width, int height )
|
||||||
{
|
{
|
||||||
Log.i( LOGTAG, String.format( "onSurfaceTextureAvailable win %08x %dx%d",
|
Log.i( LOGTAG, String.format( "onSurfaceTextureAvailable win %08x %dx%d %s",
|
||||||
window.hwnd, width, height ));
|
window.hwnd, width, height, is_client ? "client" : "whole" ));
|
||||||
window.set_surface( surftex );
|
window.set_surface( surftex, is_client );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSurfaceTextureSizeChanged( SurfaceTexture surftex, int width, int height )
|
public void onSurfaceTextureSizeChanged( SurfaceTexture surftex, int width, int height )
|
||||||
{
|
{
|
||||||
Log.i( LOGTAG, String.format( "onSurfaceTextureSizeChanged win %08x %dx%d",
|
Log.i( LOGTAG, String.format( "onSurfaceTextureSizeChanged win %08x %dx%d %s",
|
||||||
window.hwnd, width, height ));
|
window.hwnd, width, height, is_client ? "client" : "whole" ));
|
||||||
window.set_surface( surftex );
|
window.set_surface( surftex, is_client);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean onSurfaceTextureDestroyed( SurfaceTexture surftex )
|
public boolean onSurfaceTextureDestroyed( SurfaceTexture surftex )
|
||||||
{
|
{
|
||||||
Log.i( LOGTAG, String.format( "onSurfaceTextureDestroyed win %08x", window.hwnd ));
|
Log.i( LOGTAG, String.format( "onSurfaceTextureDestroyed win %08x %s",
|
||||||
window.set_surface( null );
|
window.hwnd, is_client ? "client" : "whole" ));
|
||||||
|
window.set_surface( null, is_client );
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,6 +442,7 @@ public void onSurfaceTextureUpdated(SurfaceTexture surftex)
|
||||||
|
|
||||||
public boolean onGenericMotionEvent( MotionEvent event )
|
public boolean onGenericMotionEvent( MotionEvent event )
|
||||||
{
|
{
|
||||||
|
if (is_client) return false; // let the whole window handle it
|
||||||
if (window.parent != null) return false; // let the parent handle it
|
if (window.parent != null) return false; // let the parent handle it
|
||||||
|
|
||||||
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0)
|
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0)
|
||||||
|
@ -445,6 +460,7 @@ public boolean onGenericMotionEvent( MotionEvent event )
|
||||||
|
|
||||||
public boolean onTouchEvent( MotionEvent event )
|
public boolean onTouchEvent( MotionEvent event )
|
||||||
{
|
{
|
||||||
|
if (is_client) return false; // let the whole window handle it
|
||||||
if (window.parent != null) return false; // let the parent handle it
|
if (window.parent != null) return false; // let the parent handle it
|
||||||
|
|
||||||
int[] pos = new int[2];
|
int[] pos = new int[2];
|
||||||
|
|
|
@ -87,7 +87,8 @@ extern void update_keyboard_lock_state( WORD vkey, UINT state ) DECLSPEC_HIDDEN;
|
||||||
/* JNI entry points */
|
/* JNI entry points */
|
||||||
extern void desktop_changed( JNIEnv *env, jobject obj, jint width, jint height ) DECLSPEC_HIDDEN;
|
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 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 void surface_changed( JNIEnv *env, jobject obj, jint win, jobject surface,
|
||||||
|
jboolean client ) DECLSPEC_HIDDEN;
|
||||||
extern jboolean motion_event( JNIEnv *env, jobject obj, jint win, jint action,
|
extern jboolean motion_event( JNIEnv *env, jobject obj, jint win, jint action,
|
||||||
jint x, jint y, jint state, jint vscroll ) DECLSPEC_HIDDEN;
|
jint x, jint y, jint state, jint vscroll ) DECLSPEC_HIDDEN;
|
||||||
extern jboolean keyboard_event( JNIEnv *env, jobject obj, jint win, jint action,
|
extern jboolean keyboard_event( JNIEnv *env, jobject obj, jint win, jint action,
|
||||||
|
@ -121,6 +122,7 @@ union event_data
|
||||||
enum event_type type;
|
enum event_type type;
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
ANativeWindow *window;
|
ANativeWindow *window;
|
||||||
|
BOOL client;
|
||||||
unsigned int width;
|
unsigned int width;
|
||||||
unsigned int height;
|
unsigned int height;
|
||||||
} surface;
|
} surface;
|
||||||
|
|
|
@ -458,7 +458,7 @@ static const JNINativeMethod methods[] =
|
||||||
{
|
{
|
||||||
{ "wine_desktop_changed", "(II)V", desktop_changed },
|
{ "wine_desktop_changed", "(II)V", desktop_changed },
|
||||||
{ "wine_config_changed", "(I)V", config_changed },
|
{ "wine_config_changed", "(I)V", config_changed },
|
||||||
{ "wine_surface_changed", "(ILandroid/view/Surface;)V", surface_changed },
|
{ "wine_surface_changed", "(ILandroid/view/Surface;Z)V", surface_changed },
|
||||||
{ "wine_motion_event", "(IIIIII)Z", motion_event },
|
{ "wine_motion_event", "(IIIIII)Z", motion_event },
|
||||||
{ "wine_keyboard_event", "(IIII)Z", keyboard_event },
|
{ "wine_keyboard_event", "(IIII)Z", keyboard_event },
|
||||||
};
|
};
|
||||||
|
|
|
@ -245,12 +245,13 @@ void config_changed( JNIEnv *env, jobject obj, jint dpi )
|
||||||
*
|
*
|
||||||
* JNI callback, runs in the context of the Java thread.
|
* JNI callback, runs in the context of the Java thread.
|
||||||
*/
|
*/
|
||||||
void surface_changed( JNIEnv *env, jobject obj, jint win, jobject surface )
|
void surface_changed( JNIEnv *env, jobject obj, jint win, jobject surface, jboolean client )
|
||||||
{
|
{
|
||||||
union event_data data;
|
union event_data data;
|
||||||
|
|
||||||
memset( &data, 0, sizeof(data) );
|
memset( &data, 0, sizeof(data) );
|
||||||
data.surface.hwnd = LongToHandle( win );
|
data.surface.hwnd = LongToHandle( win );
|
||||||
|
data.surface.client = client;
|
||||||
if (surface)
|
if (surface)
|
||||||
{
|
{
|
||||||
int width, height;
|
int width, height;
|
||||||
|
@ -261,8 +262,8 @@ void surface_changed( JNIEnv *env, jobject obj, jint win, jobject surface )
|
||||||
data.surface.window = win;
|
data.surface.window = win;
|
||||||
data.surface.width = width;
|
data.surface.width = width;
|
||||||
data.surface.height = height;
|
data.surface.height = height;
|
||||||
p__android_log_print( ANDROID_LOG_INFO, "wine", "surface_changed: %p %ux%u",
|
p__android_log_print( ANDROID_LOG_INFO, "wine", "surface_changed: %p %s %ux%u",
|
||||||
data.surface.hwnd, width, height );
|
data.surface.hwnd, client ? "client" : "whole", width, height );
|
||||||
}
|
}
|
||||||
data.type = SURFACE_CHANGED;
|
data.type = SURFACE_CHANGED;
|
||||||
send_event( &data );
|
send_event( &data );
|
||||||
|
@ -451,10 +452,11 @@ static int process_events( DWORD mask )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SURFACE_CHANGED:
|
case SURFACE_CHANGED:
|
||||||
TRACE("SURFACE_CHANGED %p %p size %ux%u\n", event->data.surface.hwnd,
|
TRACE("SURFACE_CHANGED %p %p %s size %ux%u\n", event->data.surface.hwnd,
|
||||||
event->data.surface.window, event->data.surface.width, event->data.surface.height );
|
event->data.surface.window, event->data.surface.client ? "client" : "whole",
|
||||||
|
event->data.surface.width, event->data.surface.height );
|
||||||
|
|
||||||
register_native_window( event->data.surface.hwnd, event->data.surface.window, FALSE );
|
register_native_window( event->data.surface.hwnd, event->data.surface.window, event->data.surface.client );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MOTION_EVENT:
|
case MOTION_EVENT:
|
||||||
|
|
Loading…
Reference in New Issue