Commit Graph

978 Commits

Author SHA1 Message Date
Hajime Hoshi
df3a1c3cdd internal/ui: remove an unused function 2023-10-15 01:32:39 +09:00
Hajime Hoshi
2a8d8d71fc internal/ui: merge init functions
The Go specification doesn't determine the order of init functions.
In order to reduce unexpected behavior, merge some init functions.
2023-10-15 00:17:09 +09:00
Hajime Hoshi
7018e7dfb1 internal/ui: rename files 2023-10-11 02:03:58 +09:00
Hajime Hoshi
738f13f73f internal/ui: remove unnecessary build tags 2023-10-09 23:39:06 +09:00
Hajime Hoshi
cede5027d3 internal/glfw: merge internal/cglfw into internal/glfw
Closes #2703
2023-10-07 23:59:55 +09:00
Hajime Hoshi
98dc59c89f internal/cglfw: let functions return errors
Updates #2703
2023-10-07 20:28:03 +09:00
Hajime Hoshi
82bceba847 internal/cglfw: let functions return errors in native_darwin.go and glfw_unix.go
Updates #2703
2023-10-07 18:37:06 +09:00
Hajime Hoshi
82f2319020 internal/hook: rename hooks -> hook 2023-10-06 13:58:00 +09:00
Hajime Hoshi
e7ad5c52fe internal/glfw: merge internal/goglfw into internal/glfw
This also changes APIs in internal/glfw to return errors.

Updates #2703
2023-10-05 03:09:51 +09:00
Hajime Hoshi
aa55953c11 internal/ui: replace (*userInterface).err with (*globalState).err 2023-10-05 00:45:04 +09:00
Hajime Hoshi
0e722669ef internal/glfw: add const definitions
This is one of the steps to merge internal/glfw and internal/goglfw.

Updates #2703
2023-10-04 03:04:47 +09:00
Hajime Hoshi
84030a3f77 internal/ui: refactoring: remove unused functions 2023-10-04 02:54:55 +09:00
Hajime Hoshi
491b578866 ebiten: add KeyF13 to KeyF24
Closes #2801
2023-10-04 00:45:49 +09:00
Hajime Hoshi
95b4eeafce all: remove unnecessary build tag restrictions 2023-10-01 23:27:57 +09:00
Hajime Hoshi
8c7eb70635 internal/ui: bug fix: wrong monitor was detected on fullscreen
Updates #2225
Updates #2794
2023-09-30 13:41:12 +09:00
Hajime Hoshi
22118ba962 internal/ui: add a comment
Updates #2796
2023-09-30 02:55:04 +09:00
Hajime Hoshi
dce18d7c23 internal/ui: bug fix: SetWindowIcon(nil) didn't reset the window icon
Closes #2796
2023-09-30 02:46:40 +09:00
Hajime Hoshi
13dfb28a98 internal/ui: copy a slice at SetIconImages
This changes makes ebiten.SetIconImages a little safer.
2023-09-30 01:46:01 +09:00
Hajime Hoshi
7204ca86e3 internal/ui: refactoring: remove an unused member 2023-09-30 01:39:34 +09:00
Hajime Hoshi
aab22f4c1e internal/ui: bug fix: use correct regions at (*monitors).monitorFromPosition
Updates #2781
2023-09-30 00:30:06 +09:00
Hajime Hoshi
2fbef2106d internal/ui: refactoring
Updates #2781
2023-09-30 00:11:15 +09:00
Hajime Hoshi
03d6811a65 internal/ui: bug fix: initialMonitorByOS could return nil on macOS
initialMonitorByOS could return nil when a cursor was at an extreme
position like the bottom of the display. Apparently, a cursor position
could take an inclusive range of the monitor size.

This change fixes this issue by fixing the comparison.

Even if initialMonitorByOS returns nil, a fallback primary monitor
should be used, so this is not a critical issue.

Updates #2794
2023-09-29 16:54:47 +09:00
Hajime Hoshi
14a2c703df internal/ui: fix wrong panic messages 2023-09-29 15:36:43 +09:00
Hajime Hoshi
91abfe2c10 internal/ui: bug fix: compilie error on Windows
Updates #2794
2023-09-29 12:54:41 +09:00
Hajime Hoshi
0bcee31a6f internal/ui: bug fix: wrong monitor initialization on macOS
This change fixes these issues:

* `currentMouseLocation()` returned a position in the macOS native
coordinate. This means the Y axis is upward, while the Y axis is
downward in the GLFW coordinate. This change adjusts the Y position.
* `(*monitors).monitorFromGLFWMonitor` always returned nil at least
on macOS. This change replaces this with a new method
`(*monitors).primaryMonitor`.

Updates #807
Closes #2794
2023-09-29 12:36:28 +09:00
Hajime Hoshi
4ca3fa5e57
internal/graphicsdriver: replace Region with image.Rectangle (#2791)
Closes #2790
2023-09-28 14:29:55 +09:00
Hajime Hoshi
7cb64ccffe internal/ui: refactoring 2023-09-28 01:01:58 +09:00
Hajime Hoshi
a65a45586f internal/ui: bug fix: need nil check at dipFromGLFWMonitorPixel
Updates #1878
2023-09-25 18:42:23 +09:00
Hajime Hoshi
58d3655597 internal/ui: remove unnecessary receivers from methods 2023-09-24 19:45:55 +09:00
Hajime Hoshi
b32575b7b2 internal/ui: refactoring: add (*Monitor).deviceScaleFactor 2023-09-24 19:41:37 +09:00
Hajime Hoshi
0e23045b90 internal/ui: refactoring: add (*monitors).monitorFromPosition 2023-09-24 19:41:28 +09:00
Hajime Hoshi
fab08bac92 internal/ui: use RLock/RUnlock whenever possible 2023-09-24 19:27:22 +09:00
Hajime Hoshi
4fb27adb9d internal/ui: remove an old comment
Now Ebitengine allows to specify the initial monitor, having an
initial monitor is no longer a hack.

Updates #1575
Updates #1835
2023-09-24 19:24:23 +09:00
Hajime Hoshi
b5d0dc3686 internal/ui: change the initial window position adjustment
The window position should be posible if possible.
2023-09-24 19:07:21 +09:00
Hajime Hoshi
a23efac01c internal/ui: refactoring: reduce member variables 2023-09-24 19:05:56 +09:00
Hajime Hoshi
c16bd1e249 internal/ui: refactoring: unify duplicated logics to initialize the window size and position 2023-09-24 18:55:45 +09:00
Hajime Hoshi
c7d1d28582 internal/ui: move impls for device scale to internal/ui for desktops
This enables to remove restrictions for some functions to be called
from the main thread.

Updates #2423
2023-09-24 15:44:41 +09:00
Hajime Hoshi
458a415131 internal/ui: move impls for device scale to internal/ui for mobiles 2023-09-24 15:29:14 +09:00
Hajime Hoshi
506a1de259 internal/ui: refactoring: move device-scale implementation to internal/ui for browsers
The returned value from internal/devicescale.At never changes for
browsers, so the detection of devicePixelRatio updates didn't work
in the first place. Also, there is not a good way to detect the
change [1].

This change moves the logic from internal/devicescale to internal/ui.
We aim to merge these packages as a device scale factor belongs to
a monitor and internal/ui manages monitors.

[1] https://crbug.com/123694
2023-09-24 03:19:31 +09:00
Hajime Hoshi
5d5e3c7c0b internal/ui: refactoring: replace *glfw.Monitor with *Monitor 2023-09-24 02:39:53 +09:00
Hajime Hoshi
f72b8a4ced internal/ui: refactoring: remove redundant Monitor members 2023-09-24 01:58:07 +09:00
Hajime Hoshi
121d6005cd internal/ui: remove (*Monitor).Bounds
Updates #2780
2023-09-24 01:46:14 +09:00
Hajime Hoshi
01e2c92e56 internal/ui: remove unnecessary code
This was an old code when Ebitengine created a dummy invisible
window before creating the main window.
2023-09-24 01:42:39 +09:00
Hajime Hoshi
69e3a2b974 internal/ui: refactoring: (*monitors).update must be called from the main thread
In the current implementation, (*monitors).update is not called
from other threads, but the current code is fragile.
2023-09-24 01:37:11 +09:00
Hajime Hoshi
7664647ad1 internal/ui: bug fix: needed to wait before entering into fullscreen
Just after moving a window to another monitor, waiting a little while
was required before entering into fullscreen.

Closes #2778
2023-09-23 19:02:36 +09:00
Hajime Hoshi
4ef98b3ea9 internal/ui: bug fix: wrong calculation of the initial window position
Updates #2778
2023-09-23 18:51:58 +09:00
Hajime Hoshi
b3058b68a0 ebiten: change the unit of (*Monitor).Bounds
Monitors can have different device scale factors, and in this case,
it doesn't make sense to use device-independent pixels as unit for
monitor positions and sizes.

Updates #2778
2023-09-23 17:58:23 +09:00
Hajime Hoshi
d736a8cff7 internal/ui: bug fix: GetVideoMode must not be called from othere threads
Now setInitMonitor can be called from any other threads than the main
thread. Do not call this.

This change fixes the issue by using *Monitor instead of *glfw.Monitor.
2023-09-23 17:30:18 +09:00
Hajime Hoshi
e0cd031aea internal/ui: bug fix: replace initWindowMonitor usages with initMonitor
There were two similar member variables internalWindowMonitor and
initMonitor, and when SetMonitor is called, probably there were
some inconsitency between them.

This change fixes the issue by not using initWindowMonitor.

Closes #2779
2023-09-23 17:17:38 +09:00
Hajime Hoshi
14f2ee198e ebiten: add SetWindowMousePassthrough and IsWindowMousePassthrough
Closes #2511
2023-09-18 18:31:22 +09:00
Hajime Hoshi
8a0aba45f5 internal/ui: update touches after the layout is determined on mobiles
Closes #2763
2023-09-17 21:56:26 +09:00
Hajime Hoshi
02fd8cfb07 internal/ui: bug fix: preserve a captured cursor positions for toggling fullscreening for browsers
Closes #2475
2023-09-17 18:38:00 +09:00
Hajime Hoshi
a5aa721bda internal/ui: update mouse and touch cursors after the layout is determined on browsers
Updates #2763
2023-09-17 16:30:47 +09:00
Hajime Hoshi
6ab509f221 internal/ui: reland: bug fix: preserve cursor positions for toggling fullscreening for desktops
Updates #2475
2023-09-17 15:54:39 +09:00
Hajime Hoshi
9d73e45677 Revert "internal/ui: bug fix: preserve cursor positions for toggling fullscreening for desktops"
This reverts commit 7ed4db90be.

Reason: compile error on Windows
2023-09-17 15:43:38 +09:00
Hajime Hoshi
7ed4db90be internal/ui: bug fix: preserve cursor positions for toggling fullscreening for desktops
Updates #2475
2023-09-17 15:26:08 +09:00
Hajime Hoshi
7becaa19e6 internal/ui: bug fix: native APIs must be called from the main thread
Updates #2763
2023-09-17 15:14:57 +09:00
Hajime Hoshi
0475baf9e2 internal/ui: update comments
Updates #2763
2023-09-17 14:59:43 +09:00
Hajime Hoshi
8c25b07336 internal/ui: call updateInputState after layoutGame
The cursor position is affected by the current layout. Then, input
states should be updated after layoutGame is called.

Updates #2763
2023-09-17 14:58:32 +09:00
Hajime Hoshi
a62b8a00e7 internal/ui: use float64 for cursor positions internally 2023-09-17 03:43:18 +09:00
Hajime Hoshi
45acc2c5d8 internal/ui: reland: bug fix: disable window size limitation on fullscreen
Closes #2260
2023-09-16 16:49:49 +09:00
Hajime Hoshi
40fc96d78c internal/ui: forbid a green button when a max window size limit is specified
Updates #2260
2023-09-16 16:40:03 +09:00
Hajime Hoshi
128215eedd Revert "internal/ui: bug fix: disable window size limitation on fullscreen"
This reverts commit 9a5ef1b553.

Reason: we should disable the green button instead

Updates #2260
2023-09-16 03:23:34 +09:00
Hajime Hoshi
657e4c2541 internal/ui: update a comment
Closes #2240
2023-09-16 03:12:37 +09:00
Hajime Hoshi
619436a47b internal/ui: refactoring: add monitor_glfw.go 2023-09-16 00:16:00 +09:00
Hajime Hoshi
dd2768d5f3 internal/ui: bug fix: introduce locks for monitors
Updates #1853
2023-09-15 03:59:13 +09:00
Hajime Hoshi
32bd565df9 internal/ui: bug fix: setWindowMonitor was processed even when the same monitor was specified
Updates #1835
2023-09-15 03:30:15 +09:00
Hajime Hoshi
b710ff17c8 internal/ui: bug fix: wait for a while after exiting fullscreen on macOS
Closes #2758
2023-09-15 03:19:37 +09:00
Hajime Hoshi
90accfba1e internal/ui: bug fix: do not call PollEvents on Windows and Linux
Updates #2296
2023-09-15 03:11:58 +09:00
Hajime Hoshi
568e98ef1c internal/ui: bug fix: call setOrigWindowPos on entering fullscreen
Closes #2757
2023-09-15 02:53:38 +09:00
Hajime Hoshi
f7a801d591 internal/ui: refactoring 2023-09-15 02:45:31 +09:00
Hajime Hoshi
9a5ef1b553 internal/ui: bug fix: disable window size limitation on fullscreen
Closes #2260
2023-09-15 02:19:20 +09:00
Hajime Hoshi
41c7852c7d internal/ui: sort selectors in alphabetical order 2023-09-11 02:15:42 +09:00
TotallyGamerJet
5dc293fe4f
internal/ui: use new OBJC API (#2750)
Updates #1162
2023-09-11 02:05:42 +09:00
Hajime Hoshi
f30a58a393 internal/ui: bug fix: disable global functions after the game termination
Closes #2743
2023-09-02 15:38:41 +09:00
Hajime Hoshi
6e968558b1 internal/ui: bug fix: setRunning(true) must be called after the main thread is set
Some functions like ebiten.SetCursorMode use `running` to detect
whether the game starts or not. If the game starts, the main thread
must exist, but there was a timing when `running` was true but the
main thread didn't exist.

This change fixes this issue by changing the timing to call
`setRunning(true)` after the main thread initialization and before
`initOnMainThread`. `initOnMainThread` assumes that `running` is
true.

Closes #2742
2023-09-02 04:24:51 +09:00
Ketchetwahmeegwun T. Southall
60b7de6a3c
ebiten: add APIs to treat monitors (#2597)
This change adds these APIs:

* `type MonitorType`
* `func (*MonitorType) Bounds() image.Rectangle`
* `func (*MonitorType) Name() string`
* `func Monitor() *MonitorType`
* `func SetMonitor(*MonitorType)`
* `func AppendMonitors([]*MonitorType) []*MonitorType`

Closes #1835
2023-08-30 21:02:04 +09:00
Hajime Hoshi
534370f7b1 internal/graphics: enable to specify regions for each source image
This is a preparation to specify different sizes of source images.

Updates #1870
2023-08-27 21:15:01 +09:00
Hajime Hoshi
a9b2f5f9ca Revert "ebiten: panic if a non-existent uniform variable name is given"
This reverts commit 1b8580fab7.

Reason: some existing applications don't work with this fix.

Updates #2710
2023-08-24 14:15:19 +09:00
Hajime Hoshi
f81dbd9288 internal/graphicsdriver: flush commands asynchronously whenever possible
Closes #2664
2023-07-30 22:44:13 +09:00
Hajime Hoshi
5a64f8299e internal/thread: refactoring: add a common interface Thread 2023-07-30 22:42:24 +09:00
Hajime Hoshi
d13bea29dc internal/ui: refactoring 2023-07-30 03:52:54 +09:00
Hajime Hoshi
3869e2e4f6 internal/ui: refactoring: integrate the render thread usages into internal/graphicscommand
Updates #2664
2023-07-30 03:50:49 +09:00
Hajime Hoshi
1b8580fab7 ebiten: panic if a non-existent uniform variable name is given
Closes #2710
2023-07-29 20:24:42 +09:00
Hajime Hoshi
0b1c7404d5 ebiten: use zero values for an unspecified uniform variable
Closes #2709
2023-07-29 19:11:49 +09:00
Hajime Hoshi
d0e4023d88 internal/ui: add a length check for uniform variables 2023-07-29 18:59:36 +09:00
Hajime Hoshi
8b4c744ca8 internal/ui: rename a file
Use `_linbsd.go` suffix for Linux and BSDs.
2023-07-23 02:29:57 +09:00
Hajime Hoshi
91e1c0ea29 ebiten: add more cursor shapes
This change adds these new cursor shapes:

* CursorShapeNESWResize
* CursorShapeNWSEResize
* CursorShapeMove
* CursorShapeNotAllowed

Closes #2476
2023-07-23 00:49:45 +09:00
Hajime Hoshi
7a7d4fd91f internal/ui: bug fix: need to delay to capture a cursor
From the spec https://w3c.github.io/pointerlock/#extensions-to-the-element-interface,
capturing a cursor might require a cooltime. This change adds a delay
to capture a cursor just after escaping from a capture.

Closes #2693
2023-07-07 01:24:02 +09:00
Hajime Hoshi
eb5c1ee818 internal/ui: bug fix: the original cursor position was not scaled correctly
Updates #2690
2023-07-05 09:24:29 +09:00
Hajime Hoshi
929539b66e add exp/textinput package
This works only for macOS and browsers so far.

Updates #1029
2023-07-05 02:09:04 +09:00
Hajime Hoshi
1d02d20879 internal/ui: fix comments 2023-07-04 23:34:00 +09:00
divVerent
b96aea70f1
internal/ui: compute antialias region size correctly. (#2681)
Closes #2679
2023-06-24 02:25:19 +09:00
Hajime Hoshi
0785502be3 internal/ui: refactoring 2023-05-09 00:35:54 +09:00
Hajime Hoshi
d2c991b774 all: refactoring: use image.Rectangle 2023-04-28 01:03:38 +09:00
Hajime Hoshi
00e45affe9 all: update OpenGL version from 2.1 to 3.2
'texelFetch' requires OpenGLSL 1.30, which requires OpenGL 3.0+.
macOS might not support OpenGL 3.0 and 3.1, so adopt 3.2.

Updates #1431
2023-04-23 14:25:36 +09:00
Hajime Hoshi
b40c5b1e99 internal/ui: catch an error at At at updateIconIfNeeded
Closes #2647
2023-04-20 00:59:14 +09:00
Hajime Hoshi
c00579509a internal/ui: bug fix: wrong mouse cursor movement calculation
Closes #2634
2023-04-10 15:25:04 +09:00
Hajime Hoshi
09d2459f1c internal/ui: a more robust fix for the unfocused-window loop
Depending on the member variable bufferOnceSwapped is a little fragile.
Detect whether the window is shown or not instead.

Updates #2620
2023-04-01 03:36:51 +09:00
Hajime Hoshi
db7c99fde8 internal/ui: bug fix: an unfocused window should not wait until buffers are swapped once
On macOS, a window is hidden until buffers are swapped once. If a game is
not runnable on unfocused, as the window is hidden and unfocused, the
waiting loop for a window never ends.

This change fixes the issue by changing the loop condition.

Closes #2620
2023-04-01 03:01:59 +09:00