WindowOptions: Support none flag (#219)

* WindowOptions: add none flag

* windows: support none flag

Signed-off-by: rupansh <rupanshsekar@hotmail.com>

* os: implement none flags for other operating systems

redox, posix
not applicable on OSX

* WindowOptions: document none option

Signed-off-by: rupansh-arch <rupanshsekar@hotmail.com>
This commit is contained in:
Rupansh 2020-10-01 16:36:48 +05:30 committed by GitHub
parent a56e79ca50
commit efbe6a1c71
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 7 deletions

View file

@ -182,8 +182,13 @@ pub struct WindowOptions {
pub topmost: bool,
/// Specifies whether or not the window is allowed to draw transparent pixels (default: false)
/// Requires borderless to be 'true'
/// TODO: Currently not implemented on Windows and OSX
/// TODO: Currently not implemented on OSX.
/// TODO: Make it work without none option on windows.
pub transparency: bool,
/// Required for transparency on windows.
/// Should be mutually exclusive to resize, automatically assumes borderless.
/// Not supported on OSX.
pub none: bool,
}
impl Window {
@ -1039,6 +1044,7 @@ impl Default for WindowOptions {
scale: Scale::X1,
scale_mode: ScaleMode::Stretch,
topmost: false,
none: false,
}
}
}

View file

@ -520,13 +520,13 @@ impl Window {
let (display, input) = DisplayInfo::new(
(width as i32 * scale, height as i32 * scale),
opts.transparency,
!opts.borderless,
!opts.borderless || opts.none,
)?;
if opts.title {
display.set_title(name);
}
if !opts.resize {
if !opts.resize || opts.none {
display.set_no_resize((width as i32 * scale, height as i32 * scale));
}
@ -558,7 +558,7 @@ impl Window {
menu_counter: MenuHandle(0),
menus: Vec::new(),
input,
resizable: opts.resize,
resizable: opts.resize && !opts.none,
buffer: Vec::with_capacity(width * height * scale as usize * scale as usize),
toplevel_info: (resolution, closed),
pointer_visibility: false,

View file

@ -403,7 +403,7 @@ impl Window {
| xlib::FocusChangeMask,
);
if !opts.resize {
if !opts.resize || opts.none {
let mut size_hints: xlib::XSizeHints = mem::zeroed();
size_hints.flags = xlib::PMinSize | xlib::PMaxSize;
@ -419,7 +419,7 @@ impl Window {
);
}
if opts.borderless {
if opts.borderless || opts.none {
let hints_property = (d.lib.XInternAtom)(
d.display,
"_MOTIF_WM_HINTS\0" as *const _ as *const c_char,

View file

@ -61,7 +61,7 @@ impl Window {
let window_height = height as u32 * window_scale as u32;
let mut window_flags = vec![orbclient::WindowFlag::Async];
if opts.resize {
if opts.resize && !opts.none {
window_flags.push(orbclient::WindowFlag::Resizable);
}
if !opts.title {

View file

@ -541,6 +541,10 @@ impl Window {
flags &= winuser::WS_EX_LAYERED;
}
if opts.none {
flags = winuser::WS_VISIBLE | winuser::WS_POPUP;
}
let handle = winuser::CreateWindowExW(
0,
class_name.as_ptr(),