Skip to content

Commit 1860fe0

Browse files
authored
Merge branch 'master' into apple-standard-events
2 parents 3c109bd + b674d20 commit 1860fe0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1011
-1053
lines changed

examples/child_window.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn main() -> Result<(), impl std::error::Error> {
2424
let attributes = WindowAttributes::default()
2525
.with_title("parent window")
2626
.with_position(Position::Logical(LogicalPosition::new(0.0, 0.0)))
27-
.with_inner_size(LogicalSize::new(640.0f32, 480.0f32));
27+
.with_surface_size(LogicalSize::new(640.0f32, 480.0f32));
2828
let window = event_loop.create_window(attributes).unwrap();
2929

3030
println!("Parent window id: {:?})", window.id());
@@ -79,7 +79,7 @@ fn main() -> Result<(), impl std::error::Error> {
7979
let parent = parent.raw_window_handle().unwrap();
8080
let mut window_attributes = WindowAttributes::default()
8181
.with_title("child window")
82-
.with_inner_size(LogicalSize::new(200.0f32, 200.0f32))
82+
.with_surface_size(LogicalSize::new(200.0f32, 200.0f32))
8383
.with_position(Position::Logical(LogicalPosition::new(0.0, 0.0)))
8484
.with_visible(true);
8585
// `with_parent_window` is unsafe. Parent window must be a valid window.

examples/run_on_demand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
3131
fn can_create_surfaces(&mut self, event_loop: &dyn ActiveEventLoop) {
3232
let window_attributes = WindowAttributes::default()
3333
.with_title("Fantastic window number one!")
34-
.with_inner_size(winit::dpi::LogicalSize::new(128.0, 128.0));
34+
.with_surface_size(winit::dpi::LogicalSize::new(128.0, 128.0));
3535
let window = event_loop.create_window(window_attributes).unwrap();
3636
self.window_id = Some(window.id());
3737
self.window = Some(window);

examples/util/fill.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ mod platform {
7272

7373
pub fn fill_window(window: &dyn Window) {
7474
GC.with(|gc| {
75-
let size = window.inner_size();
75+
let size = window.surface_size();
7676
let (Some(width), Some(height)) =
7777
(NonZeroU32::new(size.width), NonZeroU32::new(size.height))
7878
else {

examples/window.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rwh_06::{DisplayHandle, HasDisplayHandle};
1717
use softbuffer::{Context, Surface};
1818
use winit::application::ApplicationHandler;
1919
use winit::dpi::{LogicalSize, PhysicalPosition, PhysicalSize};
20-
use winit::error::ExternalError;
20+
use winit::error::RequestError;
2121
use winit::event::{DeviceEvent, DeviceId, Ime, MouseButton, MouseScrollDelta, WindowEvent};
2222
use winit::event_loop::{ActiveEventLoop, EventLoop};
2323
use winit::keyboard::{Key, ModifiersState};
@@ -78,7 +78,7 @@ struct Application {
7878
receiver: Receiver<Action>,
7979
sender: Sender<Action>,
8080
/// Custom cursors assets.
81-
custom_cursors: Result<Vec<CustomCursor>, ExternalError>,
81+
custom_cursors: Result<Vec<CustomCursor>, RequestError>,
8282
/// Application icon.
8383
icon: Icon,
8484
windows: HashMap<WindowId, WindowState>,
@@ -391,7 +391,7 @@ impl ApplicationHandler for Application {
391391
};
392392

393393
match event {
394-
WindowEvent::Resized(size) => {
394+
WindowEvent::SurfaceResized(size) => {
395395
window.resize(size);
396396
},
397397
WindowEvent::Focused(focused) => {
@@ -626,7 +626,7 @@ impl WindowState {
626626
let ime = true;
627627
window.set_ime_allowed(ime);
628628

629-
let size = window.inner_size();
629+
let size = window.surface_size();
630630
let mut state = Self {
631631
#[cfg(macos_platform)]
632632
option_as_alt: window.option_as_alt(),
@@ -700,12 +700,12 @@ impl WindowState {
700700

701701
/// Toggle resize increments on a window.
702702
fn toggle_resize_increments(&mut self) {
703-
let new_increments = match self.window.resize_increments() {
703+
let new_increments = match self.window.surface_resize_increments() {
704704
Some(_) => None,
705705
None => Some(LogicalSize::new(25.0, 25.0).into()),
706706
};
707707
info!("Had increments: {}", new_increments.is_none());
708-
self.window.set_resize_increments(new_increments);
708+
self.window.set_surface_resize_increments(new_increments);
709709
}
710710

711711
/// Toggle fullscreen.
@@ -744,22 +744,22 @@ impl WindowState {
744744
self.window.set_option_as_alt(self.option_as_alt);
745745
}
746746

747-
/// Swap the window dimensions with `request_inner_size`.
747+
/// Swap the window dimensions with `request_surface_size`.
748748
fn swap_dimensions(&mut self) {
749-
let old_inner_size = self.window.inner_size();
750-
let mut inner_size = old_inner_size;
749+
let old_surface_size = self.window.surface_size();
750+
let mut surface_size = old_surface_size;
751751

752-
mem::swap(&mut inner_size.width, &mut inner_size.height);
753-
info!("Requesting resize from {old_inner_size:?} to {inner_size:?}");
752+
mem::swap(&mut surface_size.width, &mut surface_size.height);
753+
info!("Requesting resize from {old_surface_size:?} to {surface_size:?}");
754754

755-
if let Some(new_inner_size) = self.window.request_inner_size(inner_size.into()) {
756-
if old_inner_size == new_inner_size {
755+
if let Some(new_surface_size) = self.window.request_surface_size(surface_size.into()) {
756+
if old_surface_size == new_surface_size {
757757
info!("Inner size change got ignored");
758758
} else {
759-
self.resize(new_inner_size);
759+
self.resize(new_surface_size);
760760
}
761761
} else {
762-
info!("Request inner size is asynchronous");
762+
info!("Requesting surface size is asynchronous");
763763
}
764764
}
765765

@@ -812,9 +812,9 @@ impl WindowState {
812812
Ok(())
813813
}
814814

815-
/// Resize the window to the new size.
815+
/// Resize the surface to the new size.
816816
fn resize(&mut self, size: PhysicalSize<u32>) {
817-
info!("Resized to {size:?}");
817+
info!("Surface resized to {size:?}");
818818
#[cfg(not(any(android_platform, ios_platform)))]
819819
{
820820
let (width, height) = match (NonZeroU32::new(size.width), NonZeroU32::new(size.height))
@@ -859,7 +859,7 @@ impl WindowState {
859859
},
860860
};
861861

862-
let win_size = self.window.inner_size();
862+
let win_size = self.window.surface_size();
863863
let border_size = BORDER_SIZE * self.window.scale_factor();
864864

865865
let x_direction = if position.x < border_size {

examples/x11_embed.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn main() -> Result<(), Box<dyn Error>> {
2121
fn can_create_surfaces(&mut self, event_loop: &dyn ActiveEventLoop) {
2222
let window_attributes = WindowAttributes::default()
2323
.with_title("An embedded window!")
24-
.with_inner_size(winit::dpi::LogicalSize::new(128.0, 128.0))
24+
.with_surface_size(winit::dpi::LogicalSize::new(128.0, 128.0))
2525
.with_embed_parent_window(self.parent_window_id);
2626

2727
self.window = Some(event_loop.create_window(window_attributes).unwrap());

src/changelog/unreleased.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ changelog entry.
6464
- Add `MonitorHandle::current_video_mode()`.
6565
- Add basic iOS IME support. The soft keyboard can now be shown using `Window::set_ime_allowed`.
6666
- Add `WindowEvent::AppleStandardKeyBindingAction`. This can be used to implement standard behaviours such as "go to end of line" on macOS.
67+
- On macOS, add `WindowExtMacOS::set_borderless_game` and `WindowAttributesExtMacOS::with_borderless_game`
68+
to fully disable the menu bar and dock in Borderless Fullscreen as commonly done in games.
6769

6870
### Changed
6971

@@ -106,6 +108,23 @@ changelog entry.
106108
- On iOS, no longer act as-if the application successfully open all URLs. Override
107109
`application:didFinishLaunchingWithOptions:` and provide the desired behaviour yourself.
108110
- On X11, remove our dependency on libXcursor. (#3749)
111+
- Renamed the following APIs to make it clearer that the sizes apply to the underlying surface:
112+
- `WindowEvent::Resized` to `SurfaceResized`.
113+
- `InnerSizeWriter` to `SurfaceSizeWriter`.
114+
- `WindowAttributes.inner_size` to `surface_size`.
115+
- `WindowAttributes.min_inner_size` to `min_surface_size`.
116+
- `WindowAttributes.max_inner_size` to `max_surface_size`.
117+
- `WindowAttributes.resize_increments` to `surface_resize_increments`.
118+
- `WindowAttributes::with_inner_size` to `with_surface_size`.
119+
- `WindowAttributes::with_min_inner_size` to `with_min_surface_size`.
120+
- `WindowAttributes::with_max_inner_size` to `with_max_surface_size`.
121+
- `WindowAttributes::with_resize_increments` to `with_surface_resize_increments`.
122+
- `Window::inner_size` to `surface_size`.
123+
- `Window::request_inner_size` to `request_surface_size`.
124+
- `Window::set_min_inner_size` to `set_min_surface_size`.
125+
- `Window::set_max_inner_size` to `set_max_surface_size`.
126+
127+
To migrate, you can probably just replace all instances of `inner_size` with `surface_size` in your codebase.
109128

110129
### Removed
111130

0 commit comments

Comments
 (0)