mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Auto merge of #24547 - paulrouget:click, r=jdm
UWP: better mouse interaction support
This commit is contained in:
commit
571dc127a2
9 changed files with 101 additions and 14 deletions
|
@ -278,7 +278,7 @@ pub unsafe extern "C" fn trigger_servo(servo: *mut ServoInstance, x: f32, y: f32
|
|||
ScrollState::TriggerDown(start) if !down => {
|
||||
servo.scroll_state = ScrollState::TriggerUp;
|
||||
let _ = call(|s| s.mouse_up(start.x, start.y, MouseButton::Left));
|
||||
let _ = call(|s| s.click(start.x, start.y));
|
||||
let _ = call(|s| s.click(start.x as f32, start.y as f32));
|
||||
let _ = call(|s| s.move_mouse(start.x, start.y));
|
||||
},
|
||||
ScrollState::TriggerDragging(start, prev) if !down => {
|
||||
|
|
|
@ -16,7 +16,9 @@ use backtrace::Backtrace;
|
|||
use env_logger;
|
||||
use log::LevelFilter;
|
||||
use simpleservo::{self, gl_glue, ServoGlue, SERVO};
|
||||
use simpleservo::{Coordinates, EventLoopWaker, HostTrait, InitOptions, VRInitOptions};
|
||||
use simpleservo::{
|
||||
Coordinates, EventLoopWaker, HostTrait, InitOptions, MouseButton, VRInitOptions,
|
||||
};
|
||||
use std::ffi::{CStr, CString};
|
||||
#[cfg(target_os = "windows")]
|
||||
use std::mem;
|
||||
|
@ -229,6 +231,23 @@ pub struct CInitOptions {
|
|||
pub vslogger_mod_size: u32,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub enum CMouseButton {
|
||||
Left,
|
||||
Right,
|
||||
Middle,
|
||||
}
|
||||
|
||||
impl CMouseButton {
|
||||
pub fn convert(&self) -> MouseButton {
|
||||
match self {
|
||||
CMouseButton::Left => MouseButton::Left,
|
||||
CMouseButton::Right => MouseButton::Right,
|
||||
CMouseButton::Middle => MouseButton::Middle,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// The returned string is not freed. This will leak.
|
||||
#[no_mangle]
|
||||
pub extern "C" fn servo_version() -> *const c_char {
|
||||
|
@ -541,10 +560,26 @@ pub extern "C" fn pinchzoom_end(factor: f32, x: i32, y: i32) {
|
|||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn click(x: i32, y: i32) {
|
||||
pub extern "C" fn mouse_down(x: f32, y: f32, button: CMouseButton) {
|
||||
catch_any_panic(|| {
|
||||
debug!("mouse_down");
|
||||
call(|s| s.mouse_down(x, y, button.convert()));
|
||||
});
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn mouse_up(x: f32, y: f32, button: CMouseButton) {
|
||||
catch_any_panic(|| {
|
||||
debug!("mouse_up");
|
||||
call(|s| s.mouse_up(x, y, button.convert()));
|
||||
});
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn click(x: f32, y: f32) {
|
||||
catch_any_panic(|| {
|
||||
debug!("click");
|
||||
call(|s| s.click(x as f32, y as f32));
|
||||
call(|s| s.click(x, y));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue