Commit Graph

183 Commits

Author SHA1 Message Date
divVerent
60df512352
Switch out the devicescale implementation by one that relies on glfw/xrandr. (#1800)
This should fix fullscreen mode on Linux/X11 systems in general,
while not affecting other systems.

Note that this deletes a bunch of OS X specific and Windows specific code,
as GLFW already provides this functionality.

This change is not expected to cause regressions, however,
the current behavior is still wrong and leads to wrong/unintended window sizes.
To be fixed in further PRs.

Updates #1774
2021-09-14 12:35:02 +09:00
Hajime Hoshi
39e7f71ccb internal/uidriver/glfw: Bug fix: Forbide Maximize/MinimizeWindow on the native fullscreen on macOS
Closes #1810
2021-09-12 23:38:44 +09:00
Hajime Hoshi
f23dadb8ae
Add internal/gamepaddb (#1805)
This is basically a revert of 93a156a718.
This implements parsing the SDL gamepad mappings by Ebiten instead
of GLFW, so that Ebiten can handle parsing errors completely.

Closes #1802
2021-09-11 22:46:05 +09:00
Hajime Hoshi
37771717cc internal/uidriver: Bug fix: Potential memory leak by [:0]
Updates #1803
2021-09-10 02:17:29 +09:00
Hajime Hoshi
106ff7a84b internal/ui: Reduce calls of glfw.GetMonitors
Updates #1803
2021-09-09 11:14:08 +09:00
Hajime Hoshi
d5ce0dbd90 internal/uidriver/glfw: Bug fix: Disable the sticky mode on FPSModeVsyncOffMinimum
Closes #1791
2021-08-31 11:43:11 +09:00
Hajime Hoshi
40d2dd3ba7 internal/uidriver/glfw: Update comments
Updates #1787
2021-08-26 02:05:30 +09:00
Hajime Hoshi
15ac69b8d5 internal/graphicsdriver/metal: Bug fix: Disable presentsWithTransaction on fullscreen
Closes #1745
2021-08-08 17:40:37 +09:00
Hajime Hoshi
cc1accc32a internal/uidriver/glfw: Bug fix: Disable vsync when resizing the window
Closes #1740
2021-08-06 03:08:04 +09:00
Hajime Hoshi
0bc5166a36 driver: Refactoring: Rename functions 2021-08-05 01:29:45 +09:00
Hajime Hoshi
1706d9436a ebiten: Add FPSModeType, FPSMode, SetFPSMode, and ScheduleFrame
This change adds these APIs:

  * type FPSModeType
  * func FPSMode
  * func SetFPSMode
  * func ScheduleFrame

and deprecates these APIs:

  * func SetVsyncEnabled
  * func IsVsyncEnabled

Closes #1556
2021-07-24 16:09:13 +09:00
Hajime Hoshi
2503323557 internal/driver: Add FPSMode
Updates #1556
2021-07-23 00:47:09 +09:00
Hajime Hoshi
93a156a718 internal/uidriver/glfw: Use glfwGameGamepadState
This change replaces the usage of gamepaddb package with glfwGetGamepadState.

Updates #1557
2021-07-21 16:09:30 +09:00
Hajime Hoshi
49c3c30c79 ebiten: Add IsWindowBeingClosed / SetWindowClosingHandled / IsWindowClosingHandled
IsWindowBeingClosed reports whether the window is being closed by
the user.

SetWindowClosingHandled sets whether the window closing is handled
or not. If the state is true, the window is not closed immediately
by the user and the game can handle the closing state. In this case,
the Update function should return an error in order to end the game.

This change also adds examples/windowclosing.

Closes #1574
2021-06-14 02:29:11 +09:00
Hajime Hoshi
f989ce4e64 internal/uidriver/glfw: Rename variables 2021-06-13 23:25:24 +09:00
Hajime Hoshi
3c2d562967 internal/glfw: Bug fix: NewCallbackCDecl objects were leaked
Callbacks created by NewCallbackCDecl were never released and then
they are leaked, especially when the window size was changed by
SetWindowSize on Windows.

This change defines new callback ID types with uintptr, and reuse
the callbacks.

Closes #1672
2021-06-13 22:23:01 +09:00
Hajime Hoshi
b54ad73a2b Add go:build comments with go1.17beta1 fmt 2021-06-11 01:11:46 +09:00
Hajime Hoshi
58843b68f9 internal/hooks: Enable to return error at suspend/resume audio 2021-05-04 23:09:01 +09:00
Tom Lister
bea5ab3335
internal/uidriver/glfw: Native macOS implementation for setting cursor shape (#1624)
Updates #1624
2021-05-02 14:50:50 +09:00
Hajime Hoshi
091e51ae4c internal/uidriver/glfw: Avoid allocating a new slice 2021-04-25 00:57:06 +09:00
Hajime Hoshi
91f8347500 internal/uidriver/glfw: Avoid busy loop by sleeping
Updates #1580
2021-04-24 05:19:23 +09:00
Hajime Hoshi
3df31c0fce internal/uidriver/glfw: Bug fix: Deadlock at FramebufferSize callback
glfw.PollEvents might invoke multiple FramebufferSize callbacks in
theory, this is very rare though. In this case, the sending an object
to the channel never ends.

This change fixes this deadlock by using 'select'.

Closes #1618
2021-04-24 02:22:51 +09:00
Hajime Hoshi
ac9a18931c internal/uidriver/glfw: Fix comments
Updates #1618
2021-04-23 03:28:14 +09:00
Hajime Hoshi
d446aa39a9 internal/uidriver/glfw: Bug fix: Always wait for SetFramebuffer
In case when the callback is not called, let's use timeout.

Updates #1618
2021-04-23 03:02:12 +09:00
Hajime Hoshi
c4c331b0d5 Fix misspellings 2021-04-21 22:50:00 +09:00
Hajime Hoshi
4cb6cb9d6a internal/uidriver/glfw: Misspelling 2021-04-21 22:29:54 +09:00
Hajime Hoshi
1013ca9c66 internal/uidriver/glfw: Bug fix: A window can never be 'maximized' on fullscreen
When the window is fullscreen, calling MaximizeWindow never returned.
Apparently the attribute glfw.Maximized can never be true on the
fullscreen mode.

This change fixes the issue by checking the fullscreen state.
2021-04-21 22:25:14 +09:00
Hajime Hoshi
c7dd9a4107 internal/uidriver/glfw: Bug fix: Wait for Restore/Maximize/Iconify finishes explicitly
On Linux (and probably other UNIX OSes), glfwRestore, glfwMaximize,
and glfwIconify returns even though the window state has not changed.
Wait for its finish by a for loop and glfw.PollEvents.

Closes #1608
2021-04-21 00:52:06 +09:00
Hajime Hoshi
58572fb000 internal/uidriver/glfw: Bug fix: Unexpected small window size on Linux
At the initial phase, GLFW window's GetSize seems unreliable. Do not
call it on Linux. On the other hand, this is still necessary on macOS.

Updates #1606
Closes #1609
2021-04-20 23:38:34 +09:00
Hajime Hoshi
ec5b806241 Revert "internal/uidriver/glfw: Bug fix: Delay to enable SetSize callback"
This reverts commit fbe6961528.

Reason: This doesn't fix the issue unfortunately
2021-04-20 23:01:02 +09:00
Hajime Hoshi
fbe6961528 internal/uidriver/glfw: Bug fix: Delay to enable SetSize callback
On Linux, the SetSize callback is invoked with an unexpected value
at the initial phase. Just delay it until the initialization
finishes.
2021-04-20 22:53:48 +09:00
Hajime Hoshi
47f569e473 internal/uidriver/glfw: Bug fix: setWindowSize could not accept a fullscreen size 2021-04-20 20:09:04 +09:00
Hajime Hoshi
ee8bfcd837 internal/uidriver/glfw: Bug fix: Disable the SetSize callback for most of GLFW window functions
Updates #1576
Updates #1585
Closes #1606
2021-04-20 18:32:39 +09:00
Hajime Hoshi
18ce150495 internal/uidriver/glfw: Bug fix: getWindowSizeLimits should return -1 when the original value was -1
Updates #1602
2021-04-20 11:05:17 +09:00
Hajime Hoshi
dcaa1f9722 internal/uidriver/glfw: Bug fix: Need to reregister the callback after recreating the window
Updates #1588
Closes #1593
2021-04-19 01:28:59 +09:00
Hajime Hoshi
fd80583dd0 internal/uidriver/glfw: Bug fix: Defer SetIcon on the fullscreen mode
Closes #1587
2021-04-18 22:28:01 +09:00
Hajime Hoshi
7e61189c3d internal/uidriver/glfw: Bug fix: Avoid registring C callbacks too often
Instead of registring/unregistering callbacks, use a boolean flag.

Closes #1588
2021-04-18 22:07:29 +09:00
Hajime Hoshi
c88ee0d0ad internal/uidriver/glfw: Bug fix: Unregister SetSize callback when undecorate the window
Closes #1586
2021-04-18 21:24:56 +09:00
Hajime Hoshi
f5a4216434 internal/uidriver/glfw: Bug fix: Do not call setWindowSize on iconifying
The window size might be 0 after iconifying. An iconified window is
invisible to users so setting a window size doesn't make sense anyway.

Closes #1585
2021-04-18 21:06:04 +09:00
Hajime Hoshi
78732d93f6 internal/uidriver/glfw: Bug fix: Crash on some operations on native fullscreen mode (macOS)
This change forbids some operations when the wiindow is natively
fullscreened on macOS in order to avoid crashes.

Closes #1578
2021-04-18 18:11:33 +09:00
Hajime Hoshi
fda1fd9a95 internal/uidriver/glfw: Bug fix: FramebufferSize callback was not called when the window size was not changed
Closes #1580
2021-04-18 15:22:51 +09:00
Hajime Hoshi
f09cf7fa47 internal/uidriver/glfw: Bug fix: Crash at Iconify
This is the same reason as Maximize.

Updates #1576
2021-04-18 01:03:13 +09:00
Hajime Hoshi
b5d4c834b8 internal/uidriver/glfw: Bug fix: More precise window size adjustment
Before this change, setWindowSize converts the size in device-
independent pixels once, invokes adjustWindowSizeBasedOnSizeLimitsInDP,
and then restore the values in device-dependent pixels. This might
introduce a slight error and then SetSize be unexpectedly invoked.
Such SetSize call with a slightly different size might not invoke
the FramebufferSize callback, and then this blocked forever when
maximizing the window.

This change fixes this by adjusting the size limits instead of the
window size so that the window size is not modified unexpectedly.

Closes #1577
2021-04-18 00:56:37 +09:00
Hajime Hoshi
d6ab27a5a2 internal/uidriver/glfw: Bug fix: Crash at Restore
This is the same reason as Maximize.

Updates #1576
2021-04-18 00:10:40 +09:00
Hajime Hoshi
37944d67c4 internal/uidriver/glfw: Update comments
Updates #1576
2021-04-18 00:05:48 +09:00
Hajime Hoshi
ab8477a21a internal/uidriver/glfw: Bug fix: Crash on Maximize
At least on macOS, Maximize invokes the SetSize callback in the game's
Update. This change fixes this issue by unregisting the callback
temporarily like what #1505 did.

Closes #1576
2021-04-18 00:02:58 +09:00
Hajime Hoshi
6df87a0383 internal/uidriver: Add comments
Updates #1575
2021-04-17 18:17:26 +09:00
Hajime Hoshi
deba352384 internal/uidriver/glfw: Prefer currentMonitor to get the monitor at deviceScaleFactor 2021-04-17 17:03:50 +09:00
Hajime Hoshi
585f173d1c internal/uidriver/glfw: Bug fix: Treat pixel units correctly
Updates #1385
2021-04-17 04:43:33 +09:00
Hajime Hoshi
99b2b5c1ee internal/glfw: Bug fix: compile error on Windows
Updates #1385
2021-04-17 04:24:19 +09:00