Commit Graph

868 Commits

Author SHA1 Message Date
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
Elias Naur d478bb2bc5 app/internal/window: drop zero-sized redraws in WebAssembly
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-04 18:45:10 +01:00
Alexander Arin 4ac3a7fd84 widget: add SetChecked method to CheckBox
Signed-off-by: Alexander Arin <fralx@yandex.ru>
2019-11-04 17:10:51 +01:00
Elias Naur 1110ed1aed example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-04 16:40:09 +01:00
Denis Bernard c5449f0f74 app/internal/window: implement dp/sp scaling in X11 driver
Use a constant 1.0 scaling from dp to pixels and adjust with user prefs.

Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-11-04 16:37:09 +01:00
Elias Naur 90de8b6360 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-04 15:17:42 +01:00
Elias Naur 396a538afe app/internal/window: don't second guess UI scale
Before this change, Gio tries hard to come up with a reasonable UI scale
factor on desktop OSes derived from the physical dimensions and
resolution of connected monitors. Gio also attempts to detect the user
specified system UI scale and apply it.

However, all that is complex and misguided:

- The UI scale should not depend on whatever monitor is connected at
program startup - For multiple monitors, it's unclear which one to base
the scale off.  - Applying both a monitor derived scale *and* the user
specified scale is wrong, because the user scale is relative to some
fixed scale, not Gio's derived scale.  - With an automatic scale, Gio
does not respect user preference and will not have a similar scale to
other programs on the desktop.

Get rid of the the automatic UI scale detection and rely only on the
user scale.

Updates gio#53

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-04 15:13:37 +01:00
Elias Naur 65146a5337 example/kitchen: add CheckBox example
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-04 00:42:02 +01:00
Alexander Arin 0f5b94a483 widget,widget/material: add CheckBox 2019-11-04 00:31:12 +01:00
Alexander Arin 2a06f3d3b2 widget/material: move Icon to its own file and add Color; add CornerRadius to Button 2019-11-04 00:29:21 +01:00
Daniel Martí ec0c2498a1 cmd/gogio: fix a couple of staticcheck positives
Spotted the javac one by chance when reading the code, so I ran the tool
and fixed another small bug while at it.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-11-04 00:09:40 +01:00
Elias Naur 2bee95358a .builds: run the cmd tests with and without -race
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-03 13:06:14 +01:00
Daniel Martí 2a4829d857 cmd/gogio: support running e2e with and without -race
Right now, we can only run the e2e gio app with -race, not without
-race, because the flag is hard-coded in the tests.

The reason for this change was that 'GOFLAGS=-race go test' would fail
with the JS test, since js/wasm doesn't support the race detector. Fix
that by skipping the JS test when -race is used.

Now, we can run multiple levels of -race:

	go test               # no -race at all
	go test -race         # -race for the tests, not the e2e gio app
	GOFLAGS=-race go test # -race for everything (best-effort)

To detect the race detector being on, we use a file with a build tag.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-11-03 13:05:06 +01:00
Elias Naur cc4b407647 .build,cmd: add -race to test programs
It's not possible to set GOFLAGS=-race because some programs are
built for webassembly where -race is not supported.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-03 12:09:02 +01:00
Elias Naur b3635c78ee .builds: add sway as dependency for Wayland end-to-end test
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-02 18:55:31 +01:00
Daniel Martí 12ce899bb5 cmd/gogio: first wayland end-to-end tests
Clicking doesn't quite work yet, but everything else does. We use a
custom sway config to ensure that it's a minimalist setup with no bar or
borders, like the other drivers.

The generic test now adapts to the window's real size when running in
non-headless mode, since tiling window managers resize some drivers like
sway. The default headless mode still expects the exact size that we
specify, as no real windows are at play.

While at it, clean up some now unused code from the x11 file.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-11-02 18:12:46 +01:00
Elias Naur 5eeaadccea app/internal/window: apply font scale to dp scaling on Wayland
As discussed in gio#53, Linux font scales conflate two settings: the fractional
UI scale and the user preference as a result of conditions such as impaired
vision. The former setting should apply to both dps and sps, while the latter
only to sps. However, with the assumption that more users presumable change the
font scale for the former reason rather than the latter, we should apply the
font scale to both dps and sps in Gio.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-02 17:58:56 +01:00
Elias Naur e2c29f96d9 app: fix reference to gioui.org/io/event
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-02 16:59:19 +01:00
Elias Naur 7182477f3c README.md: add supported platforms
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-02 16:32:47 +01:00
Elias Naur dde09b9d74 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-02 16:09:07 +01:00
Daniel Martí 97d13922dd cmd/gogio: remove sleeps in x11 e2e test
We can instead synchronize with the gio app via stdout. We need three
states, since we need to first invalidate a frame and then print when
the next frame is drawn.

This is not happening on the JS test yet, because stdout printing
crashes in that case. See the comment.

This change should make the X11 test a bit faster on fast machines,
while making it more stable in small or headless machines like CI.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-11-02 15:00:37 +01:00
Elias Naur 2a9361db65 Revert "gesture: add Active methods to gestures"
This reverts commit d829e56194.

We're not using the activity of gestures to track whether widgets
should behave as disabled or enabled anymore.
2019-11-02 14:49:33 +01:00
Elias Naur 4107485902 widget,widget/material: remove disabled drawing modes
Determining the enabled state of a widget from whether its Clicked method has
been called only works for button-like widgets. For example, it's not clear a
Clicked method is appropriate for a CheckBox.

Remove the feature for now, and let's find a better design in the future.

As a nice side effect, we can now process events in Layout methods, so that
buttons react to user input even when Clicked is not called.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-02 14:48:22 +01:00
Elias Naur 06aa0da2a2 .builds: add scrot to the linux image for the X11 end-to-end test
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-02 10:43:50 +01:00
Daniel Martí b8e996074b cmd/gogio: rip out cgo deps for x11
Instead rely on more tiny standalone tools. In this case, scrot lets us
take png screenshots, and works well.

On the plus side, we remove some large X Go deps, and we don't need
nearly as much code.

While at it, skip if any of the tools are missing, and actually defer
the cleanup funcs so that they run when we fail the test early.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-11-02 01:19:19 +01:00