mirror of
https://github.com/wez/wezterm.git
synced 2024-11-22 22:42:48 +03:00
windows: implement window:maximize(), window:restore()
This commit is contained in:
parent
9779b29c39
commit
2c093b976d
@ -509,12 +509,26 @@ impl Window {
|
||||
}
|
||||
}
|
||||
|
||||
fn schedule_show_window(hwnd: HWindow, show: bool) {
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
|
||||
enum ShowWindowCommand {
|
||||
Normal,
|
||||
Minimize,
|
||||
Maximize,
|
||||
}
|
||||
|
||||
fn schedule_show_window(hwnd: HWindow, show: ShowWindowCommand) {
|
||||
// ShowWindow can call to the window proc and may attempt
|
||||
// to lock inner, so we avoid locking it ourselves here
|
||||
promise::spawn::spawn(async move {
|
||||
unsafe {
|
||||
ShowWindow(hwnd.0, if show { SW_NORMAL } else { SW_MINIMIZE });
|
||||
ShowWindow(
|
||||
hwnd.0,
|
||||
match show {
|
||||
ShowWindowCommand::Normal => SW_NORMAL,
|
||||
ShowWindowCommand::Minimize => SW_MINIMIZE,
|
||||
ShowWindowCommand::Maximize => SW_MAXIMIZE,
|
||||
},
|
||||
);
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
@ -684,11 +698,19 @@ impl WindowOps for Window {
|
||||
}
|
||||
|
||||
fn show(&self) {
|
||||
schedule_show_window(self.0, true);
|
||||
schedule_show_window(self.0, ShowWindowCommand::Normal);
|
||||
}
|
||||
|
||||
fn hide(&self) {
|
||||
schedule_show_window(self.0, false);
|
||||
schedule_show_window(self.0, ShowWindowCommand::Minimize);
|
||||
}
|
||||
|
||||
fn maximize(&self) {
|
||||
schedule_show_window(self.0, ShowWindowCommand::Maximize);
|
||||
}
|
||||
|
||||
fn restore(&self) {
|
||||
schedule_show_window(self.0, ShowWindowCommand::Normal);
|
||||
}
|
||||
|
||||
fn set_cursor(&self, cursor: Option<MouseCursor>) {
|
||||
|
Loading…
Reference in New Issue
Block a user