mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-05-12 21:40:47 +00:00
fix: esc shortcut close fullscreen
Some checks are pending
Continuous integration / test (push) Waiting to run
Some checks are pending
Continuous integration / test (push) Waiting to run
This commit is contained in:
parent
bbbe882faf
commit
a5f0f62d02
2 changed files with 25 additions and 4 deletions
|
|
@ -41,6 +41,7 @@ pub struct MainWindow {
|
|||
pub force_update: bool,
|
||||
pub release_candidate: bool,
|
||||
pub autoupdater_setup_file: Arc<Mutex<Option<PathBuf>>>,
|
||||
pub requested_fullscreen: Arc<Mutex<Option<bool>>>,
|
||||
pub saved_window_style: RefCell<WindowStyle>,
|
||||
#[nwg_resource]
|
||||
pub embed: nwg::EmbedResource,
|
||||
|
|
@ -247,6 +248,7 @@ impl MainWindow {
|
|||
let hide_splash_sender = self.hide_splash_notice.sender();
|
||||
let focus_sender = self.focus_notice.sender();
|
||||
let autoupdater_setup_mutex = self.autoupdater_setup_file.clone();
|
||||
let requested_fullscreen = self.requested_fullscreen.clone();
|
||||
thread::spawn(move || loop {
|
||||
if let Some(msg) = web_rx
|
||||
.recv()
|
||||
|
|
@ -258,7 +260,16 @@ impl MainWindow {
|
|||
None if msg.is_handshake() => {
|
||||
web_tx_web.send(RPCResponse::get_handshake()).ok();
|
||||
}
|
||||
Some("win-set-visibility") => toggle_fullscreen_sender.notice(),
|
||||
Some("win-set-visibility") => {
|
||||
if let Some(fullscreen) = msg
|
||||
.get_params()
|
||||
.and_then(|params| params.get("fullscreen"))
|
||||
.and_then(|value| value.as_bool())
|
||||
{
|
||||
*requested_fullscreen.lock().unwrap() = Some(fullscreen);
|
||||
toggle_fullscreen_sender.notice();
|
||||
}
|
||||
}
|
||||
Some("quit") => quit_sender.notice(),
|
||||
Some("app-ready") => {
|
||||
hide_splash_sender.notice();
|
||||
|
|
@ -363,7 +374,13 @@ impl MainWindow {
|
|||
fn on_toggle_fullscreen_notice(&self) {
|
||||
if let Some(hwnd) = self.window.handle.hwnd() {
|
||||
if let Ok(mut saved_style) = self.saved_window_style.try_borrow_mut() {
|
||||
saved_style.toggle_full_screen(hwnd);
|
||||
let target = self
|
||||
.requested_fullscreen
|
||||
.lock()
|
||||
.unwrap()
|
||||
.take()
|
||||
.unwrap_or(!saved_style.full_screen);
|
||||
saved_style.set_full_screen(hwnd, target);
|
||||
self.tray.tray_topmost.set_enabled(!saved_style.full_screen);
|
||||
self.tray
|
||||
.tray_topmost
|
||||
|
|
|
|||
|
|
@ -71,8 +71,12 @@ impl WindowStyle {
|
|||
self.pos = ((monitor_w - self.size.0) / 2, (monitor_h - self.size.1) / 2);
|
||||
self.show_window_at(hwnd, HWND_NOTOPMOST);
|
||||
}
|
||||
pub fn toggle_full_screen(&mut self, hwnd: HWND) {
|
||||
if self.full_screen {
|
||||
pub fn set_full_screen(&mut self, hwnd: HWND, full_screen: bool) {
|
||||
if self.full_screen == full_screen {
|
||||
return;
|
||||
}
|
||||
|
||||
if !full_screen {
|
||||
let topmost = if self.ex_style as u32 & WS_EX_TOPMOST == WS_EX_TOPMOST {
|
||||
HWND_TOPMOST
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Reference in a new issue