Commit Graph

41 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 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 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 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
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 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 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 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 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 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
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
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
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 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 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
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 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 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 5b948ceece app/internal/window: tweak minimum pixels per dp/sp
To keep text legible on low DPI monitors, the number of pixels
per dp or sp is not is not allowed to go below minDensity. However,
a minimum density of 1.25 leads to too big text and widgets on a
baseline ~96 DPI monitor. Lower the minimum to 1.0, where text is still
legible.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-01 22:13:42 +01:00
Elias Naur 835714d44e app/internal/window: apply monitorScale to sp values on Wayland
macOS and Windows already applies monitorScale to sp values. Wayland
didn't apply the monitorScale when font scale detection fails. Do that.

Run gofmt -s -w . as well.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-01 21:36:15 +01:00
Elias Naur 15e34e9ca2 app/internal/window: add note about ANGLE when failing to load it
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-01 19:30:52 +01:00
Elias Naur b53c2a7c9d app/internal/window: introduce and use nilEGLDisplay
Updates gio#52

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 20:41:20 +01:00
Elias Naur 3425b25ecc app/internal: add FreeBSD support
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 14:01:02 +01:00
Elias Naur 1cc1fb1c72 app/internal/window: replace ppoll with poll
We're about to add FreeBSD where ppoll is not supported.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 13:44:59 +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 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 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