mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-05-18 06:51:54 +00:00
Merge pull request #42 from Stremio/fix/correctly-close-fullscreen-esc-shortcut
Some checks are pending
Continuous integration / test (push) Waiting to run
Some checks are pending
Continuous integration / test (push) Waiting to run
Shortcuts: Fix esc shortcut to only close fullscreen
This commit is contained in:
commit
59fe6b77a0
2 changed files with 25 additions and 4 deletions
|
|
@ -41,6 +41,7 @@ pub struct MainWindow {
|
||||||
pub force_update: bool,
|
pub force_update: bool,
|
||||||
pub release_candidate: bool,
|
pub release_candidate: bool,
|
||||||
pub autoupdater_setup_file: Arc<Mutex<Option<PathBuf>>>,
|
pub autoupdater_setup_file: Arc<Mutex<Option<PathBuf>>>,
|
||||||
|
pub requested_fullscreen: Arc<Mutex<Option<bool>>>,
|
||||||
pub saved_window_style: RefCell<WindowStyle>,
|
pub saved_window_style: RefCell<WindowStyle>,
|
||||||
#[nwg_resource]
|
#[nwg_resource]
|
||||||
pub embed: nwg::EmbedResource,
|
pub embed: nwg::EmbedResource,
|
||||||
|
|
@ -247,6 +248,7 @@ impl MainWindow {
|
||||||
let hide_splash_sender = self.hide_splash_notice.sender();
|
let hide_splash_sender = self.hide_splash_notice.sender();
|
||||||
let focus_sender = self.focus_notice.sender();
|
let focus_sender = self.focus_notice.sender();
|
||||||
let autoupdater_setup_mutex = self.autoupdater_setup_file.clone();
|
let autoupdater_setup_mutex = self.autoupdater_setup_file.clone();
|
||||||
|
let requested_fullscreen = self.requested_fullscreen.clone();
|
||||||
thread::spawn(move || loop {
|
thread::spawn(move || loop {
|
||||||
if let Some(msg) = web_rx
|
if let Some(msg) = web_rx
|
||||||
.recv()
|
.recv()
|
||||||
|
|
@ -258,7 +260,16 @@ impl MainWindow {
|
||||||
None if msg.is_handshake() => {
|
None if msg.is_handshake() => {
|
||||||
web_tx_web.send(RPCResponse::get_handshake()).ok();
|
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("quit") => quit_sender.notice(),
|
||||||
Some("app-ready") => {
|
Some("app-ready") => {
|
||||||
hide_splash_sender.notice();
|
hide_splash_sender.notice();
|
||||||
|
|
@ -409,7 +420,13 @@ impl MainWindow {
|
||||||
fn on_toggle_fullscreen_notice(&self) {
|
fn on_toggle_fullscreen_notice(&self) {
|
||||||
if let Some(hwnd) = self.window.handle.hwnd() {
|
if let Some(hwnd) = self.window.handle.hwnd() {
|
||||||
if let Ok(mut saved_style) = self.saved_window_style.try_borrow_mut() {
|
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.set_enabled(!saved_style.full_screen);
|
||||||
self.tray
|
self.tray
|
||||||
.tray_topmost
|
.tray_topmost
|
||||||
|
|
|
||||||
|
|
@ -71,8 +71,12 @@ impl WindowStyle {
|
||||||
self.pos = ((monitor_w - self.size.0) / 2, (monitor_h - self.size.1) / 2);
|
self.pos = ((monitor_w - self.size.0) / 2, (monitor_h - self.size.1) / 2);
|
||||||
self.show_window_at(hwnd, HWND_NOTOPMOST);
|
self.show_window_at(hwnd, HWND_NOTOPMOST);
|
||||||
}
|
}
|
||||||
pub fn toggle_full_screen(&mut self, hwnd: HWND) {
|
pub fn set_full_screen(&mut self, hwnd: HWND, full_screen: bool) {
|
||||||
if self.full_screen {
|
if self.full_screen == full_screen {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if !full_screen {
|
||||||
let topmost = if self.ex_style as u32 & WS_EX_TOPMOST == WS_EX_TOPMOST {
|
let topmost = if self.ex_style as u32 & WS_EX_TOPMOST == WS_EX_TOPMOST {
|
||||||
HWND_TOPMOST
|
HWND_TOPMOST
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue