Commit Graph

2345 Commits

Author SHA1 Message Date
Pierre Curto 0010ec1389 app: [Wayland] update the window mode when un-minimized
When a window goes from the Minimized state to Windowed
as the user brings it back up, the internal state needs
to reflect that change and generate the corresponding
Config event.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-22 08:10:02 +01:00
Elias Naur cf54e39736 cmd/gogio: [Android] suggest only Java 1.8 when d8 fails
We're compiling with -target and -source set to 1.8, so 1.7 is not
adequate.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-21 17:57:52 +01:00
Jan Kåre Vatne 862fa832c9 app: [Windows] don't include decorations in window sizes
Fixes: https://todo.sr.ht/~eliasnaur/gio/345
Signed-off-by: Jan Kåre Vatne <jkvatne@online.no>
2022-01-21 14:58:44 +01:00
Elias Naur 30daaef4ab app: [Android] implement key release events
Not terribly useful on Android, but easy to do.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-20 14:21:44 +01:00
Pierre Curto 8c2d9a9a57 app: apply WindowModes at startup
As reported on slack by Rajiv Kanchan, when a WindowMode
is used with app.NewWindow, it does not get applied.

Delay the Configure method to make sure it is.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-20 11:05:09 +01:00
Elias Naur 65199a2274 op,internal/ops: support CallOps without macros
A recorded macro is prefixed with an internal macro op that stores
the end of the macro. The end is used to efficiently skip the macro
when not calling it. The call a macro, the CallOp stores the start
position of the macro.

To support seamless wrapping of Ops lists, this change removes the
dependency on the macro op prefix from CallOp. Internal code can
now call an Ops like this:

    var ops op.Ops
    var wrapper op.Ops

    ops.AddCall(&wrapper.Internal, &ops.Internal, ops.PC{}, ops.PCFor(&ops.Internal))

References: https://todo.sr.ht/~eliasnaur/gio/318
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-20 09:56:30 +01:00
Pierre Curto c0f3ec88e9 io/pointer: add new pointers
Add resize pointer cursor names for resize operations
in preparation for the window decorations patch.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-19 10:39:32 +01:00
Pierre Curto f4088f94ba minor fixes
Make sure that the title is set if changed while in
Maximized mode.
Don't overwrite the config.Size when going from
Minimized to Windowed mode.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-19 10:39:07 +01:00
Pierre Curto 9a2fee1c0e op, internal/ops: cleanups
Remove unnecessary fill when starting a recording in op.Record.
Have the exact number of possible stack kinds in ops.Ops.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-18 15:49:43 +01:00
Elias Naur 1de8c9f3b0 app: process one event at a time
Commit 11aec807b2 added a waiting flag to avoid
processing platform events recursively. However the flag was only true when the
window goroutine is blocked waiting for client events, so deferred window
functions such as Window.Option may still runs multiple times for recursive
events.

This change renames the flag to busy and sets it during the entire processing
of an event, including recursive events and deferred window functions.

Fixes: https://todo.sr.ht/~eliasnaur/gio/344
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-18 12:27:54 +01:00
Pierre Curto b15a9cb595 app: update Window for macOS, X11 and Wayland
Commit #c4f98d3c1eab201419be255fafb139f7e10ad273 added
the Minimized and Maximized options for the Windows platform.
This change adds those for the remaining desktop platforms.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-18 12:00:20 +01:00
Pierre Curto 2ce9ad36af clip: check Path ops are not mixed with others
Multiple operations Op, such as clip.Path, cannot
be interleaved with other ops. This patch adds a
mechanism to ensure that is the case by starting
multi ops with ops.BeginMulti and ending them with
ops.EndMulti while operations are written to op.Ops
with ops.WriteMulti.
This mechanism is applied to clip.Path.

Fixes: https://todo.sr.ht/~eliasnaur/gio/336
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-15 19:16:07 +01:00
Elias Naur 2879fe8b41 cmd/gogio: add support for OpenJDK to java version detection
When the `d8` command from the Android SDK fails because of an incompatible
java version, the error message is cryptic. Before reporting the errors, we
attempt to detect incompatible versions and report a clearer error. This change
adds support for OpenJDK as well as other vendors to the detection logic.

