mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
servoshell: Upgrade egui
and many other dependencies (#31278)
* servoshell: Upgrade `egui` and many other dependencies This upgrades: - `core-graphics` - `core-text` - `egui` and friends - `font-kit` - `glow` and friends - `harfbuzz-sys` - `jni` - `nix` - `raqote` - `raw-window-handle` - `winit` * Downgrade jni until we can properly upgrade * Update some test results It's unclear why these are now passing, but they are. --------- Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
556bfb7dff
commit
9acf2182cd
20 changed files with 796 additions and 560 deletions
605
Cargo.lock
generated
605
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -28,5 +28,5 @@ lazy_static = { workspace = true }
|
|||
mach2 = "0.4"
|
||||
|
||||
[target.'cfg(all(target_os = "linux", not(any(target_arch = "arm", target_arch = "aarch64"))))'.dependencies]
|
||||
nix = "0.25"
|
||||
nix = { version = "0.27", features = ["signal"] }
|
||||
unwind-sys = "0.1.4"
|
||||
|
|
|
@ -22,7 +22,7 @@ canvas_traits = { workspace = true }
|
|||
crossbeam-channel = { workspace = true }
|
||||
cssparser = { workspace = true }
|
||||
euclid = { workspace = true }
|
||||
font-kit = "0.11"
|
||||
font-kit = { version = "0.13" }
|
||||
fnv = { workspace = true }
|
||||
gfx = { path = "../gfx" }
|
||||
half = "2"
|
||||
|
@ -32,7 +32,7 @@ lyon_geom = "1.0.4"
|
|||
num-traits = { workspace = true }
|
||||
pathfinder_geometry = "0.5"
|
||||
pixels = { path = "../pixels" }
|
||||
raqote = "0.8.2"
|
||||
raqote = "0.8.4"
|
||||
servo_arc = { workspace = true }
|
||||
sparkle = { workspace = true }
|
||||
style = { workspace = true }
|
||||
|
|
|
@ -22,7 +22,7 @@ euclid = { workspace = true }
|
|||
fnv = { workspace = true }
|
||||
fontsan = { git = "https://github.com/servo/fontsan" }
|
||||
gfx_traits = { workspace = true }
|
||||
harfbuzz-sys = "0.5"
|
||||
harfbuzz-sys = "0.6"
|
||||
ipc-channel = { workspace = true }
|
||||
lazy_static = { workspace = true }
|
||||
libc = { workspace = true }
|
||||
|
@ -47,19 +47,21 @@ xi-unicode = { workspace = true }
|
|||
[target.'cfg(target_os = "macos")'.dependencies]
|
||||
byteorder = { workspace = true }
|
||||
core-foundation = "0.9"
|
||||
core-graphics = "0.22"
|
||||
core-text = "19.0"
|
||||
core-graphics = "0.23"
|
||||
core-text = "20.1"
|
||||
|
||||
[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
|
||||
harfbuzz-sys = { version = "0.6", features = ["bundled"] }
|
||||
freetype = "0.7"
|
||||
servo_allocator = { path = "../allocator" }
|
||||
|
||||
[target.'cfg(target_os = "linux")'.dependencies]
|
||||
fontconfig_sys = { package = "yeslogic-fontconfig-sys", version = "3" }
|
||||
fontconfig_sys = { package = "yeslogic-fontconfig-sys", version = "5" }
|
||||
|
||||
[target.'cfg(target_os = "android")'.dependencies]
|
||||
xml-rs = "0.8"
|
||||
|
||||
[target.'cfg(target_os = "windows")'.dependencies]
|
||||
harfbuzz-sys = { version = "0.6", features = ["bundled"] }
|
||||
dwrote = "0.11"
|
||||
truetype = { version = "0.47.3", features = ["ignore-invalid-language-ids"] }
|
||||
|
|
|
@ -54,29 +54,29 @@ xr-profile = ["libservo/xr-profile"]
|
|||
servo_allocator = { path = "../../components/allocator" }
|
||||
|
||||
[target.'cfg(not(target_os = "android"))'.dependencies]
|
||||
arboard = "3"
|
||||
arboard = { version = "3" }
|
||||
backtrace = { workspace = true }
|
||||
cfg-if = { workspace = true }
|
||||
egui = "0.22.0"
|
||||
egui_glow = { version = "0.22.0", features = ["winit"] }
|
||||
egui-winit = { version = "0.22.0", default-features = false, features = ["clipboard", "wayland"] }
|
||||
egui = { version = "0.26.2" }
|
||||
egui_glow = { version = "0.26.2", features = ["winit"] }
|
||||
egui-winit = { version = "0.26.2", default-features = false, features = ["clipboard", "wayland"] }
|
||||
euclid = { workspace = true }
|
||||
getopts = { workspace = true }
|
||||
gilrs = "0.10.7"
|
||||
gleam = { workspace = true }
|
||||
glow = "0.12.2"
|
||||
glow = "0.13.1"
|
||||
keyboard-types = { workspace = true }
|
||||
lazy_static = { workspace = true }
|
||||
libc = { workspace = true }
|
||||
libservo = { path = "../../components/servo" }
|
||||
log = { workspace = true }
|
||||
raw-window-handle = "0.5"
|
||||
raw-window-handle = "0.6"
|
||||
servo-media = { workspace = true }
|
||||
shellwords = "1.0.0"
|
||||
surfman = { workspace = true, features = ["sm-x11", "sm-raw-window-handle"] }
|
||||
surfman = { workspace = true, features = ["sm-x11", "sm-raw-window-handle-06"] }
|
||||
tinyfiledialogs = "3.0"
|
||||
webxr = { git = "https://github.com/servo/webxr", features = ["ipc", "glwindow", "headless"] }
|
||||
winit = "0.28.7"
|
||||
winit = "0.29.10"
|
||||
url = { workspace = true }
|
||||
|
||||
[target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies]
|
||||
|
|
|
@ -63,7 +63,8 @@ impl App {
|
|||
user_agent: Option<String>,
|
||||
url: Option<String>,
|
||||
) {
|
||||
let events_loop = EventsLoop::new(opts::get().headless, opts::get().output_file.is_some());
|
||||
let events_loop = EventsLoop::new(opts::get().headless, opts::get().output_file.is_some())
|
||||
.expect("Failed to create events loop");
|
||||
|
||||
// Implements window methods, used by compositor.
|
||||
let window = if opts::get().headless {
|
||||
|
@ -112,13 +113,7 @@ impl App {
|
|||
debug_assert_eq!(webrender_gl.get_error(), gleam::gl::NO_ERROR);
|
||||
|
||||
app.minibrowser = Some(
|
||||
Minibrowser::new(
|
||||
&rendering_context,
|
||||
&events_loop,
|
||||
window.as_ref(),
|
||||
initial_url.clone(),
|
||||
)
|
||||
.into(),
|
||||
Minibrowser::new(&rendering_context, &events_loop, initial_url.clone()).into(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -200,7 +195,11 @@ impl App {
|
|||
return;
|
||||
}
|
||||
|
||||
if let winit::event::Event::RedrawRequested(_) = event {
|
||||
if let winit::event::Event::WindowEvent {
|
||||
window_id: _,
|
||||
event: winit::event::WindowEvent::RedrawRequested,
|
||||
} = event
|
||||
{
|
||||
// We need to redraw the window for some reason.
|
||||
trace!("RedrawRequested");
|
||||
|
||||
|
@ -227,7 +226,7 @@ impl App {
|
|||
event: WindowEvent::ScaleFactorChanged { scale_factor, .. },
|
||||
..
|
||||
} => {
|
||||
// Intercept any ScaleFactorChanged events away from EguiGlow::on_event, so
|
||||
// Intercept any ScaleFactorChanged events away from EguiGlow::on_window_event, so
|
||||
// we can use our own logic for calculating the scale factor and set egui’s
|
||||
// scale factor to that value manually.
|
||||
let effective_scale_factor = window.hidpi_factor().get();
|
||||
|
@ -244,8 +243,12 @@ impl App {
|
|||
// the minibrowser, and present the new frame.
|
||||
window.winit_window().unwrap().request_redraw();
|
||||
},
|
||||
winit::event::Event::WindowEvent { ref event, .. } => {
|
||||
let response = minibrowser.on_event(event);
|
||||
winit::event::Event::WindowEvent {
|
||||
ref event,
|
||||
window_id: _,
|
||||
} => {
|
||||
let response =
|
||||
minibrowser.on_window_event(window.winit_window().unwrap(), &event);
|
||||
// Update minibrowser if there's resize event to sync up with window.
|
||||
if let WindowEvent::Resized(_) = event {
|
||||
minibrowser.update(
|
||||
|
@ -255,7 +258,6 @@ impl App {
|
|||
"Sync WebView size with Window Resize event",
|
||||
);
|
||||
}
|
||||
|
||||
if response.repaint {
|
||||
// Request a winit redraw event, so we can recomposite, update and paint
|
||||
// the minibrowser, and present the new frame.
|
||||
|
@ -361,7 +363,7 @@ impl App {
|
|||
|
||||
/// Processes the given winit Event, possibly converting it to an [EmbedderEvent] and
|
||||
/// routing that to the App or relevant Window event queues.
|
||||
fn queue_embedder_events_for_winit_event(&self, event: winit::event::Event<'_, WakerEvent>) {
|
||||
fn queue_embedder_events_for_winit_event(&self, event: winit::event::Event<WakerEvent>) {
|
||||
match event {
|
||||
// App level events
|
||||
winit::event::Event::Suspended => {
|
||||
|
@ -376,10 +378,6 @@ impl App {
|
|||
},
|
||||
winit::event::Event::DeviceEvent { .. } => {},
|
||||
|
||||
winit::event::Event::RedrawRequested(_) => {
|
||||
self.event_queue.borrow_mut().push(EmbedderEvent::Idle);
|
||||
},
|
||||
|
||||
// Window level events
|
||||
winit::event::Event::WindowEvent {
|
||||
window_id, event, ..
|
||||
|
@ -388,14 +386,18 @@ impl App {
|
|||
warn!("Got an event from unknown window");
|
||||
},
|
||||
Some(window) => {
|
||||
if event == winit::event::WindowEvent::RedrawRequested {
|
||||
self.event_queue.borrow_mut().push(EmbedderEvent::Idle);
|
||||
}
|
||||
|
||||
window.queue_embedder_events_for_winit_event(event);
|
||||
},
|
||||
},
|
||||
|
||||
winit::event::Event::LoopDestroyed |
|
||||
winit::event::Event::NewEvents(..) |
|
||||
winit::event::Event::MainEventsCleared |
|
||||
winit::event::Event::RedrawEventsCleared => {},
|
||||
winit::event::Event::LoopExiting |
|
||||
winit::event::Event::AboutToWait |
|
||||
winit::event::Event::MemoryWarning |
|
||||
winit::event::Event::NewEvents(..) => {},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
// IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
use egui::{ViewportId, ViewportOutput};
|
||||
use egui_glow::ShaderVersion;
|
||||
pub use egui_winit;
|
||||
use egui_winit::winit;
|
||||
|
@ -61,17 +62,28 @@ impl EguiGlow {
|
|||
})
|
||||
.unwrap();
|
||||
|
||||
let egui_ctx = egui::Context::default();
|
||||
Self {
|
||||
egui_ctx: Default::default(),
|
||||
egui_winit: egui_winit::State::new(event_loop),
|
||||
egui_winit: egui_winit::State::new(
|
||||
egui_ctx.clone(),
|
||||
ViewportId::ROOT,
|
||||
event_loop,
|
||||
None,
|
||||
None,
|
||||
),
|
||||
egui_ctx,
|
||||
painter,
|
||||
shapes: Default::default(),
|
||||
textures_delta: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn on_event(&mut self, event: &winit::event::WindowEvent<'_>) -> EventResponse {
|
||||
self.egui_winit.on_event(&self.egui_ctx, event)
|
||||
pub fn on_window_event(
|
||||
&mut self,
|
||||
window: &winit::window::Window,
|
||||
event: &winit::event::WindowEvent,
|
||||
) -> EventResponse {
|
||||
self.egui_winit.on_window_event(window, event)
|
||||
}
|
||||
|
||||
/// Returns the `Duration` of the timeout after which egui should be repainted even if there's no new events.
|
||||
|
@ -85,17 +97,21 @@ impl EguiGlow {
|
|||
let raw_input = self.egui_winit.take_egui_input(window);
|
||||
let egui::FullOutput {
|
||||
platform_output,
|
||||
repaint_after,
|
||||
viewport_output,
|
||||
textures_delta,
|
||||
shapes,
|
||||
pixels_per_point: _pixels_per_point,
|
||||
} = self.egui_ctx.run(raw_input, run_ui);
|
||||
|
||||
self.egui_winit
|
||||
.handle_platform_output(window, &self.egui_ctx, platform_output);
|
||||
.handle_platform_output(window, platform_output);
|
||||
|
||||
self.shapes = shapes;
|
||||
self.textures_delta.append(textures_delta);
|
||||
repaint_after
|
||||
match viewport_output.get(&ViewportId::ROOT) {
|
||||
Some(&ViewportOutput { repaint_delay, .. }) => repaint_delay,
|
||||
None => std::time::Duration::ZERO,
|
||||
}
|
||||
}
|
||||
|
||||
/// Paint the results of the last call to [`Self::run`].
|
||||
|
@ -108,14 +124,12 @@ impl EguiGlow {
|
|||
self.painter.set_texture(id, &image_delta);
|
||||
}
|
||||
|
||||
let pixels_per_point = self.egui_ctx.pixels_per_point();
|
||||
/////// let clipped_primitives = self.egui_ctx.tessellate(shapes);
|
||||
let clipped_primitives = self.egui_ctx.tessellate(shapes.clone());
|
||||
let clipped_primitives = self.egui_ctx.tessellate(shapes.clone(), pixels_per_point);
|
||||
let dimensions: [u32; 2] = window.inner_size().into();
|
||||
self.painter.paint_primitives(
|
||||
dimensions,
|
||||
self.egui_ctx.pixels_per_point(),
|
||||
&clipped_primitives,
|
||||
);
|
||||
self.painter
|
||||
.paint_primitives(dimensions, pixels_per_point, &clipped_primitives);
|
||||
|
||||
for id in textures_delta.free.drain(..) {
|
||||
self.painter.free_texture(id);
|
||||
|
|
|
@ -33,24 +33,33 @@ impl EventsLoop {
|
|||
// Ideally, we could use the winit event loop in both modes,
|
||||
// but on Linux, the event loop requires a X11 server.
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||
pub fn new(_headless: bool, _has_output_file: bool) -> EventsLoop {
|
||||
EventsLoop(EventLoop::Winit(Some(
|
||||
winit::event_loop::EventLoopBuilder::with_user_event().build(),
|
||||
)))
|
||||
pub fn new(
|
||||
_headless: bool,
|
||||
_has_output_file: bool,
|
||||
) -> Result<EventsLoop, winit::error::EventLoopError> {
|
||||
Ok(EventsLoop(EventLoop::Winit(Some(
|
||||
winit::event_loop::EventLoopBuilder::with_user_event().build()?,
|
||||
))))
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
pub fn new(headless: bool, _has_output_file: bool) -> EventsLoop {
|
||||
EventsLoop(if headless {
|
||||
pub fn new(
|
||||
headless: bool,
|
||||
_has_output_file: bool,
|
||||
) -> Result<EventsLoop, winit::error::EventLoopError> {
|
||||
Ok(EventsLoop(if headless {
|
||||
EventLoop::Headless(Arc::new((Mutex::new(false), Condvar::new())))
|
||||
} else {
|
||||
EventLoop::Winit(Some(
|
||||
winit::event_loop::EventLoopBuilder::with_user_event().build(),
|
||||
winit::event_loop::EventLoopBuilder::with_user_event().build()?,
|
||||
))
|
||||
})
|
||||
}))
|
||||
}
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn new(headless: bool, _has_output_file: bool) -> EventsLoop {
|
||||
EventsLoop(if headless {
|
||||
pub fn new(
|
||||
headless: bool,
|
||||
_has_output_file: bool,
|
||||
) -> Result<EventsLoop, winit::error::EventLoopError> {
|
||||
Ok(EventsLoop(if headless {
|
||||
EventLoop::Headless(Arc::new((Mutex::new(false), Condvar::new())))
|
||||
} else {
|
||||
let mut event_loop_builder = winit::event_loop::EventLoopBuilder::with_user_event();
|
||||
|
@ -59,8 +68,8 @@ impl EventsLoop {
|
|||
// when generating an output file.
|
||||
event_loop_builder.with_activation_policy(ActivationPolicy::Prohibited);
|
||||
}
|
||||
EventLoop::Winit(Some(event_loop_builder.build()))
|
||||
})
|
||||
EventLoop::Winit(Some(event_loop_builder.build()?))
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -88,32 +97,36 @@ impl EventsLoop {
|
|||
pub fn run_forever<F: 'static>(self, mut callback: F)
|
||||
where
|
||||
F: FnMut(
|
||||
winit::event::Event<'_, WakerEvent>,
|
||||
winit::event::Event<WakerEvent>,
|
||||
Option<&winit::event_loop::EventLoopWindowTarget<WakerEvent>>,
|
||||
&mut winit::event_loop::ControlFlow,
|
||||
&mut ControlFlow,
|
||||
),
|
||||
{
|
||||
match self.0 {
|
||||
EventLoop::Winit(events_loop) => {
|
||||
let events_loop = events_loop.expect("Can't run an unavailable event loop.");
|
||||
events_loop.run(move |e, window_target, ref mut control_flow| {
|
||||
callback(e, Some(window_target), control_flow)
|
||||
});
|
||||
events_loop
|
||||
.run(move |e, window_target| {
|
||||
let mut control_flow = ControlFlow::default();
|
||||
callback(e, Some(window_target), &mut control_flow);
|
||||
control_flow.apply_to(window_target);
|
||||
})
|
||||
.expect("Failed while running events loop");
|
||||
},
|
||||
EventLoop::Headless(ref data) => {
|
||||
let (flag, condvar) = &**data;
|
||||
let mut event = winit::event::Event::NewEvents(winit::event::StartCause::Init);
|
||||
loop {
|
||||
self.sleep(flag, condvar);
|
||||
let mut control_flow = winit::event_loop::ControlFlow::Poll;
|
||||
let mut control_flow = ControlFlow::Poll;
|
||||
callback(event, None, &mut control_flow);
|
||||
event = winit::event::Event::<WakerEvent>::UserEvent(WakerEvent);
|
||||
|
||||
if control_flow != winit::event_loop::ControlFlow::Poll {
|
||||
if control_flow != ControlFlow::Poll {
|
||||
*flag.lock().unwrap() = false;
|
||||
}
|
||||
|
||||
if control_flow == winit::event_loop::ControlFlow::Exit {
|
||||
if control_flow == ControlFlow::Exit {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -136,6 +149,63 @@ impl EventsLoop {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
|
||||
pub enum ControlFlow {
|
||||
Poll,
|
||||
|
||||
#[default]
|
||||
Wait,
|
||||
|
||||
WaitUntil(std::time::Instant),
|
||||
|
||||
/// winit removed their ControlFlow::Exit variant in 0.29.2
|
||||
Exit,
|
||||
}
|
||||
|
||||
impl ControlFlow {
|
||||
fn apply_to(self, window_target: &winit::event_loop::EventLoopWindowTarget<WakerEvent>) {
|
||||
match self {
|
||||
ControlFlow::Poll => {
|
||||
window_target.set_control_flow(winit::event_loop::ControlFlow::Poll)
|
||||
},
|
||||
ControlFlow::Wait => {
|
||||
window_target.set_control_flow(winit::event_loop::ControlFlow::Wait)
|
||||
},
|
||||
ControlFlow::WaitUntil(instant) => {
|
||||
window_target.set_control_flow(winit::event_loop::ControlFlow::WaitUntil(instant))
|
||||
},
|
||||
ControlFlow::Exit => window_target.exit(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_poll(&mut self) {
|
||||
*self = ControlFlow::Poll;
|
||||
}
|
||||
|
||||
pub fn set_wait(&mut self) {
|
||||
*self = ControlFlow::Wait;
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn set_wait_until(&mut self, instant: std::time::Instant) {
|
||||
*self = ControlFlow::WaitUntil(instant);
|
||||
}
|
||||
|
||||
pub fn set_exit(&mut self) {
|
||||
*self = ControlFlow::Exit;
|
||||
}
|
||||
}
|
||||
|
||||
impl From<winit::event_loop::ControlFlow> for ControlFlow {
|
||||
fn from(cf: winit::event_loop::ControlFlow) -> Self {
|
||||
match cf {
|
||||
winit::event_loop::ControlFlow::Poll => Self::Poll,
|
||||
winit::event_loop::ControlFlow::Wait => Self::Wait,
|
||||
winit::event_loop::ControlFlow::WaitUntil(instant) => Self::WaitUntil(instant),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct HeadedEventLoopWaker {
|
||||
proxy: Arc<Mutex<winit::event_loop::EventLoopProxy<WakerEvent>>>,
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use std::rc::Rc;
|
|||
|
||||
use euclid::{Angle, Length, Point2D, Rotation3D, Scale, Size2D, UnknownUnit, Vector2D, Vector3D};
|
||||
use log::{debug, info, trace};
|
||||
use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle};
|
||||
use raw_window_handle::{HasDisplayHandle, HasWindowHandle};
|
||||
use servo::compositing::windowing::{
|
||||
AnimationState, EmbedderCoordinates, EmbedderEvent, MouseWindowEvent, WindowMethods,
|
||||
};
|
||||
|
@ -27,10 +27,8 @@ use surfman::{Connection, Context, Device, SurfaceType};
|
|||
#[cfg(target_os = "windows")]
|
||||
use winapi;
|
||||
use winit::dpi::{LogicalPosition, PhysicalPosition, PhysicalSize};
|
||||
use winit::event::{
|
||||
ElementState, KeyboardInput, ModifiersState, MouseButton, MouseScrollDelta, TouchPhase,
|
||||
VirtualKeyCode,
|
||||
};
|
||||
use winit::event::{ElementState, KeyEvent, MouseButton, MouseScrollDelta, TouchPhase};
|
||||
use winit::keyboard::{Key as LogicalKey, ModifiersState, NamedKey};
|
||||
#[cfg(any(target_os = "linux", target_os = "windows"))]
|
||||
use winit::window::Icon;
|
||||
|
||||
|
@ -50,10 +48,10 @@ pub struct Window {
|
|||
primary_monitor: winit::monitor::MonitorHandle,
|
||||
event_queue: RefCell<Vec<EmbedderEvent>>,
|
||||
mouse_pos: Cell<Point2D<i32, DevicePixel>>,
|
||||
last_pressed: Cell<Option<(KeyboardEvent, Option<VirtualKeyCode>)>>,
|
||||
last_pressed: Cell<Option<(KeyboardEvent, Option<LogicalKey>)>>,
|
||||
/// A map of winit's key codes to key values that are interpreted from
|
||||
/// winit's ReceivedChar events.
|
||||
keys_down: RefCell<HashMap<VirtualKeyCode, Key>>,
|
||||
keys_down: RefCell<HashMap<LogicalKey, Key>>,
|
||||
animation_state: Cell<AnimationState>,
|
||||
fullscreen: Cell<bool>,
|
||||
device_pixel_ratio_override: Option<f32>,
|
||||
|
@ -119,15 +117,19 @@ impl Window {
|
|||
let inner_size = winit_size_to_euclid_size(winit_window.inner_size());
|
||||
|
||||
// Initialize surfman
|
||||
let display_handle = winit_window.raw_display_handle();
|
||||
let connection = Connection::from_raw_display_handle(display_handle)
|
||||
.expect("Failed to create connection");
|
||||
let display_handle = winit_window
|
||||
.display_handle()
|
||||
.expect("could not get display handle from window");
|
||||
let connection =
|
||||
Connection::from_display_handle(display_handle).expect("Failed to create connection");
|
||||
let adapter = connection
|
||||
.create_adapter()
|
||||
.expect("Failed to create adapter");
|
||||
let window_handle = winit_window.raw_window_handle();
|
||||
let window_handle = winit_window
|
||||
.window_handle()
|
||||
.expect("could not get window handle from window");
|
||||
let native_widget = connection
|
||||
.create_native_widget_from_raw_window_handle(window_handle, Size2D::new(width, height))
|
||||
.create_native_widget_from_window_handle(window_handle, Size2D::new(width, height))
|
||||
.expect("Failed to create native widget");
|
||||
let surface_type = SurfaceType::Widget { native_widget };
|
||||
let rendering_context = RenderingContext::create(&connection, &adapter, surface_type)
|
||||
|
@ -199,20 +201,25 @@ impl Window {
|
|||
.push(EmbedderEvent::Keyboard(event));
|
||||
}
|
||||
|
||||
fn handle_keyboard_input(&self, input: KeyboardInput) {
|
||||
let mut event = keyboard_event_from_winit(input, self.modifiers_state.get());
|
||||
fn handle_keyboard_input(&self, input: KeyEvent) {
|
||||
if let Some(input_text) = &input.text {
|
||||
for ch in input_text.chars() {
|
||||
self.handle_received_character(ch);
|
||||
}
|
||||
}
|
||||
|
||||
let mut event = keyboard_event_from_winit(&input, self.modifiers_state.get());
|
||||
trace!("handling {:?}", event);
|
||||
if event.state == KeyState::Down && event.key == Key::Unidentified {
|
||||
// If pressed and probably printable, we expect a ReceivedCharacter event.
|
||||
// Wait for that to be received and don't queue any event right now.
|
||||
self.last_pressed.set(Some((event, input.virtual_keycode)));
|
||||
self.last_pressed
|
||||
.set(Some((event, Some(input.logical_key))));
|
||||
return;
|
||||
} else if event.state == KeyState::Up && event.key == Key::Unidentified {
|
||||
// If release and probably printable, this is following a ReceiverCharacter event.
|
||||
if let Some(key_code) = input.virtual_keycode {
|
||||
if let Some(key) = self.keys_down.borrow_mut().remove(&key_code) {
|
||||
event.key = key;
|
||||
}
|
||||
if let Some(key) = self.keys_down.borrow_mut().remove(&input.logical_key) {
|
||||
event.key = key;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -303,12 +310,21 @@ impl WindowPortsMethods for Window {
|
|||
self.winit_window.set_title(title);
|
||||
}
|
||||
|
||||
fn set_inner_size(&self, size: DeviceIntSize) {
|
||||
fn request_inner_size(&self, size: DeviceIntSize) -> Option<DeviceIntSize> {
|
||||
let toolbar_height = self.toolbar_height() * self.hidpi_factor();
|
||||
let toolbar_height = toolbar_height.get().ceil() as i32;
|
||||
let total_size = PhysicalSize::new(size.width, size.height + toolbar_height);
|
||||
self.winit_window
|
||||
.set_inner_size::<PhysicalSize<i32>>(total_size)
|
||||
.request_inner_size::<PhysicalSize<i32>>(PhysicalSize::new(
|
||||
total_size.width,
|
||||
total_size.height,
|
||||
))
|
||||
.and_then(|size| {
|
||||
Some(DeviceIntSize::new(
|
||||
size.width.try_into().ok()?,
|
||||
size.height.try_into().ok()?,
|
||||
))
|
||||
})
|
||||
}
|
||||
|
||||
fn set_position(&self, point: DeviceIntPoint) {
|
||||
|
@ -338,7 +354,7 @@ impl WindowPortsMethods for Window {
|
|||
|
||||
let winit_cursor = match cursor {
|
||||
Cursor::Default => CursorIcon::Default,
|
||||
Cursor::Pointer => CursorIcon::Hand,
|
||||
Cursor::Pointer => CursorIcon::Pointer,
|
||||
Cursor::ContextMenu => CursorIcon::ContextMenu,
|
||||
Cursor::Help => CursorIcon::Help,
|
||||
Cursor::Progress => CursorIcon::Progress,
|
||||
|
@ -384,13 +400,14 @@ impl WindowPortsMethods for Window {
|
|||
self.winit_window.id()
|
||||
}
|
||||
|
||||
fn queue_embedder_events_for_winit_event(&self, event: winit::event::WindowEvent<'_>) {
|
||||
fn queue_embedder_events_for_winit_event(&self, event: winit::event::WindowEvent) {
|
||||
match event {
|
||||
winit::event::WindowEvent::ReceivedCharacter(ch) => self.handle_received_character(ch),
|
||||
winit::event::WindowEvent::KeyboardInput { input, .. } => {
|
||||
self.handle_keyboard_input(input)
|
||||
winit::event::WindowEvent::KeyboardInput { event, .. } => {
|
||||
self.handle_keyboard_input(event)
|
||||
},
|
||||
winit::event::WindowEvent::ModifiersChanged(modifiers) => {
|
||||
self.modifiers_state.set(modifiers.state())
|
||||
},
|
||||
winit::event::WindowEvent::ModifiersChanged(state) => self.modifiers_state.set(state),
|
||||
winit::event::WindowEvent::MouseInput { state, button, .. } => {
|
||||
if button == MouseButton::Left || button == MouseButton::Right {
|
||||
self.handle_mouse(button, state, self.mouse_pos.get());
|
||||
|
@ -587,12 +604,15 @@ impl webxr::glwindow::GlWindow for XRWindow {
|
|||
device: &mut Device,
|
||||
_context: &mut Context,
|
||||
) -> webxr::glwindow::GlWindowRenderTarget {
|
||||
let window_handle = self.winit_window.raw_window_handle();
|
||||
let window_handle = self
|
||||
.winit_window
|
||||
.window_handle()
|
||||
.expect("could not get window handle from window");
|
||||
let size = self.winit_window.inner_size();
|
||||
let size = Size2D::new(size.width as i32, size.height as i32);
|
||||
let native_widget = device
|
||||
.connection()
|
||||
.create_native_widget_from_raw_window_handle(window_handle, size)
|
||||
.create_native_widget_from_window_handle(window_handle, size)
|
||||
.expect("Failed to create native widget");
|
||||
webxr::glwindow::GlWindowRenderTarget::NativeWidget(native_widget)
|
||||
}
|
||||
|
@ -648,20 +668,20 @@ impl XRWindowPose {
|
|||
self.xr_translation.set(vec);
|
||||
}
|
||||
|
||||
fn handle_xr_rotation(&self, input: &KeyboardInput, modifiers: ModifiersState) {
|
||||
fn handle_xr_rotation(&self, input: &KeyEvent, modifiers: ModifiersState) {
|
||||
if input.state != winit::event::ElementState::Pressed {
|
||||
return;
|
||||
}
|
||||
let mut x = 0.0;
|
||||
let mut y = 0.0;
|
||||
match input.virtual_keycode {
|
||||
Some(VirtualKeyCode::Up) => x = 1.0,
|
||||
Some(VirtualKeyCode::Down) => x = -1.0,
|
||||
Some(VirtualKeyCode::Left) => y = 1.0,
|
||||
Some(VirtualKeyCode::Right) => y = -1.0,
|
||||
match input.logical_key {
|
||||
LogicalKey::Named(NamedKey::ArrowUp) => x = 1.0,
|
||||
LogicalKey::Named(NamedKey::ArrowDown) => x = -1.0,
|
||||
LogicalKey::Named(NamedKey::ArrowLeft) => y = 1.0,
|
||||
LogicalKey::Named(NamedKey::ArrowRight) => y = -1.0,
|
||||
_ => return,
|
||||
};
|
||||
if modifiers.shift() {
|
||||
if modifiers.shift_key() {
|
||||
x *= 10.0;
|
||||
y *= 10.0;
|
||||
}
|
||||
|
|
|
@ -73,23 +73,27 @@ impl WindowPortsMethods for Window {
|
|||
unsafe { winit::window::WindowId::dummy() }
|
||||
}
|
||||
|
||||
fn set_inner_size(&self, size: DeviceIntSize) {
|
||||
fn request_inner_size(&self, size: DeviceIntSize) -> Option<DeviceIntSize> {
|
||||
let (width, height) = size.into();
|
||||
|
||||
// Surfman doesn't support zero-sized surfaces.
|
||||
let new_size = Size2D::new(width.max(1), height.max(1));
|
||||
if self.inner_size.get() == new_size {
|
||||
return;
|
||||
let new_size = DeviceIntSize::new(width.max(1), height.max(1));
|
||||
if self.inner_size.get() == new_size.to_untyped() {
|
||||
return Some(new_size);
|
||||
}
|
||||
|
||||
match self.rendering_context.resize(new_size.to_untyped()) {
|
||||
Ok(()) => {
|
||||
self.inner_size.set(new_size);
|
||||
self.inner_size.set(new_size.to_untyped());
|
||||
if let Ok(ref mut queue) = self.event_queue.write() {
|
||||
queue.push(EmbedderEvent::WindowResize);
|
||||
}
|
||||
Some(new_size)
|
||||
},
|
||||
Err(error) => {
|
||||
warn!("Could not resize window: {error:?}");
|
||||
None
|
||||
},
|
||||
Err(error) => warn!("Could not resize window: {error:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,7 +130,7 @@ impl WindowPortsMethods for Window {
|
|||
self.animation_state.get() == AnimationState::Animating
|
||||
}
|
||||
|
||||
fn queue_embedder_events_for_winit_event(&self, _event: winit::event::WindowEvent<'_>) {
|
||||
fn queue_embedder_events_for_winit_event(&self, _event: winit::event::WindowEvent) {
|
||||
// Not expecting any winit events.
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,8 @@
|
|||
|
||||
use keyboard_types::{Code, Key, KeyState, KeyboardEvent, Location, Modifiers};
|
||||
use log::info;
|
||||
use winit::event::{ElementState, KeyboardInput, ModifiersState, VirtualKeyCode};
|
||||
use winit::event::{ElementState, KeyEvent};
|
||||
use winit::keyboard::{Key as LogicalKey, KeyCode, ModifiersState, NamedKey, PhysicalKey};
|
||||
|
||||
// Some shortcuts use Cmd on Mac and Control on other systems.
|
||||
#[cfg(target_os = "macos")]
|
||||
|
@ -18,249 +19,249 @@ pub const CMD_OR_ALT: Modifiers = Modifiers::META;
|
|||
#[cfg(not(target_os = "macos"))]
|
||||
pub const CMD_OR_ALT: Modifiers = Modifiers::ALT;
|
||||
|
||||
fn get_servo_key_from_winit_key(key: Option<VirtualKeyCode>) -> Key {
|
||||
use winit::event::VirtualKeyCode::*;
|
||||
fn get_servo_key_from_winit_key(key: &LogicalKey) -> Key {
|
||||
// TODO: figure out how to map NavigateForward, NavigateBackward
|
||||
// TODO: map the remaining keys if possible
|
||||
let key = if let Some(key) = key {
|
||||
key
|
||||
} else {
|
||||
return Key::Unidentified;
|
||||
};
|
||||
match key {
|
||||
// printable: Key1 to Key0
|
||||
// printable: A to Z
|
||||
Escape => Key::Escape,
|
||||
F1 => Key::F1,
|
||||
F2 => Key::F2,
|
||||
F3 => Key::F3,
|
||||
F4 => Key::F4,
|
||||
F5 => Key::F5,
|
||||
F6 => Key::F6,
|
||||
F7 => Key::F7,
|
||||
F8 => Key::F8,
|
||||
F9 => Key::F9,
|
||||
F10 => Key::F10,
|
||||
F11 => Key::F11,
|
||||
F12 => Key::F12,
|
||||
LogicalKey::Named(NamedKey::Escape) => Key::Escape,
|
||||
LogicalKey::Named(NamedKey::F1) => Key::F1,
|
||||
LogicalKey::Named(NamedKey::F2) => Key::F2,
|
||||
LogicalKey::Named(NamedKey::F3) => Key::F3,
|
||||
LogicalKey::Named(NamedKey::F4) => Key::F4,
|
||||
LogicalKey::Named(NamedKey::F5) => Key::F5,
|
||||
LogicalKey::Named(NamedKey::F6) => Key::F6,
|
||||
LogicalKey::Named(NamedKey::F7) => Key::F7,
|
||||
LogicalKey::Named(NamedKey::F8) => Key::F8,
|
||||
LogicalKey::Named(NamedKey::F9) => Key::F9,
|
||||
LogicalKey::Named(NamedKey::F10) => Key::F10,
|
||||
LogicalKey::Named(NamedKey::F11) => Key::F11,
|
||||
LogicalKey::Named(NamedKey::F12) => Key::F12,
|
||||
// F13 to F15 are not mapped
|
||||
Snapshot => Key::PrintScreen,
|
||||
LogicalKey::Named(NamedKey::PrintScreen) => Key::PrintScreen,
|
||||
// Scroll not mapped
|
||||
Pause => Key::Pause,
|
||||
Insert => Key::Insert,
|
||||
Home => Key::Home,
|
||||
Delete => Key::Delete,
|
||||
End => Key::End,
|
||||
PageDown => Key::PageDown,
|
||||
PageUp => Key::PageUp,
|
||||
Left => Key::ArrowLeft,
|
||||
Up => Key::ArrowUp,
|
||||
Right => Key::ArrowRight,
|
||||
Down => Key::ArrowDown,
|
||||
Back => Key::Backspace,
|
||||
Return => Key::Enter,
|
||||
LogicalKey::Named(NamedKey::Pause) => Key::Pause,
|
||||
LogicalKey::Named(NamedKey::Insert) => Key::Insert,
|
||||
LogicalKey::Named(NamedKey::Home) => Key::Home,
|
||||
LogicalKey::Named(NamedKey::Delete) => Key::Delete,
|
||||
LogicalKey::Named(NamedKey::End) => Key::End,
|
||||
LogicalKey::Named(NamedKey::PageDown) => Key::PageDown,
|
||||
LogicalKey::Named(NamedKey::PageUp) => Key::PageUp,
|
||||
LogicalKey::Named(NamedKey::ArrowLeft) => Key::ArrowLeft,
|
||||
LogicalKey::Named(NamedKey::ArrowUp) => Key::ArrowUp,
|
||||
LogicalKey::Named(NamedKey::ArrowRight) => Key::ArrowRight,
|
||||
LogicalKey::Named(NamedKey::ArrowDown) => Key::ArrowDown,
|
||||
LogicalKey::Named(NamedKey::Backspace) => Key::Backspace,
|
||||
LogicalKey::Named(NamedKey::Enter) => Key::Enter,
|
||||
// printable: Space
|
||||
Compose => Key::Compose,
|
||||
LogicalKey::Named(NamedKey::Compose) => Key::Compose,
|
||||
// Caret not mapped
|
||||
Numlock => Key::NumLock,
|
||||
LogicalKey::Named(NamedKey::NumLock) => Key::NumLock,
|
||||
// printable: Numpad0 to Numpad9
|
||||
// AbntC1 and AbntC2 not mapped
|
||||
// printable: Add, Apostrophe,
|
||||
// Apps, At, Ax not mapped
|
||||
// printable: Backslash,
|
||||
Calculator => Key::LaunchApplication2,
|
||||
Capital => Key::CapsLock,
|
||||
LogicalKey::Named(NamedKey::LaunchApplication2) => Key::LaunchApplication2,
|
||||
LogicalKey::Named(NamedKey::CapsLock) => Key::CapsLock,
|
||||
// printable: Colon, Comma,
|
||||
Convert => Key::Convert,
|
||||
LogicalKey::Named(NamedKey::Convert) => Key::Convert,
|
||||
// not mapped: Decimal,
|
||||
// printable: Divide, Equals, Grave,
|
||||
Kana => Key::KanaMode,
|
||||
Kanji => Key::KanjiMode,
|
||||
LAlt => Key::Alt,
|
||||
LogicalKey::Named(NamedKey::KanaMode) => Key::KanaMode,
|
||||
LogicalKey::Named(NamedKey::KanjiMode) => Key::KanjiMode,
|
||||
LogicalKey::Named(NamedKey::Alt) => Key::Alt,
|
||||
// printable: LBracket,
|
||||
LControl => Key::Control,
|
||||
LShift => Key::Shift,
|
||||
LWin => Key::Meta,
|
||||
Mail => Key::LaunchMail,
|
||||
LogicalKey::Named(NamedKey::Control) => Key::Control,
|
||||
LogicalKey::Named(NamedKey::Shift) => Key::Shift,
|
||||
LogicalKey::Named(NamedKey::Meta) => Key::Meta,
|
||||
LogicalKey::Named(NamedKey::LaunchMail) => Key::LaunchMail,
|
||||
// not mapped: MediaSelect,
|
||||
MediaStop => Key::MediaStop,
|
||||
LogicalKey::Named(NamedKey::MediaStop) => Key::MediaStop,
|
||||
// printable: Minus, Multiply,
|
||||
Mute => Key::AudioVolumeMute,
|
||||
MyComputer => Key::LaunchApplication1,
|
||||
LogicalKey::Named(NamedKey::AudioVolumeMute) => Key::AudioVolumeMute,
|
||||
LogicalKey::Named(NamedKey::LaunchApplication1) => Key::LaunchApplication1,
|
||||
// not mapped: NavigateForward, NavigateBackward
|
||||
NextTrack => Key::MediaTrackNext,
|
||||
NoConvert => Key::NonConvert,
|
||||
LogicalKey::Named(NamedKey::MediaTrackNext) => Key::MediaTrackNext,
|
||||
LogicalKey::Named(NamedKey::NonConvert) => Key::NonConvert,
|
||||
// printable: NumpadComma, NumpadEnter, NumpadEquals,
|
||||
// not mapped: OEM102,
|
||||
// printable: Period,
|
||||
PlayPause => Key::MediaPlayPause,
|
||||
Power => Key::Power,
|
||||
PrevTrack => Key::MediaTrackPrevious,
|
||||
RAlt => Key::Alt,
|
||||
LogicalKey::Named(NamedKey::MediaPlayPause) => Key::MediaPlayPause,
|
||||
LogicalKey::Named(NamedKey::Power) => Key::Power,
|
||||
LogicalKey::Named(NamedKey::MediaTrackPrevious) => Key::MediaTrackPrevious,
|
||||
// printable RBracket
|
||||
RControl => Key::Control,
|
||||
RShift => Key::Shift,
|
||||
RWin => Key::Meta,
|
||||
// printable Semicolon, Slash
|
||||
Sleep => Key::Standby,
|
||||
LogicalKey::Named(NamedKey::Standby) => Key::Standby,
|
||||
// not mapped: Stop,
|
||||
// printable Subtract,
|
||||
// not mapped: Sysrq,
|
||||
Tab => Key::Tab,
|
||||
LogicalKey::Named(NamedKey::Tab) => Key::Tab,
|
||||
// printable: Underline,
|
||||
// not mapped: Unlabeled,
|
||||
VolumeDown => Key::AudioVolumeDown,
|
||||
VolumeUp => Key::AudioVolumeUp,
|
||||
Wake => Key::WakeUp,
|
||||
WebBack => Key::BrowserBack,
|
||||
WebFavorites => Key::BrowserFavorites,
|
||||
WebForward => Key::BrowserForward,
|
||||
WebHome => Key::BrowserHome,
|
||||
WebRefresh => Key::BrowserRefresh,
|
||||
WebSearch => Key::BrowserSearch,
|
||||
WebStop => Key::BrowserStop,
|
||||
LogicalKey::Named(NamedKey::AudioVolumeDown) => Key::AudioVolumeDown,
|
||||
LogicalKey::Named(NamedKey::AudioVolumeUp) => Key::AudioVolumeUp,
|
||||
LogicalKey::Named(NamedKey::WakeUp) => Key::WakeUp,
|
||||
LogicalKey::Named(NamedKey::BrowserBack) => Key::BrowserBack,
|
||||
LogicalKey::Named(NamedKey::BrowserFavorites) => Key::BrowserFavorites,
|
||||
LogicalKey::Named(NamedKey::BrowserForward) => Key::BrowserForward,
|
||||
LogicalKey::Named(NamedKey::BrowserHome) => Key::BrowserHome,
|
||||
LogicalKey::Named(NamedKey::BrowserRefresh) => Key::BrowserRefresh,
|
||||
LogicalKey::Named(NamedKey::BrowserSearch) => Key::BrowserSearch,
|
||||
LogicalKey::Named(NamedKey::BrowserStop) => Key::BrowserStop,
|
||||
// printable Yen,
|
||||
Copy => Key::Copy,
|
||||
Paste => Key::Paste,
|
||||
Cut => Key::Cut,
|
||||
LogicalKey::Named(NamedKey::Copy) => Key::Copy,
|
||||
LogicalKey::Named(NamedKey::Paste) => Key::Paste,
|
||||
LogicalKey::Named(NamedKey::Cut) => Key::Cut,
|
||||
_ => Key::Unidentified,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_servo_location_from_winit_key(key: Option<VirtualKeyCode>) -> Location {
|
||||
use winit::event::VirtualKeyCode::*;
|
||||
// TODO: add more numpad keys
|
||||
let key = if let Some(key) = key {
|
||||
key
|
||||
fn get_servo_location_from_physical_key(physical_key: PhysicalKey) -> Location {
|
||||
let key_code = if let PhysicalKey::Code(key_code) = physical_key {
|
||||
key_code
|
||||
} else {
|
||||
return Location::Standard;
|
||||
};
|
||||
match key {
|
||||
LShift | LControl | LAlt | LWin => Location::Left,
|
||||
RShift | RControl | RAlt | RWin => Location::Right,
|
||||
Numpad0 | Numpad1 | Numpad2 | Numpad3 | Numpad4 | Numpad5 | Numpad6 | Numpad7 |
|
||||
Numpad8 | Numpad9 => Location::Numpad,
|
||||
NumpadComma | NumpadEnter | NumpadEquals => Location::Numpad,
|
||||
|
||||
// TODO: add more numpad keys
|
||||
match key_code {
|
||||
KeyCode::ShiftLeft | KeyCode::ControlLeft | KeyCode::AltLeft | KeyCode::SuperLeft => {
|
||||
Location::Left
|
||||
},
|
||||
KeyCode::ShiftRight | KeyCode::ControlRight | KeyCode::AltRight | KeyCode::SuperRight => {
|
||||
Location::Right
|
||||
},
|
||||
KeyCode::Numpad0 |
|
||||
KeyCode::Numpad1 |
|
||||
KeyCode::Numpad2 |
|
||||
KeyCode::Numpad3 |
|
||||
KeyCode::Numpad4 |
|
||||
KeyCode::Numpad5 |
|
||||
KeyCode::Numpad6 |
|
||||
KeyCode::Numpad7 |
|
||||
KeyCode::Numpad8 |
|
||||
KeyCode::Numpad9 => Location::Numpad,
|
||||
KeyCode::NumpadComma | KeyCode::NumpadEnter | KeyCode::NumpadEqual => Location::Numpad,
|
||||
_ => Location::Standard,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn get_servo_code_from_scancode(scancode: u32) -> Code {
|
||||
fn get_servo_code_from_physical_key(physical_key: PhysicalKey) -> Code {
|
||||
let key_code = if let PhysicalKey::Code(key_code) = physical_key {
|
||||
key_code
|
||||
} else {
|
||||
return Code::Unidentified;
|
||||
};
|
||||
|
||||
// TODO: Map more codes
|
||||
use keyboard_types::Code::*;
|
||||
match scancode {
|
||||
1 => Escape,
|
||||
2 => Digit1,
|
||||
3 => Digit2,
|
||||
4 => Digit3,
|
||||
5 => Digit4,
|
||||
6 => Digit5,
|
||||
7 => Digit6,
|
||||
8 => Digit7,
|
||||
9 => Digit8,
|
||||
10 => Digit9,
|
||||
11 => Digit0,
|
||||
match key_code {
|
||||
KeyCode::Escape => Code::Escape,
|
||||
KeyCode::Digit1 => Code::Digit1,
|
||||
KeyCode::Digit2 => Code::Digit2,
|
||||
KeyCode::Digit3 => Code::Digit3,
|
||||
KeyCode::Digit4 => Code::Digit4,
|
||||
KeyCode::Digit5 => Code::Digit5,
|
||||
KeyCode::Digit6 => Code::Digit6,
|
||||
KeyCode::Digit7 => Code::Digit7,
|
||||
KeyCode::Digit8 => Code::Digit8,
|
||||
KeyCode::Digit9 => Code::Digit9,
|
||||
KeyCode::Digit0 => Code::Digit0,
|
||||
|
||||
14 => Backspace,
|
||||
15 => Tab,
|
||||
16 => KeyQ,
|
||||
17 => KeyW,
|
||||
18 => KeyE,
|
||||
19 => KeyR,
|
||||
20 => KeyT,
|
||||
21 => KeyY,
|
||||
22 => KeyU,
|
||||
23 => KeyI,
|
||||
24 => KeyO,
|
||||
25 => KeyP,
|
||||
26 => BracketLeft,
|
||||
27 => BracketRight,
|
||||
28 => Enter,
|
||||
KeyCode::Backspace => Code::Backspace,
|
||||
KeyCode::Tab => Code::Tab,
|
||||
KeyCode::KeyQ => Code::KeyQ,
|
||||
KeyCode::KeyW => Code::KeyW,
|
||||
KeyCode::KeyE => Code::KeyE,
|
||||
KeyCode::KeyR => Code::KeyR,
|
||||
KeyCode::KeyT => Code::KeyT,
|
||||
KeyCode::KeyY => Code::KeyY,
|
||||
KeyCode::KeyU => Code::KeyU,
|
||||
KeyCode::KeyI => Code::KeyI,
|
||||
KeyCode::KeyO => Code::KeyO,
|
||||
KeyCode::KeyP => Code::KeyP,
|
||||
KeyCode::BracketLeft => Code::BracketLeft,
|
||||
KeyCode::BracketRight => Code::BracketRight,
|
||||
KeyCode::Enter => Code::Enter,
|
||||
|
||||
30 => KeyA,
|
||||
31 => KeyS,
|
||||
32 => KeyD,
|
||||
33 => KeyF,
|
||||
34 => KeyG,
|
||||
35 => KeyH,
|
||||
36 => KeyJ,
|
||||
37 => KeyK,
|
||||
38 => KeyL,
|
||||
39 => Semicolon,
|
||||
40 => Quote,
|
||||
KeyCode::KeyA => Code::KeyA,
|
||||
KeyCode::KeyS => Code::KeyS,
|
||||
KeyCode::KeyD => Code::KeyD,
|
||||
KeyCode::KeyF => Code::KeyF,
|
||||
KeyCode::KeyG => Code::KeyG,
|
||||
KeyCode::KeyH => Code::KeyH,
|
||||
KeyCode::KeyJ => Code::KeyJ,
|
||||
KeyCode::KeyK => Code::KeyK,
|
||||
KeyCode::KeyL => Code::KeyL,
|
||||
KeyCode::Semicolon => Code::Semicolon,
|
||||
KeyCode::Quote => Code::Quote,
|
||||
|
||||
42 => ShiftLeft,
|
||||
43 => Backslash,
|
||||
44 => KeyZ,
|
||||
45 => KeyX,
|
||||
46 => KeyC,
|
||||
47 => KeyV,
|
||||
48 => KeyB,
|
||||
49 => KeyN,
|
||||
50 => KeyM,
|
||||
51 => Comma,
|
||||
52 => Period,
|
||||
53 => Slash,
|
||||
54 => ShiftRight,
|
||||
KeyCode::ShiftLeft => Code::ShiftLeft,
|
||||
KeyCode::Backslash => Code::Backslash,
|
||||
KeyCode::KeyZ => Code::KeyZ,
|
||||
KeyCode::KeyX => Code::KeyX,
|
||||
KeyCode::KeyC => Code::KeyC,
|
||||
KeyCode::KeyV => Code::KeyV,
|
||||
KeyCode::KeyB => Code::KeyB,
|
||||
KeyCode::KeyN => Code::KeyN,
|
||||
KeyCode::KeyM => Code::KeyM,
|
||||
KeyCode::Comma => Code::Comma,
|
||||
KeyCode::Period => Code::Period,
|
||||
KeyCode::Slash => Code::Slash,
|
||||
KeyCode::ShiftRight => Code::ShiftRight,
|
||||
|
||||
57 => Space,
|
||||
KeyCode::Space => Code::Space,
|
||||
|
||||
59 => F1,
|
||||
60 => F2,
|
||||
61 => F3,
|
||||
62 => F4,
|
||||
63 => F5,
|
||||
64 => F6,
|
||||
65 => F7,
|
||||
66 => F8,
|
||||
67 => F9,
|
||||
68 => F10,
|
||||
KeyCode::F1 => Code::F1,
|
||||
KeyCode::F2 => Code::F2,
|
||||
KeyCode::F3 => Code::F3,
|
||||
KeyCode::F4 => Code::F4,
|
||||
KeyCode::F5 => Code::F5,
|
||||
KeyCode::F6 => Code::F6,
|
||||
KeyCode::F7 => Code::F7,
|
||||
KeyCode::F8 => Code::F8,
|
||||
KeyCode::F9 => Code::F9,
|
||||
KeyCode::F10 => Code::F10,
|
||||
|
||||
87 => F11,
|
||||
88 => F12,
|
||||
KeyCode::F11 => Code::F11,
|
||||
KeyCode::F12 => Code::F12,
|
||||
|
||||
103 => ArrowUp,
|
||||
104 => PageUp,
|
||||
105 => ArrowLeft,
|
||||
106 => ArrowRight,
|
||||
KeyCode::ArrowUp => Code::ArrowUp,
|
||||
KeyCode::PageUp => Code::PageUp,
|
||||
KeyCode::ArrowLeft => Code::ArrowLeft,
|
||||
KeyCode::ArrowRight => Code::ArrowRight,
|
||||
|
||||
102 => Home,
|
||||
107 => End,
|
||||
108 => ArrowDown,
|
||||
109 => PageDown,
|
||||
110 => Insert,
|
||||
111 => Delete,
|
||||
KeyCode::Home => Code::Home,
|
||||
KeyCode::End => Code::End,
|
||||
KeyCode::ArrowDown => Code::ArrowDown,
|
||||
KeyCode::PageDown => Code::PageDown,
|
||||
KeyCode::Insert => Code::Insert,
|
||||
KeyCode::Delete => Code::Delete,
|
||||
|
||||
_ => Unidentified,
|
||||
_ => Code::Unidentified,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
fn get_servo_code_from_scancode(_scancode: u32) -> Code {
|
||||
// TODO: Implement for Windows and Mac OS
|
||||
Code::Unidentified
|
||||
}
|
||||
|
||||
fn get_modifiers(mods: ModifiersState) -> Modifiers {
|
||||
let mut modifiers = Modifiers::empty();
|
||||
modifiers.set(Modifiers::CONTROL, mods.ctrl());
|
||||
modifiers.set(Modifiers::SHIFT, mods.shift());
|
||||
modifiers.set(Modifiers::ALT, mods.alt());
|
||||
modifiers.set(Modifiers::META, mods.logo());
|
||||
modifiers.set(Modifiers::CONTROL, mods.control_key());
|
||||
modifiers.set(Modifiers::SHIFT, mods.shift_key());
|
||||
modifiers.set(Modifiers::ALT, mods.alt_key());
|
||||
modifiers.set(Modifiers::META, mods.super_key());
|
||||
modifiers
|
||||
}
|
||||
|
||||
pub fn keyboard_event_from_winit(input: KeyboardInput, state: ModifiersState) -> KeyboardEvent {
|
||||
pub fn keyboard_event_from_winit(input: &KeyEvent, state: ModifiersState) -> KeyboardEvent {
|
||||
info!("winit keyboard input: {:?}", input);
|
||||
KeyboardEvent {
|
||||
state: match input.state {
|
||||
ElementState::Pressed => KeyState::Down,
|
||||
ElementState::Released => KeyState::Up,
|
||||
},
|
||||
key: get_servo_key_from_winit_key(input.virtual_keycode),
|
||||
code: get_servo_code_from_scancode(input.scancode),
|
||||
location: get_servo_location_from_winit_key(input.virtual_keycode),
|
||||
key: get_servo_key_from_winit_key(&input.logical_key),
|
||||
code: get_servo_code_from_physical_key(input.physical_key),
|
||||
location: get_servo_location_from_physical_key(input.physical_key),
|
||||
modifiers: get_modifiers(state),
|
||||
repeat: false,
|
||||
is_composing: false,
|
||||
|
|
|
@ -61,7 +61,6 @@ impl Minibrowser {
|
|||
pub fn new(
|
||||
rendering_context: &RenderingContext,
|
||||
events_loop: &EventsLoop,
|
||||
window: &dyn WindowPortsMethods,
|
||||
initial_url: ServoUrl,
|
||||
) -> Self {
|
||||
let gl = unsafe {
|
||||
|
@ -70,10 +69,6 @@ impl Minibrowser {
|
|||
|
||||
// Adapted from https://github.com/emilk/egui/blob/9478e50d012c5138551c38cbee16b07bc1fcf283/crates/egui_glow/examples/pure_glow.rs
|
||||
let context = EguiGlow::new(events_loop.as_winit(), Arc::new(gl), None);
|
||||
context
|
||||
.egui_ctx
|
||||
.set_pixels_per_point(window.hidpi_factor().get());
|
||||
|
||||
let widget_surface_fbo = match rendering_context.context_surface_info() {
|
||||
Ok(Some(info)) => NonZeroU32::new(info.framebuffer_object).map(NativeFramebuffer),
|
||||
Ok(None) => panic!("Failed to get widget surface info from surfman!"),
|
||||
|
@ -96,8 +91,12 @@ impl Minibrowser {
|
|||
/// Preprocess the given [winit::event::WindowEvent], returning unconsumed for mouse events in
|
||||
/// the Servo browser rect. This is needed because the CentralPanel we create for our webview
|
||||
/// would otherwise make egui report events in that area as consumed.
|
||||
pub fn on_event(&mut self, event: &winit::event::WindowEvent<'_>) -> EventResponse {
|
||||
let mut result = self.context.on_event(event);
|
||||
pub fn on_window_event(
|
||||
&mut self,
|
||||
window: &winit::window::Window,
|
||||
event: &winit::event::WindowEvent,
|
||||
) -> EventResponse {
|
||||
let mut result = self.context.on_window_event(window, event);
|
||||
result.consumed &= match event {
|
||||
winit::event::WindowEvent::CursorMoved { position, .. } => {
|
||||
let scale = Scale::<_, DeviceIndependentPixel, _>::new(
|
||||
|
|
|
@ -65,7 +65,7 @@ mod from_winit {
|
|||
};
|
||||
}
|
||||
|
||||
impl LogTarget for winit::event::Event<'_, WakerEvent> {
|
||||
impl LogTarget for winit::event::Event<WakerEvent> {
|
||||
fn log_target(&self) -> &'static str {
|
||||
use winit::event::StartCause;
|
||||
match self {
|
||||
|
@ -80,15 +80,14 @@ mod from_winit {
|
|||
Self::UserEvent(WakerEvent) => target!("UserEvent(WakerEvent)"),
|
||||
Self::Suspended => target!("Suspended"),
|
||||
Self::Resumed => target!("Resumed"),
|
||||
Self::MainEventsCleared => target!("MainEventsCleared"),
|
||||
Self::RedrawRequested(..) => target!("RedrawRequested"),
|
||||
Self::RedrawEventsCleared => target!("RedrawEventsCleared"),
|
||||
Self::LoopDestroyed => target!("LoopDestroyed"),
|
||||
Self::AboutToWait => target!("AboutToWait"),
|
||||
Self::LoopExiting => target!("LoopExiting"),
|
||||
Self::MemoryWarning => target!("MemoryWarning"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl LogTarget for winit::event::WindowEvent<'_> {
|
||||
impl LogTarget for winit::event::WindowEvent {
|
||||
fn log_target(&self) -> &'static str {
|
||||
macro_rules! target_variant {
|
||||
($name:literal) => {
|
||||
|
@ -96,6 +95,7 @@ mod from_winit {
|
|||
};
|
||||
}
|
||||
match self {
|
||||
Self::ActivationTokenDone { .. } => target!("ActivationTokenDone"),
|
||||
Self::Resized(..) => target_variant!("Resized"),
|
||||
Self::Moved(..) => target_variant!("Moved"),
|
||||
Self::CloseRequested => target_variant!("CloseRequested"),
|
||||
|
@ -103,7 +103,6 @@ mod from_winit {
|
|||
Self::DroppedFile(..) => target_variant!("DroppedFile"),
|
||||
Self::HoveredFile(..) => target_variant!("HoveredFile"),
|
||||
Self::HoveredFileCancelled => target_variant!("HoveredFileCancelled"),
|
||||
Self::ReceivedCharacter(..) => target_variant!("ReceivedCharacter"),
|
||||
Self::Focused(..) => target_variant!("Focused"),
|
||||
Self::KeyboardInput { .. } => target_variant!("KeyboardInput"),
|
||||
Self::ModifiersChanged(..) => target_variant!("ModifiersChanged"),
|
||||
|
@ -122,6 +121,7 @@ mod from_winit {
|
|||
Self::ScaleFactorChanged { .. } => target_variant!("ScaleFactorChanged"),
|
||||
Self::ThemeChanged(..) => target_variant!("ThemeChanged"),
|
||||
Self::Occluded(..) => target_variant!("Occluded"),
|
||||
Self::RedrawRequested => target!("RedrawRequested"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -477,7 +477,7 @@ where
|
|||
.push(EmbedderEvent::MoveResizeWebView(webview_id, new_rect));
|
||||
}
|
||||
}
|
||||
self.window.set_inner_size(size);
|
||||
self.window.request_inner_size(size);
|
||||
},
|
||||
EmbedderMsg::Prompt(definition, origin) => {
|
||||
let res = if opts::get().headless {
|
||||
|
|
|
@ -34,10 +34,10 @@ pub trait WindowPortsMethods: WindowMethods {
|
|||
) -> Option<Scale<f32, DeviceIndependentPixel, DevicePixel>>;
|
||||
fn page_height(&self) -> f32;
|
||||
fn get_fullscreen(&self) -> bool;
|
||||
fn queue_embedder_events_for_winit_event(&self, event: winit::event::WindowEvent<'_>);
|
||||
fn queue_embedder_events_for_winit_event(&self, event: winit::event::WindowEvent);
|
||||
fn is_animating(&self) -> bool;
|
||||
fn set_title(&self, _title: &str) {}
|
||||
fn set_inner_size(&self, _size: DeviceIntSize);
|
||||
fn request_inner_size(&self, size: DeviceIntSize) -> Option<DeviceIntSize>;
|
||||
fn set_position(&self, _point: DeviceIntPoint) {}
|
||||
fn set_fullscreen(&self, _state: bool) {}
|
||||
fn set_cursor(&self, _cursor: Cursor) {}
|
||||
|
|
|
@ -486,11 +486,6 @@ class CommandBase(object):
|
|||
if platform.is_macos:
|
||||
util.prepend_paths_to_env(env, "DYLD_LIBRARY_PATH", os.path.join(gstreamer_root, "lib"))
|
||||
|
||||
effective_target = self.cross_compile_target or servo.platform.host_triple()
|
||||
if "msvc" in effective_target:
|
||||
# Always build harfbuzz from source
|
||||
env["HARFBUZZ_SYS_NO_PKG_CONFIG"] = "true"
|
||||
|
||||
if sys.platform != "win32":
|
||||
env.setdefault("CC", "clang")
|
||||
env.setdefault("CXX", "clang++")
|
||||
|
@ -615,7 +610,6 @@ class CommandBase(object):
|
|||
env['OBJCOPY'] = to_ndk_bin("llvm-objcopy")
|
||||
env['YASM'] = to_ndk_bin("yasm")
|
||||
env['STRIP'] = to_ndk_bin("llvm-strip")
|
||||
env['HARFBUZZ_SYS_NO_PKG_CONFIG'] = "true"
|
||||
env['RUST_FONTCONFIG_DLOPEN'] = "on"
|
||||
|
||||
env["LIBCLANG_PATH"] = path.join(llvm_toolchain, "lib64")
|
||||
|
|
|
@ -38,7 +38,7 @@ APT_PKGS = [
|
|||
'libharfbuzz-dev', 'liblzma-dev', 'libudev-dev', 'libunwind-dev',
|
||||
'libvulkan1', 'libx11-dev', 'libxcb-render0-dev', 'libxcb-shape0-dev',
|
||||
'libxcb-xfixes0-dev', 'libxmu-dev', 'libxmu6', 'libegl1-mesa-dev',
|
||||
'llvm-dev', 'm4', 'xorg-dev',
|
||||
'llvm-dev', 'm4', 'xorg-dev', 'libxkbcommon0', "libxkbcommon-x11-0"
|
||||
]
|
||||
|
||||
# https://packages.fedoraproject.org
|
||||
|
@ -56,7 +56,8 @@ DNF_PKGS = ['libtool', 'gcc-c++', 'libXi-devel', 'freetype-devel',
|
|||
'gstreamer1-devel', 'gstreamer1-plugins-base-devel',
|
||||
'gstreamer1-plugins-good', 'gstreamer1-plugins-bad-free-devel',
|
||||
'gstreamer1-plugins-ugly-free', 'libjpeg-turbo-devel',
|
||||
'zlib', 'libjpeg', 'vulkan-loader']
|
||||
'zlib', 'libjpeg', 'vulkan-loader', 'libxkbcommon',
|
||||
'libxkbcommon-x11']
|
||||
|
||||
# https://voidlinux.org/packages/
|
||||
# 1. open devtools
|
||||
|
@ -71,7 +72,8 @@ XBPS_PKGS = ['libtool', 'gcc', 'libXi-devel', 'freetype-devel',
|
|||
'ncurses-devel', 'harfbuzz-devel', 'ccache', 'glu-devel',
|
||||
'clang', 'gstreamer1-devel', 'gst-plugins-base1-devel',
|
||||
'gst-plugins-good1', 'gst-plugins-bad1-devel',
|
||||
'gst-plugins-ugly1', 'vulkan-loader']
|
||||
'gst-plugins-ugly1', 'vulkan-loader', 'libxkbcommon',
|
||||
'libxkbcommon-x11']
|
||||
|
||||
GSTREAMER_URL = \
|
||||
"https://github.com/servo/servo-build-deps/releases/download/linux/gstreamer-1.16-x86_64-linux-gnu.20190515.tar.gz"
|
||||
|
|
|
@ -34,10 +34,10 @@ packages = [
|
|||
|
||||
# New versions of these dependencies is pulled in by GStreamer / GLib.
|
||||
"itertools",
|
||||
"proc-macro-crate",
|
||||
"toml",
|
||||
|
||||
# Duplicated by winit.
|
||||
"jni",
|
||||
"windows-sys",
|
||||
"windows-targets",
|
||||
"windows_aarch64_gnullvm",
|
||||
|
@ -52,7 +52,6 @@ packages = [
|
|||
"foreign-types",
|
||||
"foreign-types-shared",
|
||||
"metal",
|
||||
"raw-window-handle",
|
||||
|
||||
# Duplicated by indexmap.
|
||||
"hashbrown",
|
||||
|
@ -68,10 +67,6 @@ packages = [
|
|||
"phf",
|
||||
"phf_generator",
|
||||
"phf_shared",
|
||||
|
||||
# These can be removed once winit, font-kit, etc are upgraded
|
||||
"core-graphics",
|
||||
"core-text",
|
||||
]
|
||||
# Files that are ignored for all tidy and lint checks.
|
||||
files = [
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
[shaping-023-ref.html]
|
||||
expected: FAIL
|
|
@ -1,2 +0,0 @@
|
|||
[shaping-023-ref.html]
|
||||
expected: FAIL
|
Loading…
Add table
Add a link
Reference in a new issue