Commit Graph

788 Commits

Author SHA1 Message Date
Daniel Martí d31a129bf9 cmd/gogio: fix a couple of x11 e2e TODOs
First, pick a random display number between 1 and 100,000. The pool is
large enough that we don't need to think about collisions for now.

Second, wait for the X server to expose its socket for up to 1s, instead
of doing a single static sleep of 200ms. The average time we actually
need to sleep on my laptop is around 5ms, so this gives a noticeable
speed-up.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-10-30 00:35:47 +01:00
Elias Naur fe54f3df4e .builds: add xvfb package to the linux builder for X11 end-to-end test
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-29 20:04:47 +01:00
Daniel Martí cea8dc374b cmd/gogio: add the first end-to-end X11 test
Right now it's very similar to the JS test on Chrome. Like it, this one
just runs the "red.go" gio app, takes a screenshot, and expects to see
red.

It also supports the -headless flag; when true, Xvfb is used and it's
entirely headless and hidden. Otherwise, Xephyr is used and once can see
the test in action. If the tool isn't installed, the test is skipped.

We need to add xgb as a dependency, so that we can connect to the X
server and interact with it, like taking screenshots.

Finally, this is an initial version, and a number of TODOs are left for
a later time. They'll get fixed in follow-up patches.

While at it, start making all tests parallel, since the end-to-end tests
take about a second each and neither are very cpu-intensive.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-10-29 20:01:52 +01:00
Elias Naur b8edf2ee04 .builds: switch from fedora/latest to debian/testing
Fedora builds kept failing at package installation. See
~sircmpwn/builds.sr.ht#220.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-29 17:48:12 +01:00
Daniel Martí 95c47aba55 cmd/gogio: clarify the need for --use-gl=egl in the e2e tests
After some investigation, it turns out that both Alpine and Arch suffer
from the same bug - their packages completely lack SwiftShader.

The current workaround is still the best that we have right now. But at
least we can actually provide a good explanation why, and a TODO to
improve this once the issues filed with the distros are fixed.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-10-29 15:35:23 +01:00
Elias Naur 4793faeadd cmd,example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-29 14:08:38 +01:00
Daniel Martí 4641607cd6 cmd/gogio: log chrome's console messages in TestJSOnChrome
For example, if the browser doesn't have webgl at all, the gio app will
fail to load. This will result in the screenshot being incorrect,
without an apparent reason:

	--- FAIL: TestJSOnChrome (0.89s)
	    js_test.go:122: got 0xffffffffffffffff at (5,5), want 0xffff00000000ffff
	    js_test.go:122: got 0xffffffffffffffff at (595,595), want 0xffff00000000ffff

The underlying webgl error was accessible if one added a sleep and ran
'go test -headless=false', allowing to open the console and see the
error messages.

Instead, capture them via chromedp and print them to the test's logger:

	--- FAIL: TestJSOnChrome (0.89s)
	    js_test.go:79: console log: "2019/10/29 12:41:07 app: webgl is not supported"
	    js_test.go:79: console warning: "exit code:", 1
	    js_test.go:122: got 0xffffffffffffffff at (5,5), want 0xffff00000000ffff
	    js_test.go:122: got 0xffffffffffffffff at (595,595), want 0xffff00000000ffff

JS Exceptions are a completely different mechanism, so they're not
covered by this patch. We can add them at a later time if needed.

While at it, update to the latest tagged version of chromedp.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-10-29 14:06:30 +01:00
Denis Bernard e834a78ab2 app/internal/window: X11 fix black window on Xephyr
On Xephyr, when fitst entering x11Window.loop(), syscall.Ppoll would
block forever while XPending() would still return a non zero value.
This commit refactors the loop so that XPending() gets called first,
then fallback to waiting in ppoll if there are no pending draw events.

This has the added benefit of reducing the number of calls to ppoll when
receiving a lot of events.

Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-10-29 14:04:20 +01:00
Elias Naur 2eb233dda6 .builds: remove -v from a tar command
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-29 01:45:05 +01:00
Elias Naur b46206e60a cmd,example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-29 01:38:16 +01:00
Elias Naur a7ae8b6e3d app/internal/window: move -Werror from LDFLAGS to CFLAGS
Discovered by the builders, yay:

+ gogio -target android ./kitchen
gogio: go build -ldflags=-w -s  -buildmode=c-shared -o /tmp/gogio-485830478/jni/arm64-v8a/libgio.so ./kitchen failed: go build gioui.org/app/internal/window: invalid flag in #cgo LDFLAGS: -Werror