Fixes: https://todo.sr.ht/~eliasnaur/gio/342
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-15 18:32:57 +01:00
Jan Kåre Vatne c4f98d3c1e app: [API] add minimized window mode, change methods to options
The window modes are extended, following microsoft conventions.
We have Fullscreen, Overlapping, Maximized and Minimized.
These modes can be set via options when a new window is creates,
or modified later by calling helper functions like w.Maximize() and w.Center()

The window configuration is automatically updated when a user
modifies the window by dragging or clicking the icons on the window's title-bar,
minimizing or maximizing the window.

Any change, either by the user or the application will emit a ConfigChange event.

This is implemented and tested on Windows only.

API change. the app.Window methods Maximize and Center are replaced with similar
options. For example, to maximize a window use

    w.Option(app.Maximized.Option())

Also, Maximize and Center implementations for X11 and macOS are left for a future
change.

Fixes: https://todo.sr.ht/~eliasnaur/gio/315
Signed-off-by: Jan Kåre Vatne <jkvatne@online.no>
2022-01-15 17:30:22 +01:00
Jeff Williams 13183522dd app: send keypress events for modifier keys
This change causes modifier keys (Control, Shift, Alt, Super) to be sent
to the application as key.Event events. These will still continue to be
used as modifiers for other key and pointer events as they are today.

This commit also adds a minor cleanup to use constants for function
keys in the OS-specific keypress handling functions.

