Allows things like "ctrl-{" and ".".
All punctuation is returned as-is, e.g. "!" is "!", not "shift-1", and
"{" is "{", not "shift-[".
Also add the Enter key as a known key (fn-return on my Mac).
Signed-off-by: Larry Clapp <larry@theclapp.org>
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>
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>