egui icon indicating copy to clipboard operation
egui copied to clipboard

InputState.screen_rect on Windows does not have position

Open barries opened this issue 1 year ago • 2 comments

Describe the bug According to the docs: InputState.screen_rect: Position and size of the egui area.

However, this code:

fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
    let ui_size = ctx.input(|i: &egui::InputState| i.screen_rect());

    info!("ui_size: {ui_size:?}");

...always reports an origin of [0.0 0.0] when dragging the window:

[2024-10-02T19:10:45Z INFO  iotasoft_ui::app] ui_size: [[0.0 0.0] - [1024.0 768.0]]
...
[2024-10-02T19:10:48Z INFO  iotasoft_ui::app] ui_size: [[0.0 0.0] - [1024.0 768.0]]
...
[2024-10-02T19:10:49Z INFO  iotasoft_ui::app] ui_size: [[0.0 0.0] - [1024.0 768.0]]

To Reproduce Steps to reproduce the behavior:

  1. Add the above code to an eframe_template
  2. Run
  3. Drag window
  4. Observe log

Expected behavior The reported origin is the actual origin, and changes when the window is moved, maximized, full-screened, restored, minimized, etc.

Screenshots

Desktop (please complete the following information):

  • OS: Windows 11 Pro
  • Browser: N/A
  • Version: egui, eframe are 0.28.1

Smartphone (please complete the following information):

  • Device: N/A
  • OS: N/A
  • Browser N/A
  • Version: N/A

Additional context

barries avatar Oct 02 '24 19:10 barries

Please see below.

                let outer_rect = ui
                    .ctx()
                    .input(|i| i.viewport().outer_rect.unwrap_or(egui::Rect::ZERO));
                let inner_rect = ui
                    .ctx()
                    .input(|i| i.viewport().inner_rect.unwrap_or(egui::Rect::ZERO));

rustbasic avatar Oct 03 '24 01:10 rustbasic

Thanks for the workarounds!

This is still a discrepancy between the docs and implementation.

barries avatar Oct 10 '24 14:10 barries