Commit Graph

2536 Commits

Author SHA1 Message Date
Elias Naur 7fc594fa4b io/key: remove key.NameUp/Down/Left/Right
They're no longer used now that Android directional keys are mapped
to key.Name*Arrow.

References: https://todo.sr.ht/~eliasnaur/gio/410
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-05-10 16:49:59 +02:00
Mearaj 7ced0d29ab app,widget: use arrow keys for Android navigation
Android doesn't distinguish between the arrow keys on a keyboard and the
directional keys on a remote control, so there's no way to move the caret
in an Editor with arrow keys. This change updates the Android port to map
Android's DPAD_* key codes to the arrow key names, fixing caret movement.
The change also updates Editor to only request arrow keys that actually move
the caret, to keep directional focus movement working.

Fixes: https://todo.sr.ht/~eliasnaur/gio/410
Signed-off-by: Mearaj <mearajbhagad@gmail.com>
2022-05-10 16:41:32 +02:00
Elias Naur c68417aaf9 go.*: upgrade github.com/benoitkugler/textlayout to v0.1.1
The v0.1.1 release is much smaller because the module no longer contains
test data. See

https://github.com/benoitkugler/textlayout/issues/10

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-05-07 09:31:44 +02:00
Chris Waldon 4996337d26 widget: ensure empty editor makes space for caret
Prior to this change an editor with no content and a zero minimum
constraint would return itself has having width zero. This
prevented users from being able to see the editor when they
moved focus to it, as it could not display its caret. This
simple change ensures that, at minimum, the editor returns
its dimensions to include the width of a caret.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2022-05-07 09:14:10 +02:00
Inkeliz c97f976e7d app: [Android] improve keyboard hints
This patch adds support for the following KeyboardHint: Text, Email,
Telephone and URL.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2022-05-06 09:18:06 +02:00
Thomas Mathews 45e8c781e2 layout: improve layout.List documentation
Updated the documentation for layout.List to include the details about how
drawing is performed for items in it. This gives the user an understanding about
how so many items can be drawn for performance.

Signed-off-by: Thomas Mathews <thomas.c.mathews@gmail.com>
2022-05-03 07:57:28 +02:00
Elias Naur a9a9a7c02f go.*: upgrade github.com/benoitkugler/textlayout to v0.1.0
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-28 11:45:41 +02:00
Elias Naur aa14056350 io/router: remove unused frect function
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-25 09:12:42 +02:00
Elias Naur 4e6a9c0909 cmd: delete tools module
It has moved to its own repository:

https://git.sr.ht/~eliasnaur/gio-cmd

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-24 14:39:16 +02:00
Elias Naur 1071f56119 app: only perform actions and apply options on wakeups
In particular, avoid a race between the setup of the platform window
returned by NewWindow and Window.Perform.

Fixes: https://todo.sr.ht/~eliasnaur/gio/405
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-24 12:51:53 +02:00
Elias Naur d22ec125ea app: replace Config.center with Perform(ActionCenter)
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-24 11:51:20 +02:00
Elias Naur 1a833ab0a4 app: replace driver.Raise with Perform(ActionRaise)
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-24 11:36:06 +02:00
Elias Naur 6ede60d84e app: [Android] avoid out-of-bounds access in getCursorCapsMode
Fixes: https://todo.sr.ht/~eliasnaur/gio/404
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-24 10:50:48 +02:00
Elias Naur 8630fee623 io/pointer: remove unused functions
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-23 16:18:32 +02:00
Elias Naur 3c45a6d420 widget: don't draw Editor selection when not focused
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-23 15:45:41 +02:00
Elias Naur 2381c5ad70 io/router,widget: give every key.InputOp a chance to process events
If the currently focused handler don't want the key event, try every
other handler, from top to bottom. This change requires widgets to
only react when focused.

Fixes: https://todo.sr.ht/~eliasnaur/gio/406
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-23 15:36:45 +02:00
Elias Naur 0273203743 app,io/router: expand IME snippets if a new range overlaps the old
Instead of cmpletely replacing the IME snippet for every update, expand
the old range if there is overlap. This change avoids never-ending
restarts of the IME on Android where snippets are expanded in two
calls, one for expanding before the selection and one for exanding after
the selection.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-23 13:20:46 +02:00
Elias Naur f3265e56b9 app: [Android] take snippet offset into account for getCursorCapsMode
References: https://todo.sr.ht/~eliasnaur/gio/404
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-23 11:40:43 +02:00
Elias Naur 30fa85f518 io/router: send key events to root handlers if nothing else wants them
Fixes: https://todo.sr.ht/~eliasnaur/gio/403
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-23 09:40:23 +02:00
Elias Naur 6ddc13ce66 widget: fix Editor key set
Arrow and delete/backspace shortcuts use ShortcutAlt, not Shortcut.

References: https://todo.sr.ht/~eliasnaur/gio/399
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-19 08:58:47 +02:00
Elias Naur 7629874237 widget/material: remove redundant offset op
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-19 08:47:15 +02:00
Elias Naur 3a4b8b81ec io/system: describe FrameEvent.Insets more precisely
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-19 08:47:15 +02:00
Elias Naur 6c76fa6dec app,io/key,io/system: [API] replace system.CommandEvent with key.Event
It's much simpler to map the Android back button to a key.Event and
let the usual key filtering determine whether to block its default
behaviour.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-19 08:47:15 +02:00
Elias Naur ad7c1eb78d app,io/key: introduce keys for directional navigation
This change adds key.NameUp/Down/Left/Right and maps the Android TV
remote directional keys to them. As a side-effect a key.InputOp can
now receive directional keys (and block their focus movement).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-14 19:09:08 +02:00
Elias Naur d37197f45b app: give key handlers a chance to process Tab and Shift-Tab
Before this change, Tab and Shift-Tab would always result in focus
movement. This this change, a key.InputOp with a matching Keys set
will block focus movement and deliver the events to it.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-14 19:09:08 +02:00
Elias Naur 380f96b3fc io/key: [API] implement key event propagation
Before this change, every Event would be passed to the focused InputOp
tag, making it impossible to implement, say, program-wide shortcuts.
This change implements key.Event routing similar to how pointer.Events
are routed: every InputOp describes the set of keys it can handle, and
the router use that information to deliver an Event to the matching
handler.

This is an API change, because every InputOp must now include a filter
matching the keys it wants to handle.

Fixes: https://todo.sr.ht/~eliasnaur/gio/395
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-14 19:09:00 +02:00
Elias Naur bec0283e54 io/router: deliver synthetic events to sibling pointer handlers
Before this change, synthetic events such as scrolling caused by
focus movement would use semantic information to determine potential
receivers. However, there can only be one handler per area so sibling
handlers would not be considered. This change makes the event delivery
traverse the entire tree of handlers, including siblings.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-14 18:51:39 +02:00
Elias Naur 9c59612e08 io/key: change Modifiers.String separator to "-"
We're about the express sets of key combinations as <modifiers>-<keys>
where modifiers are separated by dashes as well. To make Modifers.String
useful for expressing key sets, change its separator to "-".

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-14 11:48:55 +02:00
Elias Naur ed8d3e8566 io/key: [API] rename tab and modifier keys, introduce NameCommand
We already have precedence for word-named keys ("Space") and the new
names are less obscure and matches Modifiers.String.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-14 11:45:08 +02:00
Elias Naur dc25afda07 app: don't panic when the client doesn't call FrameEvent.Frame
Fixes: https://todo.sr.ht/~eliasnaur/gio/396
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-14 09:16:49 +02:00
Elias Naur 6a14269682 gpu/internal/opengl: add fallback for sparse OpenGL ES 2.0 ReadPixels
OpenGL ES 2.0 doesn't support GL_PACK_ROW_LENGTH, so this change implements
a fallback using a temporary buffer.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-13 17:28:36 +02:00
Elias Naur 43865ddabd app: don't delay FrameEvent.Frame by v-sync latency
We should return as soon as possible from FrameEvent.Frame to allow the main
goroutine to continue processing other tasks.  Whereas GPU.Frame may touch
the frame ops, GPU.Present will not, so this change moves Present to after
returning from FrameEvent.Frame.

This is a variant of 38ff78df5d that
works on OpenGL where context locking is required.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-13 16:05:28 +02:00
Elias Naur 405215f862 Revert "app: don't delay FrameEvent.Frame by v-sync latency"
This reverts commit 38ff78df5d, because
it broke OpenGL by moving eglSwapBuffers outside the MakeCurrent
context scope.

Fixes: https://todo.sr.ht/~eliasnaur/gio/393
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-13 16:01:25 +02:00
Elias Naur 6e66203881 gpu/headless: return error if NewTexture fails
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-13 12:58:33 +02:00
Elias Naur 38ff78df5d app: don't delay FrameEvent.Frame by v-sync latency
We should return as soon as possible from FrameEvent.Frame to
allow the main goroutine to continue processing other tasks.
Whereas GPU.Frame may touch the frame ops, GPU.Present will not,
so this change moves Present to after returning from FrameEvent.Frame.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-12 18:21:23 +02:00
Chris Waldon 25fae8de30 deps: update golang.org/x/text and go-text
Fixes a panic parsing language tags.

References: https://go-review.googlesource.com/c/text/+/340830
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2022-04-12 09:11:42 +02:00
Elias Naur 49bd5787e4 app: [macOS] fix caret position calculation after IME text insert
Fixes: https://todo.sr.ht/~eliasnaur/gio/385
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-08 13:05:27 +02:00
Jack Mordaunt 4e488f4c70 app: [API] don't relay raw input events from app.Window
Avoid sending raw inputs events over the window channel.

If the caller wants to access events, they should be
using input handlers and querying for events.

This change avoids saturating the channel with less important
messages which can affect frame event latency, especially in
the case of custom rendering.

See also

https://lists.sr.ht/~eliasnaur/gio/%3CCAFcc3FQNTp_UXr7oA97SsVPD7D91jSw30ZtALcT9vmopFDTeZQ%40mail.gmail.com%3E

Signed-off-by: Jack Mordaunt <jackmordaunt.dev@gmail.com>
2022-04-07 13:18:59 +02:00
Elias Naur 69f982e26f io/router: don't panic on focus moves when there is nothing to focus
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-05 13:12:03 +02:00
Elias Naur f07537335a app: clip client area
On Wayland, app.Window provides fallback window decorations but clients
are not prohibited from drawing over the decorations or capturing events.
This change adds a clip operation to ensure no unwanted interaction between
client content and decorations.

Fixes issue described in

https://lists.sr.ht/~eliasnaur/gio/%3C092fa6a19894af3306fab568fb919c965e98c4da.camel%40gmail.com%3E

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-04 10:56:01 +02:00
Elias Naur bd7f50438a io/router: account for parent clip areas when scrolling focus into view
Fixes: https://todo.sr.ht/~eliasnaur/gio/389
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-02 15:49:41 +02:00
Elias Naur 36919ef756 layout: don't clip List children
Clipping all children once to the entire List area is enough. The
change was motivated by #389 where individual child clips would
make it harder for focus scroll heuristics to work.

References: https://todo.sr.ht/~eliasnaur/gio/389
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-04-02 15:46:27 +02:00
Elias Naur a1b5ff059c io/router,app: scroll a bit when reaching the end in a focus direction
List was recently changed to include an extra child at each end, to
automatically scroll when reaching the end of a focus direction. However,
if List includes unfocusable children that strategy may fail. This change
adds another fallback where app.Window will scroll a constant amount in
the focus direction, to reveal more children.

For https://github.com/tailscale/tailscale/issues/4278.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-03-31 12:58:29 +02:00
Elias Naur cd0c9dab9f io/router: [API] don't emit Enter and Leave events for touch input
Enter/Leave events make sense for mouse pointers, to track hover
status. It doesn't make sense to track hover for touch input, so
this change stops pointer.Enter and pointer.Leave from being
emitted for pointer.Touch sources.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-03-31 11:55:48 +02:00
Elias Naur afd39a6bfe layout: compute Position.Offset correctly for ScrollToEnd Lists
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-03-31 11:55:48 +02:00
Elias Naur 508330e818 layout: layout one invisible child at each end of a List
A recent change added automatic scrolling to move focused widgets
into view. This change modifies List to layout an extra child at
each of its ends, to enable focus to move to them and trigger
automatic scrolling of the list.

For https://github.com/tailscale/tailscale/issues/4278.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-03-31 11:55:48 +02:00
Elias Naur a699fb89ac layout: default List scroll bounds to infinity
Before, List would only report the remaining scrollable area of the visible
children when positioned close to either end. Now, List always report infinite
scroll bounds *unless* it is positioned at an extremum.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-03-31 11:54:53 +02:00
Elias Naur d34544cc22 io/router: merge pointerQueue.deliverScrollEvents and deliverEvent
They're similar except for a bit of special handling for scroll events.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-03-31 11:52:31 +02:00
Elias Naur e8603ba59e io/router: use areas to determine targets for synthetic clicks
Before this change, semantic clicks would be delivered according to
the center of the targeted widget, which could result in a different
widget receiving the click. Or in worst case, no widget in case the
center is not visible because of clipping.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-03-31 11:52:31 +02:00
Elias Naur 4326fee704 app,io/router: scroll focused widgets into view
A focused widget may be partially or completely off-screen in which case
the user will have difficulty interacting with it. This change attempts to
scroll the focused widget into view by issuing synthetic scroll events.

For https://github.com/tailscale/tailscale/issues/4278, but doesn't completely
solve it because layout.Lists won't layout focusable widgets outside its visible
bounds. A follow-up change deals with that.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-03-31 11:52:31 +02:00