Commit Graph

2394 Commits

Author SHA1 Message Date
Elias Naur ce116abded op/clip: specify path for stroked Rects
Fixes: https://todo.sr.ht/~eliasnaur/gio/358
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-10 19:01:08 +01:00
Elias Naur 242045f662 gpu/internal/opengl: ensure Backend.queryState is idempotent
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>
2022-02-10 17:03:13 +01:00
Elias Naur 887ba1b6e9 app: [Android] remove dead code
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-10 11:14:25 +01:00
Elias Naur 912ddb95f8 widget: fix build on Go 1.17
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-09 21:04:18 +01:00
Elias Naur b162ed56d7 app: [macOS] implement IME support
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-09 21:00:46 +01:00
Elias Naur 98b02176db app: [Android] move UTF-16 to UTF-32 conversion routines to Go
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>
2022-02-09 20:45:12 +01:00
Elias Naur ef9e4071e7 app: [macOS,iOS] don't use [NSString UTF8String]
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>
2022-02-09 17:43:25 +01:00
Chris Waldon b28307baeb widget: ensure buffer.Read does nothing to read zero bytes
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>
2022-02-09 16:11:58 +01:00
Elias Naur e32925d6a3 widget: push calls to Editor.makeValid to lower-level indexPosition
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-09 13:00:41 +01:00
Elias Naur 430aee39be widget: don't adjust selection in Editor.makeValid
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>
2022-02-09 12:54:50 +01:00
Elias Naur 9d778d7bde app: ensure derived events are processed
A range loop may not see all items in a slice that is appended to during
iteration. Convert range loop to popping each event off the queue until
it is empty.

Fixes: https://todo.sr.ht/~eliasnaur/gio/356
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-06 11:21:00 +01:00
Andy Balholm 44c9fb7448 internal/stroke: don't draw round join if angle is NaN
References: https://todo.sr.ht/~eliasnaur/gio/331
Signed-off-by: Andy Balholm <andy@balholm.com>
2022-02-06 11:07:16 +01:00
Elias Naur 58cdb3e1da app,widget: implement Editor IME support, add Android implementation
Fixes: https://todo.sr.ht/~eliasnaur/gio/116
References: https://todo.sr.ht/~eliasnaur/gio/246
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-06 10:31:53 +01:00
Elias Naur c22138f5f8 widget: track only Editor caret start in runes
The other information can be queries at use.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-05 22:58:55 +01:00
Elias Naur e323afa822 widget: track only rune offset in Editor caret end
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-05 22:36:12 +01:00
Elias Naur ff245361a4 widget: replace Editor.makeValidCaret
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-05 22:34:52 +01:00
Elias Naur 45078813b3 widget: replace Editor.movePosToEnd, movePosToStart
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-05 22:34:52 +01:00
Elias Naur 3ce403f851 widget: replace Editor.seek
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-05 22:34:52 +01:00
Elias Naur c071750ed9 widget: replace Editor.movePosToLine
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-05 22:34:52 +01:00
Elias Naur 3a70eaa9c1 widget: replace Editor.movePos
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-05 22:34:52 +01:00
Elias Naur 44e0196173 widget: [API] change Editor.SelectionLen, Selection, SetCaret, Len to operate in runes
This change uncovered and fixes a bug in nullLayout.

This is an API change; the methods operated in bytes before.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-05 22:34:32 +01:00
Elias Naur 2babf3b997 widget: replace a call to Editor.movePosToLine
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-05 21:58:12 +01:00
Elias Naur b9e8c4eda8 widget: introduce caret indexing to Editor
An efficient index replaces all other ad-hoc caret positioning methods.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-05 21:57:49 +01:00
Elias Naur 3614782e0d widget: simplify Editor.offsetToScreenPos
It used to return an iterator function, now it just takes the result
of a previous call.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-04 16:54:14 +01:00
Elias Naur d0869ef457 widget: track rune positions for Editor carets
Needed for efficient implementation of the upcoming IME interface.

Also introduce Editor.replace, seek methods for easier caret navigation
and editing.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-04 15:45:52 +01:00
Elias Naur 212c3cc126 widget: move xoff field out of caret position type
Editor is only interested in one xoff value, this change makes it so
it's the only one tracked.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-04 15:41:34 +01:00
Elias Naur 77557edd33 app: [Wayland] make clipboard reads synchronous
app.Window.Event is no longer safe to call for goroutines outside the event
loop. This change ensures that clipboard reads happen on the even loop.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-04 15:40:06 +01:00
Elias Naur 1c2e96bcc7 app: [Wayland] send WaylandViewEvent before DestroyEvent
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-04 14:20:23 +01:00
Elias Naur 4416a13786 widget/material: add ink effect and semantic information to decorations
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-01 12:08:00 +01:00
Elias Naur 12deba2195 app: don't apply fallback decorations when CustomRenderer is set
Fixes the opengl example on client-side decorated Wayland servers.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-02-01 10:59:58 +01:00
Chris Waldon 7204632c39 app: [API] refactor app.ViewEvent to support wayland
This commit changes the definition of app.ViewEvent on Unix systems
to be an interface implemented by two different concrete types:
X11ViewEvent and WaylandViewEvent. Each provides the necessary fields
for custom rendering on its display protocol.

This is a breaking change for all users of app.ViewEvent on
Linux/BSD, as it now is an interface instead of a concrete type.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2022-01-31 19:00:29 +01:00
Pierre Curto 74acc90789 app: [API] add Window.Perform, replacing Close, Raise, Centered
This new method performs user related actions on the Window, supporting custom window decorations.
It supersedes the Close and Raise methods as well as the Centered window option.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-31 18:56:29 +01:00
Inkeliz 668d0e7d79 cmd/gogio: use JAVA_HOME first
Tools such as the Android SDK `d8` looks for Java tools in JAVA_HOME
before PATH. We should match so we use the same tools, in particular to
make sure our Java version check report the version actually used.

Fixes: https://todo.sr.ht/~eliasnaur/gio/349
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2022-01-31 18:51:07 +01:00
Elias Naur 6fba94e573 app: [Wayland] update buffer scale immediately
Simpler, and makes sure buffer scaling is set correctly regardless of
the CustomRenderer setting.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-31 16:56:52 +01:00
Elias Naur 69a6b47f7b cmd/gogio: [Android] update arguments to d8
According to the d8 documentation[0] `--lib` should be used to specify
the path to android.jar, not `--classpath`. Also specify minimum SDK version
to allow d8 to perform version-specific optimizations.

May fix #349.

References: https://todo.sr.ht/~eliasnaur/gio/349
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-31 14:46:44 +01:00
Pierre Curto dcfe36c367 widget/material: split Decorations state and style
Move Decorations to the widget package and
rename material.Decorate to material.Decorations.
This makes decorations in line with how the
other widgets are used.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-31 14:21:19 +01:00
Jack Mordaunt 4f9d063e13 app: note the implications of custom rendering
Small note to make clear how the window behaviour
changes when you call for custom rendering.

Fixes: https://todo.sr.ht/~eliasnaur/gio/346
Signed-off-by: Jack Mordaunt <jackmordaunt.dev@gmail.com>
2022-01-31 14:16:10 +01:00
Elias Naur 9f1d6f5ebf app: [Wayland] minimize redraws, ack configure events immediately
There's no reason xdg_surface_ack_configure can't be called immediate,
do that. Then, replace calls to window wlWindow.draw with a redraw
field, to ensure only one redraw per event loop iteration.

References: https://todo.sr.ht/~eliasnaur/gio/351
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-31 14:08:28 +01:00
Elias Naur ba73227469 app: revert wrong fix for #340
This is effectively a revert of b2a99fddca,
which broke Window.Run.

Fixes: https://todo.sr.ht/~eliasnaur/gio/350
References: https://todo.sr.ht/~eliasnaur/gio/340
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-29 13:38:16 +01:00
Elias Naur f23a4f8452 app: delay Window.Close until after event processing
The fix for #340, b2a99fddca, deferred
all driver functions until after event processing. Deferring functions
breaks Window.Run which expects to complete during event processing.
This change is an alternative, more targeted fix, namely deferring just
Window.Close until after event processing.

A follow-up will revert the previous fix.

References: https://todo.sr.ht/~eliasnaur/gio/340
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-29 13:30:23 +01:00
Pierre Curto 7648a5e381 app: [macOS] fix initial ConfigEvent.Size
Upon initialization, the reported window size
was incorrect.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-29 12:41:32 +01:00
Pierre Curto 030fd8a171 widget/material: update Decorations
Fix actions not processed and move the Layout method from
Decorations to DecorationsStyle.

Also clarify the comment for the app.Window.Decorated option.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-29 12:21:08 +01:00
Pierre Curto 5ce1e98282 app: use material.Decorations on undecorated platforms
This patch implements a mechanism for customizing window
decorations.
If a window is configured with app.Decorated(true), then
the widget/material.Decorations are applied. On Wayland,
the option is automatically set when the server does not
provide window decorations.

Server side decorations are no longer requested.
The Decorated flag is set according to the
server's requests.

Wayland is now the default driver for UNIX platforms.

References: https://todo.sr.ht/~eliasnaur/gio/318
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-27 15:32:42 +01:00
Elias Naur 90ad0010ec app: disable Vulkan on X11
According to

https://gioui.org/issue/347 and
https://github.com/godotengine/godot/issues/43714

choosing the integrated Intel GPU on a multi-GPU system with NVIDIA
doesn't work well in X11. According to Godot, forcing the use of the
discrete (NVIDIA) GPU works around the problem. This change disables
Vulkan on X11 instead, which is a more conservative and targeted fix.

Disabling Vulkan on X11 will reduce testing of Vulkan, but

- Pierre is making Wayland the default driver on Linux, where Vulkan
is enabled.
- The OpenGL driver will be exercized more.

Fixes: https://todo.sr.ht/~eliasnaur/gio/347
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-27 12:32:13 +01:00
Elias Naur 1bad440ef6 app: ensure deferred functions are run outside of FrameEvents
Simplify callbacks.Event a bit while here.

Fixes: https://todo.sr.ht/~eliasnaur/gio/348
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-27 12:13:20 +01:00
Elias Naur 6294390df2 .builds: disable OpenGL tests on FreeBSD
For some reason, the Mesa OpenGL software renderer fails to correctly
render some of the tests in gpu/internal/rendertest. The Linux builder
uses the Vulkan software renderer, so only the FreeBSD builders fails.

The root cause may be a Gio issue, but since all the other backends work,
including hardware OpenGL, there is a likelyhood the issue is in Mesa.
I don't have the temperament to debug Mesa issues, so this change disables
software OpenGL on FreeBSD, which will cause the rendertests to skip.

Running Vulkan tests under FreeBSD is blocked on

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257303

In practice it won't matter: FreeBSD and Linux use the same software
for software renderers.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-25 13:33:30 +01:00
Pierre Curto 3bb0171e7a layout: reorder fields in Inset to match system.Insets
This makes it simple to convert from one into the other.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-25 09:54:05 +01:00
Rajiv Kanchan 29e6159d30 gesture: fix Hover by handling pointer.Cancel event
pointer.Cancel event is ignored, resulting in Hovered returning true
even though the pointer is no longer hovering over the region.
This change fixes it.

Signed-off-by: Rajiv Kanchan <rajiivkanchan@gmail.com>
2022-01-25 09:54:01 +01:00
Pierre Curto 2cf7c5b949 io/system,widget/material: add decorations
Add the Decorations material widget and the related system
elements in preparation for the automatic window decoration
patch.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-22 08:11:59 +01:00
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