Desktop: Focus app window when loading a document (#4124)
This commit is contained in:
parent
9d876ab27d
commit
d97fe835b5
|
|
@ -368,6 +368,11 @@ impl App {
|
||||||
window.start_drag();
|
window.start_drag();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DesktopFrontendMessage::WindowFocus => {
|
||||||
|
if let Some(window) = &self.window {
|
||||||
|
window.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
DesktopFrontendMessage::WindowHide => {
|
DesktopFrontendMessage::WindowHide => {
|
||||||
if let Some(window) = &self.window {
|
if let Some(window) = &self.window {
|
||||||
window.hide();
|
window.hide();
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,11 @@ impl Window {
|
||||||
let _ = self.winit_window.drag_window();
|
let _ = self.winit_window.drag_window();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn focus(&self) {
|
||||||
|
self.winit_window.set_minimized(false);
|
||||||
|
self.winit_window.focus_window();
|
||||||
|
}
|
||||||
|
|
||||||
pub(crate) fn hide(&self) {
|
pub(crate) fn hide(&self) {
|
||||||
self.native_handle.hide();
|
self.native_handle.hide();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,9 @@ pub(super) fn intercept_frontend_message(dispatcher: &mut DesktopWrapperMessageD
|
||||||
FrontendMessage::WindowDrag => {
|
FrontendMessage::WindowDrag => {
|
||||||
dispatcher.respond(DesktopFrontendMessage::WindowDrag);
|
dispatcher.respond(DesktopFrontendMessage::WindowDrag);
|
||||||
}
|
}
|
||||||
|
FrontendMessage::WindowFocus => {
|
||||||
|
dispatcher.respond(DesktopFrontendMessage::WindowFocus);
|
||||||
|
}
|
||||||
FrontendMessage::WindowHide => {
|
FrontendMessage::WindowHide => {
|
||||||
dispatcher.respond(DesktopFrontendMessage::WindowHide);
|
dispatcher.respond(DesktopFrontendMessage::WindowHide);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ pub enum DesktopFrontendMessage {
|
||||||
WindowMaximize,
|
WindowMaximize,
|
||||||
WindowFullscreen,
|
WindowFullscreen,
|
||||||
WindowDrag,
|
WindowDrag,
|
||||||
|
WindowFocus,
|
||||||
WindowHide,
|
WindowHide,
|
||||||
WindowHideOthers,
|
WindowHideOthers,
|
||||||
WindowShowAll,
|
WindowShowAll,
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ pub enum AppWindowMessage {
|
||||||
Maximize,
|
Maximize,
|
||||||
Fullscreen,
|
Fullscreen,
|
||||||
Drag,
|
Drag,
|
||||||
|
Focus,
|
||||||
Hide,
|
Hide,
|
||||||
HideOthers,
|
HideOthers,
|
||||||
ShowAll,
|
ShowAll,
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,10 @@ impl MessageHandler<AppWindowMessage, ()> for AppWindowMessageHandler {
|
||||||
#[cfg(not(target_family = "wasm"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
responses.add(FrontendMessage::WindowDrag);
|
responses.add(FrontendMessage::WindowDrag);
|
||||||
}
|
}
|
||||||
|
AppWindowMessage::Focus => {
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
|
responses.add(FrontendMessage::WindowFocus);
|
||||||
|
}
|
||||||
AppWindowMessage::Hide => {
|
AppWindowMessage::Hide => {
|
||||||
#[cfg(not(target_family = "wasm"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
responses.add(FrontendMessage::WindowHide);
|
responses.add(FrontendMessage::WindowHide);
|
||||||
|
|
|
||||||
|
|
@ -362,6 +362,8 @@ pub enum FrontendMessage {
|
||||||
#[cfg(not(target_family = "wasm"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
WindowHide,
|
WindowHide,
|
||||||
#[cfg(not(target_family = "wasm"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
|
WindowFocus,
|
||||||
|
#[cfg(not(target_family = "wasm"))]
|
||||||
WindowHideOthers,
|
WindowHideOthers,
|
||||||
#[cfg(not(target_family = "wasm"))]
|
#[cfg(not(target_family = "wasm"))]
|
||||||
WindowShowAll,
|
WindowShowAll,
|
||||||
|
|
|
||||||
|
|
@ -819,6 +819,8 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> for Portfolio
|
||||||
|
|
||||||
// Load the document into the portfolio so it opens in the editor
|
// Load the document into the portfolio so it opens in the editor
|
||||||
self.load_document(document, document_id, responses);
|
self.load_document(document, document_id, responses);
|
||||||
|
|
||||||
|
responses.add(AppWindowMessage::Focus);
|
||||||
}
|
}
|
||||||
PortfolioMessage::OpenImage { name, image } => {
|
PortfolioMessage::OpenImage { name, image } => {
|
||||||
// `NewDocumentWithName`'s handler routes empty/None-equivalent names through `resolve_document_name` which assigns the next available "Untitled Document {N}".
|
// `NewDocumentWithName`'s handler routes empty/None-equivalent names through `resolve_document_name` which assigns the next available "Untitled Document {N}".
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue