Path: blob/main/base/src/sys/windows/foreground_window.rs
5394 views
// Copyright 2022 The ChromiumOS Authors1// Use of this source code is governed by a BSD-style license that can be2// found in the LICENSE file.34use winapi::shared::minwindef::DWORD;5use winapi::um::winuser::AllowSetForegroundWindow;67use crate::errno_result;8use crate::Result;910/// Grants the given process id temporary permission to foreground another window. This succeeds11/// only when the emulator is in the foreground, and will persist only until the next user12/// interaction with the window13pub fn give_foregrounding_permission(process_id: DWORD) -> Result<()> {14// SAFETY:15// Safe because this API does not modify memory, and process_id remains in scope for16// the duration of the call.17match unsafe { AllowSetForegroundWindow(process_id) } {180 => errno_result(),19_ => Ok(()),20}21}222324