Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split out Surface from Window #3942

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ece7569
split surface from window, linux impl
jgcodes2020 Oct 9, 2024
6148318
cargo format
jgcodes2020 Oct 9, 2024
cb8e03d
fix docs
jgcodes2020 Oct 9, 2024
9e0955c
fix docs for real this time
jgcodes2020 Oct 9, 2024
9174c7f
actually fix docs
jgcodes2020 Oct 9, 2024
3f83bbb
fix some stupid edits
jgcodes2020 Oct 9, 2024
240486a
move handles and monitor methods to Surface
jgcodes2020 Oct 12, 2024
12fb98a
Downcasting (linux impl)
jgcodes2020 Oct 12, 2024
4f5f6fe
doc fix
jgcodes2020 Oct 12, 2024
4a39a87
Rename WindowId and WindowEvent to SurfaceId and SurfaceEvent
jgcodes2020 Oct 12, 2024
190633b
port web backend names
jgcodes2020 Oct 13, 2024
bc10ce9
Rename enum variant to SurfaceEvent, fix Windows
jgcodes2020 Oct 18, 2024
07cfc01
Fix Linux and Web platforms
jgcodes2020 Oct 18, 2024
dde143b
Add changelog entry
jgcodes2020 Oct 18, 2024
44d205d
implement as_window for Web window
jgcodes2020 Oct 19, 2024
c5efc69
implement Android
jgcodes2020 Oct 21, 2024
f47c3f1
fix SurfaceId on Android
jgcodes2020 Oct 21, 2024
9b34bc5
fix SurfaceId on Android
jgcodes2020 Oct 21, 2024
1428596
try to fix apple and orbital
jgcodes2020 Oct 22, 2024
ae1d413
do impl split for apple and orbital
jgcodes2020 Oct 22, 2024
de71fd5
try to fix impl split for apple and orbital
jgcodes2020 Oct 22, 2024
970f05d
small fixes to get everything to pass CI
jgcodes2020 Oct 22, 2024
1301ea1
even more fixes to pass CI
jgcodes2020 Oct 23, 2024
0e1234d
Merge branch 'master' into window-surface-split
jgcodes2020 Oct 23, 2024
f704c68
post-merge fixes
jgcodes2020 Oct 23, 2024
ac97e65
remove a few remaining instances of WindowId
jgcodes2020 Oct 23, 2024
918ddf6
cargo fmt
jgcodes2020 Oct 23, 2024
a88dac3
improve changelog entry
jgcodes2020 Oct 23, 2024
ddde870
cargo +nightly fmt
jgcodes2020 Oct 24, 2024
be6b958
mark the renaming types stuff as breaking in the changelog
jgcodes2020 Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
try to fix impl split for apple and orbital
  • Loading branch information
jgcodes2020 committed Oct 22, 2024
commit de71fd5697f73730c5b0cda6344dbe6f8b8b04de
44 changes: 22 additions & 22 deletions src/platform_impl/apple/appkit/window.rs
Original file line number Diff line number Diff line change
@@ -141,12 +141,32 @@ impl CoreSurface for Window {
}

#[cfg(feature = "rwh_06")]
fn rwh_06_display_handle(&self) -> &dyn rwh_06::HasDisplayHandle {
fn rwh_06_window_handle(&self) -> &dyn rwh_06::HasWindowHandle {
self
}

fn current_monitor(&self) -> Option<CoreMonitorHandle> {
self.maybe_wait_on_main(|delegate| {
delegate.current_monitor().map(|inner| CoreMonitorHandle { inner })
})
}

fn available_monitors(&self) -> Box<dyn Iterator<Item = CoreMonitorHandle>> {
self.maybe_wait_on_main(|delegate| {
Box::new(
delegate.available_monitors().into_iter().map(|inner| CoreMonitorHandle { inner }),
)
})
}

fn primary_monitor(&self) -> Option<CoreMonitorHandle> {
self.maybe_wait_on_main(|delegate| {
delegate.primary_monitor().map(|inner| CoreMonitorHandle { inner })
})
}

#[cfg(feature = "rwh_06")]
fn rwh_06_window_handle(&self) -> &dyn rwh_06::HasWindowHandle {
fn rwh_06_display_handle(&self) -> &dyn rwh_06::HasDisplayHandle {
self
}
}
@@ -314,26 +334,6 @@ impl CoreWindow for Window {
fn show_window_menu(&self, position: Position) {
self.maybe_wait_on_main(|delegate| delegate.show_window_menu(position))
}

fn current_monitor(&self) -> Option<CoreMonitorHandle> {
self.maybe_wait_on_main(|delegate| {
delegate.current_monitor().map(|inner| CoreMonitorHandle { inner })
})
}

fn available_monitors(&self) -> Box<dyn Iterator<Item = CoreMonitorHandle>> {
self.maybe_wait_on_main(|delegate| {
Box::new(
delegate.available_monitors().into_iter().map(|inner| CoreMonitorHandle { inner }),
)
})
}

fn primary_monitor(&self) -> Option<CoreMonitorHandle> {
self.maybe_wait_on_main(|delegate| {
delegate.primary_monitor().map(|inner| CoreMonitorHandle { inner })
})
}
}

declare_class!(
40 changes: 20 additions & 20 deletions src/platform_impl/apple/uikit/window.rs
Original file line number Diff line number Diff line change
@@ -632,6 +632,26 @@ impl CoreSurface for Window {
Ok(self.maybe_wait_on_main(|delegate| delegate.set_cursor_hittest(hittest))?)
}

fn current_monitor(&self) -> Option<CoreMonitorHandle> {
self.maybe_wait_on_main(|delegate| {
delegate.current_monitor().map(|inner| CoreMonitorHandle { inner })
})
}

fn available_monitors(&self) -> Box<dyn Iterator<Item = CoreMonitorHandle>> {
self.maybe_wait_on_main(|delegate| {
Box::new(
delegate.available_monitors().into_iter().map(|inner| CoreMonitorHandle { inner }),
)
})
}

fn primary_monitor(&self) -> Option<CoreMonitorHandle> {
self.maybe_wait_on_main(|delegate| {
delegate.primary_monitor().map(|inner| CoreMonitorHandle { inner })
})
}

#[cfg(feature = "rwh_06")]
fn rwh_06_display_handle(&self) -> &dyn rwh_06::HasDisplayHandle {
self
@@ -807,26 +827,6 @@ impl CoreWindow for Window {
fn show_window_menu(&self, position: Position) {
self.maybe_wait_on_main(|delegate| delegate.show_window_menu(position))
}

fn current_monitor(&self) -> Option<CoreMonitorHandle> {
self.maybe_wait_on_main(|delegate| {
delegate.current_monitor().map(|inner| CoreMonitorHandle { inner })
})
}

fn available_monitors(&self) -> Box<dyn Iterator<Item = CoreMonitorHandle>> {
self.maybe_wait_on_main(|delegate| {
Box::new(
delegate.available_monitors().into_iter().map(|inner| CoreMonitorHandle { inner }),
)
})
}

fn primary_monitor(&self) -> Option<CoreMonitorHandle> {
self.maybe_wait_on_main(|delegate| {
delegate.primary_monitor().map(|inner| CoreMonitorHandle { inner })
})
}
}

// WindowExtIOS
80 changes: 40 additions & 40 deletions src/platform_impl/orbital/window.rs
Original file line number Diff line number Diff line change
@@ -194,22 +194,38 @@ impl CoreSurface for Window {
}

#[inline]
fn set_cursor_hittest(&self, _hittest: bool) -> Result<(), RequestError> {
Err(NotSupportedError::new("set_cursor_hittest is not supported").into())
fn set_cursor(&self, _: Cursor) {}

#[inline]
fn set_cursor_position(&self, _: Position) -> Result<(), RequestError> {
Err(NotSupportedError::new("set_cursor_position is not supported").into())
}

#[cfg(feature = "rwh_06")]
fn rwh_06_window_handle(&self) -> &dyn rwh_06::HasWindowHandle {
self

#[inline]
fn set_cursor_grab(&self, mode: window::CursorGrabMode) -> Result<(), RequestError> {
let (grab, relative) = match mode {
window::CursorGrabMode::None => (false, false),
window::CursorGrabMode::Confined => (true, false),
window::CursorGrabMode::Locked => (true, true),
};
self.window_socket
.write(format!("M,G,{}", if grab { 1 } else { 0 }).as_bytes())
.map_err(|err| os_error!(format!("{err}")))?;
self.window_socket
.write(format!("M,R,{}", if relative { 1 } else { 0 }).as_bytes())
.map_err(|err| os_error!(format!("{err}")))?;
Ok(())
}

#[cfg(feature = "rwh_06")]
fn rwh_06_display_handle(&self) -> &dyn rwh_06::HasDisplayHandle {
self
#[inline]
fn set_cursor_visible(&self, visible: bool) {
let _ = self.window_socket.write(format!("M,C,{}", if visible { 1 } else { 0 }).as_bytes());
}
}

impl CoreWindow for Window {
#[inline]
fn set_cursor_hittest(&self, _hittest: bool) -> Result<(), RequestError> {
Err(NotSupportedError::new("set_cursor_hittest is not supported").into())
}

#[inline]
fn primary_monitor(&self) -> Option<CoreMonitorHandle> {
@@ -225,6 +241,19 @@ impl CoreWindow for Window {
fn current_monitor(&self) -> Option<CoreMonitorHandle> {
Some(CoreMonitorHandle { inner: MonitorHandle })
}

#[cfg(feature = "rwh_06")]
fn rwh_06_window_handle(&self) -> &dyn rwh_06::HasWindowHandle {
self
}

#[cfg(feature = "rwh_06")]
fn rwh_06_display_handle(&self) -> &dyn rwh_06::HasDisplayHandle {
self
}
}

impl CoreWindow for Window {

#[inline]
fn reset_dead_keys(&self) {
@@ -381,35 +410,6 @@ impl CoreWindow for Window {
#[inline]
fn request_user_attention(&self, _request_type: Option<window::UserAttentionType>) {}

#[inline]
fn set_cursor(&self, _: Cursor) {}

#[inline]
fn set_cursor_position(&self, _: Position) -> Result<(), RequestError> {
Err(NotSupportedError::new("set_cursor_position is not supported").into())
}

#[inline]
fn set_cursor_grab(&self, mode: window::CursorGrabMode) -> Result<(), RequestError> {
let (grab, relative) = match mode {
window::CursorGrabMode::None => (false, false),
window::CursorGrabMode::Confined => (true, false),
window::CursorGrabMode::Locked => (true, true),
};
self.window_socket
.write(format!("M,G,{}", if grab { 1 } else { 0 }).as_bytes())
.map_err(|err| os_error!(format!("{err}")))?;
self.window_socket
.write(format!("M,R,{}", if relative { 1 } else { 0 }).as_bytes())
.map_err(|err| os_error!(format!("{err}")))?;
Ok(())
}

#[inline]
fn set_cursor_visible(&self, visible: bool) {
let _ = self.window_socket.write(format!("M,C,{}", if visible { 1 } else { 0 }).as_bytes());
}

#[inline]
fn drag_window(&self) -> Result<(), RequestError> {
self.window_socket.write(b"D").map_err(|err| os_error!(format!("{err}")))?;
Loading