This reverts commit 11f39582b8 that
introduced pacing of display link callbacks. Blocking the display link
callback introduced deadlocks with code that updates the display link
display.
Not pacing the display link may introduce extra view invalidations,
but invalidates are consolidated by the system and won't result in
extra redraws.
Fixes: https://todo.sr.ht/~eliasnaur/gio/370
Signed-off-by: Elias Naur <mail@eliasnaur.com>
It's now possible to directly user pointer.Cursor to add to the ops.
pointer.CursorText.Add(gtx.Ops)
This is an API change. Use pointer.Cursor directly instead of CursorNameOp.
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
Add most of the common cursors defined by different systems.
Normalize cursor names to match CSS.
This is API change: some cursor names have changed, and the
underlying type is no longer a string.
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
This commit fixes the position returned by Editor.CaretCoords
to account for the scroll position of the editor. Without this
change, the returned coordinates can easily overflow the boundaries
of the editor widget when it has been scrolled on either axis.
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
Events such as system.CommandEvent may result in Invalidate being
called. Ensure animation state is properly updated.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Mapping it to key.NameReturn confuses widgets such as Editor that
treats clicks separate from return key presses.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
For some reason, widget.Editor had a Seek method that ignored
the supplied offset and always seeked to offset zero. This
made it impossible to use it like any other io.Seeker. This
commit simply honors the requested offset.
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This change solves an issue where an editor key press such as
backspace would apply before the IME had a chance to process it.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Apparently, a Wayland server such as Sway and River may not issue
a frame pacing callback created before a top level configure event.
This change ensures the frame pacing callback is always refreshed
when animating, regardless of the reason for the frame.
Fixes: https://todo.sr.ht/~eliasnaur/gio/364
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Pointer padding was introduced in bfece0beba.
I don't remember why, and its commit message doesn't say. Regardless, adding
padding outside a widget's reported dimensions doesn't seem like a good idea
(see #365), and this change removes it.
Fixes: https://todo.sr.ht/~eliasnaur/gio/365
Signed-off-by: Elias Naur <mail@eliasnaur.com>
We'd like to re-use the Editor.closestPosition seeking for
segmentIterator.Next; this change extracts the state-less logic
into functions.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Before that patch, the Call function was used to call each
JS function related to WebGL. The Call function contains
strings, which is slow on most browsers. Now, it uses
Bind on the initialization and re-use the same function,
avoiding the usage of strings.
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
This change implements reporting of the caret position from Editor, as well
as Windows, macOS, Android support. As a result, the IME composition window
on Windows and macOS is now positioned correctly.
References: https://todo.sr.ht/~eliasnaur/gio/246
Signed-off-by: Elias Naur <mail@eliasnaur.com>
When a text range in the IME snippet is replaced, the replacement
is discarded if the range don't overlap with the snippet range. However,
the replacement is more relevant than whatever snippet is current.
This change discards the snippet in case of no overlap.
As a bonus, IMEs that leaves the snippet range at [0:0] will have the
snippet track the composing region now.
The FuzzIME test is adjusted to always generate replacements that overlap
Editor content; otherwise the IME snippet and editor state can't be expected
to match.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit adds a testcase to catch unexpected panics in the
editor's scroll offset logic introduced by using different
setting combinations that affect editor layout. It also fixes
a panic for single-line editors with alignments other than
text.Start.
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
Backend.queryState sets GL_ACTIVE_TEXTURE to access texture bindings; this change
makes sure GL_ACTIVE_TEXTURE is restored.
Also, make sure GL state changes made in Backend.restoreState is reflected
in Backend.glstate. Backend.glstate is not used after restoreState, so this
is just for clarity.
This is an alternative to https://github.com/gioui/gio/pull/77.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
They're easier to test and can be re-used for macOS/Windows.
While here, add a Go 1.18 build tag to app/ime_test.go; it relies
on Go 1.18 fuzzing.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
UTF8String is lossy in the presence of nul (\x00) runes.
While here, don't CFRelease the input to nsstringToString; leave it
up to the caller.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit ensures that the edit buffer used by widget.Editor
does not get EOF when trying to read zero bytes from the
underlying buffer, which eliminates a panic when calling
Editor.SelectedText().
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
Only rune positions are tracked for carets, and they only need adjusting
when changing Editor content, not just for re-layout.
Signed-off-by: Elias Naur <mail@eliasnaur.com>