Commit Graph

2619 Commits

Author SHA1 Message Date
Elias Naur 53da73de35 widget: ensure that Border.Layout dimensions fully contains the border
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-07-10 14:59:50 +02:00
Elias Naur 162250392b layout: respect minimum constraint size in Flex.Layout
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-07-08 09:18:13 +02:00
Egon Elbre b4acc239cd widget: fix Enum with Return
The input op started listening to Return, however the check
was looking for Enter.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2022-07-07 09:36:43 +02:00
Egon Elbre 0777afb85f gpu: avoid bounds checks in decode
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2022-07-07 09:36:26 +02:00
Elias Naur 0057e871d0 io/router: search all key handlers when there is no focus
Fixes: https://todo.sr.ht/~eliasnaur/gio/434
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-07-02 20:51:26 +02:00
Egon Elbre 6bf5d4dc2d gpu: optimize resourceCache
By keeping all the information in a single map, we avoid multiple
lookups and can switch between frames more easily.

Before ~35us, after ~20us for adding 50 new+old and switching
the frame.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2022-07-02 20:12:41 +02:00
Egon Elbre f8f68a4e9f internal/ops: optimize Decode
Using clean struct creation creates a lot of temporary variables in
assembly. Inline the assignments, which generates less code.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2022-07-02 20:12:41 +02:00
Egon Elbre 17f604fb50 internal/ops: use single table for OpType
Size and NumRefs are always used together, so consolidate info to
a single table to avoid two separate lookups.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2022-07-02 20:12:35 +02:00
Egon Elbre e7dd180447 internal/ops: avoid some bounds checks in decode
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2022-07-02 20:11:16 +02:00
Egon Elbre f8efc9c2a6 internal/ops: use lookup table for NumRefs
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2022-07-02 20:11:16 +02:00
Egon Elbre d3d2c51717 internal/ops: avoid bounds check in OpType.Size()
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2022-07-02 20:06:44 +02:00
Egon Elbre 9de13e37e9 f32: add Affine2D.Split
splitTransform func was creating multiple copies of f32.Affine2D
due to not having access to the internal and passing around non-pointer.

This makes splitTransform from ~8ns to .Split ~2ns.

It seems that the non-pointer receiver was ~0.6ns slower in this case.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2022-07-02 07:04:47 +02:00
Egon Elbre 3670f70c01 internal/f32color: optimize LinearFromSRGB
Previously each call was ~100ns, the new implementation is ~1ns.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2022-07-02 06:57:54 +02:00
Elias Naur 2adf4efcbd app: [Wayland] shrink reize gesture area
As reported by Chris Waldon, the resize area is big enough to make
it hard or impossible to grab and drag any scroll bars.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-07-01 11:16:28 +02:00
Elias Naur 2957d007a2 app: [Wayland] only start resize gesture on pointer down
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-07-01 11:15:19 +02:00
Elias Naur cab1184818 app: [Wayland] don't process resize gestures when decorated
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-07-01 08:02:23 +02:00
Chris Waldon a5f8aa35e1 app: [Wayland] scale pointer hotspot coordinates
This commit updates the way that we change cursors so that the
hotspot of the cursor is properly set to surface-local coordinates.
The previous raw hotspot coordinates are relative to the cursor
image buffer data, and do not take the buffer's scaling factor
into account.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2022-07-01 07:55:37 +02:00
Dominik Honnef 992f568ac7 widget: when clicking on scrollbar, center on that point
Previously, we'd scroll so the new viewportStart corresponded to the
clicked position. This felt okay if clicking above the current
indicator, but felt jarring when clicking below it. Centering gives a
consistent behavior regardless of the scroll direction.

