2017-05-30 12:59:15 +02:00
|
|
|
/*
|
|
|
|
* WineActivity class
|
|
|
|
*
|
|
|
|
* Copyright 2013-2017 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
package org.winehq.wine;
|
|
|
|
|
2018-11-26 14:40:33 +01:00
|
|
|
import android.annotation.TargetApi;
|
2017-05-30 12:59:15 +02:00
|
|
|
import android.app.Activity;
|
2017-05-30 14:19:57 +02:00
|
|
|
import android.app.ProgressDialog;
|
2017-06-01 09:40:29 +02:00
|
|
|
import android.content.Context;
|
2017-05-30 14:19:57 +02:00
|
|
|
import android.content.SharedPreferences;
|
2018-11-26 16:11:44 +01:00
|
|
|
import android.graphics.Bitmap;
|
2017-06-02 11:34:23 +02:00
|
|
|
import android.graphics.Rect;
|
2017-06-02 11:35:12 +02:00
|
|
|
import android.graphics.SurfaceTexture;
|
2017-05-30 14:19:57 +02:00
|
|
|
import android.os.Build;
|
2017-05-30 12:59:15 +02:00
|
|
|
import android.os.Bundle;
|
2017-05-30 14:19:57 +02:00
|
|
|
import android.preference.PreferenceManager;
|
|
|
|
import android.util.Log;
|
2017-06-08 10:16:41 +02:00
|
|
|
import android.view.InputDevice;
|
2017-06-08 16:44:20 +02:00
|
|
|
import android.view.KeyEvent;
|
2017-06-08 10:16:41 +02:00
|
|
|
import android.view.MotionEvent;
|
2018-11-26 16:11:44 +01:00
|
|
|
import android.view.PointerIcon;
|
2017-06-02 11:35:12 +02:00
|
|
|
import android.view.Surface;
|
|
|
|
import android.view.TextureView;
|
2017-06-01 09:40:29 +02:00
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2017-05-30 14:19:57 +02:00
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.File;
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
2017-05-30 19:12:11 +02:00
|
|
|
import java.util.Locale;
|
2017-05-30 14:19:57 +02:00
|
|
|
import java.util.Map;
|
2017-05-30 12:59:15 +02:00
|
|
|
|
|
|
|
public class WineActivity extends Activity
|
|
|
|
{
|
2017-05-30 19:12:11 +02:00
|
|
|
private native String wine_init( String[] cmdline, String[] env );
|
2017-06-01 09:40:29 +02:00
|
|
|
public native void wine_desktop_changed( int width, int height );
|
2017-06-12 19:12:30 +02:00
|
|
|
public native void wine_config_changed( int dpi );
|
2017-06-22 19:36:54 +02:00
|
|
|
public native void wine_surface_changed( int hwnd, Surface surface, boolean opengl );
|
2017-06-08 10:16:41 +02:00
|
|
|
public native boolean wine_motion_event( int hwnd, int action, int x, int y, int state, int vscroll );
|
2017-06-08 16:44:20 +02:00
|
|
|
public native boolean wine_keyboard_event( int hwnd, int action, int keycode, int state );
|
2017-05-30 19:12:11 +02:00
|
|
|
|
2017-05-30 14:19:57 +02:00
|
|
|
private final String LOGTAG = "wine";
|
|
|
|
private ProgressDialog progress_dialog;
|
|
|
|
|
2017-06-22 19:38:36 +02:00
|
|
|
protected WineWindow desktop_window;
|
2017-06-22 20:04:43 +02:00
|
|
|
protected WineWindow message_window;
|
2018-11-26 16:11:44 +01:00
|
|
|
private PointerIcon current_cursor;
|
2017-06-22 19:38:36 +02:00
|
|
|
|
2017-05-30 12:59:15 +02:00
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState)
|
|
|
|
{
|
|
|
|
super.onCreate( savedInstanceState );
|
2017-05-30 14:19:57 +02:00
|
|
|
|
|
|
|
requestWindowFeature( android.view.Window.FEATURE_NO_TITLE );
|
|
|
|
|
2017-05-30 19:12:11 +02:00
|
|
|
new Thread( new Runnable() { public void run() { loadWine( null ); }} ).start();
|
2017-05-30 14:19:57 +02:00
|
|
|
}
|
|
|
|
|
2018-11-26 14:40:33 +01:00
|
|
|
@TargetApi(21)
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
private String[] get_supported_abis()
|
|
|
|
{
|
|
|
|
if (Build.VERSION.SDK_INT >= 21) return Build.SUPPORTED_ABIS;
|
|
|
|
return new String[]{ Build.CPU_ABI };
|
|
|
|
}
|
|
|
|
|
|
|
|
private String get_wine_abi()
|
|
|
|
{
|
|
|
|
for (String abi : get_supported_abis())
|
|
|
|
{
|
|
|
|
File server = new File( getFilesDir(), abi + "/bin/wineserver" );
|
|
|
|
if (server.canExecute()) return abi;
|
|
|
|
}
|
|
|
|
Log.e( LOGTAG, "could not find a supported ABI" );
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2017-05-30 19:12:11 +02:00
|
|
|
private void loadWine( String cmdline )
|
2017-05-30 14:19:57 +02:00
|
|
|
{
|
2018-11-26 14:40:33 +01:00
|
|
|
copyAssetFiles();
|
|
|
|
|
|
|
|
String wine_abi = get_wine_abi();
|
|
|
|
File bindir = new File( getFilesDir(), wine_abi + "/bin" );
|
|
|
|
File libdir = new File( getFilesDir(), wine_abi + "/lib" );
|
2017-07-31 19:48:24 +02:00
|
|
|
File dlldir = new File( libdir, "wine" );
|
2017-05-30 19:12:11 +02:00
|
|
|
File prefix = new File( getFilesDir(), "prefix" );
|
|
|
|
File loader = new File( bindir, "wine" );
|
|
|
|
String locale = Locale.getDefault().getLanguage() + "_" +
|
|
|
|
Locale.getDefault().getCountry() + ".UTF-8";
|
|
|
|
|
|
|
|
HashMap<String,String> env = new HashMap<String,String>();
|
|
|
|
env.put( "WINELOADER", loader.toString() );
|
|
|
|
env.put( "WINEPREFIX", prefix.toString() );
|
2017-07-31 19:48:24 +02:00
|
|
|
env.put( "WINEDLLPATH", dlldir.toString() );
|
2017-06-26 15:13:35 +02:00
|
|
|
env.put( "LD_LIBRARY_PATH", libdir.toString() + ":" + getApplicationInfo().nativeLibraryDir );
|
2017-05-30 19:12:11 +02:00
|
|
|
env.put( "LC_ALL", locale );
|
|
|
|
env.put( "LANG", locale );
|
2017-07-03 20:58:01 +02:00
|
|
|
env.put( "PATH", bindir.toString() + ":" + System.getenv( "PATH" ));
|
2017-05-30 19:12:11 +02:00
|
|
|
|
|
|
|
if (cmdline == null)
|
|
|
|
{
|
|
|
|
if (new File( prefix, "drive_c/winestart.cmd" ).exists()) cmdline = "c:\\winestart.cmd";
|
|
|
|
else cmdline = "wineconsole.exe";
|
|
|
|
}
|
|
|
|
|
|
|
|
String winedebug = readFileString( new File( prefix, "winedebug" ));
|
|
|
|
if (winedebug == null) winedebug = readFileString( new File( getFilesDir(), "winedebug" ));
|
|
|
|
if (winedebug != null)
|
|
|
|
{
|
|
|
|
File log = new File( getFilesDir(), "log" );
|
|
|
|
env.put( "WINEDEBUG", winedebug );
|
|
|
|
env.put( "WINEDEBUGLOG", log.toString() );
|
|
|
|
Log.i( LOGTAG, "logging to " + log.toString() );
|
|
|
|
log.delete();
|
|
|
|
}
|
|
|
|
|
2017-06-01 09:41:05 +02:00
|
|
|
createProgressDialog( 0, "Setting up the Windows environment..." );
|
|
|
|
|
2020-12-08 12:45:18 +01:00
|
|
|
System.load( dlldir.toString() + "/ntdll.so" );
|
2017-05-30 19:12:11 +02:00
|
|
|
prefix.mkdirs();
|
|
|
|
|
|
|
|
runWine( cmdline, env );
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void runWine( String cmdline, HashMap<String,String> environ )
|
|
|
|
{
|
|
|
|
String[] env = new String[environ.size() * 2];
|
|
|
|
int j = 0;
|
|
|
|
for (Map.Entry<String,String> entry : environ.entrySet())
|
|
|
|
{
|
|
|
|
env[j++] = entry.getKey();
|
|
|
|
env[j++] = entry.getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
String[] cmd = { environ.get( "WINELOADER" ),
|
|
|
|
"explorer.exe",
|
|
|
|
"/desktop=shell,,android",
|
|
|
|
cmdline };
|
|
|
|
|
|
|
|
String err = wine_init( cmd, env );
|
|
|
|
Log.e( LOGTAG, err );
|
2017-05-30 14:19:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private void createProgressDialog( final int max, final String message )
|
|
|
|
{
|
|
|
|
runOnUiThread( new Runnable() { public void run() {
|
|
|
|
if (progress_dialog != null) progress_dialog.dismiss();
|
|
|
|
progress_dialog = new ProgressDialog( WineActivity.this );
|
|
|
|
progress_dialog.setProgressStyle( max > 0 ? ProgressDialog.STYLE_HORIZONTAL
|
|
|
|
: ProgressDialog.STYLE_SPINNER );
|
|
|
|
progress_dialog.setTitle( "Wine" );
|
|
|
|
progress_dialog.setMessage( message );
|
|
|
|
progress_dialog.setCancelable( false );
|
|
|
|
progress_dialog.setMax( max );
|
|
|
|
progress_dialog.show();
|
|
|
|
}});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
private final boolean isFileWanted( String name )
|
|
|
|
{
|
|
|
|
if (name.equals( "files.sum" )) return true;
|
|
|
|
if (name.startsWith( "share/" )) return true;
|
2018-11-26 14:40:33 +01:00
|
|
|
for (String abi : get_supported_abis())
|
|
|
|
{
|
|
|
|
if (name.startsWith( abi + "/system/" )) return false;
|
|
|
|
if (name.startsWith( abi + "/" )) return true;
|
|
|
|
}
|
2017-05-30 14:19:57 +02:00
|
|
|
if (name.startsWith( "x86/" )) return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private final boolean isFileExecutable( String name )
|
|
|
|
{
|
2018-11-26 14:40:33 +01:00
|
|
|
return !name.equals( "files.sum" ) && !name.startsWith( "share/" );
|
2017-05-30 14:19:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private final HashMap<String,String> readMapFromInputStream( InputStream in )
|
|
|
|
{
|
|
|
|
HashMap<String,String> map = new HashMap<String,String>();
|
|
|
|
String str;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
BufferedReader reader = new BufferedReader( new InputStreamReader( in, "UTF-8" ));
|
|
|
|
while ((str = reader.readLine()) != null)
|
|
|
|
{
|
|
|
|
String entry[] = str.split( "\\s+", 2 );
|
|
|
|
if (entry.length == 2 && isFileWanted( entry[1] )) map.put( entry[1], entry[0] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( IOException e ) { }
|
|
|
|
return map;
|
|
|
|
}
|
|
|
|
|
|
|
|
private final HashMap<String,String> readMapFromDiskFile( String file )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return readMapFromInputStream( new FileInputStream( new File( getFilesDir(), file )));
|
|
|
|
}
|
|
|
|
catch( IOException e ) { return new HashMap<String,String>(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
private final HashMap<String,String> readMapFromAssetFile( String file )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return readMapFromInputStream( getAssets().open( file ) );
|
|
|
|
}
|
|
|
|
catch( IOException e ) { return new HashMap<String,String>(); }
|
|
|
|
}
|
|
|
|
|
2017-05-30 19:12:11 +02:00
|
|
|
private final String readFileString( File file )
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
FileInputStream in = new FileInputStream( file );
|
|
|
|
BufferedReader reader = new BufferedReader( new InputStreamReader( in, "UTF-8" ));
|
|
|
|
return reader.readLine();
|
|
|
|
}
|
|
|
|
catch( IOException e ) { return null; }
|
|
|
|
}
|
|
|
|
|
2017-05-30 14:19:57 +02:00
|
|
|
private final void copyAssetFile( String src )
|
|
|
|
{
|
|
|
|
File dest = new File( getFilesDir(), src );
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Log.i( LOGTAG, "extracting " + dest );
|
|
|
|
dest.getParentFile().mkdirs();
|
|
|
|
dest.delete();
|
|
|
|
if (dest.createNewFile())
|
|
|
|
{
|
|
|
|
InputStream in = getAssets().open( src );
|
|
|
|
FileOutputStream out = new FileOutputStream( dest );
|
|
|
|
int read;
|
|
|
|
byte[] buffer = new byte[65536];
|
|
|
|
|
|
|
|
while ((read = in.read( buffer )) > 0) out.write( buffer, 0, read );
|
|
|
|
out.close();
|
|
|
|
if (isFileExecutable( src )) dest.setExecutable( true, true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Log.i( LOGTAG, "Failed to create file " + dest );
|
|
|
|
}
|
|
|
|
catch( IOException e )
|
|
|
|
{
|
|
|
|
Log.i( LOGTAG, "Failed to copy asset file to " + dest );
|
|
|
|
dest.delete();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void deleteAssetFile( String src )
|
|
|
|
{
|
|
|
|
File dest = new File( getFilesDir(), src );
|
|
|
|
Log.i( LOGTAG, "deleting " + dest );
|
|
|
|
dest.delete();
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void copyAssetFiles()
|
|
|
|
{
|
|
|
|
String new_sum = readMapFromAssetFile( "sums.sum" ).get( "files.sum" );
|
|
|
|
if (new_sum == null) return; // no assets
|
|
|
|
|
|
|
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences( this );
|
|
|
|
String old_sum = prefs.getString( "files.sum", "" );
|
|
|
|
if (old_sum.equals( new_sum )) return; // no change
|
|
|
|
prefs.edit().putString( "files.sum", new_sum ).apply();
|
|
|
|
|
|
|
|
HashMap<String,String> existing_files = readMapFromDiskFile( "files.sum" );
|
|
|
|
HashMap<String,String> new_files = readMapFromAssetFile( "files.sum" );
|
|
|
|
ArrayList<String> copy_files = new ArrayList<String>();
|
|
|
|
copy_files.add( "files.sum" );
|
|
|
|
|
|
|
|
for (Map.Entry<String, String> entry : new_files.entrySet())
|
|
|
|
{
|
|
|
|
String name = entry.getKey();
|
|
|
|
if (!entry.getValue().equals( existing_files.remove( name ))) copy_files.add( name );
|
|
|
|
}
|
|
|
|
|
|
|
|
createProgressDialog( copy_files.size(), "Extracting files..." );
|
|
|
|
|
|
|
|
for (String name : existing_files.keySet()) deleteAssetFile( name );
|
|
|
|
|
|
|
|
for (String name : copy_files)
|
|
|
|
{
|
|
|
|
copyAssetFile( name );
|
|
|
|
runOnUiThread( new Runnable() { public void run() {
|
|
|
|
progress_dialog.incrementProgressBy( 1 ); }});
|
|
|
|
}
|
2017-05-30 12:59:15 +02:00
|
|
|
}
|
2017-06-01 09:40:29 +02:00
|
|
|
|
2017-06-01 09:42:42 +02:00
|
|
|
//
|
|
|
|
// Generic Wine window class
|
|
|
|
//
|
|
|
|
|
|
|
|
private HashMap<Integer,WineWindow> win_map = new HashMap<Integer,WineWindow>();
|
|
|
|
|
2019-02-21 10:17:04 +01:00
|
|
|
protected class WineWindow
|
2017-06-01 09:42:42 +02:00
|
|
|
{
|
2017-06-22 20:04:43 +02:00
|
|
|
static protected final int HWND_MESSAGE = 0xfffffffd;
|
2017-07-31 19:16:17 +02:00
|
|
|
static protected final int SWP_NOZORDER = 0x04;
|
2017-06-02 11:34:23 +02:00
|
|
|
static protected final int WS_VISIBLE = 0x10000000;
|
|
|
|
|
2017-06-01 09:42:42 +02:00
|
|
|
protected int hwnd;
|
2017-06-02 11:34:23 +02:00
|
|
|
protected int owner;
|
|
|
|
protected int style;
|
2018-08-23 11:11:30 +02:00
|
|
|
protected float scale;
|
2017-06-02 11:34:23 +02:00
|
|
|
protected boolean visible;
|
|
|
|
protected Rect visible_rect;
|
|
|
|
protected Rect client_rect;
|
2017-06-02 11:35:12 +02:00
|
|
|
protected WineWindow parent;
|
2017-07-31 19:16:17 +02:00
|
|
|
protected ArrayList<WineWindow> children;
|
2017-06-02 11:35:12 +02:00
|
|
|
protected Surface window_surface;
|
2017-06-22 19:36:54 +02:00
|
|
|
protected Surface client_surface;
|
2017-07-13 17:22:37 +02:00
|
|
|
protected SurfaceTexture window_surftex;
|
|
|
|
protected SurfaceTexture client_surftex;
|
2017-06-22 19:38:36 +02:00
|
|
|
protected WineWindowGroup window_group;
|
|
|
|
protected WineWindowGroup client_group;
|
2017-06-01 09:42:42 +02:00
|
|
|
|
2018-12-03 16:16:48 +01:00
|
|
|
public WineWindow( int w, WineWindow parent, float scale )
|
2017-06-01 09:42:42 +02:00
|
|
|
{
|
|
|
|
Log.i( LOGTAG, String.format( "create hwnd %08x", w ));
|
|
|
|
hwnd = w;
|
2017-06-02 11:34:23 +02:00
|
|
|
owner = 0;
|
|
|
|
style = 0;
|
|
|
|
visible = false;
|
|
|
|
visible_rect = client_rect = new Rect( 0, 0, 0, 0 );
|
2017-06-02 11:35:12 +02:00
|
|
|
this.parent = parent;
|
2018-12-03 16:16:48 +01:00
|
|
|
this.scale = scale;
|
2017-07-31 19:16:17 +02:00
|
|
|
children = new ArrayList<WineWindow>();
|
2017-06-01 09:42:42 +02:00
|
|
|
win_map.put( w, this );
|
2017-07-31 19:16:17 +02:00
|
|
|
if (parent != null) parent.children.add( this );
|
2017-06-01 09:42:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void destroy()
|
|
|
|
{
|
|
|
|
Log.i( LOGTAG, String.format( "destroy hwnd %08x", hwnd ));
|
2017-06-02 11:34:23 +02:00
|
|
|
visible = false;
|
2017-06-01 09:42:42 +02:00
|
|
|
win_map.remove( this );
|
2017-07-31 19:16:17 +02:00
|
|
|
if (parent != null) parent.children.remove( this );
|
2017-06-22 19:38:36 +02:00
|
|
|
destroy_window_groups();
|
|
|
|
}
|
|
|
|
|
|
|
|
public WineWindowGroup create_window_groups()
|
|
|
|
{
|
|
|
|
if (client_group != null) return client_group;
|
2017-07-31 19:16:17 +02:00
|
|
|
window_group = new WineWindowGroup( this );
|
|
|
|
client_group = new WineWindowGroup( this );
|
2017-06-22 19:38:36 +02:00
|
|
|
window_group.addView( client_group );
|
|
|
|
client_group.set_layout( client_rect.left - visible_rect.left,
|
|
|
|
client_rect.top - visible_rect.top,
|
|
|
|
client_rect.right - visible_rect.left,
|
|
|
|
client_rect.bottom - visible_rect.top );
|
|
|
|
if (parent != null)
|
|
|
|
{
|
2017-07-31 19:16:17 +02:00
|
|
|
parent.create_window_groups();
|
|
|
|
if (visible) add_view_to_parent();
|
2017-06-22 19:38:36 +02:00
|
|
|
window_group.set_layout( visible_rect.left, visible_rect.top,
|
|
|
|
visible_rect.right, visible_rect.bottom );
|
|
|
|
}
|
|
|
|
return client_group;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void destroy_window_groups()
|
|
|
|
{
|
|
|
|
if (window_group != null)
|
|
|
|
{
|
2017-07-31 19:16:17 +02:00
|
|
|
if (parent != null && parent.client_group != null) remove_view_from_parent();
|
2017-06-22 19:38:36 +02:00
|
|
|
window_group.destroy_view();
|
|
|
|
}
|
|
|
|
if (client_group != null) client_group.destroy_view();
|
|
|
|
window_group = null;
|
|
|
|
client_group = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public View create_whole_view()
|
|
|
|
{
|
|
|
|
if (window_group == null) create_window_groups();
|
2018-08-23 11:11:30 +02:00
|
|
|
window_group.create_view( false ).layout( 0, 0,
|
|
|
|
Math.round( (visible_rect.right - visible_rect.left) * scale ),
|
|
|
|
Math.round( (visible_rect.bottom - visible_rect.top) * scale ));
|
|
|
|
window_group.set_scale( scale );
|
2017-06-22 19:38:36 +02:00
|
|
|
return window_group;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void create_client_view()
|
|
|
|
{
|
|
|
|
if (client_group == null) create_window_groups();
|
2017-07-31 19:16:17 +02:00
|
|
|
Log.i( LOGTAG, String.format( "creating client view %08x %s", hwnd, client_rect ));
|
|
|
|
client_group.create_view( true ).layout( 0, 0, client_rect.right - client_rect.left,
|
|
|
|
client_rect.bottom - client_rect.top );
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void add_view_to_parent()
|
|
|
|
{
|
|
|
|
int pos = parent.client_group.getChildCount() - 1;
|
|
|
|
|
|
|
|
// the content view is always last
|
|
|
|
if (pos >= 0 && parent.client_group.getChildAt( pos ) == parent.client_group.get_content_view()) pos--;
|
|
|
|
|
|
|
|
for (int i = 0; i < parent.children.size() && pos >= 0; i++)
|
|
|
|
{
|
|
|
|
WineWindow child = parent.children.get( i );
|
|
|
|
if (child == this) break;
|
|
|
|
if (!child.visible) continue;
|
|
|
|
if (child == ((WineWindowGroup)parent.client_group.getChildAt( pos )).get_window()) pos--;
|
|
|
|
}
|
|
|
|
parent.client_group.addView( window_group, pos + 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void remove_view_from_parent()
|
|
|
|
{
|
|
|
|
parent.client_group.removeView( window_group );
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void set_zorder( WineWindow prev )
|
|
|
|
{
|
|
|
|
int pos = -1;
|
|
|
|
|
|
|
|
parent.children.remove( this );
|
|
|
|
if (prev != null) pos = parent.children.indexOf( prev );
|
|
|
|
parent.children.add( pos + 1, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
protected void sync_views_zorder()
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
|
|
|
|
for (i = parent.children.size() - 1, j = 0; i >= 0; i--)
|
|
|
|
{
|
|
|
|
WineWindow child = parent.children.get( i );
|
|
|
|
if (!child.visible) continue;
|
|
|
|
View child_view = parent.client_group.getChildAt( j );
|
|
|
|
if (child_view == parent.client_group.get_content_view()) continue;
|
|
|
|
if (child != ((WineWindowGroup)child_view).get_window()) break;
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
while (i >= 0)
|
|
|
|
{
|
|
|
|
WineWindow child = parent.children.get( i-- );
|
|
|
|
if (child.visible) child.window_group.bringToFront();
|
|
|
|
}
|
2017-06-01 09:42:42 +02:00
|
|
|
}
|
|
|
|
|
2017-06-02 11:34:23 +02:00
|
|
|
public void pos_changed( int flags, int insert_after, int owner, int style,
|
|
|
|
Rect window_rect, Rect client_rect, Rect visible_rect )
|
|
|
|
{
|
2017-07-31 19:16:17 +02:00
|
|
|
boolean was_visible = visible;
|
2017-06-02 11:34:23 +02:00
|
|
|
this.visible_rect = visible_rect;
|
|
|
|
this.client_rect = client_rect;
|
|
|
|
this.style = style;
|
|
|
|
this.owner = owner;
|
2017-07-31 19:16:17 +02:00
|
|
|
visible = (style & WS_VISIBLE) != 0;
|
|
|
|
|
2017-06-02 11:34:23 +02:00
|
|
|
Log.i( LOGTAG, String.format( "pos changed hwnd %08x after %08x owner %08x style %08x win %s client %s visible %s flags %08x",
|
|
|
|
hwnd, insert_after, owner, style, window_rect, client_rect, visible_rect, flags ));
|
|
|
|
|
2017-07-31 19:16:17 +02:00
|
|
|
if ((flags & SWP_NOZORDER) == 0 && parent != null) set_zorder( get_window( insert_after ));
|
|
|
|
|
2017-06-22 19:38:36 +02:00
|
|
|
if (window_group != null)
|
2017-06-02 11:35:12 +02:00
|
|
|
{
|
2017-06-22 19:38:36 +02:00
|
|
|
window_group.set_layout( visible_rect.left, visible_rect.top,
|
|
|
|
visible_rect.right, visible_rect.bottom );
|
|
|
|
if (parent != null)
|
|
|
|
{
|
2017-07-31 19:16:17 +02:00
|
|
|
if (!was_visible && (style & WS_VISIBLE) != 0) add_view_to_parent();
|
|
|
|
else if (was_visible && (style & WS_VISIBLE) == 0) remove_view_from_parent();
|
|
|
|
else if (visible && (flags & SWP_NOZORDER) == 0) sync_views_zorder();
|
2017-06-22 19:38:36 +02:00
|
|
|
}
|
2017-06-02 11:35:12 +02:00
|
|
|
}
|
2017-06-22 19:38:36 +02:00
|
|
|
|
|
|
|
if (client_group != null)
|
|
|
|
client_group.set_layout( client_rect.left - visible_rect.left,
|
|
|
|
client_rect.top - visible_rect.top,
|
|
|
|
client_rect.right - visible_rect.left,
|
|
|
|
client_rect.bottom - visible_rect.top );
|
2017-06-02 11:34:23 +02:00
|
|
|
}
|
|
|
|
|
2018-08-23 11:11:30 +02:00
|
|
|
public void set_parent( WineWindow new_parent, float scale )
|
2017-06-07 11:27:54 +02:00
|
|
|
{
|
|
|
|
Log.i( LOGTAG, String.format( "set parent hwnd %08x parent %08x -> %08x",
|
2017-06-22 19:38:36 +02:00
|
|
|
hwnd, parent.hwnd, new_parent.hwnd ));
|
2018-08-23 11:11:30 +02:00
|
|
|
this.scale = scale;
|
2017-06-22 19:38:36 +02:00
|
|
|
if (window_group != null)
|
2017-06-07 11:27:54 +02:00
|
|
|
{
|
2017-07-31 19:16:17 +02:00
|
|
|
if (visible) remove_view_from_parent();
|
|
|
|
new_parent.create_window_groups();
|
2017-06-22 19:38:36 +02:00
|
|
|
window_group.set_layout( visible_rect.left, visible_rect.top,
|
|
|
|
visible_rect.right, visible_rect.bottom );
|
2017-06-07 11:27:54 +02:00
|
|
|
}
|
2017-07-31 19:16:17 +02:00
|
|
|
parent.children.remove( this );
|
2017-06-22 19:38:36 +02:00
|
|
|
parent = new_parent;
|
2017-07-31 19:16:17 +02:00
|
|
|
parent.children.add( this );
|
|
|
|
if (visible && window_group != null) add_view_to_parent();
|
2017-06-07 11:27:54 +02:00
|
|
|
}
|
|
|
|
|
2017-06-01 09:42:42 +02:00
|
|
|
public int get_hwnd()
|
|
|
|
{
|
|
|
|
return hwnd;
|
|
|
|
}
|
2017-06-02 11:35:12 +02:00
|
|
|
|
2018-12-03 18:26:50 +01:00
|
|
|
private void update_surface( boolean is_client )
|
|
|
|
{
|
|
|
|
if (is_client)
|
|
|
|
{
|
|
|
|
Log.i( LOGTAG, String.format( "set client surface hwnd %08x %s", hwnd, client_surface ));
|
|
|
|
if (client_surface != null) wine_surface_changed( hwnd, client_surface, true );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Log.i( LOGTAG, String.format( "set window surface hwnd %08x %s", hwnd, window_surface ));
|
|
|
|
if (window_surface != null) wine_surface_changed( hwnd, window_surface, false );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-22 19:36:54 +02:00
|
|
|
public void set_surface( SurfaceTexture surftex, boolean is_client )
|
2017-06-02 11:35:12 +02:00
|
|
|
{
|
2017-06-22 19:36:54 +02:00
|
|
|
if (is_client)
|
|
|
|
{
|
|
|
|
if (surftex == null) client_surface = null;
|
2017-07-13 17:22:37 +02:00
|
|
|
else if (surftex != client_surftex)
|
|
|
|
{
|
|
|
|
client_surftex = surftex;
|
|
|
|
client_surface = new Surface( surftex );
|
|
|
|
}
|
2017-06-22 19:36:54 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (surftex == null) window_surface = null;
|
2017-07-13 17:22:37 +02:00
|
|
|
else if (surftex != window_surftex)
|
|
|
|
{
|
|
|
|
window_surftex = surftex;
|
|
|
|
window_surface = new Surface( surftex );
|
|
|
|
}
|
2017-06-22 19:36:54 +02:00
|
|
|
}
|
2018-12-03 18:26:50 +01:00
|
|
|
update_surface( is_client );
|
2017-06-02 11:35:12 +02:00
|
|
|
}
|
2017-06-08 10:16:41 +02:00
|
|
|
|
|
|
|
public void get_event_pos( MotionEvent event, int[] pos )
|
|
|
|
{
|
2018-08-23 11:11:30 +02:00
|
|
|
pos[0] = Math.round( event.getX() * scale + window_group.getLeft() );
|
|
|
|
pos[1] = Math.round( event.getY() * scale + window_group.getTop() );
|
2017-06-22 19:38:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Window group for a Wine window, optionally containing a content view
|
|
|
|
//
|
|
|
|
|
|
|
|
protected class WineWindowGroup extends ViewGroup
|
|
|
|
{
|
|
|
|
private WineView content_view;
|
|
|
|
private WineWindow win;
|
|
|
|
|
2017-07-31 19:16:17 +02:00
|
|
|
WineWindowGroup( WineWindow win )
|
2017-06-22 19:38:36 +02:00
|
|
|
{
|
|
|
|
super( WineActivity.this );
|
2017-07-31 19:16:17 +02:00
|
|
|
this.win = win;
|
2017-06-22 19:38:36 +02:00
|
|
|
setVisibility( View.VISIBLE );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* wrapper for layout() making sure that the view is not empty */
|
|
|
|
public void set_layout( int left, int top, int right, int bottom )
|
|
|
|
{
|
2018-08-23 11:11:30 +02:00
|
|
|
left *= win.scale;
|
|
|
|
top *= win.scale;
|
|
|
|
right *= win.scale;
|
|
|
|
bottom *= win.scale;
|
2017-06-22 19:38:36 +02:00
|
|
|
if (right <= left + 1) right = left + 2;
|
|
|
|
if (bottom <= top + 1) bottom = top + 2;
|
|
|
|
layout( left, top, right, bottom );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onLayout( boolean changed, int left, int top, int right, int bottom )
|
|
|
|
{
|
|
|
|
if (content_view != null) content_view.layout( 0, 0, right - left, bottom - top );
|
|
|
|
}
|
|
|
|
|
2018-08-23 11:11:30 +02:00
|
|
|
public void set_scale( float scale )
|
|
|
|
{
|
|
|
|
if (content_view == null) return;
|
|
|
|
content_view.setPivotX( 0 );
|
|
|
|
content_view.setPivotY( 0 );
|
|
|
|
content_view.setScaleX( scale );
|
|
|
|
content_view.setScaleY( scale );
|
|
|
|
}
|
|
|
|
|
2017-07-31 19:16:17 +02:00
|
|
|
public WineView create_view( boolean is_client )
|
2017-06-22 19:38:36 +02:00
|
|
|
{
|
|
|
|
if (content_view != null) return content_view;
|
|
|
|
content_view = new WineView( WineActivity.this, win, is_client );
|
|
|
|
addView( content_view );
|
|
|
|
if (!is_client)
|
|
|
|
{
|
|
|
|
content_view.setFocusable( true );
|
|
|
|
content_view.setFocusableInTouchMode( true );
|
|
|
|
}
|
|
|
|
return content_view;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void destroy_view()
|
|
|
|
{
|
|
|
|
if (content_view == null) return;
|
|
|
|
removeView( content_view );
|
|
|
|
content_view = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public WineView get_content_view()
|
|
|
|
{
|
|
|
|
return content_view;
|
|
|
|
}
|
|
|
|
|
|
|
|
public WineWindow get_window()
|
|
|
|
{
|
|
|
|
return win;
|
2017-06-08 10:16:41 +02:00
|
|
|
}
|
2017-06-02 11:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// View used for all Wine windows, backed by a TextureView
|
|
|
|
|
|
|
|
protected class WineView extends TextureView implements TextureView.SurfaceTextureListener
|
|
|
|
{
|
|
|
|
private WineWindow window;
|
2017-06-22 19:36:54 +02:00
|
|
|
private boolean is_client;
|
2017-06-02 11:35:12 +02:00
|
|
|
|
2017-06-22 19:36:54 +02:00
|
|
|
public WineView( Context c, WineWindow win, boolean client )
|
2017-06-02 11:35:12 +02:00
|
|
|
{
|
|
|
|
super( c );
|
|
|
|
window = win;
|
2017-06-22 19:36:54 +02:00
|
|
|
is_client = client;
|
2017-06-02 11:35:12 +02:00
|
|
|
setSurfaceTextureListener( this );
|
|
|
|
setVisibility( VISIBLE );
|
|
|
|
setOpaque( false );
|
2017-06-08 16:44:20 +02:00
|
|
|
setFocusable( true );
|
|
|
|
setFocusableInTouchMode( true );
|
2017-06-02 11:35:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public WineWindow get_window()
|
|
|
|
{
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
2019-03-28 10:38:30 +01:00
|
|
|
@Override
|
2017-06-02 11:35:12 +02:00
|
|
|
public void onSurfaceTextureAvailable( SurfaceTexture surftex, int width, int height )
|
|
|
|
{
|
2017-06-22 19:36:54 +02:00
|
|
|
Log.i( LOGTAG, String.format( "onSurfaceTextureAvailable win %08x %dx%d %s",
|
|
|
|
window.hwnd, width, height, is_client ? "client" : "whole" ));
|
|
|
|
window.set_surface( surftex, is_client );
|
2017-06-02 11:35:12 +02:00
|
|
|
}
|
|
|
|
|
2019-03-28 10:38:30 +01:00
|
|
|
@Override
|
2017-06-02 11:35:12 +02:00
|
|
|
public void onSurfaceTextureSizeChanged( SurfaceTexture surftex, int width, int height )
|
|
|
|
{
|
2017-06-22 19:36:54 +02:00
|
|
|
Log.i( LOGTAG, String.format( "onSurfaceTextureSizeChanged win %08x %dx%d %s",
|
|
|
|
window.hwnd, width, height, is_client ? "client" : "whole" ));
|
|
|
|
window.set_surface( surftex, is_client);
|
2017-06-02 11:35:12 +02:00
|
|
|
}
|
|
|
|
|
2019-03-28 10:38:30 +01:00
|
|
|
@Override
|
2017-06-02 11:35:12 +02:00
|
|
|
public boolean onSurfaceTextureDestroyed( SurfaceTexture surftex )
|
|
|
|
{
|
2017-06-22 19:36:54 +02:00
|
|
|
Log.i( LOGTAG, String.format( "onSurfaceTextureDestroyed win %08x %s",
|
|
|
|
window.hwnd, is_client ? "client" : "whole" ));
|
|
|
|
window.set_surface( null, is_client );
|
2017-07-13 17:22:37 +02:00
|
|
|
return false; // hold on to the texture since the app may still be using it
|
2017-06-02 11:35:12 +02:00
|
|
|
}
|
|
|
|
|
2019-03-28 10:38:30 +01:00
|
|
|
@Override
|
2017-06-02 11:35:12 +02:00
|
|
|
public void onSurfaceTextureUpdated(SurfaceTexture surftex)
|
|
|
|
{
|
|
|
|
}
|
2017-06-08 10:16:41 +02:00
|
|
|
|
2018-11-26 16:11:44 +01:00
|
|
|
@TargetApi(24)
|
|
|
|
public PointerIcon onResolvePointerIcon( MotionEvent event, int index )
|
|
|
|
{
|
|
|
|
return current_cursor;
|
|
|
|
}
|
|
|
|
|
2019-03-28 10:38:30 +01:00
|
|
|
@Override
|
2017-06-08 10:16:41 +02:00
|
|
|
public boolean onGenericMotionEvent( MotionEvent event )
|
|
|
|
{
|
2017-06-22 19:36:54 +02:00
|
|
|
if (is_client) return false; // let the whole window handle it
|
2017-06-22 19:38:36 +02:00
|
|
|
if (window.parent != null && window.parent != desktop_window) return false; // let the parent handle it
|
2017-06-08 10:16:41 +02:00
|
|
|
|
|
|
|
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0)
|
|
|
|
{
|
|
|
|
int[] pos = new int[2];
|
|
|
|
window.get_event_pos( event, pos );
|
|
|
|
Log.i( LOGTAG, String.format( "view motion event win %08x action %d pos %d,%d buttons %04x view %d,%d",
|
|
|
|
window.hwnd, event.getAction(), pos[0], pos[1],
|
|
|
|
event.getButtonState(), getLeft(), getTop() ));
|
|
|
|
return wine_motion_event( window.hwnd, event.getAction(), pos[0], pos[1],
|
|
|
|
event.getButtonState(), (int)event.getAxisValue(MotionEvent.AXIS_VSCROLL) );
|
|
|
|
}
|
|
|
|
return super.onGenericMotionEvent(event);
|
|
|
|
}
|
|
|
|
|
2019-03-28 10:38:30 +01:00
|
|
|
@Override
|
2017-06-08 10:16:41 +02:00
|
|
|
public boolean onTouchEvent( MotionEvent event )
|
|
|
|
{
|
2017-06-22 19:36:54 +02:00
|
|
|
if (is_client) return false; // let the whole window handle it
|
2017-06-22 19:38:36 +02:00
|
|
|
if (window.parent != null && window.parent != desktop_window) return false; // let the parent handle it
|
2017-06-08 10:16:41 +02:00
|
|
|
|
|
|
|
int[] pos = new int[2];
|
|
|
|
window.get_event_pos( event, pos );
|
|
|
|
Log.i( LOGTAG, String.format( "view touch event win %08x action %d pos %d,%d buttons %04x view %d,%d",
|
|
|
|
window.hwnd, event.getAction(), pos[0], pos[1],
|
|
|
|
event.getButtonState(), getLeft(), getTop() ));
|
|
|
|
return wine_motion_event( window.hwnd, event.getAction(), pos[0], pos[1],
|
|
|
|
event.getButtonState(), 0 );
|
|
|
|
}
|
2017-06-08 16:44:20 +02:00
|
|
|
|
2019-03-28 10:38:30 +01:00
|
|
|
@Override
|
2017-06-08 16:44:20 +02:00
|
|
|
public boolean dispatchKeyEvent( KeyEvent event )
|
|
|
|
{
|
|
|
|
Log.i( LOGTAG, String.format( "view key event win %08x action %d keycode %d (%s)",
|
|
|
|
window.hwnd, event.getAction(), event.getKeyCode(),
|
2018-11-26 16:41:33 +01:00
|
|
|
KeyEvent.keyCodeToString( event.getKeyCode() )));;
|
2017-06-08 16:44:20 +02:00
|
|
|
boolean ret = wine_keyboard_event( window.hwnd, event.getAction(), event.getKeyCode(),
|
|
|
|
event.getMetaState() );
|
|
|
|
if (!ret) ret = super.dispatchKeyEvent(event);
|
|
|
|
return ret;
|
|
|
|
}
|
2017-06-01 09:42:42 +02:00
|
|
|
}
|
|
|
|
|
2017-06-01 09:40:29 +02:00
|
|
|
// The top-level desktop view group
|
|
|
|
|
|
|
|
protected class TopView extends ViewGroup
|
|
|
|
{
|
|
|
|
public TopView( Context context, int hwnd )
|
|
|
|
{
|
|
|
|
super( context );
|
2018-12-03 16:16:48 +01:00
|
|
|
desktop_window = new WineWindow( hwnd, null, 1.0f );
|
2017-06-22 19:38:36 +02:00
|
|
|
addView( desktop_window.create_whole_view() );
|
|
|
|
desktop_window.client_group.bringToFront();
|
2017-06-22 20:04:43 +02:00
|
|
|
|
2018-12-03 16:16:48 +01:00
|
|
|
message_window = new WineWindow( WineWindow.HWND_MESSAGE, null, 1.0f );
|
2017-06-22 20:04:43 +02:00
|
|
|
message_window.create_window_groups();
|
2017-06-01 09:40:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onSizeChanged( int width, int height, int old_width, int old_height )
|
|
|
|
{
|
|
|
|
Log.i( LOGTAG, String.format( "desktop size %dx%d", width, height ));
|
|
|
|
wine_desktop_changed( width, height );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void onLayout( boolean changed, int left, int top, int right, int bottom )
|
|
|
|
{
|
|
|
|
// nothing to do
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-01 09:42:42 +02:00
|
|
|
protected WineWindow get_window( int hwnd )
|
|
|
|
{
|
|
|
|
return win_map.get( hwnd );
|
|
|
|
}
|
|
|
|
|
2017-06-01 09:40:29 +02:00
|
|
|
// Entry points for the device driver
|
|
|
|
|
|
|
|
public void create_desktop_window( int hwnd )
|
|
|
|
{
|
|
|
|
Log.i( LOGTAG, String.format( "create desktop view %08x", hwnd ));
|
2017-06-22 19:38:36 +02:00
|
|
|
setContentView( new TopView( this, hwnd ));
|
2017-06-01 09:40:29 +02:00
|
|
|
progress_dialog.dismiss();
|
2017-06-12 19:12:30 +02:00
|
|
|
wine_config_changed( getResources().getConfiguration().densityDpi );
|
2017-06-01 09:40:29 +02:00
|
|
|
}
|
|
|
|
|
2018-08-23 11:11:30 +02:00
|
|
|
public void create_window( int hwnd, boolean opengl, int parent, float scale, int pid )
|
2017-06-01 09:42:42 +02:00
|
|
|
{
|
|
|
|
WineWindow win = get_window( hwnd );
|
2017-06-22 19:38:36 +02:00
|
|
|
if (win == null)
|
|
|
|
{
|
2018-12-03 16:16:48 +01:00
|
|
|
win = new WineWindow( hwnd, get_window( parent ), scale );
|
2017-06-22 19:38:36 +02:00
|
|
|
win.create_window_groups();
|
|
|
|
if (win.parent == desktop_window) win.create_whole_view();
|
|
|
|
}
|
|
|
|
if (opengl) win.create_client_view();
|
2017-06-01 09:42:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void destroy_window( int hwnd )
|
|
|
|
{
|
|
|
|
WineWindow win = get_window( hwnd );
|
|
|
|
if (win != null) win.destroy();
|
|
|
|
}
|
|
|
|
|
2018-08-23 11:11:30 +02:00
|
|
|
public void set_window_parent( int hwnd, int parent, float scale, int pid )
|
2017-06-07 11:27:54 +02:00
|
|
|
{
|
|
|
|
WineWindow win = get_window( hwnd );
|
|
|
|
if (win == null) return;
|
2018-08-23 11:11:30 +02:00
|
|
|
win.set_parent( get_window( parent ), scale );
|
2017-06-22 19:38:36 +02:00
|
|
|
if (win.parent == desktop_window) win.create_whole_view();
|
2017-06-07 11:27:54 +02:00
|
|
|
}
|
|
|
|
|
2018-11-26 16:11:44 +01:00
|
|
|
@TargetApi(24)
|
|
|
|
public void set_cursor( int id, int width, int height, int hotspotx, int hotspoty, int bits[] )
|
|
|
|
{
|
|
|
|
Log.i( LOGTAG, String.format( "set_cursor id %d size %dx%d hotspot %dx%d", id, width, height, hotspotx, hotspoty ));
|
|
|
|
if (bits != null)
|
|
|
|
{
|
|
|
|
Bitmap bitmap = Bitmap.createBitmap( bits, width, height, Bitmap.Config.ARGB_8888 );
|
|
|
|
current_cursor = PointerIcon.create( bitmap, hotspotx, hotspoty );
|
|
|
|
}
|
|
|
|
else current_cursor = PointerIcon.getSystemIcon( this, id );
|
|
|
|
}
|
|
|
|
|
2017-06-02 11:34:23 +02:00
|
|
|
public void window_pos_changed( int hwnd, int flags, int insert_after, int owner, int style,
|
|
|
|
Rect window_rect, Rect client_rect, Rect visible_rect )
|
|
|
|
{
|
|
|
|
WineWindow win = get_window( hwnd );
|
|
|
|
if (win != null)
|
|
|
|
win.pos_changed( flags, insert_after, owner, style, window_rect, client_rect, visible_rect );
|
|
|
|
}
|
|
|
|
|
2017-06-01 09:40:29 +02:00
|
|
|
public void createDesktopWindow( final int hwnd )
|
|
|
|
{
|
|
|
|
runOnUiThread( new Runnable() { public void run() { create_desktop_window( hwnd ); }} );
|
|
|
|
}
|
2017-06-01 09:42:42 +02:00
|
|
|
|
2018-08-23 11:11:30 +02:00
|
|
|
public void createWindow( final int hwnd, final boolean opengl, final int parent, final float scale, final int pid )
|
2017-06-01 09:42:42 +02:00
|
|
|
{
|
2018-08-23 11:11:30 +02:00
|
|
|
runOnUiThread( new Runnable() { public void run() { create_window( hwnd, opengl, parent, scale, pid ); }} );
|
2017-06-01 09:42:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void destroyWindow( final int hwnd )
|
|
|
|
{
|
|
|
|
runOnUiThread( new Runnable() { public void run() { destroy_window( hwnd ); }} );
|
|
|
|
}
|
2017-06-02 11:34:23 +02:00
|
|
|
|
2018-08-23 11:11:30 +02:00
|
|
|
public void setParent( final int hwnd, final int parent, final float scale, final int pid )
|
2017-06-07 11:27:54 +02:00
|
|
|
{
|
2018-08-23 11:11:30 +02:00
|
|
|
runOnUiThread( new Runnable() { public void run() { set_window_parent( hwnd, parent, scale, pid ); }} );
|
2017-06-07 11:27:54 +02:00
|
|
|
}
|
|
|
|
|
2018-11-26 16:11:44 +01:00
|
|
|
public void setCursor( final int id, final int width, final int height,
|
|
|
|
final int hotspotx, final int hotspoty, final int bits[] )
|
|
|
|
{
|
|
|
|
if (Build.VERSION.SDK_INT < 24) return;
|
|
|
|
runOnUiThread( new Runnable() { public void run() { set_cursor( id, width, height, hotspotx, hotspoty, bits ); }} );
|
|
|
|
}
|
|
|
|
|
2017-06-02 11:34:23 +02:00
|
|
|
public void windowPosChanged( final int hwnd, final int flags, final int insert_after,
|
|
|
|
final int owner, final int style,
|
|
|
|
final int window_left, final int window_top,
|
|
|
|
final int window_right, final int window_bottom,
|
|
|
|
final int client_left, final int client_top,
|
|
|
|
final int client_right, final int client_bottom,
|
|
|
|
final int visible_left, final int visible_top,
|
|
|
|
final int visible_right, final int visible_bottom )
|
|
|
|
{
|
|
|
|
final Rect window_rect = new Rect( window_left, window_top, window_right, window_bottom );
|
|
|
|
final Rect client_rect = new Rect( client_left, client_top, client_right, client_bottom );
|
|
|
|
final Rect visible_rect = new Rect( visible_left, visible_top, visible_right, visible_bottom );
|
|
|
|
runOnUiThread( new Runnable() {
|
|
|
|
public void run() { window_pos_changed( hwnd, flags, insert_after, owner, style,
|
|
|
|
window_rect, client_rect, visible_rect ); }} );
|
|
|
|
}
|
2017-05-30 12:59:15 +02:00
|
|
|
}
|