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

Windows 10: Window Resizing Triggered on Launch #593

Open
Fidifis opened this issue Sep 1, 2024 · 2 comments
Open

Windows 10: Window Resizing Triggered on Launch #593

Fidifis opened this issue Sep 1, 2024 · 2 comments

Comments

@Fidifis
Copy link

Fidifis commented Sep 1, 2024

On Windows 10 (possibly other versions), any app built with libcosmic opens with triggered window resizing on right edge, following mouse. You must click somewhere to release the drag. This happens on every lanuch.

Steps to Reproduce:

  1. Be on Windows
  2. Download example project libcosmic/examples/application
  3. Edit Cargo.toml and put away xdg-portal feature (crashes the build)
  4. Compile and run
  5. The window is resizing immediately upon launch

Expected Behavior: The window should open normally without being in resizing mode.

Tested with Windows 10, on physical and virtual machine.
Affects all libcosmic apps I tried.

libcosmic revision: 0a1922d (latest master)
rustc version: 1.80.1 (3f5fd8dd4 2024-08-06)
cargo version: 1.80.1 (376290515 2024-07-16)

example.mp4
@netengy-dakotaraptor
Copy link
Contributor

netengy-dakotaraptor commented Oct 6, 2024

Does anyone know of a workaround for this (that is, is there a way to manually cancel a window resize on launch)?

@netengy-dakotaraptor
Copy link
Contributor

Ok, I think I've figured out where the bug is. At the very least, I found out what to change to stop it, but I'm not sure what the actual fix should be because I don't fully understand the reasoning behind the code here.

In iced_winit::application::run_instance(), there is this call around line 413:

    // Creates closure for handling the window drag resize state with winit.
    let mut drag_resize_window_func = drag_resize::event_func(
        &window,
        resize_border as f64 * window.scale_factor(),
    );

That function is in the drag_resize submodule of application and appears to return a closure only if the following evaluates to true:

window.drag_resize_window(ResizeDirection::East).is_ok()

According to the winit docs, this starts a window drag event.

If I alter drag_resize::event_func to always return the closure and not perform that check, the resize on launch bug disappears and everything seems to work fine.

Now, that function does have this comment on it:

/// If supported by winit, returns a closure that implements cursor resize support.

So...is there a different way to perform this check without triggering a resize on launch? Or am I completely off base here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants