Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
google
GitHub Repository: google/crosvm
Path: blob/main/base/src/sys/windows/foreground_window.rs
5394 views
1
// Copyright 2022 The ChromiumOS Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
use winapi::shared::minwindef::DWORD;
6
use winapi::um::winuser::AllowSetForegroundWindow;
7
8
use crate::errno_result;
9
use crate::Result;
10
11
/// Grants the given process id temporary permission to foreground another window. This succeeds
12
/// only when the emulator is in the foreground, and will persist only until the next user
13
/// interaction with the window
14
pub fn give_foregrounding_permission(process_id: DWORD) -> Result<()> {
15
// SAFETY:
16
// Safe because this API does not modify memory, and process_id remains in scope for
17
// the duration of the call.
18
match unsafe { AllowSetForegroundWindow(process_id) } {
19
0 => errno_result(),
20
_ => Ok(()),
21
}
22
}
23
24