Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always_on_top for WindowBuilder #2265

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ You can find its changes [documented below](#070---2021-01-01).

## Unreleased

- Always on top setting for WindowBuilder ([#2265] by [@mgalos999])

### Highlights

- International text input support (IME) on macOS.
Expand Down
4 changes: 4 additions & 0 deletions druid-shell/src/backend/gtk/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ impl WindowBuilder {
self.transparent = transparent;
}

pub fn set_always_on_top(&mut self, _always_on_top: bool) {
tracing::warn!("set_always_on_top unimplemented for gtk");
}

pub fn set_position(&mut self, position: Point) {
self.position = Some(position);
}
Expand Down
4 changes: 4 additions & 0 deletions druid-shell/src/backend/mac/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,10 @@ impl WindowBuilder {
self.transparent = transparent;
}

pub fn set_always_on_top(&mut self, _always_on_top: bool) {
tracing::warn!("set_always_on_top unimplemented for mac");
}

pub fn set_level(&mut self, level: WindowLevel) {
self.level = Some(level);
}
Expand Down
6 changes: 6 additions & 0 deletions druid-shell/src/backend/wayland/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,12 @@ impl WindowBuilder {
);
}

pub fn set_always_on_top(&mut self, _always_on_top: bool) {
tracing::warn!(
"set_always_on_top unimplemented for wayland"
);
}

pub fn set_position(&mut self, position: Point) {
self.position = Some(position);
}
Expand Down
4 changes: 4 additions & 0 deletions druid-shell/src/backend/web/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ impl WindowBuilder {
// Ignored
}

pub fn set_always_on_top(&mut self, _always_on_top: bool) {
// Ignored
}

pub fn set_position(&mut self, _position: Point) {
// Ignored
}
Expand Down
10 changes: 10 additions & 0 deletions druid-shell/src/backend/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ pub(crate) struct WindowBuilder {
show_titlebar: bool,
size: Option<Size>,
transparent: bool,
always_on_top: bool,
min_size: Option<Size>,
position: Option<Point>,
level: Option<WindowLevel>,
Expand Down Expand Up @@ -1281,6 +1282,7 @@ impl WindowBuilder {
resizable: true,
show_titlebar: true,
transparent: false,
always_on_top: false,
present_strategy: Default::default(),
size: None,
min_size: None,
Expand Down Expand Up @@ -1324,6 +1326,10 @@ impl WindowBuilder {
}
}

pub fn set_always_on_top(&mut self, always_on_top: bool) {
self.always_on_top = always_on_top;
}

pub fn set_title<S: Into<String>>(&mut self, title: S) {
self.title = title.into();
}
Expand Down Expand Up @@ -1470,6 +1476,10 @@ impl WindowBuilder {
dwExStyle |= WS_EX_NOREDIRECTIONBITMAP;
}

if self.always_on_top {
dwExStyle |= WS_EX_TOPMOST;
}

match self.state {
window::WindowState::Maximized => dwStyle |= WS_MAXIMIZE,
window::WindowState::Minimized => dwStyle |= WS_MINIMIZE,
Expand Down
4 changes: 4 additions & 0 deletions druid-shell/src/backend/x11/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ impl WindowBuilder {
self.transparent = transparent;
}

pub fn set_always_on_top(&mut self, _always_on_top: bool) {
warn!("WindowBuilder::set_always_on_top is currently unimplemented for X11 backend.");
}

pub fn set_position(&mut self, position: Point) {
self.position = Some(position);
}
Expand Down
5 changes: 5 additions & 0 deletions druid-shell/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,11 @@ impl WindowBuilder {
self.0.set_transparent(transparent)
}

/// Set whether the window is always on top
pub fn set_always_on_top(&mut self, always_on_top: bool) {
self.0.set_always_on_top(always_on_top)
}

/// Sets the initial window position in display points.
/// For windows with a parent, the position is relative to the parent.
/// For windows without a parent, it is relative to the origin of the virtual screen.
Expand Down