1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use crate::{sys::cef_window_handle_t, *};
#[cfg(target_os = "windows")]
use windows_sys::Win32::UI::WindowsAndMessaging::*;
impl WindowInfo {
/// Create the browser as a child window.
pub fn set_as_child(self, parent: cef_window_handle_t, bounds: &Rect) -> Self {
Self {
#[cfg(target_os = "windows")]
style: WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_TABSTOP | WS_VISIBLE,
#[cfg(any(target_os = "linux", target_os = "windows"))]
parent_window: parent,
#[cfg(target_os = "macos")]
parent_view: parent,
bounds: bounds.clone(),
#[cfg(target_os = "macos")]
hidden: 0,
..self
}
}
/// Create the browser as a popup window.
#[cfg(target_os = "windows")]
pub fn set_as_popup(self, parent: cef_window_handle_t, title: &str) -> Self {
Self {
window_name: CefString::from(title),
parent_window: parent,
style: WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_VISIBLE,
bounds: Rect {
x: CW_USEDEFAULT,
y: CW_USEDEFAULT,
width: CW_USEDEFAULT,
height: CW_USEDEFAULT,
},
..self
}
}
/// Create the browser using windowless (off-screen) rendering. No window
/// will be created for the browser and all rendering will occur via the
/// CefRenderHandler interface. The |parent| value will be used to identify
/// monitor info and to act as the parent window for dialogs, context menus,
/// etc. If |parent| is not provided then the main screen monitor will be used
/// and some functionality that requires a parent window may not function
/// correctly. In order to create windowless browsers the
/// CefSettings.windowless_rendering_enabled value must be set to true.
/// Transparent painting is enabled by default but can be disabled by setting
/// CefBrowserSettings.background_color to an opaque value.
pub fn set_as_windowless(self, parent: cef_window_handle_t) -> Self {
Self {
windowless_rendering_enabled: 1,
#[cfg(any(target_os = "linux", target_os = "windows"))]
parent_window: parent,
#[cfg(target_os = "macos")]
parent_view: parent,
runtime_style: RuntimeStyle::ALLOY,
..self
}
}
}