Skip to content

Commit

Permalink
native: Remove custom resize method, rely on event loop (for now?)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinnerbone authored and torokati44 committed Mar 13, 2024
1 parent dd1b888 commit a4ab393
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ protected int getSurfaceHeight() {
private native void keydown(byte key_code, char key_char);
private native void keyup(byte key_code, char key_char);

private native void resized();

private native void requestContextMenu();
private native void runContextMenuCallback(int index);
private native void clearContextMenu();
Expand Down Expand Up @@ -182,10 +180,6 @@ protected void onCreateSurfaceView() {
layout.requestFocus();
this.mSurfaceView.getHolder().addCallback(this);
ViewCompat.setOnApplyWindowInsetsListener(this.mSurfaceView, this);

this.mSurfaceView.addOnLayoutChangeListener((vw, left, top, right, bottom, oldLeft, oldTop, oldRight, oldBottom) -> {
resized();
});
}

@Override
Expand Down
2 changes: 0 additions & 2 deletions native/src/custom_event.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Custom event type for Ruffle on Android
use ruffle_core::events::KeyCode;
use ruffle_core::ViewportDimensions;

/// User-defined events.
#[derive(Debug)]
Expand All @@ -15,6 +14,5 @@ pub enum RuffleEvent {
},
RunContextMenuCallback(usize),
ClearContextMenu,
Resize(ViewportDimensions),
RequestContextMenu,
}
26 changes: 0 additions & 26 deletions native/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,6 @@ fn run(app: AndroidApp) {

match receiver.try_recv() {
Err(_) => {}
Ok(RuffleEvent::Resize(size)) => {
if let Some(player) = playerbox.as_ref() {
player.player.lock().unwrap().set_viewport_dimensions(size);
needs_redraw = true;
}
}
Ok(RuffleEvent::TaskPoll) => {
if let Some(player) = playerbox.as_ref() {
player
Expand Down Expand Up @@ -524,26 +518,6 @@ pub unsafe extern "C" fn Java_rs_ruffle_FullscreenNativeActivity_keyup(
});
}

#[no_mangle]
#[allow(clippy::missing_safety_doc)]
pub unsafe extern "C" fn Java_rs_ruffle_FullscreenNativeActivity_resized(
mut env: JNIEnv,
this: JObject,
) {
let event_loop: MutexGuard<Sender<RuffleEvent>> =
env.get_rust_field(this, "eventLoopHandle").unwrap();
let size = get_view_size();
if let Ok((w, h)) = size {
let viewport_scale_factor = 1.0; //window.scale_factor();
let _ = event_loop.send(RuffleEvent::Resize(ViewportDimensions {
width: w as u32,
height: h as u32,
scale_factor: viewport_scale_factor,
}));
}
log::warn!("resized!");
}

pub fn get_jvm<'a>() -> Result<(jni::JavaVM, JObject<'a>), Box<dyn std::error::Error>> {
// Create a VM for executing Java calls
let context = ndk_context::android_context();
Expand Down

0 comments on commit a4ab393

Please sign in to comment.