Comments (7)
Btw. t.window.highdpi = true does not work on Windows.
That's correct, the version of SDL love uses doesn't support it on Windows with love 11's api.
It does work on macOS, iOS, Android, and Wayland (Linux). Microsoft ended up implementing app DPI scaling in a manner that's incompatible with how love sets it dynamically for the window though.
love 12 has a global per-app API for it instead, to accommodate Windows.
from love.
It's working as expected for me in Windows 10 with love 11.5 - in windowed mode, the mouse position isn't updated when the cursor is outside of the window (no matter what edge). In fullscreen it behaves the same, I have two monitors and if my mouse cursor goes past the right edge of the primary one where love is into my secondary monitor, then the mouse position in love doesn't update.
Additionally, if I hold my left mouse button down and move the cursor around, it updates the mouse position past the bounds of the window no matter the edge but still clamps it (this is new intended behaviour as of the latest SDL version).
Do you have a multi-monitor setup that extends past the bottom and right sides of the display where you made that recording, maybe?
love also has APIs like love.mouse.setRelativeMode and love.mouse.setGrabbed if you want to constrain the user's cursor to the window in a particular way.
from love.
I only have one monitor. The mouse is within the screen. In the gif video, you can see a bit of the cursor when moving on the right edge. I know that the mouse is not updating when moved outside. This is ok. But in this case, the mouse is still within the window. You can just detect this bug in fullscreen where you can't move outside.
One use case I'm thinking is an RTS/city building game where you can move the mouse on the edge to scroll the camera view. No mouse event (click or position) is working on the edge right or bottom.
function love.draw()
love.graphics.clear(0.1, 0.2, 0.3, 0.1)
local sw, sh = love.graphics.getDimensions()
local mx, my = love.mouse.getPosition()
love.graphics.setColor(0.3, 0.4, 0.5)
love.graphics.setLineWidth(5)
love.graphics.line(0, my, sw, my)
love.graphics.line(mx, 0, mx, sh)
love.graphics.circle("fill", mx, my, love.mouse.isDown(1) and 30 or 10)
end
function love.keypressed(key)
if key == "escape" then love.event.quit() end
if key == "f11" then love.window.setFullscreen(not love.window.getFullscreen()) end
end
As you can see in the code. You can now click the (left) mouse button to change the circle size. Try it on the edge. Unplug your second monitor and test it.
I don't know the source code but it looks like (pseudo code):
mosue_pos >= 0 and mouse_pos < screen_size
-- instead of
mosue_pos >= 0 and mouse_pos <= screen_size
You know what I mean? Or the game area is 1 pixel smaller that the screen. Or the window invisible border blocks the event. I don't know. But it's definitly a bug.
from love.
Like I said, it's working as expected on my system, I can't reproduce the problem you're describing - and also love doesn't have code like that itself (it just does what SDL and the OS do under the hood). So there's probably a difference between our two systems causing it. Maybe the OS itself considering you have windows 11 and I have windows 10, or maybe something else.
Do you use a DPI scale / display scale set to something other than 100%, for your monitor? Windows will handle a bunch of scaling itself and upscale love in that situation.
from love.
Indeed, I use 200% UI scaling for my 4k TV. For testing I changed it back to 100% and the problem no longer occurs. So it seems it's related to the UI scaling. Can someone reproduce this or explain what happened here? So, it's a bug. The question is, can we fix this in love2d? Any workaround?
from love.
Btw. t.window.highdpi = true
does not work on Windows. I would expect an option to disable scaling for the application. I also tried variations with t.window.usedpiscale
. It seems this is not supported in love2d. These options are for mobile, right? In e.g. Godot this option also works on Windows. Btw. this is one reason why the screen looks pixelated.
from love.
I just played around again and found this... (for the sake of completeness and possible bug fixes)
- It has nothing to do with the fullscreen. I was able to reproduce the same behavior with
mouse.setGrabbed
. - If
isGrabbed
then the mouse also hangs on right / bottom edges. - If I click and hold the mouse button while moving the cursor around the edges and outside, it works without any problems.
In both cases (grabbed and pressing) the mouse position on edge is the same. But only pressing works as expected (mouse also works on edges). But you can also move the mouse outside the game (if windowed). So I guess it's a global mouse event. Only the last pixel on the right/bottom doesn't seem to be a part of the game view. So setGrabbed
does also not work. ...
demo.webm
function love.load()
love.mouse.setGrabbed(true)
end
function love.draw()
love.graphics.clear(0.1, 0.2, 0.3, 0.1)
local sw, sh = love.graphics.getDimensions()
local mx, my = love.mouse.getPosition()
love.graphics.setColor(0.3, 0.4, 0.5)
love.graphics.setLineWidth(5)
love.graphics.line(0, my, sw, my)
love.graphics.line(mx, 0, mx, sh)
love.graphics.circle("fill", mx, my, love.mouse.isDown(1) and 30 or 10)
love.graphics.setColor(1, 1, 1)
love.graphics.print("ESC: Quit; F11: Fullscreen; F1: Grab/Free mouse", 10, 10)
love.graphics.print("Screen size: " .. sw .. ", " .. sh, 10, 30)
love.graphics.print("Mouse pos: " .. mx .. ", " .. my, 10, 50)
end
function love.keypressed(key)
if key == "escape" then love.event.quit() end
if key == "f11" then love.window.setFullscreen(not love.window.getFullscreen()) end
if key == "f1" then love.mouse.setGrabbed(not love.mouse.isGrabbed()) end
end
from love.
Related Issues (20)
- Request: Love2D Android app ability to import and store .love files in its own directory (similar to iOS version) HOT 6
- Feature request: love.filesystem.newTempFile HOT 7
- Bug: File:read() returns empty string instead of nil when past end of file HOT 2
- Low FPS on certain monitor HOT 6
- love.data.compress causes a segfault on macOS Big Sur (LOVE 11.5) HOT 9
- Regression 11.5: key events not triggered when an IME language is active (windows) HOT 12
- [12.0] C++ exception with newShader() and Vulkan renderer
- (Android/IOS) Display rotation control HOT 1
- [Linux] Add better packaging/distribution options HOT 20
- Brew install fails on macOS with: Error : SHA256 mismatch HOT 1
- Add a way to get Video duration
- Android Depth Buffer HOT 2
- remove the arbitrary 10x near/far plane scaling in the default projection matrix HOT 12
- Improve documentation about the window's depth buffer HOT 2
- Feature request: more performant anti-aliasing. Like FXAA or TAA. HOT 3
- Depth writes not writing to set mipmap HOT 2
- t.window.resizble = false doesn't work on android with LOVE 12 HOT 5
- Documentation: optional didactic "Implementation Details" section HOT 12
- symbol not found in flat namespace (___PHYSFS_platformCalcBaseDir) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from love.