You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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.
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).
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.
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.
Activity
francesca64 commentedon Jul 4, 2018
What's the use-case for this?
So you think it should be
f64for consistency? That would definitely be easy.This is actually probably easy to implement. The window icon API sets a precedent for how to expose it, too.
icefoxen commentedon Jul 4, 2018
Paranoia that someone will ask for it. :-p
Basically. It's not a big deal, just seemed odd that size and distance values were generally f64 except there.
Awesome. I might give it a go sometime.
icefoxen commentedon Jul 6, 2018
Another discovery:
WindowBuildertakes the window sizes asLogicalSize. I wantggezto 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 aWindow, which means we've already created it at a given size viaWindowBuilder.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.Query window hidpi factor and store it.
francesca64 commentedon Jul 6, 2018
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
Applethe 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.
Well, with the physical size logic above implemented, this would be easy to add on (given some refactoring to make everything link up nicely).
icefoxen commentedon Jul 6, 2018
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.
Osspial commentedon Apr 24, 2019
Actually, why is
LineDeltaexposed 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.michaelkirk commentedon Sep 4, 2020
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
skillman623 commentedon Mar 2, 2024
It would help avoid custom implementations. Currently we are working around this lack of functionality.
Lea-fish/Leafish#97
kchibisov commentedon Mar 2, 2024
most things here are not relevant anymore.