Commit graph

74 commits

Author SHA1 Message Date
Daniel Eklöf
79182ac287
pgo: add fdm_del_no_close() 2025-05-08 10:35:37 +02:00
Daniel Eklöf
e5a0755451
config: tweak.surface-bit-depth now defaults to 'auto'
When set to 'auto', use 10-bit surfaces if gamma-correct blending is
enabled, and 8-bit surfaces otherwise.

Note that we may still fallback to 8-bit surfaces (without disabling
gamma-correct blending) if the compositor does not support 10-bit
surfaces.

Closes #2082
2025-05-01 08:54:30 +02:00
Daniel Eklöf
ccf625b991
render: gamma-correct blending
This implements gamma-correct blending, which mainly affects font
rendering.

The implementation requires compile-time availability of the new
color-management protocol (available in wayland-protocols >= 1.41),
and run-time support for the same in the compositor (specifically, the
EXT_LINEAR TF function and sRGB primaries).

How it works: all colors are decoded from sRGB to linear (using a
lookup table, generated in the exact same way pixman generates it's
internal conversion tables) before being used by pixman. The resulting
image buffer is thus in decoded/linear format. We use the
color-management protocol to inform the compositor of this, by tagging
the wayland surfaces with the 'ext_linear' image attribute.

Sixes: all colors are sRGB internally, and decoded to linear before
being used in any sixels. Thus, the image buffers will contain linear
colors. This is important, since otherwise there would be a
decode/encode penalty every time a sixel is blended to the grid.

Emojis: we require fcft >= 3.2, which adds support for sRGB decoding
color glyphs. Meaning, the emoji pixman surfaces can be blended
directly to the grid, just like sixels.

Gamma-correct blending is enabled by default *when the compositor
supports it*. There's a new option to explicitly enable/disable it:
gamma-correct-blending=no|yes. If set to 'yes', and the compositor
does not implement the required color-management features, warning
logs are emitted.

There's a loss of precision when storing linear pixels in 8-bit
channels. For this reason, this patch also adds supports for 10-bit
surfaces. For now, this is disabled by default since such surfaces
only have 2 bits for alpha. It can be enabled with
tweak.surface-bit-depth=10-bit.

Perhaps, in the future, we can enable it by default if:

* gamma-correct blending is enabled
* the user has not enabled a transparent background
2025-03-05 18:45:01 +01:00
Daniel Eklöf
2a07a2e6b9
Add support for the new Wayland protocol xdg-system-bell
From the release notes:

    system bell - allowing e.g. terminal emulators to hand off system
    bell alerts to the compositor for among other things accessibility
    purposes

The new protocol is used when the new config option
bell.system=yes (and the compositor implements the protocol,
obviously).

The system bell is rung independent of whether the foot window has
keyboard focus or not (thus relying on compositor configuration to
determine whether anything should be done or not in response to the
bell).

The new option is enabled by default.
2025-01-17 10:21:50 +01:00
Alexander Orzechowski
f0253633d3
render: Expose render_overlay
This function updates the overlay that foot uses. It will be used to
update the overlay when the flash effect ends.
2025-01-09 07:53:50 +01:00
heather7283
768f254286 pgo: prefer full-headless-sway over full-headless-cage 2024-12-08 14:02:11 +04:00
heather7283
7e88e0bfdc
pgo: explicitly set LLVM_PROFILE_FILE envvar
When building foot with pgo under gentoo's portage, LLVM tried to
generate profile data files directly under system root, triggering
sandbox violation and causing build to fail. Setting this envvar fixes
the issue by explicitly specifying profiling data location.

Reference: https://clang.llvm.org/docs/UsersManual.html#profiling-with-instrumentation
2024-12-08 09:10:43 +01:00
heather7283
de305a7e58
pgo: run sway with --unsupported-gpu flag
Sway refuses to run if it detects an nvidia GPU on the system,
causing pgo build to fail. Adding --unsupported-gpu flag disables
this behaviour.
2024-12-08 09:10:43 +01:00
Daniel Eklöf
f5caa2d265
pgo: add missing stub for render_refresh_icon() 2024-09-13 09:04:18 +02:00
Daniel Eklöf
8f16fe54d3
pgo: add notify_close() stub 2024-07-25 19:31:27 +02:00
Daniel Eklöf
50efd9726d
pgo: updated stubs for notification functions 2024-07-23 12:15:50 +02:00
Daniel Eklöf
e88ec86c93
pgo: update notify_notify() prototype, add notify_free() 2024-07-23 07:43:56 +02:00
Daniel Eklöf
7268ee9078
pgo: update spawn() prototype 2024-07-23 07:43:42 +02:00
Daniel Eklöf
b0bf8ca5f7
osc/notify: add support for OSC-99, kitty desktop notifications
This adds limited support for OSC-99, kitty desktop notifications[^1]. We
support everything defined by the "protocol", except:

* 'a': action to perform on notification activation. Since we don't
  trigger the notification ourselves (over D-Bus), we don't know a)
  which ID the notification got, or b) when it is clicked.
* ... and that's it. Everything else is supported

To be explicit, we *do* support:

