mirror of
https://github.com/servo/servo.git
synced 2025-06-22 08:08:59 +01:00
Add a "-Z convert-mouse-to-touch" debug argument.
This is enabled by default on Android, because Glutin currently sends mouse events instead of touch events on Android. It's also useful for testing on non-touch platforms.
This commit is contained in:
parent
fe7460f34d
commit
817eed22d1
2 changed files with 32 additions and 2 deletions
|
@ -1123,7 +1123,16 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
chan.send(msg).unwrap()
|
chan.send(msg).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_mouse_window_event_class(&self, mouse_window_event: MouseWindowEvent) {
|
fn on_mouse_window_event_class(&mut self, mouse_window_event: MouseWindowEvent) {
|
||||||
|
if opts::get().convert_mouse_to_touch {
|
||||||
|
match mouse_window_event {
|
||||||
|
MouseWindowEvent::Click(_, _) => {}
|
||||||
|
MouseWindowEvent::MouseDown(_, p) => self.on_touch_down(0, p),
|
||||||
|
MouseWindowEvent::MouseUp(_, p) => self.on_touch_up(0, p),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let point = match mouse_window_event {
|
let point = match mouse_window_event {
|
||||||
MouseWindowEvent::Click(_, p) => p,
|
MouseWindowEvent::Click(_, p) => p,
|
||||||
MouseWindowEvent::MouseDown(_, p) => p,
|
MouseWindowEvent::MouseDown(_, p) => p,
|
||||||
|
@ -1135,7 +1144,12 @@ impl<Window: WindowMethods> IOCompositor<Window> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_mouse_window_move_event_class(&self, cursor: TypedPoint2D<DevicePixel, f32>) {
|
fn on_mouse_window_move_event_class(&mut self, cursor: TypedPoint2D<DevicePixel, f32>) {
|
||||||
|
if opts::get().convert_mouse_to_touch {
|
||||||
|
self.on_touch_move(0, cursor);
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
match self.find_topmost_layer_at_point(cursor / self.scene.scale) {
|
match self.find_topmost_layer_at_point(cursor / self.scene.scale) {
|
||||||
Some(result) => result.layer.send_mouse_move_event(self, result.point),
|
Some(result) => result.layer.send_mouse_move_event(self, result.point),
|
||||||
None => {},
|
None => {},
|
||||||
|
|
|
@ -168,6 +168,9 @@ pub struct Opts {
|
||||||
/// Whether to run absolute position calculation and display list construction in parallel.
|
/// Whether to run absolute position calculation and display list construction in parallel.
|
||||||
pub parallel_display_list_building: bool,
|
pub parallel_display_list_building: bool,
|
||||||
|
|
||||||
|
/// Translate mouse input into touch events.
|
||||||
|
pub convert_mouse_to_touch: bool,
|
||||||
|
|
||||||
/// True to exit after the page load (`-x`).
|
/// True to exit after the page load (`-x`).
|
||||||
pub exit_after_load: bool,
|
pub exit_after_load: bool,
|
||||||
|
|
||||||
|
@ -247,6 +250,9 @@ pub struct DebugOptions {
|
||||||
/// Build display lists in parallel.
|
/// Build display lists in parallel.
|
||||||
pub parallel_display_list_building: bool,
|
pub parallel_display_list_building: bool,
|
||||||
|
|
||||||
|
/// Translate mouse input into touch events.
|
||||||
|
pub convert_mouse_to_touch: bool,
|
||||||
|
|
||||||
/// Replace unpaires surrogates in DOM strings with U+FFFD.
|
/// Replace unpaires surrogates in DOM strings with U+FFFD.
|
||||||
/// See https://github.com/servo/servo/issues/6564
|
/// See https://github.com/servo/servo/issues/6564
|
||||||
pub replace_surrogates: bool,
|
pub replace_surrogates: bool,
|
||||||
|
@ -260,6 +266,12 @@ impl DebugOptions {
|
||||||
pub fn new(debug_string: &str) -> Result<DebugOptions, &str> {
|
pub fn new(debug_string: &str) -> Result<DebugOptions, &str> {
|
||||||
let mut debug_options = DebugOptions::default();
|
let mut debug_options = DebugOptions::default();
|
||||||
|
|
||||||
|
// FIXME: Glutin currently converts touch input to mouse events on Android.
|
||||||
|
// Convert it back to touch events.
|
||||||
|
if cfg!(target_os = "android") {
|
||||||
|
debug_options.convert_mouse_to_touch = true;
|
||||||
|
}
|
||||||
|
|
||||||
for option in debug_string.split(',') {
|
for option in debug_string.split(',') {
|
||||||
match option {
|
match option {
|
||||||
"help" => debug_options.help = true,
|
"help" => debug_options.help = true,
|
||||||
|
@ -283,6 +295,7 @@ impl DebugOptions {
|
||||||
"validate-display-list-geometry" => debug_options.validate_display_list_geometry = true,
|
"validate-display-list-geometry" => debug_options.validate_display_list_geometry = true,
|
||||||
"disable-share-style-cache" => debug_options.disable_share_style_cache = true,
|
"disable-share-style-cache" => debug_options.disable_share_style_cache = true,
|
||||||
"parallel-display-list-building" => debug_options.parallel_display_list_building = true,
|
"parallel-display-list-building" => debug_options.parallel_display_list_building = true,
|
||||||
|
"convert-mouse-to-touch" => debug_options.convert_mouse_to_touch = true,
|
||||||
"replace-surrogates" => debug_options.replace_surrogates = true,
|
"replace-surrogates" => debug_options.replace_surrogates = true,
|
||||||
"gc-profile" => debug_options.gc_profile = true,
|
"gc-profile" => debug_options.gc_profile = true,
|
||||||
"" => {},
|
"" => {},
|
||||||
|
@ -326,6 +339,7 @@ pub fn print_debug_usage(app: &str) -> ! {
|
||||||
print_option("replace-surrogates", "Replace unpaires surrogates in DOM strings with U+FFFD. \
|
print_option("replace-surrogates", "Replace unpaires surrogates in DOM strings with U+FFFD. \
|
||||||
See https://github.com/servo/servo/issues/6564");
|
See https://github.com/servo/servo/issues/6564");
|
||||||
print_option("gc-profile", "Log GC passes and their durations.");
|
print_option("gc-profile", "Log GC passes and their durations.");
|
||||||
|
print_option("convert-mouse-to-touch", "Send touch events instead of mouse events");
|
||||||
|
|
||||||
println!("");
|
println!("");
|
||||||
|
|
||||||
|
@ -422,6 +436,7 @@ pub fn default_opts() -> Opts {
|
||||||
sniff_mime_types: false,
|
sniff_mime_types: false,
|
||||||
disable_share_style_cache: false,
|
disable_share_style_cache: false,
|
||||||
parallel_display_list_building: false,
|
parallel_display_list_building: false,
|
||||||
|
convert_mouse_to_touch: false,
|
||||||
exit_after_load: false,
|
exit_after_load: false,
|
||||||
no_native_titlebar: false,
|
no_native_titlebar: false,
|
||||||
}
|
}
|
||||||
|
@ -628,6 +643,7 @@ pub fn from_cmdline_args(args: &[String]) {
|
||||||
sniff_mime_types: opt_match.opt_present("sniff-mime-types"),
|
sniff_mime_types: opt_match.opt_present("sniff-mime-types"),
|
||||||
disable_share_style_cache: debug_options.disable_share_style_cache,
|
disable_share_style_cache: debug_options.disable_share_style_cache,
|
||||||
parallel_display_list_building: debug_options.parallel_display_list_building,
|
parallel_display_list_building: debug_options.parallel_display_list_building,
|
||||||
|
convert_mouse_to_touch: debug_options.convert_mouse_to_touch,
|
||||||
exit_after_load: opt_match.opt_present("x"),
|
exit_after_load: opt_match.opt_present("x"),
|
||||||
no_native_titlebar: opt_match.opt_present("b"),
|
no_native_titlebar: opt_match.opt_present("b"),
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue