mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2025-01-11 11:31:32 +11:00
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:
parent
a56e79ca50
commit
efbe6a1c71
|
@ -182,8 +182,13 @@ pub struct WindowOptions {
|
||||||
pub topmost: bool,
|
pub topmost: bool,
|
||||||
/// Specifies whether or not the window is allowed to draw transparent pixels (default: false)
|
/// Specifies whether or not the window is allowed to draw transparent pixels (default: false)
|
||||||
/// Requires borderless to be 'true'
|
/// 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,
|
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 {
|
impl Window {
|
||||||
|
@ -1039,6 +1044,7 @@ impl Default for WindowOptions {
|
||||||
scale: Scale::X1,
|
scale: Scale::X1,
|
||||||
scale_mode: ScaleMode::Stretch,
|
scale_mode: ScaleMode::Stretch,
|
||||||
topmost: false,
|
topmost: false,
|
||||||
|
none: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -520,13 +520,13 @@ impl Window {
|
||||||
let (display, input) = DisplayInfo::new(
|
let (display, input) = DisplayInfo::new(
|
||||||
(width as i32 * scale, height as i32 * scale),
|
(width as i32 * scale, height as i32 * scale),
|
||||||
opts.transparency,
|
opts.transparency,
|
||||||
!opts.borderless,
|
!opts.borderless || opts.none,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
if opts.title {
|
if opts.title {
|
||||||
display.set_title(name);
|
display.set_title(name);
|
||||||
}
|
}
|
||||||
if !opts.resize {
|
if !opts.resize || opts.none {
|
||||||
display.set_no_resize((width as i32 * scale, height as i32 * scale));
|
display.set_no_resize((width as i32 * scale, height as i32 * scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,7 +558,7 @@ impl Window {
|
||||||
menu_counter: MenuHandle(0),
|
menu_counter: MenuHandle(0),
|
||||||
menus: Vec::new(),
|
menus: Vec::new(),
|
||||||
input,
|
input,
|
||||||
resizable: opts.resize,
|
resizable: opts.resize && !opts.none,
|
||||||
buffer: Vec::with_capacity(width * height * scale as usize * scale as usize),
|
buffer: Vec::with_capacity(width * height * scale as usize * scale as usize),
|
||||||
toplevel_info: (resolution, closed),
|
toplevel_info: (resolution, closed),
|
||||||
pointer_visibility: false,
|
pointer_visibility: false,
|
||||||
|
|
|
@ -403,7 +403,7 @@ impl Window {
|
||||||
| xlib::FocusChangeMask,
|
| xlib::FocusChangeMask,
|
||||||
);
|
);
|
||||||
|
|
||||||
if !opts.resize {
|
if !opts.resize || opts.none {
|
||||||
let mut size_hints: xlib::XSizeHints = mem::zeroed();
|
let mut size_hints: xlib::XSizeHints = mem::zeroed();
|
||||||
|
|
||||||
size_hints.flags = xlib::PMinSize | xlib::PMaxSize;
|
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)(
|
let hints_property = (d.lib.XInternAtom)(
|
||||||
d.display,
|
d.display,
|
||||||
"_MOTIF_WM_HINTS\0" as *const _ as *const c_char,
|
"_MOTIF_WM_HINTS\0" as *const _ as *const c_char,
|
||||||
|
|
|
@ -61,7 +61,7 @@ impl Window {
|
||||||
let window_height = height as u32 * window_scale as u32;
|
let window_height = height as u32 * window_scale as u32;
|
||||||
|
|
||||||
let mut window_flags = vec![orbclient::WindowFlag::Async];
|
let mut window_flags = vec![orbclient::WindowFlag::Async];
|
||||||
if opts.resize {
|
if opts.resize && !opts.none {
|
||||||
window_flags.push(orbclient::WindowFlag::Resizable);
|
window_flags.push(orbclient::WindowFlag::Resizable);
|
||||||
}
|
}
|
||||||
if !opts.title {
|
if !opts.title {
|
||||||
|
|
|
@ -541,6 +541,10 @@ impl Window {
|
||||||
flags &= winuser::WS_EX_LAYERED;
|
flags &= winuser::WS_EX_LAYERED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if opts.none {
|
||||||
|
flags = winuser::WS_VISIBLE | winuser::WS_POPUP;
|
||||||
|
}
|
||||||
|
|
||||||
let handle = winuser::CreateWindowExW(
|
let handle = winuser::CreateWindowExW(
|
||||||
0,
|
0,
|
||||||
class_name.as_ptr(),
|
class_name.as_ptr(),
|
||||||
|
|
Loading…
Reference in a new issue