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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>