linebender / linebender/druid

WindowSizePolicy::Content leaves a gap on Windows

Open
#2,030 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug shell/win
Dominant language
Rust
Stars
9.7k
Forks
565
PR merge metrics
No merged PRs in 30d

Description

Building from `git+https://github.com/linebender/druid.git?branch=master#b6d389dec1aaafb239e7f0e72caac0d9de4285b6`.

For code,

```rust
use druid::widget::{TextBox};
use druid::{AppLauncher, Data, Lens, PlatformError, Widget, WidgetExt, WindowDesc};

#[derive(Clone, Data, Lens)]
struct State {
input: String,
}

fn main() -> Result<(), PlatformError> {
let main_window = WindowDesc::new(ui_builder())
.show_titlebar(true)
.window_size_policy(druid::WindowSizePolicy::Content);
let initial_state = State { input: String::new() };
AppLauncher::with_window(main_window)
.launch(initial_state)
}

fn ui_builder() -> impl Widget {
TextBox::new()
.lens(State::input)
.fix_width(350.0)
}
```

When `show_titlebar` is true, the main window size is perfect: https://snipboard.io/d2U4pv.jpg

When `show_titlebar` is false, the main window size is too tall, leaving a gap between the text box and the bottom border of the main window: https://snipboard.io/1o9ts4.jpg

This bug only happens on Windows. On Macos, both cases are fine.

Windows version info: 20H2 (OS Build 19042.1288)

---

Additional info: height of the gap changes with font family. For example, after I changed textbox's font to the monospace family, the gap got visibly bigger.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the provided Rust example using WindowSizePolicy::Content, comparing show_titlebar(true) and false on Windows. Search the WindowSizePolicy implementation and Windows window-sizing entry points, then trace how the content height is calculated. Done means titlebar and borderless windows fit the TextBox without a gap, including with different font families.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.