Function reset_activation_token_env

Source
pub fn reset_activation_token_env()
Expand description

Remove the activation environment variables from the current process.

This is wise to do before running child processes, which may not to support the activation token.

Examples found in repository?
examples/window.rs (line 146)
131    fn create_window(
132        &mut self,
133        event_loop: &ActiveEventLoop,
134        _tab_id: Option<String>,
135    ) -> Result<WindowId, Box<dyn Error>> {
136        // TODO read-out activation token.
137
138        #[allow(unused_mut)]
139        let mut window_attributes = Window::default_attributes()
140            .with_title("Winit window")
141            .with_transparent(true)
142            .with_window_icon(Some(self.icon.clone()));
143
144        #[cfg(any(x11_platform, wayland_platform))]
145        if let Some(token) = event_loop.read_token_from_env() {
146            startup_notify::reset_activation_token_env();
147            info!("Using token {:?} to activate a window", token);
148            window_attributes = window_attributes.with_activation_token(token);
149        }
150
151        #[cfg(macos_platform)]
152        if let Some(tab_id) = _tab_id {
153            window_attributes = window_attributes.with_tabbing_identifier(&tab_id);
154        }
155
156        #[cfg(web_platform)]
157        {
158            use rio_window::platform::web::WindowAttributesExtWebSys;
159            window_attributes = window_attributes.with_append(true);
160        }
161
162        let window = event_loop.create_window(window_attributes)?;
163
164        #[cfg(ios_platform)]
165        {
166            use rio_window::platform::ios::WindowExtIOS;
167            window.recognize_doubletap_gesture(true);
168            window.recognize_pinch_gesture(true);
169            window.recognize_rotation_gesture(true);
170            window.recognize_pan_gesture(true, 2, 2);
171        }
172
173        let window_state = WindowState::new(self, window)?;
174        let window_id = window_state.window.id();
175        info!("Created new window with id={window_id:?}");
176        self.windows.insert(window_id, window_state);
177        Ok(window_id)
178    }