aboutsummaryrefslogtreecommitdiff
path: root/wayland.h (follow)
Commit message (Collapse)AuthorAgeLines
* wayland: handle_global_remove(): call wl_fixes::ack_global_remove(), when availableDaniel Eklöf2026-08-19-0/+4
| | | | | | | | | | | wayland 1.26 adds wl_fixes::ack_global_remove(). Clients should call it when they've received a global_remove() event, after doing internal cleanup. Not tested yet: * Waiting for arch to update wayland to 1.26 * None of the compositors I use (or test on) implement it yet.
* terminal: add visibility reportsTim Culverhouse2026-07-30-0/+2
| | | | | | | | | | | | | Applications cannot infer whether their terminal view is observable from keyboard focus alone, so they may continue expensive rendering while the surface is hidden. Implement private mode 2033 and the one-shot visibility query. Report Wayland xdg_toplevel suspension as not visible and otherwise remain conservative by treating the terminal as potentially visible. Amp-Thread-ID: https://ampcode.com/threads/T-019fb2b7-f245-7124-a69a-1484812532bb Co-authored-by: Amp <amp@ampcode.com>
* Add support for background blurDaniel Eklöf2026-03-02-0/+11
| | | | | | | | | This patch adds a new config option: colors{,2}.blur=no|yes. When enabled, transparent background are also blurred. Note that this requires the brand new ext-background-effect-v1 protocol, and specifically, that the compositor implements the blur effect.
* input: ignore release events after a keyboard shortcut was triggeredDaniel Eklöf2026-01-28-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes an issue with the kitty keyboard protocol, where 'release' events associated with a shortcut was sent to the client application. Example: user triggers "scroll up". We scroll up. No key event(s) are sent to the client application. Then the user releases the keys. we don't do any shortcut handling on release events, and so we continue with the normal input processing. If the kitty keyboard protocol has been enabled (and specifically, release event reporting has been enabled), then we'll emit a 'release' escape sequence. This in itself is wrong, since the client application never saw the corresponding press event. But we _also_ reset the viewport. The effect (in this example), is that it's impossible to scroll up in the scrollback history. Note that we don't ignore _any_ release event, only the release event for the (final) symbol that triggered the shortcut. This should allow e.g. modifier keys release events to be processed normally, if released before the shortcut key. This is somewhat important, since the client application will have received press events for the modifier keys leading up to the shortcut (if modifier press/release events have been enabled in the kitty keyboard protocol - _Report all keys as escape codes_). Closes #2257
* shm: don't bother with xrgb surfaces, always use argbDaniel Eklöf2026-01-04-3/+0
| | | | | | | | | | | | | | | Before this patch, foot used xrgb surfaces for all fully opaque surfaces, and only used argb surfaces for the main window when the user enabled translucency. However, several compositors have damage-like issues when we switch between opaque and non-opaque surfaces (for example, when switching color theme, or when toggling fullscreen). Since the performance benefit of using non-alpha aware surfaces are likely minor (if there's any measurable performance difference at all!), lets workaround these compositor issues by always using argb surfaces.
* config: add toplevel-tag=TAGDaniel Eklöf2025-11-12-0/+8
| | | | | | | | | | | Add support for the new xdg-toplevel-tag-v1 Wayland protocol, by exposing a new config option, `toplevel-tag`, and a corresponding command option, `--toplevel-tag` (in both `foot` and `footclient`). This can help the compositor with session management, or custom window rules. Closes #2212
* cursor-shape: add 'dnd-ask' and 'all-resize'Daniel Eklöf2025-05-22-0/+1
| | | | | | | | | | | | | | | | | | | | These (non-css) cursor shapes were added to the cursor-shape-v1 protocol in wayland-protocols 1.42. We don't need (or use them at all) internally, but add them to the list we use to translate from shape names to shape enums. This allows users to set a custom shape (via OSC-22), while still using server side cursors (i.e. no need to fallback to client-side cursors). If we try to set a shape not implemented by the server, we get a protocol error and foot exits. This is bad. So, make sure we don't do that: 1. First, we need to explicitly bind v2 if implemented by the server 2. Track the bound version number in the wayland struct 3. When matching shape enum, skip shapes not supported in the currently bound version of the cursor-shape protocol
* config: tweak.surface-bit-depth: add support for 16-bit surfacesDaniel Eklöf2025-05-03-0/+2
| | | | | | | | | This adds supports for 16-bit surfaces, using the new PIXMAN_a16b16g16r16 buffer format. This maps to WL_SHM_FORMAT_ABGR16161616 (little-endian). Use the new 16-bit surfaces by default, when gamma-correct-blending=yes.
* config: tweak.surface-bit-depth now defaults to 'auto'Daniel Eklöf2025-05-01-0/+2
| | | | | | | | | | | 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
* wayland+input: add support for toplevel edge constraintsDaniel Eklöf2025-04-07-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Edge constraints are new (not yet available in a wayland-protocols release) toplevel states, acting as a complement to the existing tiled states. Tiled tells us we shouldn't draw shadows etc *outside our window geometry*. Constrained tells us the window cannot be resized in the constrained direction. This patch does a couple of things: * Recognize the new states when debug logging * Change is_top_left() etc to look at the new constrained state instead of the tiled state. These functions are used when both choosing cursor shape, and when determining if/how to resize a window on a CSD edge click-and-drag. * Update cursor shape selection to use the default (left_ptr) shape when on a constrained edge (or corner). * Update CSD resize triggering, to not trigger a resize when attempted on a constrained edge (or corner). See https://gitlab.freedesktop.org/wayland/wayland-protocols/-/commit/86750c99ed062c306e837f11bb9492df572ad677: An edge constraint is an complementery state to the tiled state, meaning that it's not only tiled, but constrained in a way that it can't resize in that direction. This typically means that the constrained edge is tiled against a monitor edge. An example configuration is two windows tiled next to each other on a single monitor. Together they cover the whole work area. The left window would have the following tiled and edge constraint state: [ tiled_top, tiled_right, tiled_bottom, tiled_left, constrained_top, constrained_bottom, constrained_left ] while the right window would have the following: [ tiled_top, tiled_right, tiled_bottom, tiled_left, constrained_top, constrained_bottom, constrained_right ] This aims to replace and deprecate the `gtk_surface1.configure_edges` event and the `gtk_surface1.edge_constraint` enum.
* input: xkb: ignore virtual modifiersDaniel Eklöf2025-03-31-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Some compositors (mutter/GNOME is one) adds _virtual_ modifiers to the set of active modifiers when e.g. Alt, Meta, Super or Hyper is pressed. For example, pressing Alt+b would result in *both* the Alt *and* the Mod1 modifier being set. Since foot makes close to zero assumptions on how the modifiers should be interpreted, this causes various breakages. For example, a foot shortcut defined as Mod1+b will not match, since the Alt modifiers is also set. This has forced users to redefine/override some of the default key bindings to include the additional modifiers. It also causes issues with the kitty keyboard protocol, for some key combinations. Mainly whether or not to use unshifted key or not, resulting in incorrect escape sequences. Since all the "real" modifiers are always set as well, we can safely ignore the virtual modifiers. Closes #2009
* meson: require wayland-protocols >= 1.41Daniel Eklöf2025-03-13-20/+3
|
* render: gamma-correct blendingDaniel Eklöf2025-03-05-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add support for the new Wayland protocol xdg-system-bellDaniel Eklöf2025-01-17-0/+9
| | | | | | | | | | | | | | | | | | | 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.
* wayland: bind the xdg-toplevel-icon manager globalDaniel Eklöf2024-09-13-0/+8
|
* wayland: add wayl_activate()Daniel Eklöf2024-07-23-0/+2
| | | | | wayl_activate() takes an XDG activation token and does an XDG activation request.
* wayland: use wl_shm v2 if availableDaniel Eklöf2024-07-18-0/+3
|
* input: implement wl_pointer::axis_value120()Daniel Eklöf2024-06-18-0/+1
| | | | | | | | | | | | | | | | | | | This implements high resolution mouse wheel scroll events. A "normal" scroll step corresponds to the value 120. Anything less than that is a partial scroll step. This event replaces axis_discrete(), when we bind wl_seat v8 (which we now do, when available). We calculate the number of degrees that is required to scroll a single line, based off of the scrollback.multiplier value. Each high-res event accumulates, until we have at least the number of degress required to scroll one, or more lines. The remaining degrees are kept, and added to in the next scroll event. Closes #1738
* render: use single-pixel buffers for overlays, when possibleDaniel Eklöf2024-05-22-1/+4
| | | | | | | | | | | | | | | | | | | The unicode-mode, and flash overlays are single color buffers. This means we can use the single-pixel buffer protocol. It's undefined whether the compositor will release the buffer or not; to make things easier, simply destroy the buffer as soon as we've committed it. Note that since compositors don't necessarily release single-pixel buffers, we can't plug them into our own buffer interface. This means we can't use buffer pointers to check if we can re-use the previous buffer (i.e. we can skip comitting a new buffer), or if we have to create a new one. It's _almost_ enough to just check if the last overlay style is the same as the current one. Except that that doesn't take window resizes into account...
* unicode-mode: move state from seat to termDaniel Eklöf2024-05-21-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes an issue where entering unicode-mode in one foot client, also enabled unicode-mode on other foot clients. Both visually (although glitchy), and in effect. The reason the state was originally in the seat objects, was to fully support multi-seat. That is, one seat/keyboard entering unicode-mode should not affect other seats/keyboards. The issue with this is that seat objects are Wayland global. Thus, in server mode, all seat objects are shared between the foot clients. There is a similarity with IME, which also keeps state in the seat. There's one big difference, however, and that is IME has Wayland native enter/leave events, that the compositor emits when windows are focused/unfocused. These events allow us to reset IME state. For our own Unicode mode, there is nothing similar. This patch moves the Unicode state from seats, to the terminal struct. This does mean that if one seat/keyboard enters Unicode mode, then *all* seats/keyboards will affect the unicode state. This potential downside is outweighed by the fact that different foot clients no longer affect each other. Closes #1717
* wayland: remove has_wl_compositor_v6Daniel Eklöf2024-04-12-2/+0
| | | | | | | | | We deviate slightly from the specification, in that we don't assume a preferred buffer scale of 1. Instead, we "guess" the scale *until we receive a surface_preferred_buffer_scale event. Because of this, we don't need the has_wl_compositor_v6 member, as it's enough to check if we have a non-zero 'preferred buffer scale'.
* shm: use XRGB surfaces when we know we wont be using transparencyDaniel Eklöf2024-02-21-1/+0
|
* input: remove the concept of "significant" modifiersDaniel Eklöf2024-02-06-1/+0
| | | | | | | | | | | | | | | | | | | For the purpose of matching key bindings, "significant" modifiers are no more. We're really only interested in filtering out "locked" modifiers. We're already doing this, so there's no need to *also* match against a set of "significant" modifiers. Furthermore, we *never* want to consider locked keys (e.g. when emitting escapes to the client application), thus we can filter those out already when retrieving the set of active modifiers. The exception is the kitty keyboard protocol, which has support for CapsLock and NumLock. Since we're already re-retrieving the "consumed" modifiers (using the GTK style, rather than normal "XKB" style, to better match the kitty terminal), we might as well re-retrieve the effective modifiers as well.
* input/config: support *all* modifier namesDaniel Eklöf2024-02-06-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | That is, allow custom modifiers (i.e. other than ctrl/shift/alt etc) in key bindings. This is done by no longer validating/translating modifier names to booleans for a pre-configured set of modifiers (ctrl, shift, alt, super). Instead, we keep the modifier *names* in a list, in the key binding struct. When a keymap is loaded, and we "convert" the key binding, _then_ we do modifier translation. For invalid modifier names, we print an error, and then ignore it. I.e. we no longer fail to load a config due to invalid modifier names. We also need to update how we determine the set of significant modifiers. Any modifier not in this list will be ignored when matching key bindings. Before this patch, we hardcoded this to shift/alt/ctrl/super. Now, to handle custom modifiers as well, we simply treat *all* modifiers defined by the current layout as significant. Typically, the only unwanted modifiers are "locked" modifiers. We are already filtering these out.
* wayland: use wl_compositor version 6 when availableLeonardo Hernández Hernández2024-01-24-0/+3
|
* input: improve touch handling on pointer presenseCismonX2023-08-23-0/+1
| | | | | | | | | | | No longer inhibits touch event handling when terminal window has pointer focus. Instead, inhibit touch event when at least one pointer button is held down. This change improves user experience when using foot with both a mouse and a touchscreen. Closes #1428.
* wayland: cursor-shape-v1 is now always availableDaniel Eklöf2023-08-07-4/+0
| | | | Since we're requiring wayland-protocols >= 1.32
* wayland: fractional-scale-v1 is now always availableDaniel Eklöf2023-08-07-18/+8
| | | | Since we're requiring wayland-protocols >= 1.32
* wayland: xdg-activation is now always availableDaniel Eklöf2023-08-07-12/+3
| | | | Since we're requiring wayland-protocols >= 1.32
* wayland: use physical DPI on fractional-scale capable compositorsDaniel Eklöf2023-07-18-1/+4
| | | | | | | | | | | | | | | | | | | | | With legacy scaling, we need to use a "scaled", or "logical" DPI value, that is basically the real DPI value scaled by the monitor’s scaling factor. This is necessary to compensate for the compositor downscaling the surface, for "fake" fractional scaling. But with true fractional scaling, *we* scale the surface to the final size. This means we should *not* use the scaled DPI, but the monitor’s actual DPI. To facilitate this, store both the scaled and the unscaled DPI value in the monitor struct. This patch also changes how we pick the DPI value. Before, we would use the highest DPI value from all the monitors we were mapped on. Now, we use the DPI value from the monitor we were *last* mapped on (typically the window we’re dragging the window *to*).
* wayland: fractional_scale_preferred_scale(): only push update if scale has changedDaniel Eklöf2023-07-18-1/+0
| | | | Also, drop wl_window::have_preferred_scale. Check for scale > 0 instead.
* input: add basic support for touchscreen inputCismonX2023-07-05-0/+19
| | | | Closes #517
* cursor-shape: use server-side cursors for custom (OSC-22), if possibleDaniel Eklöf2023-07-03-0/+2
| | | | | | | | | | | | Using a lookup table, try to map the user-provided xcursor string to a cursor-shape-v1 known shape. If we succeed, set the user’s custom cursor using server side cursors (i.e. using cursor-shape-v1). If not, fallback to trying to load the image ourselves (using wl_cursor_theme_get_cursor()), and set it using the legacy wl_pointer_set_cursor().
* cursor-shape: add support for server side cursor shapesDaniel Eklöf2023-07-03-1/+11
| | | | | | | | | | | | | This implements support for the new cursor-shape-v1 protocol. When available, we use it, instead of client-side cursor surfaces, to select the xcursor shape. Note that we still need to keep client side pointers, for: * backward compatibility * to be able to "hide" the cursor Closes #1379
* refactor: track current xcursor using an enum, instead of a char pointerDaniel Eklöf2023-07-03-1/+2
|
* wayland: use legacy scaling until fractional_scale::preferred_scale() has been calledDaniel Eklöf2023-06-29-0/+1
| | | | | | | | | | This way, the initial frame is more likely to get scaled correctly; foot will guess the initial (integer) scale from the available monitors, and use that. By using legacy scaling, we force the compositor to down-scale the image to the correct scale factor. If we use the new fraction scaling method with an integer scaling factor, the initial frame gets rendered way too big.
* wayland: refactor: surface_scale(): pass wl_window pointer, instead of wayland globalDaniel Eklöf2023-06-29-2/+2
|
* wayland: refactor: add a buffer argument to wayl_*_scale() functionsDaniel Eklöf2023-06-29-2/+7
| | | | | This will be needed later, when using fractional scaling + viewporter to scale.
* wayland: refactor: wayl_surface_scale(): pass wayl_surface pointerDaniel Eklöf2023-06-29-1/+1
| | | | | | | | Instead of passing a raw wl_surface pointer, pass a wayl_surface pointer. This is needed later, when using fractional scaling to scale the surface (since then we need the surface’s viewport object).
* wayland: refactor: wrap wl_surface pointers in a wayl_surface structDaniel Eklöf2023-06-29-20/+23
| | | | | | | | | And add a viewport object to accompany the surface (to be used when scaling the surface). Also rename the wl_surf_subsurf struct to wayl_sub_surface, and add a wayl_surface object to it, rather than a plain wl_surface pointer (to also get the viewport pointer).
* wayland: add viewport object to sub-surface structDaniel Eklöf2023-06-29-0/+3
|
* wayland: add wayl_surface_scale(), and wayl_win_scale()Daniel Eklöf2023-06-29-2/+5
| | | | | | | These functions scale a surface+buffer. For now, only using the legacy scaling method (wl_surface_set_buffer_scale()).
* wayland: add wayl_fractional_scaling()Daniel Eklöf2023-06-29-0/+2
| | | | Returns true if fractional scaling is available.
* wayland: pointer.scale: convert to floatDaniel Eklöf2023-06-29-2/+2
|
* wayland: plumbing for wp-fractional-scaleDaniel Eklöf2023-06-29-0/+16
| | | | | | | * Bind the wp-viewporter and wp-fractional-scale-manager globals. * Create a viewport and fractional-scale when instantiating a window. * Add fractional-scale listener (that does nothing at the moment). * Destroy everything on teardown.
* osc: update font subpixel mode, and window opaque compositor hint, on alpha changesDaniel Eklöf2023-05-26-0/+1
| | | | | | | | | | | | | | | | | | | | | 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.
* wayland: ignore configure events for unmapped surfacesDaniel Eklöf2023-02-25-0/+1
| | | | | | | | | | | | Closes #1249 Note that it is still unclear whether ack:ing a configure event for an unmapped surface is a protocol violation, or something that should be handled by the compositor. According to https://gitlab.freedesktop.org/wayland/wayland-protocols/-/issues/108, Kwin, Mutter and Weston handles it, while wlroots does not.
* Add support for xdg_toplevel.wm_capabilitiesSimon Ser2022-08-04-0/+5
| | | | See https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/122
* input: add new Unicode input modeDaniel Eklöf2022-07-29-0/+6
| | | | | | | | | | | | | | This mode is activated through the new key-bindings.unicode-input and search-bindings.unicode-input key bindings. When active, the user can “build” a Unicode codepoint by typing its hexadecimal value. Note that there’s no visual feedback in this mode. This is intentional. This mode is intended to be a fallback for users that don’t use an IME. Closes #1116
* ime: track IME focus independently from keyboard focusDaniel Eklöf2022-06-15-1/+1
| | | | | | | | | | | | | | | | | Replace the seat->ime.focused boolean with a terminal instace pointer, seat->ime_focus. Set and reset this on ime::enter() and ime::leave() events, and use this instead of seat->kbd_focus on all other IME events. This fixes two issues: a) buggy compositors that sometimes sends an IME enter event without first having sent a keyboard enter event. b) seats may be IME capable while still lacking the keyboard capability. Such seats will *always* see IME enter events without a corresponding keyboard enter event.
* wayland: throttle xdg activation token requests for window urgencyDaniel Eklöf2022-05-11-0/+1
| | | | | | | | | | | | | | | | | When XDG activation support was added to URL mode, we introduced a regression, where it is possible to flood the Wayland socket with XDG activation token requests. Start foot with “foot -o bell.urgency=yes”, then run: while true; do echo -en ‘\a’; done Finally, switch keyboard focus to another window. Foot crashes. Throttle the token requests by limiting the number of outstanding urgency token requests to 1. Closes #1065
* url-mode: add support for XDG activation when opening URLsDaniel Eklöf2022-05-05-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | | First, add a ‘token’ argument to spawn(). When non-NULL, spawn() will set the ‘XDG_ACTIVATION_TOKEN’ environment variable in the forked process. If DISPLAY is non-NULL, we also set DESKTOP_STARTUP_ID, for compatibility with X11 applications. Note that failing to set either of these environment variables are considered non-fatal - i.e. we ignore failures. Next, add a helper function, wayl_get_activation_token(), to generate an XDG activation token, and call a user-provided callback when it’s ‘done (since token generation is asynchronous). This function takes an optional ‘seat’ and ‘serial’ arguments - when both are non-NULL/zero, we set the serial on the token. ‘win’ is a required argument, used to set the surface on the token. Re-write wayl_win_set_urgent() to use the new helper function. Finally, rewrite activate_url() to first try to get an activation token (and spawn the URL launcher in the token callback). If that fails, or if we don’t have XDG activation support, spawn the URL launcher immediately (like before this patch). Closes #1058
* wayland: remove selection_override_modmask memberDaniel Eklöf2022-04-19-2/+0
| | | | | This member is no longer valid - we need to use one from the current key-binding set.
* wayland: refactor: remove ‘struct config’ pointer from wayland structDaniel Eklöf2022-04-17-5/+5
| | | | | | | | | | | | | | The global config doesn’t necessarily reflect the correct configuration to use - we should *always* use the current terminal instance’s conf pointer. * Move selection override modifier mask to the key_binding_set struct * Always warn if XDG activation is unavailable, not just if bell.urgent is set (we no longer have access to this information) * Pass ‘bool presentation_timings’ as a parameter to wayl_init() * Remove ‘presentation_timings’ member from the ‘terminal’ struct Closes #932
* key-binding: new API, for handling sets of key bindingsDaniel Eklöf2022-04-17-109/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, our Wayland seats have been tracking key bindings. This makes sense, since the seat’s keymap determines how the key bindings are resolved. However, tying bindings to the seat/keymap alone isn’t enough, since we also depend on the current configuration (i.e. user settings) when resolving a key binding. This means configurations that doesn’t match the wayland object’s configuration, currently don’t resolve key bindings correctly. This applies to footclients where the user has overridden key bindings on the command line (e.g. --override key-bindings.foo=bar). Thus, to correctly resolve key bindings, each set of key bindings must be tied *both* to a seat/keymap, *and* a configuration. This patch introduces a key-binding manager, with an API to add/remove/lookup, and load/unload keymaps from sets of key bindings. In the API, sets are tied to a seat and terminal instance, since this makes the most sense (we need to instantiate, or incref a set whenever a new terminal instance is created). Internally, the set is tied to a seat and the terminal’s configuration. Sets are *added* when a new seat is added, and when a new terminal instance is created. Since there can only be one instance of each seat, sets are always removed when a seat is removed. Terminals on the other hand can re-use the same configuration (and typically do). Thus, sets ref-count the configuration. In other words, when instantiating a new terminal, we may not have to instantiate a new set of key bindings, but can often be incref:ed instead. Whenever the keymap changes on a seat, all key bindings sets associated with that seat reloads (re-resolves) their key bindings. Closes #931
* url-mode: add a key binding that enables “persistent” URL modeDaniel Eklöf2022-04-17-1/+2
| | | | | | | This is an alternative to ‘show-urls-launch’, where we stay in URL mode after activating an URL. Closes #964
* render: implement ‘flash’ and search mode’s ‘dimming’ with a sub-surfaceDaniel Eklöf2022-04-16-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Search mode and ‘flash’ (OSC-555) both achieves similar visual effects: flash tints the entire window yellow, and search mode dims it (except the search match). But, they do so in completely different ways. Search mode is detected in render_cell(), and the colors are then dimmed there. Flash is implemented by blending a yellow, semi-transparent color on top of the rendered grid. This patch replaces those two implementations with a single one. We add a new sub-surface, called the ‘overlay’. In normal mode, it’s unmapped. When either search mode, or flash, is enabled, we enable it, and fill it with a semi-transparent color. Yellow for ‘flash’, and “black” (i.e. no color) for search mode. The compositor then blends it with the grid. Hopefully on the GPU, meaning it’ll be faster than if we blend in software. There are more performance benefits however. By using a separate surface, we can do much better damage tracking. The normal grid rendering code no longer have to care about neither search mode, nor flash. Thus, we get rid of a couple of ‘if’ statements in render_cell(), which is nice. But more importantly, we can drop full grid repaints in a couple of circumstances: * Entering/exiting search mode * Every frame while flash is active Now, when rendering the search mode overlay, we do want to do some damage tracking, also of the overlay. This, since search mode doesn’t dim the *entire* window. The search match is *not* dimmed. This is implemented by punching a hole in the overlay sub-surface. That is, we make part of it *fully* transparent. The basic idea is to set a clip region that excludes the search match, and then dim the rest of the overlay. It’s slightly more complicated than that however, if we want to reuse the last frame’s overlay buffer (i.e we don’t want to re-render the *entire* overlay every frame). In short, we need to: * Clear (punch hole) in areas that are part of this frame’s search match, but not the last frame’s (since those parts are _already_ cleared). * Dim the areas that were part of the last frame’s search match, but aren’t anymore (the rest of the overlay should already be dimmed). To do this, we save the last frame’s “holes” (as a pixman region). Then, when rendering the next frame, we first calculate the new frame’s “holes” region. The region to clear is “this frame’s holes minus last frame’s holes” The region to dim is “last frame’s holes minus this frames holes”. Finally, we compute the bounding box of all modified cells by taking the union of the two diff regions mentioned above. This allows us to limit the buffer damage sent to the compositor.
* wayland: optionally disable pointer input on subsurfacesDaniel Eklöf2022-04-16-2/+3
| | | | | | | | | | | | | | | | We have a number of sub-surfaces for which we are *not* interrested in pointer (or touch) input. Up until now, we’ve manually dealt with these, by recognizing these surfaces in all pointer events, and ignoring them. But, lo and behold, there are better ways of doing this. By clearing the subsurface’s input region, the compositor will do this for us - when a pointer is outside a surface’s input region, the event is passed to the next surface underneath it. This is exactly what we want! Do this for all subsurfaces, *except* the CSDs.
* wayland: add helper functions wayl_win_csd_{titlebar,borders}_visible()Daniel Eklöf2022-04-16-0/+3
|
* config/input: add scrollback-home|end key bindings (unbound by default)Daniel Eklöf2022-02-23-0/+2
|
* wip: map key combos to custom text strings (including escapes)Daniel Eklöf2022-02-16-1/+1
| | | | | | | | | | | | | With this, it is now possible to map key combos to custom escapes. The new bindings are defined in a new section, “text-bindings”, on the form “string=key combo”. The string can consist of printable characters, or \xNN style hex digits: [text-bindings] abcd = Control+a \x1b[A = Control+b Control+c Control+d # map ctrl+b/c/d to UP
* config: ‘pipe’ is now optional ‘aux’ data in the key-binding structDaniel Eklöf2022-02-09-2/+2
| | | | | This allows us to add helper functions that e.g. compare bindings’ aux data in a generic way.
* config: rename enum config_key_binding_type -> key_binding_typeDaniel Eklöf2022-02-09-1/+1
|
* wayland: add wayl_bindings_reset()Daniel Eklöf2022-02-09-0/+2
| | | | | This function resets (clears) all key- and mouse-bindings associated with the seat.
* wayland: unify key- and mouse-binding structsDaniel Eklöf2022-02-09-12/+16
|
* config: move structs and enums used by config from terminal.h -> config.hDaniel Eklöf2022-02-09-0/+1
|
* fcft: adapt to API changes in fcft-3.xDaniel Eklöf2022-02-05-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fcft no longer uses wchar_t, but plain uint32_t to represent codepoints. Since we do a fair amount of string operations in foot, it still makes sense to use something that actually _is_ a string (or character), rather than an array of uint32_t. For this reason, we switch out all wchar_t usage in foot to char32_t. We also verify, at compile-time, that char32_t used UTF-32 (which is what fcft expects). Unfortunately, there are no string functions for char32_t. To avoid having to re-implement all wcs*() functions, we add a small wrapper layer of c32*() functions. These wrapper functions take char32_t arguments, but then simply call the corresponding wcs*() function. For this to work, wcs*() must _also_ be UTF-32 compatible. We can check for the presence of the __STDC_ISO_10646__ macro. If set, wchar_t is at least 4 bytes and its internal representation is UTF-32. FreeBSD does *not* define this macro, because its internal wchar_t representation depends on the current locale. It _does_ use UTF-32 _if_ the current locale is UTF-8. Since foot enforces UTF-8, we simply need to check if __FreeBSD__ is defined. Other fcft API changes: * fcft_glyph_rasterize() -> fcft_codepoint_rasterize() * font.space_advance has been removed * ‘tags’ have been removed from fcft_grapheme_rasterize() * ‘fcft_log_init()’ removed * ‘fcft_init()’ and ‘fcft_fini()’ must be explicitly called
* replace gettimeofday with clock_gettimePranjal Kole2022-01-15-3/+2
| | | | | | | | | | | | | POSIX.1-2008 has marked gettimeofday(2) as obsolete, recommending the use of clock_gettime(2) instead. CLOCK_MONOTONIC has been used instead of CLOCK_REALTIME because it is unaffected by manual changes in the system clock. This makes it better for our purposes, namely, measuring the difference between two points in time. tv_sec has been casted to long in most places since POSIX does not define the actual type of time_t.
* config, input: allow configuring select-override modifiersfeeptr@codeberg.org2021-12-02-0/+2
|
* input: rename ‘meta’ to ‘super’Daniel Eklöf2021-11-28-2/+2
|
* input: get_current_modifiers() no longer strips insignificant modsDaniel Eklöf2021-11-28-0/+3
| | | | | | | | | | | | | | Our internal binding handling cares about a different set of modifiers, compared to the kitty keyboard protocol. To handle this, get_current_modifiers() has been modified, to no longer strip the “unsignificant” modifiers. This is now up to the caller to do. To help, we keep two masks (for significant modifiers) in the seat struct; one for our internal binding handling (and the legacy keyboard protocol), and one for the kitty keyboard protocol. These two masks are updated when the seat’s keymap is updated/changed.
* input: kitty: use base symbol instead of lowering the symbolDaniel Eklöf2021-11-28-0/+2
| | | | | | | | | | | | | | | | | | | When emitting an escape sequence for a printable character, with modifiers (e.g. ctrl+a), use the key’s base symbol instead of “lowering” it. This means we now handle e.g. ctrl+2 and ctrl+shift+2, with Swedish layout. There’s a twist however. We *only* use the base symbol if the modifiers that is used to “generate” the symbol are “significant”. Significant modifiers are, in this context, modifiers we can encode in the kitty escape sequences. In the Swedish layout, pressing AltGr+2 results in ‘@’. AltGr cannot be encoded in the kitty protocol. If we were to use the base symbol, AltGr+Alt+2 would result in exactly the same escape sequence as Alt+2.
* foot/client: implement xdga client activationRonan Pigott2021-11-01-1/+1
| | | | | | | | | | | 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.
* config: add [key-bindings].noop actionDaniel Eklöf2021-10-27-0/+1
| | | | | | | Key combinations assigned to this action will not be sent to the application. Closes #765
* input: implement support for mouse wheel left/rightDaniel Eklöf2021-08-07-1/+1
| | | | | | | | | | | | | We now emit button 6/7 events (when the client application grabs the mouse). This buttons map to mouse wheel horizontal scroll events. Or, left/right tilting, if you like. Wayland report these as ‘axis’ events (just like regular scroll wheel events), and thus we need to translate those scroll events to button events. libinput does not define any mouse buttons for wheel tilts, so we add our own defitions. These are added last in the BTN_* range, just before the BTN_JOYSTICK events.
* render: csd_title(): use a custom font, sized based on the title bar’s heightDaniel Eklöf2021-07-24-0/+2
| | | | | | | | We still use the primary font, but use a custom size, based on the title bar’s height. This fixes an issue where the window title could be way too small, or way too big. And changed size when the terminal font size was changed.
* wayland: apply CSD/SSD changes in the surface configure eventDaniel Eklöf2021-06-23-1/+4
| | | | | | | | | | | | | | | | | | The configure event asks the client to change its decoration mode. The configured state should not be applied immediately. Clients must send an ack_configure in response to this event. See xdg_surface.configure and xdg_surface.ack_configure for details. In particular, ”the configured state should *not* be applied immediately”. Instead, treat CSD/SSD changes like all other window dimension related changes: store the to-be mode in win->configure, and apply it in the surface configure event. This fixes an issue where foot incorrectly resized the window when the server switched between CSD/SSD at run-time.
* selection: add support for TEXT/STRING/UTF8_STRING mime-types in incoming offersDaniel Eklöf2021-06-09-0/+4
| | | | | | | | | We were already offering these mime types for our own clipboard data, but ignored them in incoming offers. Fixes paste issues from Geany. Closes #583
* meson: add xdg-activation-v1.xml conditionallyDaniel Eklöf2021-05-14-1/+8
| | | | | | | | | | Only enable XDG activation when compiling against wayland-protocols 1.21. Older versions don’t have this protocol. When available, define HAVE_XDG_ACTIVATION. Make all usages of xdg_activation_v1 and xdg_activation_token_v1 conditional.
* xdg-activation: initial support for setting urgency using XDG activationDaniel Eklöf2021-05-14-1/+12
|
* ime: move preedit state from terminal struct to the seat structDaniel Eklöf2021-03-25-0/+9
| | | | | | | | | | | | | | | | | This ensures different seat’s don’t step on each others IME pre-edit state. It also removes most dependencies on having a valid term pointer for many IME operations. We’re still not all the way, since we support disabling IME with a private mode, which is per terminal, not seat. Thus, we still require the seat to have keyboard focus on one of our windows. Closes #324. But note that *rendering* of multiple seat’s IME pre-edit strings is still broken.
* ime: don’t commit IME changes when we don’t have IME focusDaniel Eklöf2021-03-02-0/+1
| | | | | | | | | Fixes log spamming in Sway: 00:54:07.780 [DEBUG] [wlr] [types/wlr_text_input_v3.c:181] Text input commit received without focus 00:54:07.780 [INFO] [sway/input/text_input.c:127] Inactive text input tried to commit an update Closes #384
* urls: add key binding that toggles whether URLs are displayed on jump-labelDaniel Eklöf2021-02-21-0/+1
| | | | | | | | | | | | | | | | | By default, the URL isn’t shown on the jump-label. For auto-detect URLs, doing so is virtually always useless, as the URL is already visible in the grid. For OSC-8 URLs however, the URL is often _not_ visible in the grid. Many times, seeing the URL is still not needed (if you’re doing ‘ls --hyperlink’, you already know what the URIs are). But it is still useful to have a way to show the URLs. This patch adds a new key binding action that can be used in url-mode to toggle the URL on and off in the jump label. It is bound to ctrl+t by default.
* wayland: drop ‘_surface’ suffix from subsurface struct instancesDaniel Eklöf2021-02-17-3/+3
|
* render-timer: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-3/+1
|
* scrollback-indicator: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-4/+1
|
* search: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-2/+1
|
* csd: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-2/+1
|
* url-mode: convert struct wl_url to use wayl_win_subsurface_new()Daniel Eklöf2021-02-17-2/+1
|
* wayland: add wayl_win_subsurface_new() and wayl_win_subsurface_destroy()Daniel Eklöf2021-02-17-1/+13
| | | | | These are utility functions to create a Wayland subsurface associated with the window.
* key-bindings: refactor: use a single type for all key bindingsDaniel Eklöf2021-02-08-35/+22
| | | | | | | | | | | | | | | | Up until now, the various key binding modes (“normal”, “search” and “url”) have used their own struct definitions for their key bindings. The only reason for this was to have a properly typed “action” (using the appropriate “action” enum). This caused lots of duplicated code. This patch refactors this to use a single struct definition for the “unparsed” key bindings handled by the configuration, and another single definition for “parsed” bindings used while handling input. This allows us to implement configuration parsing, keymap translation and so on using one set of functions, regardless of key binding mode.
* config: add show-urls-copy actionDaniel Eklöf2021-02-07-0/+1
| | | | | | This works just like show-urls-launch, except that instead of opening the URL (typically using xdg-open), it is placed in the clipboard when activated.
* config: rename ‘show-urls’ to ‘show-urls-launch’Daniel Eklöf2021-02-07-2/+2
|
* urls: initial support for detecting URLs and rendering jump-labelsDaniel Eklöf2021-02-07-0/+7
| | | | The jump labels work, but is currently hardcoded to use xdg-open
* config: add infrastructure to handle URL mode specific key bindingsDaniel Eklöf2021-02-07-1/+14
| | | | | | * Add “show-urls” action to regular key bindings * Add url-bindings section to foot.ini * Add “cancel” action to URL mode key bindings
* Send text_input_rectangle requests for text-inputTadeo Kondrak2021-01-29-0/+12
|
* render: delay TIOCSWINSZ while doing an interactive resizeDaniel Eklöf2021-01-26-0/+2
| | | | | | | | | | | | | | | | | | | Instead of disabling content centering, delay the TIOCSWINSZ (a.k.a delay sending the new dimensions to the client) by a small amount while doing an interactive resize. Non-interactive resizes are still immediate. For now, force a resize when the user stops the interactive resize. This ensures the client application receives the new dimensions immediately. It still works without the last, forced, resize, but there typically be a small delay until the client application receives the final dimensions. Closes #301 Closes #283
* wayland: pending ‘configure’ flags: use ’bool’ in bit-fieldsDaniel Eklöf2021-01-26-8/+8
|
* wayland: track is-resizing stateDaniel Eklöf2021-01-26-0/+2
|
* wayland: pack booleans in the “pending” configure structDaniel Eklöf2021-01-26-7/+7
|