Skip to content

Commit 1428596

Browse files
committed
try to fix apple and orbital
1 parent 9b34bc5 commit 1428596

File tree

9 files changed

+121
-121
lines changed

9 files changed

+121
-121
lines changed

src/platform_impl/apple/appkit/app_state.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ use super::event_loop::{stop_app_immediately, ActiveEventLoop, PanicInfo};
1313
use super::menu;
1414
use super::observer::{EventLoopWaker, RunLoop};
1515
use crate::application::ApplicationHandler;
16-
use crate::event::{StartCause, WindowEvent};
16+
use crate::event::{StartCause, SurfaceEvent};
1717
use crate::event_loop::ControlFlow;
18-
use crate::window::WindowId;
18+
use crate::window::SurfaceId;
1919

2020
#[derive(Debug)]
2121
pub(super) struct AppState {
@@ -40,7 +40,7 @@ pub(super) struct AppState {
4040
waker: RefCell<EventLoopWaker>,
4141
start_time: Cell<Option<Instant>>,
4242
wait_timeout: Cell<Option<Instant>>,
43-
pending_redraw: RefCell<Vec<WindowId>>,
43+
pending_redraw: RefCell<Vec<SurfaceId>>,
4444
// NOTE: This is strongly referenced by our `NSWindowDelegate` and our `NSView` subclass, and
4545
// as such should be careful to not add fields that, in turn, strongly reference those.
4646
}
@@ -240,12 +240,12 @@ impl AppState {
240240
self.control_flow.get()
241241
}
242242

243-
pub fn handle_redraw(self: &Rc<Self>, window_id: WindowId) {
243+
pub fn handle_redraw(self: &Rc<Self>, window_id: SurfaceId) {
244244
// Redraw request might come out of order from the OS.
245245
// -> Don't go back into the event handler when our callstack originates from there
246246
if !self.event_handler.in_use() {
247247
self.with_handler(|app, event_loop| {
248-
app.window_event(event_loop, window_id, WindowEvent::RedrawRequested);
248+
app.window_event(event_loop, window_id, SurfaceEvent::RedrawRequested);
249249
});
250250

251251
// `pump_events` will request to stop immediately _after_ dispatching RedrawRequested
@@ -258,7 +258,7 @@ impl AppState {
258258
}
259259
}
260260

261-
pub fn queue_redraw(&self, window_id: WindowId) {
261+
pub fn queue_redraw(&self, window_id: SurfaceId) {
262262
let mut pending_redraw = self.pending_redraw.borrow_mut();
263263
if !pending_redraw.contains(&window_id) {
264264
pending_redraw.push(window_id);
@@ -357,7 +357,7 @@ impl AppState {
357357
let redraw = mem::take(&mut *self.pending_redraw.borrow_mut());
358358
for window_id in redraw {
359359
self.with_handler(|app, event_loop| {
360-
app.window_event(event_loop, window_id, WindowEvent::RedrawRequested);
360+
app.window_event(event_loop, window_id, SurfaceEvent::RedrawRequested);
361361
});
362362
}
363363
self.with_handler(|app, event_loop| {

src/platform_impl/apple/appkit/view.rs

+28-28
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use super::window::WinitWindow;
2727
use crate::dpi::{LogicalPosition, LogicalSize};
2828
use crate::event::{
2929
DeviceEvent, ElementState, Ime, Modifiers, MouseButton, MouseScrollDelta, PointerKind,
30-
PointerSource, TouchPhase, WindowEvent,
30+
PointerSource, TouchPhase, SurfaceEvent,
3131
};
3232
use crate::keyboard::{Key, KeyCode, KeyLocation, ModifiersState, NamedKey};
3333
use crate::platform::macos::OptionAsAlt;
@@ -196,7 +196,7 @@ declare_class!(
196196
// 2. Even when a window resize does occur on a new tabbed window, it contains the wrong size (includes tab height).
197197
let logical_size = LogicalSize::new(rect.size.width as f64, rect.size.height as f64);
198198
let size = logical_size.to_physical::<u32>(self.scale_factor());
199-
self.queue_event(WindowEvent::SurfaceResized(size));
199+
self.queue_event(SurfaceEvent::SurfaceResized(size));
200200
}
201201

202202
#[method(drawRect:)]
@@ -301,7 +301,7 @@ declare_class!(
301301
// Notify IME is active if application still doesn't know it.
302302
if self.ivars().ime_state.get() == ImeState::Disabled {
303303
*self.ivars().input_source.borrow_mut() = self.current_input_source();
304-
self.queue_event(WindowEvent::Ime(Ime::Enabled));
304+
self.queue_event(SurfaceEvent::Ime(Ime::Enabled));
305305
}
306306

307307
if unsafe { self.hasMarkedText() } {
@@ -324,8 +324,8 @@ declare_class!(
324324
Some((lowerbound_utf8, upperbound_utf8))
325325
};
326326

327-
// Send WindowEvent for updating marked text
328-
self.queue_event(WindowEvent::Ime(Ime::Preedit(string.to_string(), cursor_range)));
327+
// Send SurfaceEvent for updating marked text
328+
self.queue_event(SurfaceEvent::Ime(Ime::Preedit(string.to_string(), cursor_range)));
329329
}
330330

331331
#[method(unmarkText)]
@@ -336,7 +336,7 @@ declare_class!(
336336
let input_context = self.inputContext().expect("input context");
337337
input_context.discardMarkedText();
338338

339-
self.queue_event(WindowEvent::Ime(Ime::Preedit(String::new(), None)));
339+
self.queue_event(SurfaceEvent::Ime(Ime::Preedit(String::new(), None)));
340340
if self.is_ime_enabled() {
341341
// Leave the Preedit self.ivars()
342342
self.ivars().ime_state.set(ImeState::Ground);
@@ -403,8 +403,8 @@ declare_class!(
403403

404404
// Commit only if we have marked text.
405405
if unsafe { self.hasMarkedText() } && self.is_ime_enabled() && !is_control {
406-
self.queue_event(WindowEvent::Ime(Ime::Preedit(String::new(), None)));
407-
self.queue_event(WindowEvent::Ime(Ime::Commit(string)));
406+
self.queue_event(SurfaceEvent::Ime(Ime::Preedit(String::new(), None)));
407+
self.queue_event(SurfaceEvent::Ime(Ime::Commit(string)));
408408
self.ivars().ime_state.set(ImeState::Committed);
409409
}
410410
}
@@ -442,7 +442,7 @@ declare_class!(
442442
*prev_input_source = current_input_source;
443443
drop(prev_input_source);
444444
self.ivars().ime_state.set(ImeState::Disabled);
445-
self.queue_event(WindowEvent::Ime(Ime::Disabled));
445+
self.queue_event(SurfaceEvent::Ime(Ime::Disabled));
446446
}
447447
}
448448

@@ -483,7 +483,7 @@ declare_class!(
483483

484484
if !had_ime_input || self.ivars().forward_key_to_app.get() {
485485
let key_event = create_key_event(&event, true, unsafe { event.isARepeat() }, None);
486-
self.queue_event(WindowEvent::KeyboardInput {
486+
self.queue_event(SurfaceEvent::KeyboardInput {
487487
device_id: None,
488488
event: key_event,
489489
is_synthetic: false,
@@ -503,7 +503,7 @@ declare_class!(
503503
self.ivars().ime_state.get(),
504504
ImeState::Ground | ImeState::Disabled
505505
) {
506-
self.queue_event(WindowEvent::KeyboardInput {
506+
self.queue_event(SurfaceEvent::KeyboardInput {
507507
device_id: None,
508508
event: create_key_event(&event, false, false, None),
509509
is_synthetic: false,
@@ -554,7 +554,7 @@ declare_class!(
554554
self.update_modifiers(&event, false);
555555
let event = create_key_event(&event, true, unsafe { event.isARepeat() }, None);
556556

557-
self.queue_event(WindowEvent::KeyboardInput {
557+
self.queue_event(SurfaceEvent::KeyboardInput {
558558
device_id: None,
559559
event,
560560
is_synthetic: false,
@@ -642,7 +642,7 @@ declare_class!(
642642

643643
let position = self.mouse_view_point(event).to_physical(self.scale_factor());
644644

645-
self.queue_event(WindowEvent::PointerEntered {
645+
self.queue_event(SurfaceEvent::PointerEntered {
646646
device_id: None,
647647
position,
648648
kind: PointerKind::Mouse,
@@ -655,7 +655,7 @@ declare_class!(
655655

656656
let position = self.mouse_view_point(event).to_physical(self.scale_factor());
657657

658-
self.queue_event(WindowEvent::PointerLeft {
658+
self.queue_event(SurfaceEvent::PointerLeft {
659659
device_id: None,
660660
position: Some(position),
661661
kind: PointerKind::Mouse,
@@ -698,7 +698,7 @@ declare_class!(
698698
self.ivars().app_state.maybe_queue_with_handler(move |app, event_loop|
699699
app.device_event(event_loop, None, DeviceEvent::MouseWheel { delta })
700700
);
701-
self.queue_event(WindowEvent::MouseWheel {
701+
self.queue_event(SurfaceEvent::MouseWheel {
702702
device_id: None,
703703
delta,
704704
phase,
@@ -720,7 +720,7 @@ declare_class!(
720720
_ => return,
721721
};
722722

723-
self.queue_event(WindowEvent::PinchGesture {
723+
self.queue_event(SurfaceEvent::PinchGesture {
724724
device_id: None,
725725
delta: unsafe { event.magnification() },
726726
phase,
@@ -733,7 +733,7 @@ declare_class!(
733733

734734
self.mouse_motion(event);
735735

736-
self.queue_event(WindowEvent::DoubleTapGesture {
736+
self.queue_event(SurfaceEvent::DoubleTapGesture {
737737
device_id: None,
738738
});
739739
}
@@ -753,7 +753,7 @@ declare_class!(
753753
_ => return,
754754
};
755755

756-
self.queue_event(WindowEvent::RotationGesture {
756+
self.queue_event(SurfaceEvent::RotationGesture {
757757
device_id: None,
758758
delta: unsafe { event.rotation() },
759759
phase,
@@ -764,7 +764,7 @@ declare_class!(
764764
fn pressure_change_with_event(&self, event: &NSEvent) {
765765
trace_scope!("pressureChangeWithEvent:");
766766

767-
self.queue_event(WindowEvent::TouchpadPressure {
767+
self.queue_event(SurfaceEvent::TouchpadPressure {
768768
device_id: None,
769769
pressure: unsafe { event.pressure() },
770770
stage: unsafe { event.stage() } as i64,
@@ -840,7 +840,7 @@ impl WinitView {
840840
self.ivars()._ns_window.load().expect("view to have a window")
841841
}
842842

843-
fn queue_event(&self, event: WindowEvent) {
843+
fn queue_event(&self, event: SurfaceEvent) {
844844
let window_id = self.window().id();
845845
self.ivars().app_state.maybe_queue_with_handler(move |app, event_loop| {
846846
app.window_event(event_loop, window_id, event);
@@ -899,7 +899,7 @@ impl WinitView {
899899

900900
if self.ivars().ime_state.get() != ImeState::Disabled {
901901
self.ivars().ime_state.set(ImeState::Disabled);
902-
self.queue_event(WindowEvent::Ime(Ime::Disabled));
902+
self.queue_event(SurfaceEvent::Ime(Ime::Disabled));
903903
}
904904
}
905905

@@ -914,7 +914,7 @@ impl WinitView {
914914
pub(super) fn reset_modifiers(&self) {
915915
if !self.ivars().modifiers.get().state().is_empty() {
916916
self.ivars().modifiers.set(Modifiers::default());
917-
self.queue_event(WindowEvent::ModifiersChanged(self.ivars().modifiers.get()));
917+
self.queue_event(SurfaceEvent::ModifiersChanged(self.ivars().modifiers.get()));
918918
}
919919
}
920920

@@ -978,7 +978,7 @@ impl WinitView {
978978
let mut event = event.clone();
979979
event.location = KeyLocation::Left;
980980
event.physical_key = get_left_modifier_code(&event.logical_key).into();
981-
events.push_back(WindowEvent::KeyboardInput {
981+
events.push_back(SurfaceEvent::KeyboardInput {
982982
device_id: None,
983983
event,
984984
is_synthetic: false,
@@ -987,7 +987,7 @@ impl WinitView {
987987
if phys_mod.contains(ModLocationMask::RIGHT) {
988988
event.location = KeyLocation::Right;
989989
event.physical_key = get_right_modifier_code(&event.logical_key).into();
990-
events.push_back(WindowEvent::KeyboardInput {
990+
events.push_back(SurfaceEvent::KeyboardInput {
991991
device_id: None,
992992
event,
993993
is_synthetic: false,
@@ -1018,7 +1018,7 @@ impl WinitView {
10181018
event.state = if is_pressed { Pressed } else { Released };
10191019
}
10201020

1021-
events.push_back(WindowEvent::KeyboardInput {
1021+
events.push_back(SurfaceEvent::KeyboardInput {
10221022
device_id: None,
10231023
event,
10241024
is_synthetic: false,
@@ -1037,7 +1037,7 @@ impl WinitView {
10371037
return;
10381038
}
10391039

1040-
self.queue_event(WindowEvent::ModifiersChanged(self.ivars().modifiers.get()));
1040+
self.queue_event(SurfaceEvent::ModifiersChanged(self.ivars().modifiers.get()));
10411041
}
10421042

10431043
fn mouse_click(&self, event: &NSEvent, button_state: ElementState) {
@@ -1046,7 +1046,7 @@ impl WinitView {
10461046

10471047
self.update_modifiers(event, false);
10481048

1049-
self.queue_event(WindowEvent::PointerButton {
1049+
self.queue_event(SurfaceEvent::PointerButton {
10501050
device_id: None,
10511051
state: button_state,
10521052
position,
@@ -1072,7 +1072,7 @@ impl WinitView {
10721072

10731073
self.update_modifiers(event, false);
10741074

1075-
self.queue_event(WindowEvent::PointerMoved {
1075+
self.queue_event(SurfaceEvent::PointerMoved {
10761076
device_id: None,
10771077
position: view_point.to_physical(self.scale_factor()),
10781078
source: PointerSource::Mouse,

src/platform_impl/apple/appkit/window.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::error::RequestError;
1212
use crate::monitor::MonitorHandle as CoreMonitorHandle;
1313
use crate::window::{
1414
Cursor, Fullscreen, Icon, ImePurpose, Theme, UserAttentionType, Window as CoreWindow,
15-
WindowAttributes, WindowButtons, WindowId, WindowLevel,
15+
WindowAttributes, WindowButtons, SurfaceId, WindowLevel,
1616
};
1717

1818
pub(crate) struct Window {
@@ -91,7 +91,7 @@ impl rwh_06::HasWindowHandle for Window {
9191
}
9292

9393
impl CoreWindow for Window {
94-
fn id(&self) -> crate::window::WindowId {
94+
fn id(&self) -> crate::window::SurfaceId {
9595
self.maybe_wait_on_main(|delegate| delegate.id())
9696
}
9797

@@ -363,7 +363,7 @@ declare_class!(
363363
);
364364

365365
impl WinitWindow {
366-
pub(super) fn id(&self) -> WindowId {
367-
WindowId::from_raw(self as *const Self as usize)
366+
pub(super) fn id(&self) -> SurfaceId {
367+
SurfaceId::from_raw(self as *const Self as usize)
368368
}
369369
}

0 commit comments

Comments
 (0)