Newsletter, February 2022
pointer.CursorNameOp renamed to pointer.Cursor

core gio

Elias implemented focus traversal for Gio interfaces this month. This enables users to navigate between focusable widgets (buttons, editors, etc) with actions like pressing tab. This single feature has a huge impact on the ease of using Gio for entering data into form fields and general keyboard navigation.

There were 47 commits to core since the last newsletter.

Breaking API changes by author:

Egon Elbre:

  • app,io/pointer: [API] remove CursorNameOp and rename CursorName -> Cursor. (cdb288d1)
  • io/pointer: [API] make cursor name into a byte. Add most of the common cursors defined by different systems. (4172566a)

Non-breaking changes by author:

Elias Naur:

  • cmd/gogio: bump Android target SDK to 31. (9b2bdf6c)
  • io/router: replace cursor stack with area field. (3e18a310)
  • io/router: always choose the topmost cursor among candidates. See #373 (99bb5429)
  • io/router: ensure root pointer area in deferred calls. See #372 (68544111)
  • .builds: upgrade Android builds tools and SDK. (2b0898fc)
  • app: replace C-to-Go handle maps with cgo.Handle. (c0c25b77)
  • app/internal/windows,app: [Windows] generalize windows.GetPointerLong. (95365d58)
  • app: [iOS] disable fallback decorations. Before this change, the iOS backend would not report decoration support at window creation. (b9e8a177)
  • all: replace unsafe slice operations with unsafe.Slice. (fea2f888)
  • go.*: upgrade to Go 1.17. (af8ca964)
  • .builds: upgrade to Go 1.17.7. (09309d33)
  • app: [Android] avoid a null pointer exception at initialization. GioView.onCreateView may call methods on the imm field of GioView. Make sure it is initialized before use. (b0838bf6)
  • app: [macOS] redraw when window moves to a different monitor. The monitor may have a different backing store scale, yet the system doesn’t redraw automatically when that happens (1fa9dd0f)
  • Revert “app: [macOS] pace display link”. This reverts commit 11f39582b84703c33d3aae4c1b703698a1bb4ea6 that introduced pacing of display link callbacks. Blocking the display link callback introduced deadlocks with code that updates the display link display. (34f10d9c)
  • widget: reset focused states when disabled. (79bfd3ad)
  • widget/material: add focus and hover indicators to Clickable. (50e35c9c)
  • app: ensure Window.Invalidate redraws after delivering events. Events such as system.CommandEvent may result in Invalidate being called. Ensure animation state is properly updated. (f711e7ea)
  • widget: treat enter and space as clicks on release, not press. (aaf457d6)
  • app,io/router: map Androids’ DPAD_CENTER to a click. Mapping it to key.NameReturn confuses widgets such as Editor that treats clicks separate from return key presses. (21431975)
  • internal/f32color: add support for light widgets to Hovered. (2bea9a37)
  • internal/f32color: extract color mixing into separate function. (b74c9f96)
  • io/router,app: add support for directional focus moves. Implement support for up/down/right/left directional focus moves and map Android directional pad keys to focus moves. (73eabb35)
  • io/router: move focus on tab and shift+tab. See #195 (2e9df04a)
  • widget,widget/material: make Clickable widgets focusable. This change adds focus and keyboard control to Clickable widgets. They now consider a press of the enter or return key equivalent to a click. To keep the change simple, the focus indication is the same as the hover indication. (cd2ade05)
  • app: [Android] map numpad enter to key.NameReturn. (eb48b459)
  • widget: only ask for software keyboard once per click. (8ff10a20)
  • app: [macOS] pass key events to system before handling them. This change solves an issue where an editor key press such as backspace would apply before the IME had a chance to process it. (7f90f04c)
  • app: [Wayland] always refresh frame pacing notification. Apparently, a Wayland server such as Sway and River may not issue a frame pacing callback created before a top level configure event. This change ensures the frame pacing callback is always refreshed when animating, regardless of the reason for the frame. (2e91edaf)
  • op/clip: don’t panic when stroking empty path. See #367 (773a7e48)
  • widget: remove pointer area padding from Editor. Pointer padding was introduced in bfece0bebacb5cec4fdf5682b886333e03b6549b. I don’t remember why, and its commit message doesn’t say. Regardless, adding padding outside a widget’s reported dimensions doesn’t seem like a good idea (see #365), and this change removes it. (bed59024)
  • widget: replace segmentIterator with simpler functions. (41489fb7)
  • widget: extract seeking logic from Editor.closestPosition. We’d like to re-use the Editor.closestPosition seeking for segmentIterator.Next; this change extracts the state-less logic into functions. (b7341672)
  • widget: fix moveLines residual x offset calculation. (2df3db36)
  • io/key: update stale comment. (845d35dd)

Egon Elbre:

  • app: [macos] add missing cursors. (e9e00994)
  • app: [windows] add missing cursors. (b7a42da3)

Lucas Rodrigues:

  • app: [windows] fix maximized window size. Previously, the window size was equal to the screen size. That doesn’t consider the size of the taskbar, causing the height to be bigger than the real height. Now, the maximized state has the same behavior as windowed, since both of them must include decorations and taskbar. (b82427d4)
  • io/pointer: rename cursors to match the JavaScript DOM. (730e0463)
  • internal/gl: [js] replace Call to Bind/Invoke. Before that patch, the Call function was used to call each JS function related to WebGL. The Call function contains strings, which is slow on most browsers. Now, it uses Bind on the initialization and re-use the same function, avoiding the usage of strings. (182e7010)

Chris Waldon:

  • widget: test caret coordinates. This commit adds a check that caret coordinates never exceed the max constraints of the editor. (9b692339)
  • widget: fix Editor.CaretCoords when scrolled. This commit fixes the position returned by Editor.CaretCoords to account for the scroll position of the editor. Without this change, the returned coordinates can easily overflow the boundaries of the editor widget when it has been scrolled on either axis. (a401d7aa)
  • widget: fix editor’s io.Seeker implementation. For some reason, widget.Editor had a Seek method that ignored the supplied offset and always seeked to offset zero. This made it impossible to use it like any other io.Seeker. This commit simply honors the requested offset. (a7afa4d6)

Pierre Curto:

  • app: remove defer op in window decorate. See #361 (20d4bc21)
  • widget: adjust Draggable.Pos to be relative. When dragging objects around an area, it is easier to reason with the relative movement of the dragged item. (42ea56ac)

Aman Karmani: - app: [Android] handle DPAD_CENTER keycode. (27762fdd)

gio-x

There have been 4 commits to gio-x since the last newsletter.

Non-breaking changes:

Chris Waldon:

  • component: defer modal layout. This commit alters the ModalStyle to defer laying out the scrim and modal widget. This was always the intended behavior, and I’m frankly unsure why I didn’t do it before. I guess I always laid out the modal layer last, and therefore didn’t notice. (729e3a0)
  • explorer: allow no extensions on linux. This commit fixes a bug in the linux backend that would fail to present a file selector if no extensions were provided as a parameter. (d5cf750)
  • component: expand ContextArea’s positioning options. This commit allows users to position a ContextArea’s contextual widget at a fixed location instead of at the location of the triggering pointer interaction. It also allows users to provide a hint to the ContextArea about where it is positioned within a larger layout, enabling the ContextArea to avoid positioning its contextual widget off-screen. (22cb65b)

Egon Elbre:

  • component,richtext: update pointer.Cursor usages. (8b9099e)

gio-example

A couple of small changes went into the examples repository this month:

Elias Naur:

  • opengl: render on app thread, not window event loop thread. Binding a GPU context to a window surface must happen on the event thread, but rendering doesn’t. (e49702a)

Egon Elbre:

  • mod: bump gioui.org and gioui.org/x. (e051ef6)

gioui.org

Last month, I accidentally failed to include updates to our website in the newsletter, so here I’ll detail changes to the site since the start of the year. At a high level, Egon has been hard at work modernizing the website layout, and I’ve been updating inaccurate documentation as I find it.

Egon Elbre:

  • content/doc/architecture: use ops.Reset instead of recreating. (57881f1)
  • go.mod: bump gioui dependencies. (6556fa2)
  • content/architecture/drawing: add info about clip.Stroke. (7e2a7b1)
  • content: fix toc on home. (1a0d2c6)
  • content/showcase: add example applications. This adds a showcase section for the site. There are other modifications to support this. (a4bf3c3)
  • style: dark-mode. (5da0fe5)
  • style: add repeating bg to examples. (2bb2345)
  • content/home: simplify the content. (ea6d728)
  • files/sponsors: remove 2x size. (1ece1b5)
  • content/doc/faq: add closure information. (3c4839b)
  • content/doc/contribute: organize information. (4d9cbcc)
  • content/doc/community: page for finding help. (f3ae1d6)
  • content: use triple-quote for code. Triple-quote makes it more consistent and easier to manage. Additionally add annotations for the languages. (838ca06)
  • template: use more common triangle. (3ded86f)

Chris Waldon:

  • content/doc/architecture: remove obsolete text about Add. The content referred to clip.Op.Add, which is removed in favor of Push/Pop. (308259a)
  • include/files/architecture: balance ops in helpers. This commit balances the push/pop of clip and offset operations in the helper functions for the drawing examples. This prevents a panic when the unbalanced operations are used in a macro. (8b0179a)
  • content: add note about Java 1.8 to Android docs. Added a note to the Android docs about having OpenJDK 1.8 installed, as gogio cannot build APKs with more recent versions of Java. (1262ca4)
  • content: fix Android SDK variable name. This commit updates the Android install documentation to refer to ANDROID_SDK_ROOT instead of the obsolete ANDROID_HOME. Thanks to ~u542620 for pointing this out! (c16d2f8)

Elias Naur:

  • content/doc: fix issue linking format examples. (191f2e7)

go-text

I’m still hard at work revising the patches that I posted last month. Elias has considerably simplified the editor in response to seeing the sprawling mess I wrote to integrate with it, and I think the result is a considerably cleaner codebase all around. I’m sorry that these changes are taking so long, but very happy with the clarity and quality of the new code.