From f18a81451fffa2ead0eb6be72f9a32f5f683a016 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 7 Feb 2024 09:47:15 +0100 Subject: Rename `fetch_native_handle` to `run_with_handle` in `window` --- winit/src/application.rs | 17 +++++++++-------- winit/src/multi_window.rs | 22 +++++++++++----------- 2 files changed, 20 insertions(+), 19 deletions(-) (limited to 'winit/src') diff --git a/winit/src/application.rs b/winit/src/application.rs index f28aca32..6a176834 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -23,8 +23,6 @@ use crate::{Clipboard, Error, Proxy, Settings}; use futures::channel::mpsc; -use winit::raw_window_handle::HasWindowHandle; - use std::mem::ManuallyDrop; use std::sync::Arc; @@ -785,13 +783,16 @@ pub fn run_command( .send_event(tag(window.id().into())) .expect("Send message to event loop"); } - window::Action::FetchNativeHandle(_id, tag) => { - proxy - .send_event(tag(&window - .window_handle() - .expect("Missing window handle"))) - .expect("Send message to event loop"); + window::Action::RunWithHandle(_id, tag) => { + use window::raw_window_handle::HasWindowHandle; + + if let Ok(handle) = window.window_handle() { + proxy + .send_event(tag(&handle)) + .expect("Send message to event loop"); + } } + window::Action::Screenshot(_id, tag) => { let bytes = compositor.screenshot( renderer, diff --git a/winit/src/multi_window.rs b/winit/src/multi_window.rs index 1b5fe375..23b2f3c4 100644 --- a/winit/src/multi_window.rs +++ b/winit/src/multi_window.rs @@ -22,8 +22,6 @@ use crate::runtime::Debug; use crate::style::application::StyleSheet; use crate::{Clipboard, Error, Proxy, Settings}; -use winit::raw_window_handle::HasWindowHandle; - use std::collections::HashMap; use std::mem::ManuallyDrop; use std::sync::Arc; @@ -1000,7 +998,7 @@ fn run_command( proxy .send_event(tag(mode)) - .expect("Event loop doesn't exist."); + .expect("Send message to event loop"); } } window::Action::ToggleMaximize(id) => { @@ -1036,17 +1034,19 @@ fn run_command( if let Some(window) = window_manager.get_mut(id) { proxy .send_event(tag(window.raw.id().into())) - .expect("Event loop doesn't exist."); + .expect("Send message to event loop"); } } - window::Action::FetchNativeHandle(id, tag) => { - if let Some(window) = window_manager.get_mut(id) { + window::Action::RunWithHandle(id, tag) => { + use window::raw_window_handle::HasWindowHandle; + + if let Some(handle) = window_manager + .get_mut(id) + .and_then(|window| window.raw.window_handle().ok()) + { proxy - .send_event(tag(&window - .raw - .window_handle() - .expect("Missing window handle."))) - .expect("Event loop doesn't exist."); + .send_event(tag(&handle)) + .expect("Send message to event loop"); } } window::Action::Screenshot(id, tag) => { -- cgit