* Chunked notifications (d=0|1), allowing the application to append
  data to a notification in chunks, before it's finally displayed.
* Plain UTF-8, or base64-encoded UTF-8 payload (e=0|1).
* Notification identifier (i=xyz).
* Payload type (p=title|body).
* When to honor the notification (o=always|unfocused|invisible), with
  the following quirks:
    - we don't know when the window is invisible, thus it's treated as
      'unfocused'.
    - the foot option 'notify-focus-inhibit' overrides 'always'
* Urgency (u=0|1|2)

[^1]: https://sw.kovidgoyal.net/kitty/desktop-notifications/
2024-07-23 07:17:21 +02:00
Daniel Eklöf
9d9690410a
pgo: render_resize_force() has been removed, adjust stub accordingly
Closes #1601
2024-02-08 16:44:55 +01:00
Daniel Eklöf
3b5d83a3ec
pgo: add missing stub for render_refresh_app_id() 2024-02-06 14:04:22 +01:00
Daniel Eklöf
af114f81a0
pgo: fix function prototype for stub function get_current_modifiers() 2024-02-06 14:03:07 +01:00
Daniel Eklöf
7999975016
Don't use fancy Unicode quotes, stick to ASCII 2024-02-06 12:36:45 +01:00
Fazzi
85a4e4ccc1 add CCACHE_DISABLE=1 to pgo.sh to avoid errors when ccache is enabled 2023-10-20 10:06:05 +01:00
Daniel Eklöf
4a4f2b5dae
pgo: add stub for wayl_fractional_scaling() 2023-07-18 05:48:22 +02:00
Daniel Eklöf
803b250652
pgo: update xcursor stubs to use enum instead of char pointer 2023-07-03 14:36:32 +02:00
Daniel Eklöf
c51050a9bc
osc: update font subpixel mode, and window opaque compositor hint, on alpha changes
When background alpha is changed at runtime (using OSC-11), we (may)
have to update the opaque hint we send to the compositor.

We must also update the subpixel mode used when rendering font
glyphs.

Why?

When the window is fully opaque, we use wl_surface_set_opaque_region()
on the entire surface, to hint to the compositor that it doesn’t have
to blend the window content with whatever is behind the
window. Obviously, if alpha is changed from opaque, to transparent (or
semi-transparent), that hint must be removed.

Sub-pixel mode is harder to explain, but in short, we can’t do
subpixel hinting with a (semi-)transparent background. Thus, similar
to the opaque hint, subpixel antialiasing must be enabled/disabled
when background alpha is changed.
2023-05-26 10:01:32 +02:00
Andrea Pappacoda
1313e6352a
build: fix GCC detection in pgo.sh
On my system, GCC doesn't output its name when passing the --version
flag:

    $ cc --version
    cc (Debian 12.2.0-3) 12.2.0
    Copyright (C) 2022 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

As the Free Software Foundation is unlikely to write another compiler, I
think that searching for the foundation's name instead of GCC is a good
enough fix (and I'm almost sure we wouldn't be the first ones to do so).
2022-10-23 23:56:34 +02:00
Daniel Eklöf
3ba03901b8
pgo: don’t re-use the rows between the ‘normal’ and ‘alt’ grids
This used to work because we never free:d any of the rows. Now
however, we do free (some of) them when reverse scrolling. This means
we can no longer re-use the rows between the two screens.

Closes #1196
2022-10-18 18:31:18 +02:00
Daniel Eklöf
a9fc7ce180
pgo: run xtgettcap without any arguments
We execute xtgettcap in the parent terminal. Thus we don’t know if it
implements XTGETTCAP, and thus it’s not guaranteed to exit - it may
hang indefinitely waiting for a reply.

Fix by not actually quering anything.
2022-10-10 17:18:04 +02:00
Daniel Eklöf
503740f836
pgo: execute xtgettcap utility, to get profiling data
Fixes:

  ../utils/xtgettcap.c:175:1: error: ‘/home/daniel/src/foot/src/utils/xtgettcap.p/xtgettcap.c.gcda’ profile count data file not found [-Werror=missing-profile]
2022-10-07 21:47:56 +02:00
Daniel Eklöf
d2e67689ea
terminal: don’t unref a not-yet-referenced key-binding set
Key-binding sets are bound to a seat/configuration pair. The conf
reference is done when a new terminal instance is created.

When that same terminal instance is destroyed, the key binding set is
unref:ed.

If the terminal instance is destroyed *before* the key binding set has
been referenced, we’ll still unref it. This creates an imbalance.

In particular, when the there is exactly one other terminal instance
referencing that same key binding set, that terminal instance will
trigger a foot server crash as soon as it receives a key press/release
event. This happens because the next-to-last terminal instance brought
the reference count of the binding set down to 0, causing it to be
free:d.

Thus, we *must* reference the binding set *before* we can error
out (when instantiating a new terminal instance).

At this point, we don’t yet have a valid terminal instance. But,
that’s ok, because all the key_binding_new_for_term() did with the
terminal instance was get the "struct wayland" and "struct config"
pointers. So, rename the function and simply pass these pointers
explicitly.