Signed-off-by: Dominik Honnef <dominik@honnef.co>
2022-06-30 08:01:49 +02:00
Dominik Honnef 6981a88720 widget: move scrollbar indicator if dragging starts outside of it
Signed-off-by: Dominik Honnef <dominik@honnef.co>
2022-06-30 08:01:49 +02:00
Dominik Honnef f229601e2d widget: consider size of indicator when limiting scrollbar dragging
Signed-off-by: Dominik Honnef <dominik@honnef.co>
2022-06-30 08:01:49 +02:00
Dominik Honnef aea376fbaf widget: clicking on the scrollbar indicator shouldn't jump
Signed-off-by: Dominik Honnef <dominik@honnef.co>
2022-06-30 08:01:49 +02:00
Dominik Honnef 8f990a6fdc widget: correctly set s.dragging to false when releasing drag
Before, we would set s.dragging to false on pointer.Release and then
immediately set it back to true because we were processing the event and
saw that s.dragging was false.

Signed-off-by: Dominik Honnef <dominik@honnef.co>
2022-06-30 08:01:49 +02:00
Dominik Honnef ea37124686 widget: constrain drag offset to [0, 1]
Once the user begins dragging, the cursor can move outside the clip
area (or even the window on at least X11), leading to events with
positions that are either negative, or larger than the clip area.

Negative values outright break the delta tracking and cause the
scrollbar to misbehave. Positive values "only" break the invariant of
Scrollbar.ScrollDistance that the returned value is in the range [-1, 1].

Signed-off-by: Dominik Honnef <dominik@honnef.co>
2022-06-30 08:01:49 +02:00
Elias Naur d8766f6d2d app: [macOS] fix Intel build
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-29 22:25:11 +02:00
Elias Naur fa3978e18e app: [macOS] use NSWindow.zoom for Maximized
NSWindow.zoom is what the native window control calls when maximizing.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-29 07:47:45 +02:00
Elias Naur 78d1eab950 app: call driver Perform and Configure after idling
Before this change, Perform and Configure could be called during the
event processing where additional events would be queued. However,
a Maximize animation on macOS works by repeatedly sending draw
requests, and they must not be postponed.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-29 07:35:33 +02:00
Dominik Honnef e21c665e70 text: optimize faceCache.hashGIDs
Use binary.LittleEndian directly instead of going through the
binary.Write indirection. This allows the following optimizations to
occur:

  - We can reuse our own byte slice between iterations
  - We don't have to put g.ID in an interface value
  - h doesn't escape
  - PutUint32 gets inlined

On top of that, the argument to maphash.Hash.Write doesn't escape, so b
doesn't move to the heap.

Signed-off-by: Dominik Honnef <dominik@honnef.co>
2022-06-28 18:33:31 +02:00
Elias Naur 4d593927ae app: [Windows] fix window state update after window restore
This patch ensures a correct transition from Minimized to Windowed.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-28 18:32:45 +02:00
Elias Naur 5dc8e0e39d app: [Windows] always send ConfigEvent after Configure
This case was missed in 69e4a3cff3.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-28 18:32:45 +02:00
btop 29f4a1d07b app: fix iOS build
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-28 18:32:33 +02:00
Elias Naur b82b9b258a layout: truncate negative List.Position.First positions to 0
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-27 16:58:32 +02:00
Elias Naur dab796808a internal/gl: avoid excessive Cgo pointer checks
As suggested by Egon Elbre, passing a large struct of function pointers
forces Cgo checks on all of the pointer on every Cgo call. This
change instead passes only the relevant function pointer.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-27 11:08:19 +02:00
Elias Naur fa538f219f app: remove ackEvent, tighten error check
ackEvent is not necessary, a nil event.Event doesn't allocate.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-26 10:14:02 +02:00
Elias Naur 546d971e49 app: [Wayland] ensure monitor scale changes propagate to active windows
This broke during an earlier refactor.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-26 09:18:02 +02:00
Chris Waldon 9151009b2a app: [Wayland] respect XCURSOR_* environment variables
This commit adds support for the commonly-used XCURSOR_THEME and
XCURSOR_SIZE environment variables. Wayland lacks a protocol-level
way to standardize cursor size right now, but these variables are
used consistently by many applications and compositors. Many users
(including me) will find that their environment is already configuring
these for them, and will get consistent cursor sizing for free.