(https://builds.sr.ht/~eliasnaur/job/101366)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-29 01:35:39 +01:00
Elias Naur 9671406cdd .builds: combine curl and tar to avoid temporary files
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-29 01:20:38 +01:00
Elias Naur 48e0a5315d .builds: fix apple.yml again
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 22:40:45 +01:00
Elias Naur 3f66d34599 app/internal/window: (Wayland) handle EAGAIN from wl_display_flush
Fixes gio#50

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 22:36:08 +01:00
Elias Naur f353c8c780 .builds: fix apple.yml builder
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 22:15:45 +01:00
Elias Naur 754db8c3d7 .builds: add macOS+iOS builder
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 22:08:27 +01:00
Elias Naur 4ba6b1a20c example/go.*: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 22:05:47 +01:00
Elias Naur 7115b448e8 app/internal/window: don't use module imports in framework header
Using the module import syntax "@import UIKit" results in a complaint
from the compiler:

> warning: use of '@import' in framework header is discouraged,
> including this header requires -fmodules [-Watimport-in-framework-header]

Use the regular #include syntax instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 18:26:07 +01:00
Elias Naur a6e452d6d5 cmd/gogio: add -Werror to main.m build
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 18:24:27 +01:00
Elias Naur 439d3e652c app/internal: consolidate CFLAGS and move -Werror to #cgo directives
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 13:30:51 +01:00
Elias Naur ddba67cc90 example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 11:47:49 +01:00
Elias Naur 4a26bdad5d cmd/gogio: build for iOS/macOS without -fmodules and -fobjc-arc
The `gogio` tool adds the `-fmodules -fobjc-arc` flags to the Cgo
C flags. Unfortunately, that masks problems where Cgo packages
accidentally didn't have the flags in their #cgo directives such
as package log.

Move the flags so they're only explicitly mentioned when `gogio`
invokes the host compiler to build the `main.m` shim.

Fix package log to include the missing flags.

While we're here, silence OpenGL ES deprecation warnings on iOS, just
as we do for macOS. The warnings are normally not visible because
the gogio tool suppress output from the go tool.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 11:40:53 +01:00
Daniel Martí a0692d74af cmd/gogio: improve the UX of the e2e tests
First, add a headless boolean flag that defaults to true. That way, one
can run 'go test -headless=false' to, for example, see how Chrome runs
the webassembly endtoend test.

Second, skip the Chrome test if the browser isn't installed.

While at it, run 'gofmt -s' on the package.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-10-27 21:31:53 +01:00
Elias Naur 8fab2f8cb1 .builds: add automatic testing script
Add fedora.yml for testing on linux and windows.

Add android.yml for testing `gogio -target android`.

Add a build badge to the README.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-27 19:12:50 +01:00
Elias Naur f4c6ec4fbe README.md: add sr.ht related documentation from gioui.org
Use https for the Unlicense URL and add one for MIT as well.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-27 16:29:36 +01:00
Elias Naur 3de204b8ef cmd/gogio/testdata: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-27 15:42:18 +01:00
Elias Naur a8e5e7a788 example: update gio version (X11 support!)
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-27 15:12:15 +01:00
Denis Bernard 547ff2e484 app/internal/window: x11 driver
This driver still lacks fling support and dp/sp configuration.

By default, linux builds will try to use the Wayland driver then
fallback to X11 if it fails. Drivers can be disabled by using either the
nowayland or nox11 build tags.

Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-10-27 15:06:53 +01:00
Elias Naur ec672ca06a README.md: remove documentation and link to gioui.org
There is now a real website on gioui.org. Use that for documentation.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-26 21:43:49 +02:00
Denis Bernard b78d144119 app/internal/window: add needVSync() to eglDriver interface
This enables calling eglSwapInterval with an interval value of 0 or 1
on a per driver basis.

Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-10-26 15:45:03 +02:00
Elias Naur 2c75f52de6 example/go.*: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-26 11:38:33 +02:00
Elias Naur fff9293c9b app/internal/window: work around missing MESA_EGL_NO_X11_HEADERS support
Some versions of eglplatform.h don't support the MESA_EGL_NO_X11_HEADER
define for cross-platform definitions of the EGL types. Remove the
define and use an explicit cast instead.

Fixes gio#46

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-26 11:37:06 +02:00
Elias Naur 88adc0ee1a website: delete
The website is now in a separate repository.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-24 17:49:24 +02:00
Elias Naur c4ac40e609 layout: remove Format
Move Format to eliasnaur.com/giox/layout because it's not clear it
belongs in the Gio standard library.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-23 10:53:59 +02:00
Elias Naur 9a62468c25 example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-23 10:21:08 +02:00
Elias Naur 143d2aae95 font/gofont: add explicit Register
Registering the font as a side effect of importing the gofont package
was too magic. Require an explicit Register call instead. As a side
effect, it is more clear which font is the default (the first one
registered).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-23 10:18:11 +02:00
Elias Naur 0504c27e46 widget/material: respect height minimum constraint in Button.Layout
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-23 09:56:34 +02:00
Elias Naur 2884604521 example/kitchen: clean up
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-22 08:42:59 +02:00
Elias Naur a35a2f5eb1 example/go.*: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-22 08:30:30 +02:00
Elias Naur 3a60a384e6 widget/material: respect min width in Button.Layout
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-21 12:58:05 +02:00
Elias Naur afcff9c8b5 layout: fix comment
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-21 10:38:58 +02:00
Elias Naur 72ed58e914 example/go.*: update Gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-21 09:37:49 +02:00
Elias Naur 86f45f813e widget/material: fix IconButton padding
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-21 09:34:26 +02:00
Elias Naur 78963bdaae widget/material: add and use Icon.Layout method
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-21 09:21:23 +02:00
Elias Naur dafb180176 layout: fix ambiguous parsing of stack and flex arguments
Fixed gio#44

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-21 01:04:31 +02:00
Elias Naur 79d505623a layout: parse empty names and let higher levels generate errors
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-21 01:04:31 +02:00
Elias Naur c07b520157 layout: rename formatState to formatter
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-21 01:04:31 +02:00
Elias Naur 32d51dd9e6 layout: fix spelling of "northeast"
Fixes gio#45

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-21 01:04:19 +02:00
Greg Pomerantz 5ef176af81 app: add Handle type and PlatformHandle()
On Android, allow access to JVM and Application context.

Signed-off-by: Greg Pomerantz <gmp.gio@wow.st>
2019-10-18 20:16:17 +02:00
Greg Pomerantz 175144fa99 cmd/gogio: Android: include jar files from package directory
Look for *.jar files in package directory for inclusion in
Android .apk file.

Signed-off-by: Greg Pomerantz <gmp.gio@wow.st>
2019-10-18 16:45:43 +02:00