Skip to content

Winit 0.16 API changes #591

Closed
Closed

Description

@icefoxen

Just bits and pieces I'm stumbling across as I upgrade ggez, that come across as rough edges that should be easy to smooth. Maybe these have perfectly good reasons to be the way they are though, hence an issue rather than a PR.

  • There's grab_cursor() and hide_cursor() methods on Window, but no methods to check whether the cursor is hidden or grabbed
  • MouseScrollDelta::LineDelta provides (f32, f32) but MouseScrollDelta::PixelDelta gives a LogicalPosition which is (f64, f64)
  • Is it possible to set custom mouse cursors via bitmap, or is that too platform-wonky?

Activity

  1. added
    S - api
    C - needs discussion
    on Jul 4, 2018
  2. francesca64 commented on Jul 4, 2018

    @francesca64
    Member

    but no methods to check whether the cursor is hidden or grabbed

    What's the use-case for this?

    MouseScrollDelta::LineDelta

    So you think it should be f64 for consistency? That would definitely be easy.

    Is it possible to set custom mouse cursors via bitmap, or is that too platform-wonky?

    This is actually probably easy to implement. The window icon API sets a precedent for how to expose it, too.

  3. icefoxen commented on Jul 4, 2018

    @icefoxen
    ContributorAuthor

    What's the use-case for this?

    Paranoia that someone will ask for it. :-p

    So you think it should be f64 for consistency?

    Basically. It's not a big deal, just seemed odd that size and distance values were generally f64 except there.

    This is actually probably easy to implement.

    Awesome. I might give it a go sometime.

  4. icefoxen commented on Jul 6, 2018

    @icefoxen
    ContributorAuthor

    Another discovery: WindowBuilder takes the window sizes as LogicalSize. I want ggez to offer user the ability to manage their stuff using either logical or physical sizes. But we can't find the hidpi factor before we have a Window, which means we've already created it at a given size via WindowBuilder.

    We can just create the window, query the hidpi factor, then resize it, so it's not a disaster (unless it's not resizable?), but it feels odd.

    Edit for another thought: It might be convenient to be able to override the hidpi factor to something specific if we want to? We even have a hook to handle this in WindowEvent::HiDpiFactorChanged.

  5. francesca64 commented on Jul 6, 2018

    @francesca64
    Member

    Another discovery: WindowBuilder takes the window sizes as LogicalSize

    Being able to create windows with physical sizes would be fairly trivial to implement on X11 and Windows. On macOS and Wayland, it involves inverting the hacks used for logical sizes on X11 and Windows. This means manually writing logic for resizing windows to desired physical size whenever they move across monitors/etc, while also updating the stored min/max dimensions and so on... along with the logic for guessing the initial DPI factor, and triggering an appropriate resize and corresponding events if said guess is wrong.

    I keep telling people that they can solve any problem using a combination of linear scaling and scissoring (which is necessary anyway unless someone can make the guarantee the window will never resize, which is spoiler: impossible), but people seem to just want winit to do what they tell it to. While I have reservations about encouraging applications that don't respect the user's DPI (admittedly, it's only properly the user's DPI on Windows and Wayland), I'm not Apple the Supreme Goddess Dictator of Application Design, and I recognize that winit exists to serve the people.

    But - and this is a very big but - I don't want to implement this. It should come as a surprise to no one, but I've burned myself out, and I'd like to put more time into my personal projects.

    Edit for another thought: It might be convenient to be able to override the hidpi factor to something specific if we want to

    Well, with the physical size logic above implemented, this would be easy to add on (given some refactoring to make everything link up nicely).

  6. icefoxen commented on Jul 6, 2018

    @icefoxen
    ContributorAuthor

    Hey, that's fine. Platforms differ on the "right" way to do things, so platform-compatibility hacks have to happen somewhere, I'm just glad that they're happening in winit. You've made it so that this is a problem I can solve via a combination of linear scaling and scissoring, so life is good. ;-) It's just a question of whether it's easier for it to be possible for that scaling to happen in winit. It sounds like it isn't; you need special cases either way.

    I totally agree that things should be DPI-agnostic by default, but with ggez my hands are a little tied by the application domain. People writing pixel-y 2D things are usually going to expect one pixel in their sprite editor to be one pixel on the screen, and having to jump through hoops to make that be the case is going to make few people happy. So, I want to figure out the best way to do it, so we can ease people into a new paradigm bit by bit.

    I'll dig a bit at the winit backend code. If I can find a nice way to query and/or set the DPI scaling factor before creating a window, or something like that, we can talk about it and I'll whip up a PR. If not, I'll just have to fake it with a window resize when the application starts and some conversions in ggez, which is kind of annoying but not a huge deal.

  7. Osspial commented on Apr 24, 2019

    @Osspial
    Contributor

    Actually, why is LineDelta exposed as floats, and not ints? I'd assume from the name that it's intended to scroll through lines of text, and I'd assume those would always be integer numbers.

  8. michaelkirk commented on Sep 4, 2020

    @michaelkirk
    Contributor

    why is LineDelta exposed as floats, and not ints

    I believe platforms can send fractional scroll wheel events to control sensitivity.

    e.g. I want to scroll faster in general so I set it to 2x, or I want to scroll slower, so I set it to 0.5x
    one example: https://github.com/up-to-you/linux_notes/blob/master/mouse/scroll_speed.md

  9. skillman623 commented on Mar 2, 2024

    @skillman623

    but no methods to check whether the cursor is hidden or grabbed

    What's the use-case for this?

    It would help avoid custom implementations. Currently we are working around this lack of functionality.
    Lea-fish/Leafish#97

  10. kchibisov commented on Mar 2, 2024

    @kchibisov
    Member

    most things here are not relevant anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C - needs discussionS - api

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions