Commit Graph

892 Commits

Author SHA1 Message Date
Elias Naur de7d6b28fa io/key: add support for the Tab and Space keys
Fixes gio#62

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 11:57:36 +01:00
Elias Naur da42412e56 README.md: add an Oxford comma to emphasize only WebAssembly is
experimental

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 00:42:02 +01:00
Elias Naur 9def3153de README.md: note that the WebAssembly is experimental
It's slow and syscall/js has seen incompatible changes in Go 1.13
and Go 1.14.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 22:27:06 +01:00
Elias Naur 294308d8aa example/gophers: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 22:22:41 +01:00
Elias Naur cc43588aba io/key: switch Event.Name to be a string and add function keys
Function keys don't have a natural rune representation so switch
Event.Name to be a string to fit "F1"-"F12".

Fixes gio#59

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 22:20:17 +01:00
Elias Naur c833c98fd7 io/key: add ModAlt, ModSuper
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 18:39:21 +01:00
Elias Naur c4416ffbc4 example/gophers: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 18:04:56 +01:00
Elias Naur d293dfe604 key: add ModCtrl, ModShortcut
ModCtrl is the physical Ctrl key, ModShortcut is the virtual
"shortcut" modifier, which is Ctrl on most platforms, Command on
Apple platforms.

Updates #59

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 18:02:26 +01:00
Elias Naur 1eaa5dd15e app,app/internal/gpu: process frame in parallel
A frame ops buffers is tracersed twice: once for GPU commands,
and once for everything else. There is already a GPU goroutine for
concurrentl issuing of GPU commands; move the frame ops processing
to the goroutine as well. Both frame ops passed can then proceed
in parallel.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 13:53:11 +01:00
Elias Naur 1678f922e7 app: make CPU timings more useful
Record the time for generating a frame and submitting it as well
as the time for issuing the frame to the GPU and swapping buffers.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 13:29:35 +01:00
Elias Naur f6cdc62120 app: don't schedule a new frame for profiling events
Sometimes it's useful to profile yet not continously re-draw. If the programs
wants the old behaviour, it can issue an InvalidateOp or call
Window.Invalidate.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 13:02:19 +01:00
Elias Naur e16712321f .builds: use gotip on freebsd builder
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 12:45:25 +01:00
Elias Naur f1d971268e op/paint: guard against nil image in ImageOp.Size
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-07 21:08:01 +01:00
Elias Naur 508f615f0b example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-07 18:51:32 +01:00
Elias Naur 9c0fc631bd widget/material: use theme TextSize for Editors
Thanks to Werner Laurensse for noticing.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-07 18:45:53 +01:00
aarzilli 454b226404 op/paint: NewImageOp does not need to make copies of RGBA images
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-07 18:44:31 +01:00
Elias Naur 237a8dad8f app/internal/window: re-create EGL surface on resizing
This is effectively a revert of 60e4cca934, which
seems to have caused flickering problems on some versions of Windows.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-07 18:34:05 +01:00
Elias Naur 97299dc2f9 op/paint: make every ImageOp unique
The gioui.org/commit/74407a50d598bfd27e8f8e48b6832cc5df04de77
added a NewImageOp constructor that always copies the supplied
image. It does that for two reasons:

First, the image.Image reference is used in the image=>texture
map of cached textures. Without a copy, we wouldn't detect a
modified image even if a new ImageOp was created.

Second, we don't want the program to touch the image while the GPU
is uploading it.

The second reason was removed in a previous change that blocks
FrameEvent.Frame until we're done with the operations, including
uploading images to the GPU.

The first reason is easily fixed by using a unique per ImageOp,
as pointed out by Alessandro Arzilli.

This change switches to using the unique key. Alessandro's patch
avoids the copy when possible.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-07 18:27:06 +01:00
Elias Naur d980c4652a app: don't touch the frame after returning from FrameEvent.Frame
It was already true that the GPU wouldn't touch the frame after
calling GPU.Draw. This change makes FrameEvent.Frame block until
GPU.Draw is complete.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-07 17:34:32 +01:00
Daniel Martí 6fedfaf3af cmd/gogio: start using testing.T.Cleanup
Now that we use tip due to breaking changes in Go's JS APIs, let's
replace our hacky cleanup list code with 1.14's upcoming
testing.T.Cleanup.

Adding more deliberate uses of tip would ususally be best avoided, but
these will only affect developers working on gio's tests, not regular
users of gio.

While at it, remove some debug t.Logf calls I forgot to remove.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-11-07 16:11:38 +01:00
Denis Bernard 75a58e42ef app/internal/window: remove direct pointer arithmetic in x11 driver.
Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-11-07 14:22:47 +01:00
Elias Naur e683b19b29 .builds: use Go 1.14 for the basic tests
WebAssembly builds require Go 1.14 since the breaking change in Go,
golang.org/cl/203600.

