Commit Graph

2606 Commits

Author SHA1 Message Date
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
Elias Naur 8457df2d1f app: [macOS] add support for undecorated windows
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-24 20:56:16 +02:00
Elias Naur 8a9382940a widget/material: make DecorationsStyle method receivers by-value
Style values are ephemeral, and pointer methods can't be called in
the same expression a style value is constructed. Matches other style
types.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-24 19:56:56 +02:00
Elias Naur 6a5d3f996a app: don't draw fallback decorations for undecorated windows.
Until now, fallback decorations were only needed for Wayland client-side
decorations. We're about to support app.Decorated(false) one some platforms,
where Window should not fall back to drawing its own decorations.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-23 21:10:57 +02:00
Elias Naur 9f91fecdb3 app: [Wayland] don't allow changes to decoration mode
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>
2022-06-23 20:33:20 +02:00
Elias Naur 3ca4c98596 gpu/headless: tweak test to pass on MacBook Pro M1
Apparently, there is a rounding error somewhere in the pipeline
from clearing a FBO to downloading its contents on at least one Apple
M1 machine. Tweak the test colors a bit to make it pass.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-23 19:14:53 +02:00
Elias Naur 371de3462b app: replace driver.Close with Perform(ActionClose)
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-23 19:04:30 +02:00
Elias Naur 43116400d0 app: fix racing app.Window.Perform and app.Window.Option
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-23 17:58:45 +02:00
Elias Naur e31aa35622 app: draw fallback decorations on top
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>
2022-06-23 13:41:34 +02:00
Chris Waldon 6a6ddc3f19 app: [Wayland] scale min/max window size correctly
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>
2022-06-23 10:10:22 +02:00
Chris Waldon 55c96adb91 app: [Wayland] handle multiple global registry event orders
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>
2022-06-23 10:10:11 +02:00
Egon Elbre 72669e19bc unit: add Metric.DpToSp and Metric.SpToDp
It's sometimes necessary to specify padding or spacing based on
the text size.

Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2022-06-15 11:30:12 +02:00
Elias Naur bf6371c8e9 app: restore IME snippet after an EditorReplace
Commit 0273203743 removed the snippet
restore event, which broke IME on macOS and Windows.

Fixes: https://todo.sr.ht/~eliasnaur/gio/424
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-15 11:30:12 +02:00
Elias Naur 5ff316ed6d gpu: re-align coverUniforms struct
Direct3D requires GPU vertex attribute structs sizes be a multiple
16. A cleanup commit removed an unusued field, and broke that
assumption.

Fixes: https://todo.sr.ht/~eliasnaur/gio/422
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2022-06-15 11:30:05 +02:00