Similarly, change key_binding_for() to take a "struct config" pointer,
rather than a "struct terminal" pointer.

Also rename key_binding_unref_term() -> key_binding_unref().
2022-09-06 20:44:05 +02:00
Daniel Eklöf
d3c51b51b7
pgo: slave_spawn(): sync function signature 2022-06-13 16:32:59 +02:00
Daniel Eklöf
f14fc120ad
pgo: add xdg_activation_token parameter to spawn() stub 2022-05-06 10:39:49 +02:00
Daniel Eklöf
8ceb6e45a4
pgo: add missing stubs for key-binding functions
* key_binding_new_for_term()
* key_binding_unref_term()
2022-04-23 00:44:46 +02:00
Daniel Eklöf
876044df8d
wayland: remove selection_override_modmask member
This member is no longer valid - we need to use one from the current
key-binding set.
2022-04-19 17:24:25 +02:00
Daniel Eklöf
a1796ba5cd
pgo: sync up stub version of slave_spawn() 2022-04-12 15:23:41 +02:00
Daniel Eklöf
d1a072d67d
pgo: fix selection.{start,end} initializers
This fixes a regression introduced in
5b1f1602bc
2022-04-10 18:31:13 +02:00
Ashish SHUKLA
91559fe480
pgo: add stub for render_xcursor_is_valid 2022-02-07 22:15:07 +05:30
Daniel Eklöf
81233e092c
pgo: stub get_current_modifiers() 2021-12-04 18:29:58 +01:00
Daniel Eklöf
1752745fcf
pgo: add stub for xcursor_for_csd_border() 2021-11-30 22:43:41 +01:00
Ronan Pigott
99d5bf64bc foot/client: implement xdga client activation
This is an application of the xdg activation protocol that will allow
compositors to associate new foot toplevels with the command that
launched them.

footclient receives an activation token from the launcher which the
compositor can use to track application startup. It passes the token
to the foot server, which then activates the new window with the token
to complete the startup sequence.
2021-10-31 18:52:29 -07:00
Daniel Eklöf
d4b365b55c
pgo: full-inner: add --override tweak.grapheme-shaping=no
Grapheme shaping is now enabled by default in foot. However, when
generating the profiling data in PGO builds, this results in skewed
optimizations.

The end result is worse benchmark results regardless of whether
grapheme-shaping is enabled or not (when running the benchmarks).
2021-10-16 16:58:59 +02:00
Stanislav Ochotnický
85aaff68fb pgo: Use pixman renderer by default for PGO builds
Without pixman renderer override pgo builds in cage/sway require
access to actual render devices. In Gentoo's case the builds are run
as ordinary user and within a "sandbox" which prevents and logs access
outside of predefined places during build.

So let's default to pixman renderer for the PGO builds. Hopefully that
won't matter for the pgo optimizations to do the right thing within foot.
2021-10-08 16:34:36 +02:00
Daniel Eklöf
b1c03861cd
pgo: verify source dir really is a foot source dir before proceeding 2021-10-06 20:10:58 +02:00
Daniel Eklöf
9389f337d0
pgo: full-inner: do not set LC_CTYPE=en_US.UTF-8
That locale may not exist. Instead, require the user/build script to
explicitly set an UTF-8 locale.

Document this in INSTALL.md, and in the bundled PKGBUILD.
2021-10-02 14:46:02 +02:00
Daniel Eklöf
b6df5f6456
pgo.sh: set -x *after* verifying input 2021-09-12 16:11:42 +02:00
Daniel Eklöf
5493267bf7
pgo: pgo.sh: remove both gcc and clang generated profile stats 2021-09-12 10:39:45 +02:00
Daniel Eklöf
a941253ba7
pgo: pgo.sh: add meson bld/src dir arguments last 2021-09-12 10:39:45 +02:00
Daniel Eklöf
6d67c2b4ab
pgo: pgo.sh: run ‘find’ in the build-directory, not cwd 2021-09-12 10:39:45 +02:00
Daniel Eklöf
e907ec209c
pgo: pgo.sh: allow a pre-existing build directory 2021-09-12 10:39:45 +02:00
Daniel Eklöf
cf7c5050f6
pgo: pgo.sh: auto: don’t use full-headless-sway
This requires Sway >= 1.6.2, which hasn’t been released yet. Thus,
don’t auto-use it.

Users can still request it explicitly.
2021-09-12 10:39:44 +02:00
Daniel Eklöf
99c4e51e19
pgo: add set -x to all PGO scripts
Without this, debugging error reports from users is going to be _very_
difficult...
2021-09-12 10:39:44 +02:00
Daniel Eklöf
f25055f101
pgo: full-headless-cage: remove references to Sway 2021-09-12 10:39:44 +02:00
Daniel Eklöf
801bce335b
pgo: full-headless-cage: new headless variant
Appears to work, but cage spams a lot of

 00:00:08.026 [types/wlr_output.c:720] Basic output test failed for HEADLESS-1
 00:00:08.036 [types/wlr_output.c:720] Basic output test failed for HEADLESS-1
2021-09-12 10:39:44 +02:00