Commit Graph

2377 Commits

Author SHA1 Message Date
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
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