Add API for transparency and decorations and add support for win32
This commit is contained in:
parent
1377f276b7
commit
81314f91d8
5 changed files with 80 additions and 2 deletions
|
|
@ -44,6 +44,7 @@ fn send_event(input_window: winapi::HWND, event: Event) {
|
|||
/// This is the callback that is called by `DispatchMessage` in the events loop.
|
||||
///
|
||||
/// Returning 0 tells the Win32 API that the message has been processed.
|
||||
// FIXME: detect WM_DWMCOMPOSITIONCHANGED and call DwmEnableBlurBehindWindow if necessary
|
||||
pub unsafe extern "system" fn callback(window: winapi::HWND, msg: winapi::UINT,
|
||||
wparam: winapi::WPARAM, lparam: winapi::LPARAM)
|
||||
-> winapi::LRESULT
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ unsafe fn init(title: Vec<u16>, builder: BuilderAttribs<'static>,
|
|||
}
|
||||
|
||||
// computing the style and extended style of the window
|
||||
let (ex_style, style) = if builder.monitor.is_some() {
|
||||
let (ex_style, style) = if builder.monitor.is_some() || builder.decorations == false {
|
||||
(winapi::WS_EX_APPWINDOW, winapi::WS_POPUP | winapi::WS_CLIPSIBLINGS | winapi::WS_CLIPCHILDREN)
|
||||
} else {
|
||||
(winapi::WS_EX_APPWINDOW | winapi::WS_EX_WINDOWEDGE,
|
||||
|
|
@ -214,6 +214,27 @@ unsafe fn init(title: Vec<u16>, builder: BuilderAttribs<'static>,
|
|||
}
|
||||
};
|
||||
|
||||
// making the window transparent
|
||||
if builder.transparent {
|
||||
let bb = winapi::DWM_BLURBEHIND {
|
||||
dwFlags: 0x1, // FIXME: DWM_BB_ENABLE;
|
||||
fEnable: 1,
|
||||
hRgnBlur: ptr::null_mut(),
|
||||
fTransitionOnMaximized: 0,
|
||||
};
|
||||
|
||||
let dll = kernel32::LoadLibraryA(b"dwmapi.dll\0".as_ptr() as *const _);
|
||||
if !dll.is_null() {
|
||||
let pr = kernel32::GetProcAddress(dll, b"DwmEnableBlurBehindWindow\0".as_ptr() as *const _);
|
||||
if !pr.is_null() {
|
||||
let pr: unsafe extern "system" fn(winapi::HWND, *const winapi::DWM_BLURBEHIND)
|
||||
-> winapi::HRESULT = mem::transmute(pr);
|
||||
pr(real_window.0, &bb);
|
||||
}
|
||||
kernel32::FreeLibrary(dll);
|
||||
}
|
||||
}
|
||||
|
||||
// calling SetForegroundWindow if fullscreen
|
||||
if builder.monitor.is_some() {
|
||||
user32::SetForegroundWindow(real_window.0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue