Commit Graph

41 Commits

Author SHA1 Message Date
Elias Naur 2e605f2dcb app: ensure the previous frame is complete before accepting another
It matters for end-to-end tests that rely on the window contents.

Before this change, tests had to wait for 2 extra frames. This change
ensures that the first completed FrameEvent.Frame call guarantees
the previous frame is complete.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 00:53:21 +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 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 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 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 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 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
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
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 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
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
Elias Naur 42d2c98455 app/internal/gpu: clip in floating point
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-17 15:30:37 +02:00
Elias Naur 0c75e7c605 app/internal/gpu: don't apply gamma linearization to alpha values
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-17 14:35:10 +02:00
Elias Naur b3c0eaac80 app/internal/window: fix Windows build
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-17 14:18:46 +02:00
Elias Naur 1d47f0c5d8 app/internal/window: fall back to OpenGL ES 2 if 3 is unavailable
Systems that only support ES 2 are unlikely to have the required
extensions available. But we'll get a better exit error in that case.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-15 17:59:23 +02:00
Elias Naur 88208891de op/paint,app/internal/gpu: post-process paths during GPU upload
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 22:51:52 +02:00
Elias Naur 74407a50d5 op/paint: add NewImageOp, unexport ImageOp fields
With public ImageOp fields there was no way to mark an image.Image as modified.
Replace them with NewImageOp that always make a copy, and use the opportunity
to ensure the copy is ready to upload to a GPU texture.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 18:06:50 +02:00
Elias Naur b30bf3cef8 app/internal/log: extract log setup to separate package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 16:39:32 +02:00
Elias Naur 10c1b2cb8d app,internal/window: extract native window code to separate package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 16:39:32 +02:00
Elias Naur 36d1cd90f2 app,io/system: extract system events to separate package
Package app is the only package that depends on native libraries and
Cgo. Minimize its API, thereby minimizing Gio clients' dependency on
it. In the future, a headless, testing or remote "Window" should be
very easy to replace app.Window.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 16:20:20 +02:00
Elias Naur 4475bf10bf app: disable darwin SIGPIPE workaround from Go 1.14
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 14:21:02 +02:00
Elias Naur 52fedc27a2 app/internal/xkb: extra XKB interface to internal package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-14 11:50:44 +02:00
Elias Naur e1de1ba591 io/pointer: delete Foremost priority
It wasn't used, and it's not clear that it is useful at all in its current
form. For example, a single control with multiple handler keys (say, one for
scrolling and one for clicking) will only receive priority Foremost for one of
them.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 16:31:23 +02:00
Elias Naur a937a76534 app: rename UpdateEvent to FrameEvent and add Frame field
While "DrawEvent" was too specific (op.Ops contains non-draw events),
"Update" is too vague: it's a common word, and could be misunderstood
to mean update parts of a window, not replace it.

"FrameEvent" is more specific, and is the usual way to refer to immediate
mode drawing.

While we're here, unexport Window.Update and add a Frame function to
FrameEvent, to emphasize that updating the window frame is only
appropriate during the handling of a FrameEvent.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 14:01:46 +02:00
Elias Naur e49df512f6 app/internal/input: remove event delivery tracking field
The "hadEvents" field of handlerEvents is enough to track event
delivery.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 14:01:46 +02:00
Elias Naur ff4fa71738 app/internal/input: really reset dropped handlers
First, let the handlers know they're dropping with a cancel event.

Second, reset the grab flag of dropped handlers.

Fixes issues when drag-scrolling and then clicking and another with two nested
drag gestures where the grab flag is kept for the second handler even after it
is pushed out by the first handler grabbing.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 14:01:46 +02:00
Elias Naur a184faa50e app: remove two remaining Wayland references from xkb
Noticed by ~db47h.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-11 15:31:15 +02:00
Elias Naur a76de40e9a app: another macOS < 10.12 build fix
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-08 17:30:31 +02:00
Elias Naur da5a83d2b2 app: fix more macOS 10.11 build warnings
Furthermore, add -Wno-deprecated-declarations; it is not worth it.

Updated gio#41

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-08 16:52:29 +02:00
Elias Naur c3a6ab1174 app: fix build on macOS < 10.12
Fixes gio#41

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-08 14:22:41 +02:00
Elias Naur 4864459291 app: rename WindowOption to Option, and leave out "With" from options
While we're here, replace Height and Width options with just a Size; the value
of separate width and height options is not clear to me.

Finally, leave out the wrapping struct from the Option type, the
function is enough.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-07 12:00:17 +02:00
Elias Naur 07a36d71d9 app: (linux,android) merge EGLNative* types and functions
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-02 23:21:48 +02:00
Elias Naur 2dcbf6fe3c app: confine the eglWindow indirection to the Wayland backend
Only the Wayland backend needs an wl_egl_window between the wl_surface
and EGL. Move code dealing with the indirection to Wayland specific
code.

Then, introduce the eglDriver interface instead of referencing the
native window type directly. This will help when multiple backends are
supported at runtime (e.g. Wayland+X11).

Finally, move the eglDriver implementation methods from GOOS-specific
code to separate EGL-specific files, allowing EGL types to be used
directly instead of unsafe.Pointer and uinptr.

The result is simpler generic EGL code, and easier path towards X11
support.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-02 23:07:54 +02:00
Elias Naur 32bda106e7 app: (android,ios) fix build
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-02 22:55:28 +02:00
Elias Naur 3784ece6dd all: rename package ui to unit
Package ui is now only about units except for the Config.Now method.
Remove Now and rename Config to Converter. Add layout.Config to
replace the old ui.Config.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 16:55:47 +02:00
Elias Naur beaec661d2 op/paint: move paint package below the op package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 16:55:47 +02:00
Elias Naur 8cf35a1f97 op: add package op for operations
Extract operation types from package ui into package op.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 16:55:47 +02:00
Elias Naur eba1b3a95f app,ui: move instructions link to package app documentation
We're about the split up and finally delete package ui. Move the
instructions link to the second most "top-level" package in Gio,
package app.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 15:25:22 +02:00
Elias Naur e7a97bf176 io/event: move event types from package ui to its own package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 15:18:08 +02:00
Elias Naur 7a259e68f7 io: give event packages a common prefix
Packages that provide support for external events such as pointer, key and
system are only the beginning. Future packages are expected for clipboard
access, drag and drop, gps positions and so on.

To keep the number of top-level packages under control, move such I/O packages
to the new `io` directory.

The `system` package name was the previous solution to keeping the number of
top-level packages under control: I named it `system` instead of the narrower
`profile` because I expected to put all the less common events into it, turning
`system` into a "package util" smell.

With `io`, package system can be renamed to `profile`.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 14:50:55 +02:00
Elias Naur 22cd88df9f all: rename the gioui.org/ui module to gioui.org
The "ui" is redundant and stutters.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 12:37:06 +02:00