Commit Graph

102 Commits

Author SHA1 Message Date
Greg Pomerantz 2ca2e5462f app: add RegisterFragment method on *Window for Android
RegisterFragment creates an instance of a Java class and registers
it as a Fragment in the window's Context.

Signed-off-by: Greg Pomerantz <gmp.gio@wow.st>
2019-11-26 18:52:43 +01:00
Greg Pomerantz 8321745de9 app/permission: add documentation and storage permissions
Storage permissions enables the Android permissions
READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE.
2019-11-26 12:29:00 +01:00
Elias Naur aca511f849 app/internal/window: (wasm) generate key.Events for all printable characters
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-24 19:41:11 +01:00
Larry Clapp 65bc7be256 app/internal/window: allow punctuation as keycode events
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>
2019-11-24 19:41:11 +01:00
Elias Naur d5424ef7fc app/internal/window: replace X11 input handling with xkb
Unifies Wayland and X11 keyboard handling.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-24 19:41:11 +01:00
Elias Naur 5a34b6f2c3 app/internal/xkb: send key.Events for shifted keysyms
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-22 16:13:38 +01:00
Elias Naur 968669d39e app/internal/xkb: fix cleanup check
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-22 14:52:33 +01:00
Elias Naur 4072361fd5 app/internal/gpu: fix Pathfinder URL
Noticed by Daniel Martí.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-22 14:50:04 +01:00
Elias Naur 72840d7b88 app/internal/window: delete redundant draw on WM_MAXIMIZE, WM_RESTORED
There's always a WM_PAINT after a restore or maximize message.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-20 15:19:26 +00:00
Larry Clapp f8de7545f4 several: add modifiers to mouse events and clicks
macOS only, for the os-specific bits.

Signed-off-by: Larry Clapp <larry@theclapp.org>
2019-11-18 15:38:09 +01:00
Konstantin Kulikov 101b65f4e5 app/internal/window: map window after defining WM protocols
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>
2019-11-14 10:56:49 +01:00
Denis Bernard 1bf2c7ef29 app/internal/window: (X11) Add support for UTF-8 window title.
Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-11-13 00:56:26 +01:00
Elias Naur 1d0a7b845e app: destroy GPU before ack'ing the DestroyEvent
The DestroyEvent ack allows the backend to release the window.
Ensure that the GPU associated with the window is done before that
happens.

Updates gio#67

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-12 22:17:29 +01:00
Elias Naur 41abb5b08d Revert "app: release GPU before processing DestroyEvent"
This reverts commit 8620b43eb3.

Releasing the GPU after ack'ing the DestroyEvent is too late.

Updates gio#67
2019-11-12 22:12:57 +01:00
Denis Bernard 2e0406802b app/internal/window: cleanup X11 initialization
Removed redundant XSelectInput and XChangeWindowAttributes as well as
obsolete screen parameter in x11DetectUIScale.

Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-11-11 13:50:45 +01:00
Elias Naur d8c9cb426c example/gophers: update gio version
gofmt -w -s . as well.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 19:46:10 +01:00
Elias Naur e864ac3fc3 op/clip: split clip operations into its own package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 19:07:00 +01:00
Elias Naur 0dac972b25 app,os: update documentation to match changed API
Updates gio#61

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 18:25:28 +01:00
Elias Naur 8620b43eb3 app: release GPU before processing DestroyEvent
In fact, move the release of the GPU to a deferred function, saving
a release.

Fixes #65

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 18:17:11 +01:00
Elias Naur b950aa71e1 app/internal/window: (X11) don't destroy window on EGL destroy
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 18:05:33 +01:00
Elias Naur 0cfcf5ca2d app/internal/window: (X11) implement right and middle mouse buttons
Updates gio#60

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 17:57:20 +01:00
Elias Naur dc7f9bab23 io/pointer,gesture: report right and middle mouse button events
Updates gio#60

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 17:41:39 +01:00
Denis Bernard a0050ab79b app/internal/window: x11: fix issue with space not sending key.EditEvent
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>
2019-11-09 16:06:54 +01:00
Elias Naur c8d01d99cc app/internal/xkb: translate physical "Backtab" keys to Shift-Tab
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 15:55:03 +01:00
Elias Naur dca25a7708 app/internal/window: map "Backtab" to Shift-Tab
Updates gio#62

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 15:47:06 +01:00
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 1eaa5dd15e app,app/internal/gpu: process frame in parallel
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>
2019-11-08 13:53:11 +01:00
Elias Naur 1678f922e7 app: make CPU timings more useful
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>
2019-11-08 13:29:35 +01:00
Elias Naur f6cdc62120 app: don't schedule a new frame for profiling events
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>
2019-11-08 13:02:19 +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
Elias Naur 97299dc2f9 op/paint: make every ImageOp unique
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>
2019-11-07 18:27:06 +01:00
Elias Naur d980c4652a app: don't touch the frame after returning from FrameEvent.Frame
It was already true that the GPU wouldn't touch the frame after
calling GPU.Draw. This change makes FrameEvent.Frame block until
GPU.Draw is complete.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-07 17:34:32 +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