Minimized Window State is incorrect on Linux
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 9.7k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
I've noticed that `WindowHandle::get_window_state()` returns an incorrect state when the window is minimized (it returns Restored, instead of Minimized, maximized works btw). I've noticed that on Windows it returns the correct state (Minimized).
Attaching an example code below.
I'm still new to both Rust and Druid so my approach to this might be wrong (correct me if I'm doing it wrong).
```rust
use druid::widget::{Button, Flex, Label, Widget};
use druid::{
AppDelegate, AppLauncher, Command, Data, DelegateCtx, Env, EventCtx, Handled, Lens,
PlatformError, Selector, Target, WindowDesc, WindowHandle,
};
use std::sync::Arc;
use std::thread;
pub const DELAY_COMMAND: Selector<()> = Selector::new("delay_command");
#[derive(Data, Clone, Lens)]
pub struct AppState {
pub text: String,
pub window_handle: Arc>,
}
fn main() -> Result<(), PlatformError> {
let main_window = WindowDesc::new(ui_builder());
AppLauncher::with_window(main_window)
.log_to_console()
.delegate(Delegate {})
.launch(AppState {
text: "".to_string(),
window_handle: Arc::new(None),
})
}
fn ui_builder() -> impl Widget {
Flex::column()
.with_child(
Button::new("click me to show current window state after 3 secs")
.on_click(on_button_clicked),
)
.with_child(Label::new(|data: &AppState, _env: &_| {
format!("State: {}", &data.text)
}))
}
fn on_button_clicked(ctx: &mut EventCtx, data: &mut AppState, _env: &Env) {
data.window_handle = Arc::new(Some(ctx.window().clone()));
let event_sink = ctx.get_external_handle();
thread::spawn(move || {
thread::sleep(std::time::Duration::from_secs(3));
event_sink
.submit_command(DELAY_COMMAND, (), Target::Auto)
.expect("Can't send message.");
});
}
struct Delegate;
impl AppDelegate for Delegate {
fn command(
&mut self,
_ctx: &mut DelegateCtx,
_target: Target,
cmd: &Command,
data: &mut AppState,
_env: &Env,
) -> Handled {
if cmd.get(DELAY_COMMAND).is_some() {
data.text = format!(
"{:?}",
data.window_handle
.as_ref()
.as_ref()
.unwrap()
.get_window_state()
);
println!("State: {}", data.text);
}
Handled::Yes
}
}
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the attached Rust example on Linux and inspect the implementation of WindowHandle::get_window_state(), especially its Linux platform path. Done means a minimized window reports Minimized rather than Restored, while the existing maximized and Windows behavior remains correct.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100