ICCCM 4.1.2 says WMs will examine client properties every time
window is mapped. Because SetWMProtocols is called before MapWindow
some WMs (specifically taowm) never see them.
In other WMs this works because they check for WM_DELETE_WINDOW
when user tries to close window, not when window is mapped.
Signed-off-by: Konstantin Kulikov <k.kulikov2@gmail.com>
Removed redundant XSelectInput and XChangeWindowAttributes as well as
obsolete screen parameter in x11DetectUIScale.
Signed-off-by: Denis Bernard <db047h@gmail.com>
This is a general fix where keys with names differing from their UTF8
representation could not be sent as EditEvents.
Signed-off-by: Denis Bernard <db047h@gmail.com>
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>
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>
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>