From eecb00bd43a2367058a5f8123fda0bc47f58e1c2 Mon Sep 17 00:00:00 2001 From: Sl-L Date: Mon, 23 Dec 2024 10:37:08 -0300 Subject: [PATCH 01/18] added color argument to fill::fill_window on examples/util/fill --- examples/control_flow.rs | 2 +- examples/pump_events.rs | 2 +- examples/run_on_demand.rs | 2 +- examples/util/fill.rs | 7 +++---- examples/x11_embed.rs | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/control_flow.rs b/examples/control_flow.rs index 47a518c181..1eb5b9cb1d 100644 --- a/examples/control_flow.rs +++ b/examples/control_flow.rs @@ -114,7 +114,7 @@ impl ApplicationHandler for ControlFlowDemo { WindowEvent::RedrawRequested => { let window = self.window.as_ref().unwrap(); window.pre_present_notify(); - fill::fill_window(window.as_ref()); + fill::fill_window(window.as_ref(), 0xff181818); }, _ => (), } diff --git a/examples/pump_events.rs b/examples/pump_events.rs index 3ec8abe38b..a32564dab7 100644 --- a/examples/pump_events.rs +++ b/examples/pump_events.rs @@ -43,7 +43,7 @@ fn main() -> std::process::ExitCode { match event { WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::RedrawRequested => { - fill::fill_window(window.as_ref()); + fill::fill_window(window.as_ref(), 0xff181818); window.request_redraw(); }, _ => (), diff --git a/examples/run_on_demand.rs b/examples/run_on_demand.rs index e6d105ad5e..3c0e8e3c0f 100644 --- a/examples/run_on_demand.rs +++ b/examples/run_on_demand.rs @@ -69,7 +69,7 @@ fn main() -> Result<(), Box> { self.window = None; }, WindowEvent::RedrawRequested => { - fill::fill_window(window.as_ref()); + fill::fill_window(window.as_ref(), 0xff181818); }, _ => (), } diff --git a/examples/util/fill.rs b/examples/util/fill.rs index c93dfc5861..8e371e3474 100644 --- a/examples/util/fill.rs +++ b/examples/util/fill.rs @@ -70,7 +70,7 @@ mod platform { } } - pub fn fill_window(window: &dyn Window) { + pub fn fill_window(window: &dyn Window, color: u32) { GC.with(|gc| { let size = window.surface_size(); let (Some(width), Some(height)) = @@ -84,13 +84,12 @@ mod platform { let surface = gc.get_or_insert_with(|| GraphicsContext::new(window)).create_surface(window); - // Fill a buffer with a solid color. - const DARK_GRAY: u32 = 0xff181818; + // Fill a buffer with a solid color surface.resize(width, height).expect("Failed to resize the softbuffer surface"); let mut buffer = surface.buffer_mut().expect("Failed to get the softbuffer buffer"); - buffer.fill(DARK_GRAY); + buffer.fill(color); buffer.present().expect("Failed to present the softbuffer buffer"); }) } diff --git a/examples/x11_embed.rs b/examples/x11_embed.rs index 1b9a796ff6..8807412fd3 100644 --- a/examples/x11_embed.rs +++ b/examples/x11_embed.rs @@ -38,7 +38,7 @@ fn main() -> Result<(), Box> { WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::RedrawRequested => { window.pre_present_notify(); - fill::fill_window(window.as_ref()); + fill::fill_window(window.as_ref(), 0xff181818); }, _ => (), } From 354ff6ad6bb8daf72fedd07c85d26ed64f051da4 Mon Sep 17 00:00:00 2001 From: Sl-L Date: Mon, 23 Dec 2024 10:38:27 -0300 Subject: [PATCH 02/18] edited example/child_window.rs so that the child windows are filled with a different color than the parent window and made it so the child windows fill a grid instead of stacking on top of one another --- examples/child_window.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/examples/child_window.rs b/examples/child_window.rs index 43ed75c9b1..7058876a10 100644 --- a/examples/child_window.rs +++ b/examples/child_window.rs @@ -56,15 +56,20 @@ fn main() -> Result<(), impl std::error::Error> { event: KeyEvent { state: ElementState::Pressed, .. }, .. } => { + let child_index = self.windows.len() - 1; let parent_window = self.windows.get(&self.parent_window_id.unwrap()).unwrap(); - let child_window = spawn_child_window(parent_window.as_ref(), event_loop); + let child_window = spawn_child_window(parent_window.as_ref(), event_loop, child_index as i32); let child_id = child_window.id(); println!("Child window created with id: {child_id:?}"); self.windows.insert(child_id, child_window); }, WindowEvent::RedrawRequested => { if let Some(window) = self.windows.get(&window_id) { - fill::fill_window(window.as_ref()); + if window_id == self.parent_window_id.unwrap() { + fill::fill_window(window.as_ref(), 0xff181818); + } else { + fill::fill_window(window.as_ref(), 0xffBBBBBB); + } } }, _ => (), @@ -75,12 +80,21 @@ fn main() -> Result<(), impl std::error::Error> { fn spawn_child_window( parent: &dyn Window, event_loop: &dyn ActiveEventLoop, + child_count: i32, ) -> Box { let parent = parent.raw_window_handle().unwrap(); + + //As child count increases, x goes from 0*128 to 5*128 and then repeats + println!("{}", child_count); + let x: f64 = child_count.rem_euclid(5) as f64 * 128.0; + + //After 5 windows have been put side by side horizontally, a new row starts + let y: f64 = (child_count / 5) as f64 * 96.0; + let mut window_attributes = WindowAttributes::default() .with_title("child window") - .with_surface_size(LogicalSize::new(200.0f32, 200.0f32)) - .with_position(Position::Logical(LogicalPosition::new(0.0, 0.0))) + .with_surface_size(LogicalSize::new(128.0f32, 96.0)) + .with_position(Position::Logical(LogicalPosition::new(x, y))) .with_visible(true); // `with_parent_window` is unsafe. Parent window must be a valid window. window_attributes = unsafe { window_attributes.with_parent_window(Some(parent)) }; From 8096ed5e7f1fbe1dab8a2c4e2d8d90462ea0eb54 Mon Sep 17 00:00:00 2001 From: Sl-L Date: Mon, 23 Dec 2024 11:12:09 -0300 Subject: [PATCH 03/18] corrected mixed-case hex --- examples/child_window.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/child_window.rs b/examples/child_window.rs index 7058876a10..10d0a0d3c0 100644 --- a/examples/child_window.rs +++ b/examples/child_window.rs @@ -68,7 +68,7 @@ fn main() -> Result<(), impl std::error::Error> { if window_id == self.parent_window_id.unwrap() { fill::fill_window(window.as_ref(), 0xff181818); } else { - fill::fill_window(window.as_ref(), 0xffBBBBBB); + fill::fill_window(window.as_ref(), 0xffbbbbbb); } } }, From e4db6e14b11cdf9f165e2578076a56404bc16129 Mon Sep 17 00:00:00 2001 From: Sl-L Date: Mon, 23 Dec 2024 11:14:54 -0300 Subject: [PATCH 04/18] add space at beggining of the added comments --- examples/child_window.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/child_window.rs b/examples/child_window.rs index 10d0a0d3c0..64b5c03975 100644 --- a/examples/child_window.rs +++ b/examples/child_window.rs @@ -84,11 +84,11 @@ fn main() -> Result<(), impl std::error::Error> { ) -> Box { let parent = parent.raw_window_handle().unwrap(); - //As child count increases, x goes from 0*128 to 5*128 and then repeats + // As child count increases, x goes from 0*128 to 5*128 and then repeats println!("{}", child_count); let x: f64 = child_count.rem_euclid(5) as f64 * 128.0; - //After 5 windows have been put side by side horizontally, a new row starts + // After 5 windows have been put side by side horizontally, a new row starts let y: f64 = (child_count / 5) as f64 * 96.0; let mut window_attributes = WindowAttributes::default() From edc071cf31c9599580cd3615cdd40f9256ef44cc Mon Sep 17 00:00:00 2001 From: Sl-L Date: Mon, 23 Dec 2024 11:17:14 -0300 Subject: [PATCH 05/18] forgot to add color argument to fill_window used in android and ios --- examples/util/fill.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/util/fill.rs b/examples/util/fill.rs index 8e371e3474..a8eed20c6f 100644 --- a/examples/util/fill.rs +++ b/examples/util/fill.rs @@ -107,7 +107,7 @@ mod platform { #[cfg(any(target_os = "android", target_os = "ios"))] mod platform { - pub fn fill_window(_window: &dyn winit::window::Window) { + pub fn fill_window(_window: &dyn winit::window::Window, color: u32) { // No-op on mobile platforms. } From 09f24f482313ecf235960b1e476d2502034d5fc2 Mon Sep 17 00:00:00 2001 From: Sl-L Date: Mon, 23 Dec 2024 11:23:11 -0300 Subject: [PATCH 06/18] color arg added to for android and ios had to be prefixed with an underscore --- examples/util/fill.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/util/fill.rs b/examples/util/fill.rs index a8eed20c6f..d0b534f664 100644 --- a/examples/util/fill.rs +++ b/examples/util/fill.rs @@ -107,7 +107,7 @@ mod platform { #[cfg(any(target_os = "android", target_os = "ios"))] mod platform { - pub fn fill_window(_window: &dyn winit::window::Window, color: u32) { + pub fn fill_window(_window: &dyn winit::window::Window, _color: u32) { // No-op on mobile platforms. } From f623b5018c307d9204a5be587415da54e1ffe812 Mon Sep 17 00:00:00 2001 From: Sl-L Date: Mon, 23 Dec 2024 11:28:15 -0300 Subject: [PATCH 07/18] Deleted child_count print --- examples/child_window.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/child_window.rs b/examples/child_window.rs index 64b5c03975..6aa1684f25 100644 --- a/examples/child_window.rs +++ b/examples/child_window.rs @@ -85,7 +85,6 @@ fn main() -> Result<(), impl std::error::Error> { let parent = parent.raw_window_handle().unwrap(); // As child count increases, x goes from 0*128 to 5*128 and then repeats - println!("{}", child_count); let x: f64 = child_count.rem_euclid(5) as f64 * 128.0; // After 5 windows have been put side by side horizontally, a new row starts From 81ea5abbbd43c20b1258472ebd487275f4dbf5fe Mon Sep 17 00:00:00 2001 From: Sl-L Date: Mon, 23 Dec 2024 11:31:13 -0300 Subject: [PATCH 08/18] Now shouldn't give formatting errors --- examples/child_window.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/child_window.rs b/examples/child_window.rs index 6aa1684f25..35249de874 100644 --- a/examples/child_window.rs +++ b/examples/child_window.rs @@ -58,7 +58,8 @@ fn main() -> Result<(), impl std::error::Error> { } => { let child_index = self.windows.len() - 1; let parent_window = self.windows.get(&self.parent_window_id.unwrap()).unwrap(); - let child_window = spawn_child_window(parent_window.as_ref(), event_loop, child_index as i32); + let child_window = + spawn_child_window(parent_window.as_ref(), event_loop, child_index as i32); let child_id = child_window.id(); println!("Child window created with id: {child_id:?}"); self.windows.insert(child_id, child_window); @@ -87,7 +88,7 @@ fn main() -> Result<(), impl std::error::Error> { // As child count increases, x goes from 0*128 to 5*128 and then repeats let x: f64 = child_count.rem_euclid(5) as f64 * 128.0; - // After 5 windows have been put side by side horizontally, a new row starts + // After 5 windows have been put side by side horizontally, a new row starts let y: f64 = (child_count / 5) as f64 * 96.0; let mut window_attributes = WindowAttributes::default() From bcc6849fa3dd274a9e2e36de2324936ff39017d4 Mon Sep 17 00:00:00 2001 From: Sl-L Date: Wed, 25 Dec 2024 10:48:23 -0300 Subject: [PATCH 09/18] reverted changes to other examples, added fill_window_with_color to util/fill.rs and defined fill_window with it --- examples/child_window.rs | 4 ++-- examples/control_flow.rs | 2 +- examples/pump_events.rs | 2 +- examples/run_on_demand.rs | 2 +- examples/util/fill.rs | 11 ++++++++++- examples/x11_embed.rs | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/examples/child_window.rs b/examples/child_window.rs index 35249de874..939f3833f3 100644 --- a/examples/child_window.rs +++ b/examples/child_window.rs @@ -67,9 +67,9 @@ fn main() -> Result<(), impl std::error::Error> { WindowEvent::RedrawRequested => { if let Some(window) = self.windows.get(&window_id) { if window_id == self.parent_window_id.unwrap() { - fill::fill_window(window.as_ref(), 0xff181818); + fill::fill_window_with_color(window.as_ref(), 0xff181818); } else { - fill::fill_window(window.as_ref(), 0xffbbbbbb); + fill::fill_window_with_color(window.as_ref(), 0xffbbbbbb); } } }, diff --git a/examples/control_flow.rs b/examples/control_flow.rs index 1eb5b9cb1d..47a518c181 100644 --- a/examples/control_flow.rs +++ b/examples/control_flow.rs @@ -114,7 +114,7 @@ impl ApplicationHandler for ControlFlowDemo { WindowEvent::RedrawRequested => { let window = self.window.as_ref().unwrap(); window.pre_present_notify(); - fill::fill_window(window.as_ref(), 0xff181818); + fill::fill_window(window.as_ref()); }, _ => (), } diff --git a/examples/pump_events.rs b/examples/pump_events.rs index a32564dab7..3ec8abe38b 100644 --- a/examples/pump_events.rs +++ b/examples/pump_events.rs @@ -43,7 +43,7 @@ fn main() -> std::process::ExitCode { match event { WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::RedrawRequested => { - fill::fill_window(window.as_ref(), 0xff181818); + fill::fill_window(window.as_ref()); window.request_redraw(); }, _ => (), diff --git a/examples/run_on_demand.rs b/examples/run_on_demand.rs index 3c0e8e3c0f..e6d105ad5e 100644 --- a/examples/run_on_demand.rs +++ b/examples/run_on_demand.rs @@ -69,7 +69,7 @@ fn main() -> Result<(), Box> { self.window = None; }, WindowEvent::RedrawRequested => { - fill::fill_window(window.as_ref(), 0xff181818); + fill::fill_window(window.as_ref()); }, _ => (), } diff --git a/examples/util/fill.rs b/examples/util/fill.rs index d0b534f664..e5826c6c79 100644 --- a/examples/util/fill.rs +++ b/examples/util/fill.rs @@ -9,8 +9,13 @@ #[allow(unused_imports)] pub use platform::cleanup_window; + +#[allow(unused_imports)] pub use platform::fill_window; +#[allow(unused_imports)] +pub use platform::fill_window_with_color; + #[cfg(not(any(target_os = "android", target_os = "ios")))] mod platform { use std::cell::RefCell; @@ -70,7 +75,7 @@ mod platform { } } - pub fn fill_window(window: &dyn Window, color: u32) { + pub fn fill_window_with_color(window: &dyn Window, color: u32) { GC.with(|gc| { let size = window.surface_size(); let (Some(width), Some(height)) = @@ -94,6 +99,10 @@ mod platform { }) } + pub fn fill_window(window: &dyn Window) { + fill_window_with_color(window, 0xff181818); + } + #[allow(dead_code)] pub fn cleanup_window(window: &dyn Window) { GC.with(|gc| { diff --git a/examples/x11_embed.rs b/examples/x11_embed.rs index 8807412fd3..1b9a796ff6 100644 --- a/examples/x11_embed.rs +++ b/examples/x11_embed.rs @@ -38,7 +38,7 @@ fn main() -> Result<(), Box> { WindowEvent::CloseRequested => event_loop.exit(), WindowEvent::RedrawRequested => { window.pre_present_notify(); - fill::fill_window(window.as_ref(), 0xff181818); + fill::fill_window(window.as_ref()); }, _ => (), } From 60ddec06562bd1c35a978cb1df3f3363aa74862c Mon Sep 17 00:00:00 2001 From: Sl-L Date: Wed, 25 Dec 2024 12:40:57 -0300 Subject: [PATCH 10/18] "fixed" warnings --- examples/util/fill.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/util/fill.rs b/examples/util/fill.rs index e5826c6c79..c4be6e9d6f 100644 --- a/examples/util/fill.rs +++ b/examples/util/fill.rs @@ -99,6 +99,7 @@ mod platform { }) } + #[allow(dead_code)] pub fn fill_window(window: &dyn Window) { fill_window_with_color(window, 0xff181818); } From 7f89e1f69f6329615d0bdd848834b65c406ff8d8 Mon Sep 17 00:00:00 2001 From: Sl-L Date: Wed, 25 Dec 2024 12:41:29 -0300 Subject: [PATCH 11/18] added color cycling for child windows --- examples/child_window.rs | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/examples/child_window.rs b/examples/child_window.rs index 939f3833f3..ff923afae5 100644 --- a/examples/child_window.rs +++ b/examples/child_window.rs @@ -1,5 +1,6 @@ #[cfg(any(x11_platform, macos_platform, windows_platform))] #[allow(deprecated)] + fn main() -> Result<(), impl std::error::Error> { use std::collections::HashMap; @@ -13,10 +14,24 @@ fn main() -> Result<(), impl std::error::Error> { #[path = "util/fill.rs"] mod fill; + struct WindowData { + window: Box, + color: u32 + } + + impl WindowData { + fn new(window: Box, color: u32) -> Self { + Self { + window: window, + color: color + } + } + } + #[derive(Default)] struct Application { parent_window_id: Option, - windows: HashMap>, + windows: HashMap, } impl ApplicationHandler for Application { @@ -26,11 +41,10 @@ fn main() -> Result<(), impl std::error::Error> { .with_position(Position::Logical(LogicalPosition::new(0.0, 0.0))) .with_surface_size(LogicalSize::new(640.0f32, 480.0f32)); let window = event_loop.create_window(attributes).unwrap(); - println!("Parent window id: {:?})", window.id()); self.parent_window_id = Some(window.id()); - self.windows.insert(window.id(), window); + self.windows.insert(window.id(), WindowData::new(window, 0xffbbbbbb)); } fn window_event( @@ -56,20 +70,22 @@ fn main() -> Result<(), impl std::error::Error> { event: KeyEvent { state: ElementState::Pressed, .. }, .. } => { - let child_index = self.windows.len() - 1; + let child_index: i32 = ( self.windows.len() - 1 ) as i32; + let child_color: u32 = 0xff000000 as u32 + ( (3 as u32).pow((child_index + 2).rem_euclid(16) as u32)); + let parent_window = self.windows.get(&self.parent_window_id.unwrap()).unwrap(); let child_window = - spawn_child_window(parent_window.as_ref(), event_loop, child_index as i32); + spawn_child_window(parent_window.window.as_ref(), event_loop, child_index); let child_id = child_window.id(); println!("Child window created with id: {child_id:?}"); - self.windows.insert(child_id, child_window); + self.windows.insert(child_id, WindowData::new(child_window, child_color as u32)); }, WindowEvent::RedrawRequested => { if let Some(window) = self.windows.get(&window_id) { if window_id == self.parent_window_id.unwrap() { - fill::fill_window_with_color(window.as_ref(), 0xff181818); + fill::fill_window_with_color(window.window.as_ref(), 0xff181818); } else { - fill::fill_window_with_color(window.as_ref(), 0xffbbbbbb); + fill::fill_window_with_color(window.window.as_ref(), window.color); } } }, From 165f9d5be8ea39b20506491bdd73ca20f55f3ac1 Mon Sep 17 00:00:00 2001 From: Sl-L Date: Wed, 25 Dec 2024 12:48:47 -0300 Subject: [PATCH 12/18] fixed formatting --- examples/child_window.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/examples/child_window.rs b/examples/child_window.rs index ff923afae5..7a91b18c8d 100644 --- a/examples/child_window.rs +++ b/examples/child_window.rs @@ -16,15 +16,12 @@ fn main() -> Result<(), impl std::error::Error> { struct WindowData { window: Box, - color: u32 + color: u32, } impl WindowData { fn new(window: Box, color: u32) -> Self { - Self { - window: window, - color: color - } + Self { window, color } } } @@ -70,15 +67,17 @@ fn main() -> Result<(), impl std::error::Error> { event: KeyEvent { state: ElementState::Pressed, .. }, .. } => { - let child_index: i32 = ( self.windows.len() - 1 ) as i32; - let child_color: u32 = 0xff000000 as u32 + ( (3 as u32).pow((child_index + 2).rem_euclid(16) as u32)); + let child_index: i32 = (self.windows.len() - 1) as i32; + let child_color: u32 = 0xff000000 as u32 + + ((3 as u32).pow((child_index + 2).rem_euclid(16) as u32)); let parent_window = self.windows.get(&self.parent_window_id.unwrap()).unwrap(); let child_window = spawn_child_window(parent_window.window.as_ref(), event_loop, child_index); let child_id = child_window.id(); println!("Child window created with id: {child_id:?}"); - self.windows.insert(child_id, WindowData::new(child_window, child_color as u32)); + self.windows + .insert(child_id, WindowData::new(child_window, child_color as u32)); }, WindowEvent::RedrawRequested => { if let Some(window) = self.windows.get(&window_id) { From 20c80385a7770ca99451a67fdf30c9ec6ec9c19d Mon Sep 17 00:00:00 2001 From: Sl-L Date: Wed, 25 Dec 2024 12:52:25 -0300 Subject: [PATCH 13/18] removed unnecessary type casts and empty line before main --- examples/child_window.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/child_window.rs b/examples/child_window.rs index 7a91b18c8d..55f853cdf2 100644 --- a/examples/child_window.rs +++ b/examples/child_window.rs @@ -1,6 +1,5 @@ #[cfg(any(x11_platform, macos_platform, windows_platform))] #[allow(deprecated)] - fn main() -> Result<(), impl std::error::Error> { use std::collections::HashMap; @@ -68,7 +67,7 @@ fn main() -> Result<(), impl std::error::Error> { .. } => { let child_index: i32 = (self.windows.len() - 1) as i32; - let child_color: u32 = 0xff000000 as u32 + let child_color: u32 = 0xff000000_u32 + ((3 as u32).pow((child_index + 2).rem_euclid(16) as u32)); let parent_window = self.windows.get(&self.parent_window_id.unwrap()).unwrap(); @@ -77,7 +76,7 @@ fn main() -> Result<(), impl std::error::Error> { let child_id = child_window.id(); println!("Child window created with id: {child_id:?}"); self.windows - .insert(child_id, WindowData::new(child_window, child_color as u32)); + .insert(child_id, WindowData::new(child_window, child_color)); }, WindowEvent::RedrawRequested => { if let Some(window) = self.windows.get(&window_id) { From 33b28859b9e521c62ba02edcab3b15f9b61accab Mon Sep 17 00:00:00 2001 From: Sl-L Date: Wed, 25 Dec 2024 13:02:02 -0300 Subject: [PATCH 14/18] android and iOS fill_window revert --- examples/util/fill.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/util/fill.rs b/examples/util/fill.rs index c4be6e9d6f..e8c59f15f1 100644 --- a/examples/util/fill.rs +++ b/examples/util/fill.rs @@ -117,7 +117,7 @@ mod platform { #[cfg(any(target_os = "android", target_os = "ios"))] mod platform { - pub fn fill_window(_window: &dyn winit::window::Window, _color: u32) { + pub fn fill_window(_window: &dyn winit::window::Window) { // No-op on mobile platforms. } From 9bbf5ef8b1462b3c1794bf6ff7b39dc912d127f2 Mon Sep 17 00:00:00 2001 From: Sl-L Date: Wed, 25 Dec 2024 13:02:35 -0300 Subject: [PATCH 15/18] same as last last time, formatting and unnecessary casting --- examples/child_window.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/child_window.rs b/examples/child_window.rs index 55f853cdf2..77731ae7d0 100644 --- a/examples/child_window.rs +++ b/examples/child_window.rs @@ -67,16 +67,15 @@ fn main() -> Result<(), impl std::error::Error> { .. } => { let child_index: i32 = (self.windows.len() - 1) as i32; - let child_color: u32 = 0xff000000_u32 - + ((3 as u32).pow((child_index + 2).rem_euclid(16) as u32)); + let child_color: u32 = + 0xff000000_u32 + ((3_u32).pow((child_index + 2).rem_euclid(16) as u32)); let parent_window = self.windows.get(&self.parent_window_id.unwrap()).unwrap(); let child_window = spawn_child_window(parent_window.window.as_ref(), event_loop, child_index); let child_id = child_window.id(); println!("Child window created with id: {child_id:?}"); - self.windows - .insert(child_id, WindowData::new(child_window, child_color)); + self.windows.insert(child_id, WindowData::new(child_window, child_color)); }, WindowEvent::RedrawRequested => { if let Some(window) = self.windows.get(&window_id) { From f6c3df57044dbf040c5eca7d4fd4508511431d92 Mon Sep 17 00:00:00 2001 From: Sl-L Date: Wed, 25 Dec 2024 13:05:57 -0300 Subject: [PATCH 16/18] formatter doesn't like empty lines sometimes, noted --- examples/util/fill.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/examples/util/fill.rs b/examples/util/fill.rs index e8c59f15f1..50d84d6e7d 100644 --- a/examples/util/fill.rs +++ b/examples/util/fill.rs @@ -9,10 +9,8 @@ #[allow(unused_imports)] pub use platform::cleanup_window; - #[allow(unused_imports)] pub use platform::fill_window; - #[allow(unused_imports)] pub use platform::fill_window_with_color; From 79b41a0343f932bd1b99ae5151b432f0a3ed1a82 Mon Sep 17 00:00:00 2001 From: Sl-L Date: Wed, 25 Dec 2024 13:22:47 -0300 Subject: [PATCH 17/18] android and ios --- examples/util/fill.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/util/fill.rs b/examples/util/fill.rs index 50d84d6e7d..7a8f700a0a 100644 --- a/examples/util/fill.rs +++ b/examples/util/fill.rs @@ -119,6 +119,10 @@ mod platform { // No-op on mobile platforms. } + pub fn fill_window_with_color(_window: &dyn winit::window::Window, _color: u32) { + // No-op on mobile platforms. + } + #[allow(dead_code)] pub fn cleanup_window(_window: &dyn winit::window::Window) { // No-op on mobile platforms. From cbbecb2c59606cf61598490d4878fe671630b16c Mon Sep 17 00:00:00 2001 From: Sl-L Date: Wed, 25 Dec 2024 13:26:13 -0300 Subject: [PATCH 18/18] android and ios --- examples/util/fill.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/util/fill.rs b/examples/util/fill.rs index 7a8f700a0a..dab4a1d776 100644 --- a/examples/util/fill.rs +++ b/examples/util/fill.rs @@ -119,6 +119,7 @@ mod platform { // No-op on mobile platforms. } + #[allow(dead_code)] pub fn fill_window_with_color(_window: &dyn winit::window::Window, _color: u32) { // No-op on mobile platforms. }