Commit Graph

1263 Commits

Author SHA1 Message Date
Elias Naur 26641344bc app/internal/window: [Wayland] move notification channel to wlDisplay
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur 55881fc09c app/internal/window: [Wayland] remove redundant event dispatch
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur 28a3de6e32 app/internal/window: [Wayland] delete unused field
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur 0181f22d01 app/internal/window: block Main until all windows are closed
With this change, the Wayland backend now supports multiple windows.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur cf72e684b6 app/internal/window: use a sync.Map for callback references
Multiple Wayland windows are now separate, except for the global callback
reference map. Use a sync.Map to support multiple concurrent windows.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur 0aa7d4ab3f app/internal/window: [Wayland] move outputMap and outputConfig to wlDisplay
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur 1a48b5c33c app/internal/window: [Wayland] use a single callback entry for each object
The callbackMap is used to look up Go references in event callbacks. Instead
of registering one entry for each possible callback type, use a single
handle for each Go reference.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur bf129ca989 app/internal/window: get rid of the global Wayland display
Instead, create a display for each window.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur 3e648715db app/internal/window: rename wlConn to wlDisplay
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur bc645c3ca4 app/internal/window: [Wayland] introduce wlSeat for seat-specific state
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur fd6f6c4485 app: move GPU context validation and retry logic to separate method
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur 56dbaf326a app: move frame waiting code out of Window.run to a separate method
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-16 11:01:19 +02:00
Elias Naur db0af521d0 app/internal/window: move Wayland callback structs into function scope
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-15 12:14:17 +02:00
Elias Naur 31acd5451e op/paint: further clarify PaintOp documentation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-14 13:44:36 +02:00
Elias Naur 29c9b06dab op/paint: document ImageOp gotcha
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-14 13:31:21 +02:00
Elias Naur b7ba809517 op/paint: rename material to brush
The "material" name clashes with the theme of the same name.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-14 13:19:15 +02:00
Elias Naur 81f474f5d7 op/paint,io/system: document ImageOp lifetime
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-14 13:15:05 +02:00
Elias Naur 391b89d11d example/glfw: add package documentation and link to installation
Fixes #114

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-14 11:12:39 +02:00
Elias Naur f16e8fd122 app: update package documentation
Reflect the move of Queue from Window to FrameEvent.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-14 10:11:18 +02:00
Elias Naur 2e25a28a54 app: fix typo in Main documentation
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-14 10:08:28 +02:00
Elias Naur 05dfceb7e7 app/clipboard: implement clipboard for Android
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-13 17:14:58 +02:00
Elias Naur a6dd70b2dc app: add license header to app_android.go
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-13 15:18:07 +02:00
Wagner Riffel 390949790e f32: implement fmt.Stringer to Point and Rectangle
Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
2020-05-13 12:59:39 +02:00
Wagner Riffel 4bbc6379ed doc: rewrite references to preivous api to current
Signed-off-by: Wagner Riffel <wgrriffel@gmail.com>
2020-05-13 12:59:33 +02:00
Egon Elbre f29964fee1 example/tabs: animated switching
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-05-13 12:59:29 +02:00
Elias Naur d682e92606 example/tabs: use material.Clickable
Replace the hacked material.Buttons with Clickables for the tab areas.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-13 10:31:40 +02:00
Elias Naur 062e2bc54b gesture: only report TypePress for Click gestures if pointer is grabbed
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 16:50:07 +02:00
Elias Naur ca0af08ff2 gesture: use Enter/Leave events instead of Moves
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 16:32:37 +02:00
Elias Naur a0df8ba59b example: bump gio version and add flat button example to kitchen
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 13:20:17 +02:00
Elias Naur 23baeff18d widget/button,widget/material: introduce Clickable for generic click areas
material.Clickable is useful for adding a click response to any widget
or area.

Rename widget.Button to widget.Clickable to reflect the wider use
spectrum.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 13:17:14 +02:00
Elias Naur 47ce4b8cb8 widget: export Button.Update method for accessing raw gesture events
Document Button while we're here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 12:56:56 +02:00
Elias Naur 43c2b90716 widget: simplify popping an element from a slice
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 12:47:27 +02:00
Elias Naur fd2cb4a7a1 widget,widget/material: use constraints for setting up hit area
Before this change, the widget.Button.Layout method assumed the caller had set
up the pointer hit area before. Further, the very common rectangular hit
areas needed both an AreaOp and a widget.Button.Layout call.

Make widget.Button less subtle and more useful by setting up a
pointer hit area given by the incoming minimum constraints.

Drop a pointer.AreaOp made redundant by the change.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 12:37:08 +02:00
Elias Naur 4e20ea83a1 widget/material: use cosntraints for setting pointer hit areas
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 12:23:18 +02:00
Elias Naur 3fd1ccbbed io/router: fix ellipse hit function
The previous formula was simply wrong.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 12:15:54 +02:00
Elias Naur a046f15156 io/router: return boolean expressions directly
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 11:57:37 +02:00
Elias Naur 73475270fe example: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 11:32:45 +02:00
Elias Naur c32b3fe43a widget/material: drop Color from ButtonLayoutStyle
Setting a ColorOp before calling a widget function is too subtle.
Let the widget manage its color instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-11 11:31:48 +02:00
Daniel Martí 669e4cc96a cmd/gogio: speed up the wine e2e test
First, use wineboot instead of winecfg to set up the WINEPREFIX. It's
the right tool for it.

Second, when initialising WINEPREFIX, use output pipes instead of
CombinedOutput. The latter will wait for *all* output to be copied to a
buffer, including the output from grandchildren processes. Since wine
starts wineserver automatically, and wineserver lingers for three
seconds by default, this is bad. We would waste three seconds waiting
for wineserver doing nothing, and then the next wine call (to start the
app) would need to start wineserver all over.

Instead, with pipes we can get cmd.Run to only wait for the parent
process to finish. wineserver stays running but we don't care. And, when
we start the gio app, we very likely reuse the same wineserver process.

Third, disable wine-gecko and wine-mono. This ensures we don't get stuck
if they're not installed, and speeds up wineboot by avoiding work we
don't need.

The time to set up WINEPREFIX goes down form ~6s to ~1s, and the overall
subtest run-time goes down from ~10s to ~3s.

Finally, copiously document all of the precious data I've gathered above
after hours of debugging.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-10 21:51:30 +02:00
Daniel Martí 023e022255 cmd/gogio: make e2e test output consistent
Fix a long-standing TODO: instead of each sub-test handling its own
output separately, just make each expose its output via an io.Reader.
Then, the shared driverBase code can tell if any of the lines contain
the magic "gio frame ready" string.

Reduces the amount of code a bit, but most importantly, it keeps the "is
a frame ready?" logic in a single place.

In the future, this also enables us to do more with all the e2e test app
output consistently. For example, we might want to add a -debug flag to
always log output lines as they happen.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-10 20:32:57 +02:00
Daniel Martí 9ad412ea0b cmd: bump gioui.org dependency, use -modfile properly on CI
A simple 'go test -modfile=<path>' won't work properly for the
end-to-end tests, since they run 'go build' under the hood as well.

To properly propagate the flag, we need to use GOFLAGS. Since -modfile
is always relative to the current directory, we can't use it to test
many packages at once, nor can we use it via 'go test ./gogio'.

While at it, document this distinction in go.local.mod to prevent others
getting confused like I did.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-10 20:32:53 +02:00
Daniel Martí c2cbcee78d cmd/gogio: use a standalone WINEPREFIX for the wine e2e test
This way, if the user has a custom winecfg, it can't possibly affect the
tests. I was encountering this as DXVK does not work on virtual Xorg
servers (which we use), and Gio thus failed to render on such a
combination.

>From the numbers below, it can be seen that setting up a new WINEPREFIX
takes roughly five seconds:

	$ rm -rf ~/.cache/gio-e2e-wine
	$ go test -run EndToEnd/Windows
	PASS
	ok  	gioui.org/cmd/gogio	16.369s
	$ go test -run EndToEnd/Windows
	PASS
	ok  	gioui.org/cmd/gogio	11.810s

A repeated run still has a slow "wine winecfg /?", for some reason. Add
a TODO since I can see it taking a third of the time on my terminal. I
haven't been able to properly investigate why, unfortunately. As far as
I can tell, winecfg is just faster when run with a terminal instead of
an output buffer. They might use isatty on stdout/stderr.

The overall time to run the wine sub-test is increased from ~5s to ~11s,
but it's worth it to make it run everywhere. It looks like there is
plenty of room as per the TODO above, as winecfg seems to mostly do
nothing. We're also not too worried, as all e2e subtests run in
parallel.

Fixes #106.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-10 08:40:36 +02:00
Chris Waldon 29a9e5bc27 io/router: fix Enter/Leave during press events
This commit updates the implementation of the Enter/Leave pointer
events so that it no longer shares any state with the processing
of pointer presses and grabs. This simplifies the implementation,
though it does leave a certain amount of structural redundancy.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-05-09 08:47:01 +02:00
Chris Waldon c1f0f9b5c7 io/router: improve benchmark by trying multiple sizes
This commit improves the usefulness of the benchmark by automatically
measuring event processing times with a range of values for the complexity
of the UI.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-05-09 08:46:56 +02:00
Chris Waldon b2f1776670 io/router: fix enter/leave event tests and add more
This commit fixes a bug which concealed test failures when
the actual event sequence was empty but the expected events
were not.

Additionally, this commit adds the following tests:

- a test for when the active input
area disappears while it is still being "hovered".
- a test for when there are two nested input areas that are
being hovered

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2020-05-09 08:46:53 +02:00
Elias Naur 0ad8f85c05 cmd/gogio: add -linkmode flags
For experimenting with https://github.com/golang/go/issues/38918.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-08 08:31:26 +02:00
Elias Naur bcbea7e653 cmd/gogio: fix ldflags overwriting
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-08 08:27:42 +02:00
Elias Naur 630e0b494d app/internal/windows: remove extra empty line
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-07 16:03:22 +02:00
Elias Naur 681bafce08 cmd/gogio: use filepath for Windows compatibility
Fixes gio#112

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-07 15:52:13 +02:00
Elias Naur 3957be37c8 app: [Android] tweak environment for os.UserHomeDir and os.UserConfigDir
Set the fallback environment variables XDG_CONFIG_HOME and HOME to
make os.UserConfigDir and os.UserHomeDir report useful paths.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-06 16:54:55 +02:00