Signed-off-by: Jeff Williams <kanobe@gmail.com>
2022-01-15 16:56:47 +01:00
Pierre Curto fcaadb3698 app: remove unused types and func arguments
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-15 16:55:13 +01:00
Elias Naur 9209fd9143 app: [Android don't map the empty string to Java null
Map it to the empty string in Java, which is less surprising.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-13 19:47:48 +01:00
Elias Naur 23bd7aa1d4 app: don't call Window.driverDefer for cursor updates
Like d951d07c93, calls to Window.updateCursor happens on the
evennt loop thread, and so must not go through Window.driverDefer.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-13 19:47:48 +01:00
Elias Naur d951d07c93 app: don't call Window.driverDefer for direct callbacks
The internal calls to ReadClipboard and WriteClipboard happen during a callback
from the event loop. This change avoids the roundtrip through driverDefer.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-13 16:03:12 +01:00
Elias Naur 72c48a3c18 widget: fix editBuffer.WriteTo for short writes
Noticed while working in the area.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-13 13:16:19 +01:00
Elias Naur abd8c2c9a3 widget: remove debug panic
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-13 13:05:54 +01:00
Andy Balholm 456f22c986 gpu/internal/rendertest: add regression test for issue 331
References: https://todo.sr.ht/~eliasnaur/gio/331
Signed-off-by: Andy Balholm <andy@balholm.com>
2022-01-12 11:34:37 +01:00
Elias Naur b2a99fddca app: run driver callbacks after event processing
Running, for example, Window.Close during a FrameEvent processing doesn't end
well on platforms that immediately destroys the window.  This change defers
callbacks to after the completing the current event.

Fixes: https://todo.sr.ht/~eliasnaur/gio/340
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-11 09:03:18 +01:00
Elias Naur aadb6609ec internal/vk: [Android] add workaround for Vulkan on the emulator
According to the Vulkan specification the pApplicationInfo member of
the VkInstanceCreateInfo structure may be NULL. However, the Android
emulator crashes on vkEnumeratePhysicalDevices if set to NULL.
This change adds a minimal info to please the emulator.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-08 17:20:35 +01:00
Elias Naur c3bbff4cf9 app: remove duplicate error check
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-08 16:44:36 +01:00
Elias Naur 454e75dd14 app: don't process Window state updates before client is ready for events
On Android, a call to update soft keyboard state may result in focus events.
Before this change, the client would still be blocked in FrameEvent.Frame,
resulting in a deadlock.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-08 16:24:08 +01:00
Elias Naur 86330faca6 gpu/internal/opengl: restore Android emulator OpenGL workaround
For some reason, the Android emulator OpenGL implementation needs the output
framebuffer current when eglSwapBuffers is called; otherwise sRGB emulation
breaks. We used to restore the default FBO explicitly, 9b5e9ae607
restored it implicitly through automatic state restoring, but 30ecf75a0f
broke that by only saving and restoring shared context state. This change
restores the explicit behaviour for non-shared contexts.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-08 14:50:14 +01:00
Elias Naur 11f39582b8 app: [macOS] pace display link
On macOS the display link that drives redraws runs on a separate thread, and
must switch to the main thread to invalidate its view. This change makes sure
the display link can never call invalidate faster than we can draw.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-07 18:16:40 +01:00
Elias Naur 11aec807b2 app: deliver one event at a time to client
If the client calls, say, Window.Configure during a frame which in turn results
in a ConfigEvent, the program deadlocks. This change implements a queue of
events to be delivered after processing another.

Fixes: https://todo.sr.ht/~eliasnaur/gio/337
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-07 18:09:18 +01:00
Pierre Curto 4c6d98879e widget: add Draggable.Pos
When the position of the cursor is required while dragging
a widget around, the pointer's cannot be tracked as the drag
grabs the event priority. Therefore, this patch exposes
the drag's current position.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-07 17:11:43 +01:00
Elias Naur 8d8aeef66b app,gpu,internal/egl: lock OS thread when making OpenGL context current
OpenGL stores the current context in thread-local memory, but commit
4f5baa9a51 removed a runtime.LockOSThread from app.Window that ensured
the goroutine that drives the context stays on the operating thread that
has the context current. This change restores the thread lock.

As a bonus, this change makes the OpenGL contexts responsible for locking
the thread at MakeCurrent, thereby removing LockOSThread calls from GPU
backend-agnostic code.

Fixes: https://todo.sr.ht/~eliasnaur/gio/334
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-05 11:49:29 +01:00
Elias Naur 7751d73740 app: [Wayland] don't change cursor when there is no pointer
Fixes: https://todo.sr.ht/~eliasnaur/gio/333
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-04 18:24:05 +01:00
Elias Naur 5860fbbe8e io/key: remove "Mod" prefix from Modifiers.String names, concatenate by "+"
"Mod" is implied by the type, and "+" is the natural concatenation character
for displaying shortcuts.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-04 17:46:14 +01:00
Chris Waldon 99e3481419 cmd/gogio: allow missing tool version components
This commit changes the way that gogio searches for build tools
so that it correctly identifies versions like '31' as equivalent
to '31.0.0'. The Android SDK appears to not provide version
components in the path name when the component is zero.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2022-01-04 17:42:10 +01:00
Fabien Jansem 9b7ec167bc delete unicode chars with length > 1 correctly
When there were non ASCII characters (for exemple éèàçîï) in a deleted
selection or word, more characters were deleted because there was a
mismatch between runes and bytes in Delete and deleteWord

Fixes: https://todo.sr.ht/~eliasnaur/gio/330
Signed-off-by: Fabien Jansem <fabien@jansem.eu.org>
2022-01-04 17:37:00 +01:00
Inkeliz ac3bbc72ac cmd/gogio: add -minsdk to iOS
Before that patch the minimum iOS version was hardcoded. That patch makes possible
to change the minimum iOS version using `-minsdk`.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2022-01-04 17:35:48 +01:00
Andy Balholm 6d9db2b13c internal/stroke: properly calculate maxDist
The calculated value for maxDist (the maximum allowable error when
converting cubic Beziers to quadratics) was way too small when the
first control point was very close to the starting point of the segment.

(f32.Rectangle.Add does not expand the rectangle to include the new point;
it moves the rectangle by the point's X and Y coordinates.)

Splitting the curve into such small pieces was resulting in very ugly
output.

Fixes: https://todo.sr.ht/~eliasnaur/gio/331
Signed-off-by: Andy Balholm <andy@balholm.com>
2022-01-04 17:28:37 +01:00
Elias Naur 4f5baa9a51 app: let drivers control Window directly
Before this change, Window driver callbacks would all go through
channels to be processed by Window.run. However, Window.run may call
into the driver, which again may invoke a Window callback. These
re-entrant calls have been a source of deadlocks and subtle errors,
resulting in increasingly complex channel logic. This change eliminates
the goroutine split between Window and the driver, allowing callbacks
between Window and the driver without restrictions.

The goroutine split between Window and the driver is historical and
was meant to tame the complicated callback logic of drivers into a nice
for-select loop. However, the complexity isn't worth the gain, and there is
no concurrency concerns because there is always a 1:1 correspondance between
a driver goroutine and its Window object.

Fixes: https://todo.sr.ht/~eliasnaur/gio/329
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-04 17:01:05 +01:00
Elias Naur 72b2f2c1bf app: ensure SetDriver is called before sending events
This used to not matter, but a follow-up change will require a valid
driver to process events.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-04 15:48:01 +01:00
Elias Naur 787295a6e8 app: fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-03 16:23:37 +01:00
Elias Naur cce0a121e1 io/router: don't panic if AppendSemantics is called without a frame
Fixes: https://todo.sr.ht/~eliasnaur/gio/328
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-30 10:23:23 +01:00
Inkeliz 6913c856a2 app: [android] fix vulkan crash when activity/surface is recreated
On Android it's possible that the Activity/View must be restore. But,
before that patch, an new VkSurfaceKHR is created but never used and
that may lead to crash, in an attempt to destroy/use one invalid
surface.

Fixes: https://todo.sr.ht/~eliasnaur/gio/327
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-12-30 09:50:11 +01:00
Pierre Curto 3a20330d82 app: detect fullscreen mode for macOS and Windows
When an application goes into or out of fullscreen mode,
Gio now emits a ConfigEvent with the current window mode.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-26 10:20:54 +01:00
Pierre Curto 11bb86166a op/clip: automatically close Path in Outlines
Unclosed path segments in Path will be automatically
closed by a line.

Fixes: https://todo.sr.ht/~eliasnaur/gio/320
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-21 10:13:20 +01:00
Pierre Curto 0117de71d3 app: add String method to WindowMode and Orientation
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-21 10:09:45 +01:00
Elias Naur 6534639276 io/pointer,op/clip: remove clip.Circle, pointer.Rect, pointer.Ellipse
They've been deprecated for a while, and gio-x is updated to not use
them.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-20 16:23:16 +01:00
Elias Naur 170d24bdcd widget/material: replace deprecated clip.Circle with clip.Ellipse
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-20 16:22:39 +01:00
Elias Naur 533f85cf8e gpu/internal/vulkan: don't destroy nil vkDescriptorPool
Most drivers seem to tolerate vkDestroyDescriptorPool with a nil
pool, but NVIDIA's (rightly) doesn't. Fix that.

References: https://todo.sr.ht/~eliasnaur/gio/323
References: https://todo.sr.ht/~eliasnaur/gio/314
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-19 14:19:37 +01:00
Christophe Meessen a34e239c04 text,widget,opentype: change text.Face.Shape to return a clip.PathSpec
With this change, the Shape function returns a clip.PathSpec
instead of a clip.Outline op. It is then possible to create
a clip.Outline or clip.Stroke op to fill the text path or
draw its stroke.

Signed-off-by: Christophe Meessen <meessen@cppm.in2p3.fr>
2021-12-19 13:30:45 +01:00
Pierre Curto 3db11cbaad io/router: make transfer targets hovering easier to detect
In commit 929e4dc12, the rules to send pointer.{Enter,Leave}
events were relaxed. Unfortunately, to be able to make use
of them was not straight forward as it required the transfer
target op to use the same handle as the hover one.
This patch eases this by allowing any handle for the target
as well as not requiring the hover op to be defined on the same
clip op as the target (then requiring a PassOp though), making
it much easier to use.

Also added a test for pointer.Enter events not being generated
if the target type does not match the source one.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-19 13:22:11 +01:00