Commit Graph

2322 Commits

Author SHA1 Message Date
Elias Naur aadb6609ec internal/vk: [Android] add workaround for Vulkan on the emulator
According to the Vulkan specification the pApplicationInfo member of
the VkInstanceCreateInfo structure may be NULL. However, the Android
emulator crashes on vkEnumeratePhysicalDevices if set to NULL.
This change adds a minimal info to please the emulator.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-08 17:20:35 +01:00
Elias Naur c3bbff4cf9 app: remove duplicate error check
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-08 16:44:36 +01:00
Elias Naur 454e75dd14 app: don't process Window state updates before client is ready for events
On Android, a call to update soft keyboard state may result in focus events.
Before this change, the client would still be blocked in FrameEvent.Frame,
resulting in a deadlock.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-08 16:24:08 +01:00
Elias Naur 86330faca6 gpu/internal/opengl: restore Android emulator OpenGL workaround
For some reason, the Android emulator OpenGL implementation needs the output
framebuffer current when eglSwapBuffers is called; otherwise sRGB emulation
breaks. We used to restore the default FBO explicitly, 9b5e9ae607
restored it implicitly through automatic state restoring, but 30ecf75a0f
broke that by only saving and restoring shared context state. This change
restores the explicit behaviour for non-shared contexts.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-08 14:50:14 +01:00
Elias Naur 11f39582b8 app: [macOS] pace display link
On macOS the display link that drives redraws runs on a separate thread, and
must switch to the main thread to invalidate its view. This change makes sure
the display link can never call invalidate faster than we can draw.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-07 18:16:40 +01:00
Elias Naur 11aec807b2 app: deliver one event at a time to client
If the client calls, say, Window.Configure during a frame which in turn results
in a ConfigEvent, the program deadlocks. This change implements a queue of
events to be delivered after processing another.

Fixes: https://todo.sr.ht/~eliasnaur/gio/337
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-07 18:09:18 +01:00
Pierre Curto 4c6d98879e widget: add Draggable.Pos
When the position of the cursor is required while dragging
a widget around, the pointer's cannot be tracked as the drag
grabs the event priority. Therefore, this patch exposes
the drag's current position.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2022-01-07 17:11:43 +01:00
Elias Naur 8d8aeef66b app,gpu,internal/egl: lock OS thread when making OpenGL context current
OpenGL stores the current context in thread-local memory, but commit
4f5baa9a51 removed a runtime.LockOSThread from app.Window that ensured
the goroutine that drives the context stays on the operating thread that
has the context current. This change restores the thread lock.

As a bonus, this change makes the OpenGL contexts responsible for locking
the thread at MakeCurrent, thereby removing LockOSThread calls from GPU
backend-agnostic code.

Fixes: https://todo.sr.ht/~eliasnaur/gio/334
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-05 11:49:29 +01:00
Elias Naur 7751d73740 app: [Wayland] don't change cursor when there is no pointer
Fixes: https://todo.sr.ht/~eliasnaur/gio/333
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-04 18:24:05 +01:00
Elias Naur 5860fbbe8e io/key: remove "Mod" prefix from Modifiers.String names, concatenate by "+"
"Mod" is implied by the type, and "+" is the natural concatenation character
for displaying shortcuts.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-04 17:46:14 +01:00
Chris Waldon 99e3481419 cmd/gogio: allow missing tool version components
This commit changes the way that gogio searches for build tools
so that it correctly identifies versions like '31' as equivalent
to '31.0.0'. The Android SDK appears to not provide version
components in the path name when the component is zero.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2022-01-04 17:42:10 +01:00
Fabien Jansem 9b7ec167bc delete unicode chars with length > 1 correctly
When there were non ASCII characters (for exemple éèàçîï) in a deleted
selection or word, more characters were deleted because there was a
mismatch between runes and bytes in Delete and deleteWord

