To get the `popstate` we need to create a new entry into
the browser history. Then, Gio will handle the "back" and
"forward" of the page.
In some browsers (Chrome 87/Edge 87): The user must
click inside the window/page at least one time. It will not
work if the user leaves the page (clicking back button)
without interaction with Gio.
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
Update key.State documentation and add State.String while here. Also
update Event.String to include State.
Signed-off-by: Raffaele Sena <raff367@gmail.com>
That change mitigates the issue gio#150 and gio#166. The
iOS can only `focus()` as a response to touchstart/click
events. We can't `focus()` at random, without user interaction.
The `w.requestFocus` will try to focus on the next `touchstart`,
which may need some "double click" in some cases. That mitigates
the issue, but doesn't fixes completely, but open the keyboard. (:
I didn't notice any side-effect of that change on Android and on
Windows.
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
The context-menu seems useless. The only action available, on the
context-menu is to "Save image": which gives a black image.
I think it's better to remove it. The right-click still work and still
provide `pointer.Event`.
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
This reverts commit e84a2344cf.
The fix is wrong: it's supressing the release key.Event, not key.EditEvents.
The culprit is that Editor fails to ignore release events.
Updates gio#171
Edit events were being sent twice, once upon key press and again on key release for special keys such as Enter, Arrow keys etc, which resulted in duplicate inputs while pressing these keys. key.EditEvents for special keys now fire once on key press only.
Signed-off-by: Rajiv Kanchan <rajiivkanchan@gmail.com>
Implement key state for the following platforms:
js, wayland, windows, x11.
Unsupported platforms will continue to function as before, sending
key.Press for all key events.
Signed-off-by: Josiah Niedrauer <josiah@niedrauer.com>
First, don't filter on HWND in GetMessage and PeekMessage, lest
thread-specific messages may get lost. See
https://devblogs.microsoft.com/oldnewthing/20050209-00/?p=36493
Second, replace the dead status with the detection of WM_QUIT; it's
what it's there for.
May update gio#168
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Wayland doesn't guarantee the presence of server-side window decorations
(border, close/maximize/minimize buttons), and Gio doesn't have client-side
decorations either (issue #29). The issue is more than a year old, so it's time
to default to X11 to have a good out-of-the-box experience on unix systems.
Updates gio#29
Signed-off-by: Elias Naur <mail@eliasnaur.com>
32-bit property values are transferred with the C type "long", which
may be 64 bit.
Fixes "invalid atoms" errors from Firefox and Gedit.
While here, add additional clipboard formats to please Gedit.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
When modifier keys are active DispatchKey should not send a
key.EditEvent for the key that was pressed. For example when pressing
Ctrl+Alt+e DispatchEvent should not generate a key.EditEvent{Text:"e"}.
Signed-off-by: aarzilli <alessandro.arzilli@gmail.com>
On my setup:
Extended renderer info (GLX_MESA_query_renderer):
Vendor: Intel (0x8086)
Device: Mesa Intel(R) HD Graphics 530 (SKL GT2) (0x1912)
Version: 20.1.5
Accelerated: yes
Video memory: 3072MB
Unified memory: yes
Preferred profile: core (0x1)
Max core profile version: 4.6
Max compat profile version: 4.6
Max GLES1 profile version: 1.1
Max GLES[23] profile version: 3.2
eglCreateWindowSurface with the sRGB flag fails with EGL_BAD_MATCH.
Bumping the ALPHA_SIZE from 1 to 8 seems to make the driver happy
again.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
An event reporting the most recent Android View attached to the Window is both
simpler to implement and automatically tracks the Activity lifecycle.
The downside is that buggy programs may hold on to a stale references.
Fortunately, JNI references are handles not pointers so the always-on Android
JNI checks will very likely catch stale references on use.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Gio apps use a single Android View for the entire UI, rendering the platform
focus highlight unsuitable.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
A single EGL display may be shared among several contexts. Don't
eglTerminate a context display when destroying the context.
Updates gio#144
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Larry Clapp reported a panic from failing to start the display link.
Ignore the error and hope the error is transient.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Casting a *XClientMessageEvent or *XSelectionEvent to *XEvent is
technically incorrect because the union XEvent is the larger structure.
Use an XEvent variable as the backing storage for the specialized
event types instead.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This CL implements the app.Main function as a blocking-forever function
for JS, Wayland, Windows and X11.
This works better for applications that can now programmatically close
windows.
The Gio GioAppDelegate created the GioViewController programmatically.
When using gogio's -buildmode=archive users may want to use a different
method (for example storyboards) but there can only be one app delegate.
Move the GioAppDelegate to gogio's exe buildmode, and export the
GioViewController for embedding use.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
We'd like to remove GioAppDelegate when Gio is embedded with
gogio's -buildmode=archive. Minimize the code in GioAppDelegate.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Before this change, Android and iOS were special for two reasons:
app.Main would return immediately, and the program main was invoked from
a goroutine. We can reduce that to one special case by either
- run the program main from the main thread,
- or make app.Main block.
Choose to run main on the main thread.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The app.MinSize and app.MaxSize options restricts the window size:
w := app.NewWindow(
app.Size(unit.Dp(600), unit.Dp(596)),
app.MinSize(unit.Dp(600), unit.Dp(596)),
app.MaxSize(unit.Dp(600), unit.Dp(596)),
app.Title(APPNAME),
)
Signed-off-by: Jason <sourcehut@sweatyballs.es>
Recently support was added for multiple top-level windows. Add support
for closing those windows.
macOS only; all others stubbed out.
Signed-off-by: Larry Clapp <larry@theclapp.org>
An interface for scaling dp and sp is overkill, at least for all
current uses. Make it a concrete struct type, and rename it to the
shorter and more precise Metric.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
At least one Samsung S9 device ignores the sRGB setting if the context
wasn't created with alpha in its attributes.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Do is a function for accessing the underlying Android View in a safe
context, the main thread. Do is
- more general than RegisterFragment and may be expanded to other platforms
- simpler to implement (from the Gio side)
and as a bonus, the Do implementation avoids a race condition where
a call to RegisterFragment during an Activity re-create would be ignored.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The Activity context may not be available, so it's safer and simpler
to use the always available app context.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Then, make layout.Context.Now a field, copied from FrameEvent.Now.
API change:
gofmt -r 'gtx.Now() -> gtx.Now'
Signed-off-by: Elias Naur <mail@eliasnaur.com>