gofmt -w -s . as well.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 18:35:44 +01:00
Elias Naur b0c29b5489 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 18:04:52 +01:00
Daniel Martí 6f860200b9 cmd/gogio: join all endtoend tests as subtests
This means we can deduplicate some of the logic, and keep it all in one
place.

Start expanding the logic too; the tests are slow, so they should be
skipped on 'go test -short'. The ones we have so far all run in a matter
of seconds on an average laptop today, but future tests will probably
require heavier work like wine or kvm.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-11-06 18:03:51 +01:00
Elias Naur 62da32be9c app/internal/gl: support Go 1.14 change to WebAssembly's js.Value
Gio programs will no longer build with Go 1.13; let's keep it at that
until someone complains.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 17:59:39 +01:00
Elias Naur c3533c3f84 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 17:32:21 +01:00
Elias Naur 7256bdae38 app/internal/windows: don't draw window background on Windows
Avoids flickering between GPU content and the CPU drawn background
color.

gofmt -w -s . now we're here.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 17:28:14 +01:00
Elias Naur 9c84b95f7d app/internal/window: specify None as the X11 window background
Avoids flickering on my Fedora 31 Gnome setup.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 17:13:03 +01:00
Elias Naur 96072cec66 README.md: add note about gio-patches mailing list
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 16:41:13 +01:00
Elias Naur 0ad9bd9725 app/internal/window: finish GL commands before surface detruction
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 16:11:46 +01:00
Elias Naur 6287c1750f Revert "app/internal/window: finish GL commands before resizing"
This reverts commit 8e874e1afd.

Didn't fix flickering.
2019-11-06 16:09:21 +01:00
Denis Bernard 68063633f2 app/internal/window: Fix keyboard handling on X11
When the control key is pressed, clear event.state bits before calling
Xutf8LookupString in order to get the unmodified key name. This allows
proper handling of all keys in combination with ModCommand.

`key.Event.Name` is however layout dependent. Client code should be
careful about this when picking key shortcuts like CTRL-'+': on a QWERTY
keyboard, only CTRL-'=' and CTRL-SHIFT-'=' are generated when pressing
the '=' key of the top row. The keypad '+' key generates events with
`Name = '+'` as expected.

Fixes gio#57

Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-11-06 15:16:47 +01:00
Elias Naur 1defd4e759 widget/material: clean up package docs, add license, rename file
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 11:46:52 +01:00
Elias Naur 90e25ed52f example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 11:26:08 +01:00
Elias Naur 8e874e1afd app/internal/window: finish GL commands before resizing
Perhaps fixes flickering during window resize.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 11:23:49 +01:00
Elias Naur 6f3471e4ad example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 11:06:58 +01:00
Alexander Arin 089ae31f0c widgets, widgets/material: add RadioButton & Enum
Signed-off-by: Alexander Arin <fralx@yandex.ru>
2019-11-06 11:02:28 +01:00
Elias Naur 82e51019e1 widget/material: document package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 10:57:17 +01:00
Elias Naur 1438e504cc example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-05 18:25:27 +01:00
Elias Naur ef78ba37f6 app/internal/window: implement GetDpiForMonitor fallback for < Win 8.1
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-05 18:20:36 +01:00
aarzilli 299e966816 op/paint: make documentation of Line clearer
The movement is not to an absolute coordinate but by a delta relative
to the current position of the pen.
2019-11-05 17:57:50 +01:00
Denis Bernard 60e4cca934 app/internal/window: Do not re-create EGL surfaces when only resizing
This prevents flickering when resizing the window on X11.

Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-11-05 17:45:24 +01:00
Elias Naur 4719d56f86 .builds: fix go fmt test and go fmt -w -s .
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-05 12:50:07 +01:00
Denis Bernard 900acc08a1 app/internal/window: replace gio_x11_connection_number stub by proper xlib function
Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-11-05 12:43:05 +01:00
Daniel Martí 4d7c89fec3 cmd/gogio: simplify the test -race setup
In an earlier commit, we made it possible to run the e2e tests with the
race detector enabled everywhere via GOFLAGS=-race go test.

However, that's not at all standard; most users will simply use 'go test
-race'. Moreover, having 'go test -race' run the test program with the
race detector, but not the e2e gio app, is a bit useless.

Instead, have the tests detect when they run with the race detector, and
enable the race detector in the test app too. As before, the JS test is
skipped whenever -race is used.

This also means we can test with -race in the same way in each of the
modules, which simplifies CI.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-11-04 22:21:21 +01:00
Elias Naur c2cab4505c example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-04 19:32:07 +01:00
Elias Naur 4adaea3396 app/internal/window: correct baseline DPI on Windows, iOS
Updates gio#53

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-04 19:27:34 +01:00
Elias Naur 615840352e example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-04 19:11:32 +01:00
Elias Naur 03eeba7974 app/internal/window: make 1 dp = 1 px in WebAssembly
Updates gio#53

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-04 19:07:37 +01:00
Elias Naur 513b19b2c5 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-04 18:47:18 +01:00