Fixes: https://todo.sr.ht/~eliasnaur/gio/330
Signed-off-by: Fabien Jansem <fabien@jansem.eu.org>
2022-01-04 17:37:00 +01:00
Inkeliz ac3bbc72ac cmd/gogio: add -minsdk to iOS
Before that patch the minimum iOS version was hardcoded. That patch makes possible
to change the minimum iOS version using `-minsdk`.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2022-01-04 17:35:48 +01:00
Andy Balholm 6d9db2b13c internal/stroke: properly calculate maxDist
The calculated value for maxDist (the maximum allowable error when
converting cubic Beziers to quadratics) was way too small when the
first control point was very close to the starting point of the segment.

(f32.Rectangle.Add does not expand the rectangle to include the new point;
it moves the rectangle by the point's X and Y coordinates.)

Splitting the curve into such small pieces was resulting in very ugly
output.

Fixes: https://todo.sr.ht/~eliasnaur/gio/331
Signed-off-by: Andy Balholm <andy@balholm.com>
2022-01-04 17:28:37 +01:00
Elias Naur 4f5baa9a51 app: let drivers control Window directly
Before this change, Window driver callbacks would all go through
channels to be processed by Window.run. However, Window.run may call
into the driver, which again may invoke a Window callback. These
re-entrant calls have been a source of deadlocks and subtle errors,
resulting in increasingly complex channel logic. This change eliminates
the goroutine split between Window and the driver, allowing callbacks
between Window and the driver without restrictions.

The goroutine split between Window and the driver is historical and
was meant to tame the complicated callback logic of drivers into a nice
for-select loop. However, the complexity isn't worth the gain, and there is
no concurrency concerns because there is always a 1:1 correspondance between
a driver goroutine and its Window object.

Fixes: https://todo.sr.ht/~eliasnaur/gio/329
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-04 17:01:05 +01:00
Elias Naur 72b2f2c1bf app: ensure SetDriver is called before sending events
This used to not matter, but a follow-up change will require a valid
driver to process events.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-04 15:48:01 +01:00
Elias Naur 787295a6e8 app: fix typo
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-01-03 16:23:37 +01:00
Elias Naur cce0a121e1 io/router: don't panic if AppendSemantics is called without a frame
Fixes: https://todo.sr.ht/~eliasnaur/gio/328
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-30 10:23:23 +01:00
Inkeliz 6913c856a2 app: [android] fix vulkan crash when activity/surface is recreated
On Android it's possible that the Activity/View must be restore. But,
before that patch, an new VkSurfaceKHR is created but never used and
that may lead to crash, in an attempt to destroy/use one invalid
surface.

Fixes: https://todo.sr.ht/~eliasnaur/gio/327
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-12-30 09:50:11 +01:00
Pierre Curto 3a20330d82 app: detect fullscreen mode for macOS and Windows
When an application goes into or out of fullscreen mode,
Gio now emits a ConfigEvent with the current window mode.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-26 10:20:54 +01:00
Pierre Curto 11bb86166a op/clip: automatically close Path in Outlines
Unclosed path segments in Path will be automatically
closed by a line.

Fixes: https://todo.sr.ht/~eliasnaur/gio/320
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-21 10:13:20 +01:00
Pierre Curto 0117de71d3 app: add String method to WindowMode and Orientation
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-21 10:09:45 +01:00
Elias Naur 6534639276 io/pointer,op/clip: remove clip.Circle, pointer.Rect, pointer.Ellipse
They've been deprecated for a while, and gio-x is updated to not use
them.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-20 16:23:16 +01:00
Elias Naur 170d24bdcd widget/material: replace deprecated clip.Circle with clip.Ellipse
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-20 16:22:39 +01:00
Elias Naur 533f85cf8e gpu/internal/vulkan: don't destroy nil vkDescriptorPool
Most drivers seem to tolerate vkDestroyDescriptorPool with a nil
pool, but NVIDIA's (rightly) doesn't. Fix that.

References: https://todo.sr.ht/~eliasnaur/gio/323
References: https://todo.sr.ht/~eliasnaur/gio/314
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-19 14:19:37 +01:00
Christophe Meessen a34e239c04 text,widget,opentype: change text.Face.Shape to return a clip.PathSpec
With this change, the Shape function returns a clip.PathSpec
instead of a clip.Outline op. It is then possible to create
a clip.Outline or clip.Stroke op to fill the text path or
draw its stroke.

Signed-off-by: Christophe Meessen <meessen@cppm.in2p3.fr>
2021-12-19 13:30:45 +01:00
Pierre Curto 3db11cbaad io/router: make transfer targets hovering easier to detect
In commit 929e4dc12, the rules to send pointer.{Enter,Leave}
events were relaxed. Unfortunately, to be able to make use
of them was not straight forward as it required the transfer
target op to use the same handle as the hover one.
This patch eases this by allowing any handle for the target
as well as not requiring the hover op to be defined on the same
clip op as the target (then requiring a PassOp though), making
it much easier to use.

Also added a test for pointer.Enter events not being generated
if the target type does not match the source one.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-19 13:22:11 +01:00
Pierre Curto af63c089f6 gpu/headless: make Screenshot take an input image to tranfer into
When extracting headless.Window's content via screenshots,
it can be useful to keep reusing the same image for output,
as well as specify which area of the Window is to be
extracted.
The updated Screenshot method does this by using the supplied
image.

API change: users must pass an existing image to Window.Screenshot.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-15 16:05:19 +01:00
Elias Naur 0c7b0b1d0b gpu,gpu/headless: plug a resource leak when taking screenshots
Ever since commit 8ff654628, the headless implementation has used two
GPU backend (not renderer) instances, one for the renderer and one for
creating the offscreen texture to render into. This arrangment leaks
resources because the backends only clear temporary storage at
BeginFrame, which is not called when reading pixel data from renders.

This change adds an internal constructor, gpu.NewWithDevice, to allow
headless.Window to share its device with the renderer, fixing the leak.
It also makes the code simpler (took me a while to debug this issue); in
fact I'm surprised it even works.

This is not a great fix: it adds an exported yet internal constructor,
and the ownership transfer of the device is surprising enough to warrant
two comments.

Fixes gio#322

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-14 20:53:00 +01:00
Jeff Williams f5c9d2725c app: X11 clipboard: write to primary selection
This change is to augment the X11 clipboard write behaviour.
When writing to the clipboard both the primary and clipboard
selections are published so that non-GIO applications that read
the primary selection (i.e. such as terminal emulators using
middle-mouse clicks) can read the data from a GIO app.

Signed-off-by: Jeff Williams <kanobe@gmail.com>
2021-12-14 11:49:07 +01:00
Pierre Curto 929e4dc120 io/router: deliver enter/leave events to transfer participants
When a drag and drop gesture is ongoing, let the potential target
handlers receive enter/leave events so that they can react to them (e.g.
highlight themselves when the dragged item is over them).

Fixes #321.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-14 11:43:23 +01:00
Pierre Curto c8ca36b1e6 gesture: add comment to Scroll.Add
Provide a reference to the documentation of io/pointer.InputOp.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-14 10:53:51 +01:00
Pierre Curto 294ecfbe9d io/router: avoid extra work when dealing with EnterLeave events
When computing the set of Enter/Leave events to be
delivered to handlers, skip non mouse pointers
right away instead of processing hit events.

Also, remove use of pointer to slice use in opHit.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-10 06:25:48 +01:00
Pierre Curto 038ec2cc3f widget: fix handling of disabled context in Draggable
While here, add an example on how to use the Draggable
widget.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-10 06:25:43 +01:00
Pierre Curto 27e38154a0 io/transfer: fix package description formatting
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-10 06:25:35 +01:00
Inkeliz 2a32ece084 app: [iOS] replace ViewEvent.View with add ViewController field
For mixing native UI with Gio UI, the UIViewController is sometimes
needed, not just the UIView. This change replace the View field of
ViewEvent with ViewController.

Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
2021-12-10 06:16:26 +01:00
Pierre Curto 03016f0c69 widget: add drag and drop support
This patch adds internal Drag and Drop support to app.Windows.

The new package io/transfer adds the ability to
define draggable and droppable targets, which
are leveraged by the new widget.Draggable type.

The API is generic and could handle future use
cases, such as external Drag and Drop.

Updates gio#153

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-07 12:45:53 +01:00
Pierre Curto 2d75181b51 layout: fix dimensions of empty list
When the Min constraints are set but the list
has no item to display, use those as the list
returned dimensions.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-07 12:18:28 +01:00
Pierre Curto 872b4ba41b op/clip: fix Path open state
If a Move/MoveTo did not move the pen, the Path
was still set as open.

Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2021-12-02 11:50:01 +01:00
Elias Naur e6e69812af app: expose semantic information to Android platforms
Previous changes added semantic API and semantic information to Gio
widgets. This change maps the information to Android accessibility
classes so that TalkBack can traverse and interact with Gio programs.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:57:04 +01:00
Elias Naur 6b1ca4ca7e widget: add semantic descriptions
Some semantic information is automatically extracted, but some must be
provided by UI components. This change enriches the generic and material
widgets with such information.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:57:04 +01:00
Elias Naur 8a90074d04 io/semantic: add package for adding semantic descriptions to UI components
Software such as screen readers require semantic descriptions of user
interfaces to effectively present and interact with them. Package
semantic, combined with the existing package clip provide the operations
for Gio programs to describe themselves.

This change implements the semantic package and the routing changes for
accessing semantic trees; follow-ups add semantic information to widgets
and implement mapping semantic tree to platform representations.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:23:54 +01:00
Elias Naur 48a96305c8 io/router: move transform state tracking from pointerCollector to Router
We're going to need transform tracking for the upcoming meta ops.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:23:54 +01:00
Elias Naur 529baed88b widget/material: [API] add description argument to Switch constructor
Switch needs a semantic description, but doesn't have a text label
attached. This change adds a description argument to the constructor.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:23:54 +01:00
Elias Naur 763fca1f29 widget/material: [API] add description argument to IconButton
Icons have no inherent semantic meaning such as a label, so this change
adds another argument to the IconButton constructor for the client to
provide a description.

This is an API change, because it seems best to force every client to
provide semantic descriptions for icon buttons.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:23:54 +01:00
Elias Naur d82be97a71 widget: [API] add content widget parameter to Enum.Layout
To make the semantic relation between the enum widget and its content,
the content must be laid out inside the enum clip rect.

This is an API change. Users of Enum.Layout must provide a content
widget.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:23:54 +01:00
Elias Naur ac97b9d6e1 widget: [API] add content widget argument to Editor.Layout
To make the semantic relation between the editor and its content clear,
the editor clip operation must cover the content. This change adds an
explicit widget argument to editor, and lays it out inside the clip
rect.

This is an API change. Users of Editor.Layout must provide a content
widget.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:23:54 +01:00
Elias Naur 665e23693f widget: [API] add child widget argument to Clickable.Layout
To make the semantic relation between the clickable area and its
content clear, it will be important for the clickable clip operation
to cover all of the clickable content.

API change: users of widget.Clickable must now pass the clickable
content to Layout.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:23:54 +01:00
Elias Naur a894bd6c9c widget: add missing license headers
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-12-01 17:23:54 +01:00
Elias Naur e5c040be1b widget/material: fix click area offset for Switch
The click area was mistakenly offset by half the track width, but it
really should be offset by half the thumb diameter.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2021-11-30 14:34:15 +01:00