We're about to enable platform support for switching native
window decorations on and off. However, the Wayland platform
only supports server-side switching of decoration mode, not
(yet) client-side. Thus, don't switch mode even when asked to.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Before this change, client-side decorations for Wayland were drawn
before client content, which was prevented from drawing over
decorations with a clip. While visually correct, resize handles would't
work as long as client listeners are near the window edges to swallow
pointer input.
This change makes app.Window draw decorations last, fixing resizing
and saves a clipping operation. This is an alternative to the original
fix for #361, commit 20d4bc2.
References: https://todo.sr.ht/~eliasnaur/gio/361
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The xdg_toplevel expects the min/max window size in DP rather
than pixels. The scaling factor would be applied twice because
we supplied pixels that we scaled ourselves, resulting in windows
twice the expected size on HiDPI screens. This bug probably went
for so long without being detected because it only manifests if
you actually set a minimum or maximum size.
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
Not all wayland compositors advertise the global registry events
in the same order. In particular, river and sway differ in that
sway advertises the data_device_manager before the seat, and river
does it after. This commit updates our code to correctly bind
the data_device so that we can work with the clipboard regardless
of the registry event order.
Special thanks to Isaac Freund (river maintainer) for helping me
find the root of this problem. You can see Isaac's extremely helpful
and detailed analysis here:
https://github.com/riverwm/river/issues/554#issuecomment-1059750874
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
There are no public API that uses f32.Rectangle anymore. Move Rectangle
to an internal package for internal use.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The unit.Value is a struct and thus more inconvenient to use than its
underlying float32 type. In addition, most uses don't need a general
value, but rather a specific unit given by the context. This change
replaces unit.Value with two float32 units, Dp and Sp. It also changes
variables and parameters of unit.Value to a specific unit type matching
the context. That is, unit.Dp everywhere except for text sizes which are
in Sp.
Switching to typed float32s has multiple advantages
- They can be constants:
const touchSlop = unit.Dp(16)
- Casting untyped constants is no longer necessary:
insets := layout.UniformInset(16)
- Calculation with values is natural:
func (s ScrollbarStyle) Width() unit.Dp {
return s.Indicator.MinorWidth + s.Track.MinorPadding + s.Track.MinorPadding
}
The main API change is that calls to gtx.Px must be replaced with either
gtx.Dp or gtx.Sp depending on the unit.
Idea by Christophe Meessen.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
op.Offset is a convenience function most often used by layouts. Layouts
usually operate in integer coordinates, and the float32 version of op.Offset
needlessly force conversions from int to float32. This change makes op.Offset
take integer coordinates, to better match its intended use.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The OpenGL backend needs it, but I keep forgetting to test it when
rearranging the window rendering code. The gogio X11 end-to-end test
tests this issue, but unfortunately it is disabled because of flakiness.
Fixes: https://todo.sr.ht/~eliasnaur/gio/412
Signed-off-by: Elias Naur <mail@eliasnaur.com>
A recent change broke custom rendering by not allowing the client
to continue after calling FrameEvent.Frame. This change makes sure
the client is allowed to continue regardless of rendering mode.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Android doesn't distinguish between the arrow keys on a keyboard and the
directional keys on a remote control, so there's no way to move the caret
in an Editor with arrow keys. This change updates the Android port to map
Android's DPAD_* key codes to the arrow key names, fixing caret movement.
The change also updates Editor to only request arrow keys that actually move
the caret, to keep directional focus movement working.
Fixes: https://todo.sr.ht/~eliasnaur/gio/410
Signed-off-by: Mearaj <mearajbhagad@gmail.com>
Instead of cmpletely replacing the IME snippet for every update, expand
the old range if there is overlap. This change avoids never-ending
restarts of the IME on Android where snippets are expanded in two
calls, one for expanding before the selection and one for exanding after
the selection.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
It's much simpler to map the Android back button to a key.Event and
let the usual key filtering determine whether to block its default
behaviour.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This change adds key.NameUp/Down/Left/Right and maps the Android TV
remote directional keys to them. As a side-effect a key.InputOp can
now receive directional keys (and block their focus movement).
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Before this change, Tab and Shift-Tab would always result in focus
movement. This this change, a key.InputOp with a matching Keys set
will block focus movement and deliver the events to it.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
We should return as soon as possible from FrameEvent.Frame to allow the main
goroutine to continue processing other tasks. Whereas GPU.Frame may touch
the frame ops, GPU.Present will not, so this change moves Present to after
returning from FrameEvent.Frame.
This is a variant of 38ff78df5d that
works on OpenGL where context locking is required.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
We should return as soon as possible from FrameEvent.Frame to
allow the main goroutine to continue processing other tasks.
Whereas GPU.Frame may touch the frame ops, GPU.Present will not,
so this change moves Present to after returning from FrameEvent.Frame.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
List was recently changed to include an extra child at each end, to
automatically scroll when reaching the end of a focus direction. However,
if List includes unfocusable children that strategy may fail. This change
adds another fallback where app.Window will scroll a constant amount in
the focus direction, to reveal more children.
For https://github.com/tailscale/tailscale/issues/4278.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
A focused widget may be partially or completely off-screen in which case
the user will have difficulty interacting with it. This change attempts to
scroll the focused widget into view by issuing synthetic scroll events.
For https://github.com/tailscale/tailscale/issues/4278, but doesn't completely
solve it because layout.Lists won't layout focusable widgets outside its visible
bounds. A follow-up change deals with that.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This is a refactor to make it easier to add higher level logic to
focus moves. A follow-up will add automatic scrolling to bring
focused widgets into view.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
vkDeviceWaitIdle and vkQueueWaitIdle are expensive; a vkFence is cheaper
and the usual way to ensure a previous frame has completed before starting
another.
References: https://todo.sr.ht/~eliasnaur/gio/375
Signed-off-by: Elias Naur <mail@eliasnaur.com>
After 34f10d9cbb, the display link callback
will never block. However, if the main thread is blocked for another reason,
say a bug in the user program, callback requests will pile up as blocked
goroutines.
This change ensures that a redraw request is queued only if no other request
is pending.
References: https://todo.sr.ht/~eliasnaur/gio/370
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Previously, the window size is equal to the screen size. That doesn't
consider the size of the taskbar, causing the height be bigger than the
real height. Now, the maximized have the same behavior of windowed,
since both of them must include decorations and taskbar.
Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
GioView.onCreateView may call methods on the imm field of GioView.
Make sure it is initialized before use.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
The monitor may have a different backing store scale, yet the
system doesn't redraw automatically when that happens
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This reverts commit 11f39582b8 that
introduced pacing of display link callbacks. Blocking the display link
callback introduced deadlocks with code that updates the display link
display.
Not pacing the display link may introduce extra view invalidations,
but invalidates are consolidated by the system and won't result in
extra redraws.
Fixes: https://todo.sr.ht/~eliasnaur/gio/370
Signed-off-by: Elias Naur <mail@eliasnaur.com>
It's now possible to directly user pointer.Cursor to add to the ops.
pointer.CursorText.Add(gtx.Ops)
This is an API change. Use pointer.Cursor directly instead of CursorNameOp.
Signed-off-by: Egon Elbre <egonelbre@gmail.com>