I explored a lot of ways to tackle this, but it looks like nobody has
ever gotten around to implementing the cursor theme protocol discussed
here:

https://wayland-devel.freedesktop.narkive.com/VuMSOO55/possible-wayland-extension-to-publish-mouse-pointer-size

Given that it doesn't seem to be resolved anytime soon, supporting a
widely-used convention to tweak these things seems reasonable to me.

I say that it fixes issue 382 because it enables the user to make
Gio's cursor size match the rest of their system.

Fixes: https://todo.sr.ht/~eliasnaur/gio/382
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2022-06-26 09:13:43 +02:00
Chris Waldon 414a91c49e app: [Wayland] use HiDPI cursor on HiDPI screen
This commit scales both the loaded cursor theme and the cursor
surface appropriately so that the cursor image is not blurry on
HiDPI screens.

References: https://todo.sr.ht/~eliasnaur/gio/382
Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
2022-06-26 09:13:43 +02:00
Elias Naur 3f38e67ce0 io/system: add ActionInputOp to register window move gesture areas
The app.Window.Perform(ActionMove) is the wrong abstraction for
initiating a move gesture: Windows needs to know the move gesture
area at pointer move, and macOS needs to know the pointer button
down event that triggers the move gesture. This change replaces
Perform(ActionMove) with a new system.ActionInputOp that marks an
area movable.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 19:40:46 +02:00
Elias Naur b53cdfef8d io/system: remove resize actions
Allowing clients to initiate resize gestures is a waste: macOS
doesn't support them, and the only reason we added them was to
implement client-side decorations for Wayland. Now all desktop
platforms implement resize gestures as needed, and we no longer
need the system.Action actions.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur b34dc63531 app: [Wayland] hard-code border resize gestures
We're about to remove the system.Action machinery for initiating resize
gestures. This is the Wayland implementation that hard-codes the border
drag gesture for resizing.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur fd3a3eb1b9 app: [Windows] support resize gestures for undecorated windows
We're about to remove the client-controlled system.Action machinery
for resize gestures initiated by the client. This is the replacement
implementation for Windows, where the behaviour is hard-coded to
mimic the decorated automatic handling.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur 45443a2c3a app: [Windows] don't recompute window size during fullscreen switch
The redraw machinery takes care of it automatically.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur 5bdf5950b2 app: [Windows] support app.Decorated(false)
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur 2973c7fa5a app: [Windows] consolidate window mode switch branches
This change is a refactor to make undecorated window support easier
to implement.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur 5e7bf1716e app: [Windows] don't re-compute window size when maximizing
The redraw machinery will take care of it like any other resize.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur 8ef0ad43cb app: [Windows] share extended window styles across Win32 calls
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur df43ba8be0 app: [Windows] don't add or remove the WS_MAXIMIZE flag
ShowWindow(SW_SHOWMAXIMIZED/SW_SHOWNORMAL) is what changes the
window size and state.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur 5cf657065e app: [Windows] use SWP_NOZORDER instead of SWP_NOOWNERZORDER
As I read the SetWindowPos documentation, SWP_NOZORDER is the correct
flag for keeping the z-order of the window.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur 59480066b4 app: [Windows] don't assume fullscreen when not WS_OVERLAPPEDWINDOW
We're about to remove the WS_OVERLAPPEDWINDOW style for undecorated
windows, in which case the fullscreen assumption will no longer hold.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:32 +02:00
Elias Naur 69e4a3cff3 app: guarantee a ConfigEvent for every Window.Configure call
Not only is the client guaranteed a ConfigEvent, but app.Window
can assume that an unsupported decoration change will be corrected
(by a ConfigEvent with Decorated forced to the supported value).

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-25 18:41:22 +02:00
Elias Naur c5e07ba01f app: [macOS] add support for ActionMove
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-24 21:41:56 +02:00