XSDL: screen follows mouse cursor
This commit is contained in:
@@ -52,7 +52,8 @@ class Globals
|
||||
public static boolean AppNeedsTwoButtonMouse = false;
|
||||
public static boolean RightMouseButtonLongPress = true;
|
||||
public static boolean ForceRelativeMouseMode = false; // If both on-screen keyboard and mouse are needed, this will only set the default setting, user may override it later
|
||||
public static boolean ShowMouseCursor = false;
|
||||
public static boolean ShowMouseCursor = false; // Draw system mouse cursor, if the app does not do it
|
||||
public static boolean ScreenFollowsMouse = false; // Move app screen make mouse cursor always visible, when soft keyboard is shown
|
||||
public static boolean AppNeedsArrowKeys = true;
|
||||
public static boolean AppNeedsTextInput = true;
|
||||
public static boolean AppUsesJoystick = false;
|
||||
|
||||
@@ -83,6 +83,8 @@ import android.util.Log;
|
||||
import android.view.Surface;
|
||||
import android.app.ProgressDialog;
|
||||
import android.app.KeyguardManager;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.graphics.Rect;
|
||||
|
||||
|
||||
public class MainActivity extends Activity
|
||||
@@ -350,6 +352,24 @@ public class MainActivity extends Activity
|
||||
}
|
||||
DimSystemStatusBar.get().dim(_videoLayout);
|
||||
DimSystemStatusBar.get().dim(mGLView);
|
||||
|
||||
if( Globals.ScreenFollowsMouse )
|
||||
{
|
||||
Rect r = new Rect();
|
||||
_videoLayout.getWindowVisibleDisplayFrame(r);
|
||||
mGLView.nativeScreenVisibleRect(r.left, r.top, r.right, r.bottom);
|
||||
_videoLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener()
|
||||
{
|
||||
public void onGlobalLayout()
|
||||
{
|
||||
Rect r = new Rect();
|
||||
_videoLayout.getWindowVisibleDisplayFrame(r);
|
||||
int heightDiff = _videoLayout.getRootView().getHeight() - _videoLayout.getHeight(); // Take system bar into consideration
|
||||
mGLView.nativeScreenVisibleRect(r.left, r.top + heightDiff, r.width(), r.height());
|
||||
Log.v("SDL", "Main window visible region changed: " + r.left + ":" + r.top + ":" + r.width() + ":" + r.height() );
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1031,12 +1031,10 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
|
||||
MainActivity mParent;
|
||||
|
||||
public static native void nativeMotionEvent( int x, int y, int action, int pointerId, int pressure, int radius );
|
||||
public static native int nativeKey( int keyCode, int down, int unicode );
|
||||
public static native void initJavaCallbacks();
|
||||
public static native int nativeKey( int keyCode, int down, int unicode );
|
||||
public static native void nativeHardwareMouseDetected( int detected );
|
||||
public static native void nativeMouseButtonsPressed( int buttonId, int pressedState );
|
||||
public static native void nativeMouseWheel( int scrollX, int scrollY );
|
||||
public static native void nativeGamepadAnalogJoystickInput( float stick1x, float stick1y, float stick2x, float stick2y, float rtrigger, float ltrigger, int usingHat );
|
||||
public static native void nativeScreenVisibleRect( int x, int y, int w, int h );
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user