Replace change_always_on_top action with change_level
This commit is contained in:
parent
a7fa7e4005
commit
f0788b9f37
3 changed files with 17 additions and 28 deletions
|
|
@ -5,7 +5,7 @@ pub use action::Action;
|
|||
|
||||
use crate::command::{self, Command};
|
||||
use crate::core::time::Instant;
|
||||
use crate::core::window::{Event, Icon, Mode, UserAttention};
|
||||
use crate::core::window::{Event, Icon, Level, Mode, UserAttention};
|
||||
use crate::futures::subscription::{self, Subscription};
|
||||
|
||||
/// Subscribes to the frames of the window of the running application.
|
||||
|
|
@ -53,7 +53,7 @@ pub fn move_to<Message>(x: i32, y: i32) -> Command<Message> {
|
|||
Command::single(command::Action::Window(Action::Move { x, y }))
|
||||
}
|
||||
|
||||
/// Sets the [`Mode`] of the window.
|
||||
/// Changes the [`Mode`] of the window.
|
||||
pub fn change_mode<Message>(mode: Mode) -> Command<Message> {
|
||||
Command::single(command::Action::Window(Action::ChangeMode(mode)))
|
||||
}
|
||||
|
|
@ -99,9 +99,9 @@ pub fn gain_focus<Message>() -> Command<Message> {
|
|||
Command::single(command::Action::Window(Action::GainFocus))
|
||||
}
|
||||
|
||||
/// Changes whether or not the window will always be on top of other windows.
|
||||
pub fn change_always_on_top<Message>(on_top: bool) -> Command<Message> {
|
||||
Command::single(command::Action::Window(Action::ChangeAlwaysOnTop(on_top)))
|
||||
/// Changes the window [`Level`].
|
||||
pub fn change_level<Message>(level: Level) -> Command<Message> {
|
||||
Command::single(command::Action::Window(Action::ChangeLevel(level)))
|
||||
}
|
||||
|
||||
/// Fetches an identifier unique to the window.
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
use crate::core::window::{Icon, Mode, UserAttention};
|
||||
use crate::core::window::{Icon, Level, Mode, UserAttention};
|
||||
use crate::futures::MaybeSend;
|
||||
|
||||
use std::fmt;
|
||||
|
||||
/// An operation to be performed on some window.
|
||||
pub enum Action<T> {
|
||||
/// Closes the current window and exits the application.
|
||||
/// Close the current window and exits the application.
|
||||
Close,
|
||||
/// Moves the window with the left mouse button until the button is
|
||||
/// Move the window with the left mouse button until the button is
|
||||
/// released.
|
||||
///
|
||||
/// There’s no guarantee that this will work unless the left mouse
|
||||
|
|
@ -20,7 +20,7 @@ pub enum Action<T> {
|
|||
/// The new logical height of the window
|
||||
height: u32,
|
||||
},
|
||||
/// Sets the window to maximized or back
|
||||
/// Set the window to maximized or back
|
||||
Maximize(bool),
|
||||
/// Set the window to minimized or back
|
||||
Minimize(bool),
|
||||
|
|
@ -70,15 +70,11 @@ pub enum Action<T> {
|
|||
///
|
||||
/// - **Web / Wayland:** Unsupported.
|
||||
GainFocus,
|
||||
/// Change whether or not the window will always be on top of other windows.
|
||||
///
|
||||
/// ## Platform-specific
|
||||
///
|
||||
/// - **Web / Wayland:** Unsupported.
|
||||
ChangeAlwaysOnTop(bool),
|
||||
/// Change the window [`Level`].
|
||||
ChangeLevel(Level),
|
||||
/// Fetch an identifier unique to the window.
|
||||
FetchId(Box<dyn FnOnce(u64) -> T + 'static>),
|
||||
/// Changes the window [`Icon`].
|
||||
/// Change the window [`Icon`].
|
||||
///
|
||||
/// On Windows and X11, this is typically the small icon in the top-left
|
||||
/// corner of the titlebar.
|
||||
|
|
@ -119,9 +115,7 @@ impl<T> Action<T> {
|
|||
Action::RequestUserAttention(attention_type)
|
||||
}
|
||||
Self::GainFocus => Action::GainFocus,
|
||||
Self::ChangeAlwaysOnTop(on_top) => {
|
||||
Action::ChangeAlwaysOnTop(on_top)
|
||||
}
|
||||
Self::ChangeLevel(level) => Action::ChangeLevel(level),
|
||||
Self::FetchId(o) => Action::FetchId(Box::new(move |s| f(o(s)))),
|
||||
Self::ChangeIcon(icon) => Action::ChangeIcon(icon),
|
||||
}
|
||||
|
|
@ -154,8 +148,8 @@ impl<T> fmt::Debug for Action<T> {
|
|||
write!(f, "Action::RequestUserAttention")
|
||||
}
|
||||
Self::GainFocus => write!(f, "Action::GainFocus"),
|
||||
Self::ChangeAlwaysOnTop(on_top) => {
|
||||
write!(f, "Action::AlwaysOnTop({on_top})")
|
||||
Self::ChangeLevel(level) => {
|
||||
write!(f, "Action::ChangeLevel({level:?})")
|
||||
}
|
||||
Self::FetchId(_) => write!(f, "Action::FetchId"),
|
||||
Self::ChangeIcon(_icon) => {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ use crate::{Clipboard, Error, Proxy, Settings};
|
|||
use futures::channel::mpsc;
|
||||
|
||||
use std::mem::ManuallyDrop;
|
||||
use winit::window::WindowLevel;
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
pub use profiler::Profiler;
|
||||
|
|
@ -795,12 +794,8 @@ pub fn run_command<A, E>(
|
|||
window::Action::GainFocus => {
|
||||
window.focus_window();
|
||||
}
|
||||
window::Action::ChangeAlwaysOnTop(on_top) => {
|
||||
let level = match on_top {
|
||||
true => WindowLevel::AlwaysOnTop,
|
||||
false => WindowLevel::Normal,
|
||||
};
|
||||
window.set_window_level(level);
|
||||
window::Action::ChangeLevel(level) => {
|
||||
window.set_window_level(conversion::window_level(level));
|
||||
}
|
||||
window::Action::FetchId(tag) => {
|
||||
proxy
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue