Closed GreenXenith closed 5 years ago
I'll take a look at this myself this/next week
Also, the invisible cursor persists even after the user leaves the game window or alt-tabs to another window.
I don't see this as an issue. Using focus events (or exit/entry events once implemented) this is easily solved.
local function focus(self, event)
if event == window.WINDOW_EVENT_FOCUS_GAINED then
defos.set_cursor_visible(false)
elseif event == window.WINDOW_EVENT_FOCUS_LOST the
defos.set_cursor_visible(true)
end
end
function init(self)
window.set_listener(focus)
end
Seems to me its up to the developer to implement on their own.
I will look into solving the GNOME issue if I can.
UPDATE: It is not GNOME-specific. I failed to test mouse input I guess. This can likely be fixed.
Usually on Windows we check in game if the cursor is outside of the view to unhide it I think.
@dapetcu21 The issue is now fixed on this PR simply because I nuked XGrabPointer
, now using XFixes instead (much simpler) and it seems to work.
As @subsoap has said, defining when the cursor is visible or not should be totally up to the developer. I prefer to give them maximum freedom.
I don't see this as an issue. Using focus events (or exit/entry events once implemented) this is easily solved.
Changes to the mouse cursor when the application is not in focus is not desirable behaviour in any situation. Most developers will forget to handle that situation. Moreso, on macOS this behaviour is not even possible. We should keep the API consistent between OS-es.
So, I checked. On macOS, hiding the pointer hides it no matter where the pointer is, but unfocusing the app brings the pointer back and on Windows, the pointer is only hidden within the confines of the window. It's currently a bit inconsistent, but I think the best compromise would be for Linux to mirror the macOS behaviour, where the pointer is un-hidden when Alt+Tabbing to another app, but otherwise hidden no matter where on the screen the pointer is.
If the user wants to only hide the pointer inside the game window, they can use the enter/leave events, just like in the example script.
I also tested this on Linux. The XFixes solution works great. I'll implement un-hide on alt+tab, then merge this.
Hiding the cursor was broken on Linux (XFCE), perhaps other flavors as well. This uses
XGrabPointer
to set the cursor visibility. Theevent_mask
contains a few events, I'm not sure if they are enough or are even needed. Needs testing on other flavors to make sure it didn't break.