aboutsummaryrefslogtreecommitdiff
path: root/wayland.c (follow)
Commit message (Collapse)AuthorAgeLines
* wayland: update_terms_on_monitor(): skip terminals in the process of shutting downDaniel Eklöf2026-10-25-8/+11
| | | | | | | | | In rare cases, xdg_output_handle_done() may be called while a terminal is shutting down. This triggered a crash in update_terms_for_monitor(), which de-references term->window (which is NULL for terminals shutting down). Closes #2487
* wayland: clear touch focus in wayl_win_destroy()Marinus Klasen2026-08-29-0/+17
| | | | | | | | | | | | | | | | wl_touch has no leave event, so unmapping the surfaces cannot drop touch focus the way it drops keyboard and pointer focus. seat->touch.surface kept pointing at the window being destroyed, and seat->touch.state stayed HELD/DRAGGING, so the guard in wl_touch_up() and wl_touch_motion() did not fire. A wl_touch.up dispatched from the roundtrips in wayl_win_destroy() then dereferenced the freed window: #0 wl_touch_up () at input.c:3587 #12 wayl_roundtrip () at wayland.c:2416 #13 wayl_win_destroy () at wayland.c:2297 Reproduced by touching a foot window and holding while the window is destroyed: 3/3 crashes before, 0/7 after.
* wayland: handle_global_remove(): call wl_fixes::ack_global_remove(), when availableDaniel Eklöf2026-08-19-2/+34
| | | | | | | | | | | 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-1/+7
| | | | | | | | | | | | | 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>
* wayland: fix version selection of the shape-manager globalDaniel Eklöf2026-07-30-2/+2
| | | | | | | | | Use the smallest of the *implemented* version, and the *preferred* version. Before this, we used the minimum of our *required* version, and the *preferred* version, which is both useless and wrong, since we'll always pick the required version (since required <= preferred).
* wayland: win_destroy(): unmap overlay surface before destroyDaniel Eklöf2026-06-18-0/+5
| | | | Like we do with all other surfaces.
* wayland: shm: fix debug builds when LOG_ENABLE_DBG == 0Daniel Eklöf2026-04-06-1/+1
|
* wayland: shm: included decoded fourcc name when logging shm formatsDaniel Eklöf2026-04-06-2/+18
|
* wayland: do all surface unmap and roundtrips before waiting for pre-apply damageDaniel Eklöf2026-03-10-2/+2
| | | | | | | | | | | | | | | | | | | The pre-apply damage thread may be running when we destroy a terminal instance, and we need to wait for it to finish before destroying the underlying buffer. c291194a4e593bbbb91420e81fa0111508084448 did this, but failed to realize the thread may get re-started in the roundtrips done later in wayl_win_destroy(); after the wait added in c291194a4e593bbbb91420e81fa0111508084448, we unmap all surfaces (including the main grid), and roundtrip. This means the compositor will release the currently active buffer, and that means _we_ will trigger the pre-apply damage thread on it. This introduces a race, where wayl_win_destroy() may reach its shm_purge() calls before the pre-apply damage thread has finished. That typically causes foot to crash. Closes #2288
* Add support for background blurDaniel Eklöf2026-03-02-6/+91
| | | | | | | | | 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.
* wayland: wait for pre-apply damage thread before destroying a terminal instanceDaniel Eklöf2026-02-02-0/+2
| | | | | | | | | | | | | | | | It's possible, but unlikely, that we've pushed a "pre-apply damage" job to the renderer thread queue (or that we've pushed it, and the a thread is now working on it) when we shutdown a terminal instance. This is sometimes caught in an assertion in term_destroy(), where we check the queue length is 0. Other times, or in release builds, we might crash in the thread, or in the shutdown logic when freeing the buffer chains associated with the terminal instance. Fix by ensuring there's no pre-apply damage operation queued, or running, before shutting down a terminal instance. Closes #2263
* 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-1/+32
| | | | | | | | | | | 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
* wayland: always render a new frame after a fullscreen changeDaniel Eklöf2025-10-15-8/+19
| | | | | | | | | | | This is needed, since we disable alpha in fullscreen, and since we use different image buffer formats (XRGB vs. ARGB) when we have alpha vs. when we don't (and fullscreen always disables alpha). Normally, this happens anyway, as the window is resized when going in or out from fullscreen. But, it's technically possible for a compositor to change an application's fullscreen state without resizing the window.
* wayland: restore opacity after exiting fullscreenCharalampos Mitrodimas2025-10-10-1/+12
| | | | | | | | | | | | | | | | | | | | When exiting fullscreen mode, the window's transparency was not being restored, leaving it opaque until another window was fullscreened. This occurred because the Wayland opaque region was set based only on the configured alpha value, without considering the fullscreen state. Since commit 899b768b74 ("render: disable transparency when we're fullscreened") transparency is disabled during fullscreen to avoid compositor-mandated black backgrounds affecting the intended colors. However, the opaque region was not being updated when the fullscreen state changed. Fixes: https://codeberg.org/dnkl/foot/issues/2180 Signed-off-by: Charalampos Mitrodimas <charmitro@posteo.net>
* wayland: fix global listener for xdg_toplevel_icon_manager_v1tokyo4j2025-05-24-2/+2
|
* cursor-shape: add 'dnd-ask' and 'all-resize'Daniel Eklöf2025-05-22-1/+9
| | | | | | | | | | | | | | | | | | | | 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
* wayland: configure: don't commit if we have a pending refreshDaniel Eklöf2025-05-21-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Currently, if the following occurs: 1. foot has AxB size 2. Compositor sends CxD size 3. foot detects a resize, acks and saves CxD, but doesn't redraw immediately 4. Compositor sends CxD size again (due to a toplevel state array change, for example) Then foot will detect no resize occurred, and will do an "empty" commit immediately. In this particular case that's wrong, since we're effectively acking+committing the initial AxB size. Fix by only doing the immediate commit if there's no size change **and** there's no pending refresh. Note: normally, we'd resize and refresh+commit immediately, but if we're waiting for a frame callback, then the refresh+commit will be delayed (i.e. scheduled). This is what we're checking here. Closes #2105
* 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.
* wayland: attempt to log protocol errors on failure to flushDaniel Eklöf2025-05-02-1/+8
| | | | | When failing to flush, and the error is EPIPE, attempt to read and dispatch events. This ensures protocol errors are logged.
* wayland: always call wl_display_dispatch_pending() at least once, after readingDaniel Eklöf2025-05-02-0/+2
| | | | | | | | | | | This fixes an issue where protocol errors aren't reported. I'm guessing the read succeeds, but that prepare_read() _also_ succeeds immediately, since there aren't any events to dispatch (only log the protocol error). By calling dispatch unconditionally, we ensure any error messages are printed. Then we proceed to loop prepare_read() + dispatch_pending() until the queue is empty.
* config: tweak.surface-bit-depth now defaults to 'auto'Daniel Eklöf2025-05-01-0/+7
| | | | | | | | | | | 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
* config: gamma-correct-blending: disable by defaultDaniel Eklöf2025-05-01-4/+2
|
* wayland+input: add support for toplevel edge constraintsDaniel Eklöf2025-04-07-10/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* wayland: handle xdg-shell edge constraintsDominique Martinet2025-04-07-0/+6
| | | | | | | | | | | | | | | | | | | wayland-protocols commit 86750c99ed06 ("xdg-shell: Add edge constraints") added a few more enums to handle, making the build fail with -Werror: ../wayland.c: In function ‘xdg_toplevel_configure’: ../wayland.c:878:9: error: enumeration value ‘XDG_TOPLEVEL_STATE_CONSTRAINED_LEFT’ not handled in switch [-Werror=switch] 878 | switch (*state) { | ^~~~~~ ../wayland.c:878:9: error: enumeration value ‘XDG_TOPLEVEL_STATE_CONSTRAINED_RIGHT’ not handled in switch [-Werror=switch] ../wayland.c:878:9: error: enumeration value ‘XDG_TOPLEVEL_STATE_CONSTRAINED_TOP’ not handled in switch [-Werror=switch] ../wayland.c:878:9: error: enumeration value ‘XDG_TOPLEVEL_STATE_CONSTRAINED_BOTTOM’ not handled in switch [-Werror=switch] (This is not part of any release yet, but can be used when building with the submodule) From a quick look it sounds like the meaning is the same as tiling as far as we are concerned so handle these as we do of tiling.
* meson: require wayland-protocols >= 1.41Daniel Eklöf2025-03-13-33/+0
|
* render: gamma-correct blendingDaniel Eklöf2025-03-05-3/+179
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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/+37
| | | | | | | | | | | | | | | | | | | 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.
* main: include toplevel-icon support in --version outputDaniel Eklöf2024-09-13-7/+13
|
* toplevel-icon: set to app-id, instead of hardcoding to "foot"Daniel Eklöf2024-09-13-1/+5
| | | | And, special case "footclient", and map it to "foot".
* wayland: set toplevel iconDaniel Eklöf2024-09-13-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the xdg-toplevel-icon-v1 protocol is available, and we have the corresponding manager global, set the toplevel icon to "foot". Note: we do *not* provide any pixel data. This is by design; we want to keep things simple. To be able to provide pixel data, we would have to either: * embed the raw pixel data in the foot binary * link against either libpng or/and e.g. nanosvg, locate, at run-time, the paths to our own icons, and load them at run-time. * link against either libpng or/and e.g. nanosvg, and, at run-time, do a full icon lookup. This would also require us to add a config option for which icon theme to use. Of the two, I would prefer the first option. But, let's skip this completely for now. By providing the icon as a name, the compositor will have to lookup the icon itself. Compositors supporting icons is likely to already support this. So what do we gain by implementing this protocol? Compositors no longer has to parse .desktop files and map our app-id to find the icon to use. There's one question remaining. With this patch, the icon name is hardcoded to "foot", just like our .desktop files. But, perhaps we should use the app-id instead? And if so, should we also change the icon when the app-id changes? My gut feeling is, yes, we should use the app-id instead, and yes, we should update the icon when the app-id is changed at run-time.
* wayland: bind the xdg-toplevel-icon manager globalDaniel Eklöf2024-09-13-0/+15
|
* wayland: add wayl_activate()Daniel Eklöf2024-07-23-2/+13
| | | | | wayl_activate() takes an XDG activation token and does an XDG activation request.
* wayland: #ifdef guard code related to wl_shm_release()Daniel Eklöf2024-07-18-0/+6
|
* wayland: use wl_shm v2 if availableDaniel Eklöf2024-07-18-3/+14
|
* input: don't reset the XKB compose state in keymap()Daniel Eklöf2024-06-22-3/+19
| | | | | | | | | | | | | When the compositor sends a new keymap, don't reset the XKB compose state. This is done by initializing the XKB context, along with the compose state, when binding the seat, instead of in keymap(). Then, in keymap(), simply stop destroying the old xkb state. Only destroy, and re-create the keymap state. Closes #1744
* input: implement wl_pointer::axis_value120()Daniel Eklöf2024-06-18-1/+7
| | | | | | | | | | | | | | | | | | | 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/+14
| | | | | | | | | | | | | | | | | | | 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...
* wayland: remove has_wl_compositor_v6Daniel Eklöf2024-04-12-1/+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'.
* wayland: only use the surface preferred scale if set by the compositorDaniel Eklöf2024-04-05-4/+0
| | | | | | | | Before this patch, we would, in some cases, fallback to the surface preferred (not fractional) scaling, even though the compositor hadn't actually published a preferred buffer scale; the presence of a v6 compositor interface doesn't mean we've actually received a preferred scale yet.
* wayland: skip loading cursor theme when using server side cursorsDaniel Eklöf2024-03-16-0/+5
| | | | | We don't need the client side cursor theme when using server side cursors.
* shm: use XRGB surfaces when we know we wont be using transparencyDaniel Eklöf2024-02-21-10/+0
|
* wayland: regression: use correct scaling factor when calling render_resize()Daniel Eklöf2024-02-07-3/+5
| | | | | | | | | | | | When an output property (such as scaling factor) has changed, we need to call render_resize() to ensure the window surface is correct (for example, we may have to change its scale). The width/height parameters are in *logical* pixels (i.e. already scaled). For render_resize() to work correctly when the scale is being changed, it needs to be called with *current* logical size. This means we need to scale our current width/height using the *old* scaling factor.
* Don't use fancy Unicode quotes, stick to ASCIIDaniel Eklöf2024-02-06-4/+4
|
* feature: add resize-by-cells option to constrain window sizes...Andrew J. Hesford2024-02-05-17/+29
| | | | | ...to multiples of the cell size, and preserve grid size when changing fonts or display scales in floating windows.
* util: add streq() function and use in place of strcmp(...) == 0Craig Barnes2024-02-05-16/+16
|
* wayland: 'mode' is unused when LOG_ENABLE_DBG is not setDaniel Eklöf2024-01-24-1/+1
|
* wayland: use wl_compositor version 6 when availableLeonardo Hernández Hernández2024-01-24-3/+44
|
* wayland: surface_scale_explicit_width_height(): dont assert width/height are valid for scale, take 2Daniel Eklöf2024-01-09-3/+12
| | | | | | | | | | | | | | | | | | | | | | | 764248bb0d846f65c20931024c1f4adca57aae29 modified wayl_surface_scale_explicit_width_height() to not assert the surface size is valid for the given scaling factor. This, since that function is only used when scaling a mouse pointer surface. However, that commit only updated the code path run when fractional scaling is available (i.e. when the compositor implements the fractional-scale-v1 protocol). The legacy code path, that does integer scaling, was still asserting the surface width/height were divisible with the scaling factor. For the same reasons this isn't true with fractional scaling available, it's not true with integer scaling. Fix by skipping the assertions. This patch also converts the assertions to more verbose BUG() calls, that prints more information on the numbers involved. Closes #1573
* wayland: debug: log wm-capabilities as human-readable stringsDaniel Eklöf2023-10-02-4/+39
|
* changelog: crash when xdg token is set, but compositor does not support activationDaniel Eklöf2023-09-21-1/+1
|
* wayland: check activation supported before activatingAlyssa Ross2023-09-21-1/+1
| | | | | | | | It's possible for token to be set when the compositor doesn't support activation, and this caused a segfault. For example, this can happen when overriding WAYLAND_DISPLAY to point to a compositor that doesn't support activation, in a terminal running under one that does, and so has set XDG_ACTIVATION_TOKEN.
* input: improve touch handling on pointer presenseCismonX2023-08-23-0/+6
| | | | | | | | | | | 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-21/+1
| | | | Since we're requiring wayland-protocols >= 1.32
* wayland: fractional-scale-v1 is now always availableDaniel Eklöf2023-08-07-34/+5
| | | | Since we're requiring wayland-protocols >= 1.32
* wayland: xdg-activation is now always availableDaniel Eklöf2023-08-07-19/+1
| | | | Since we're requiring wayland-protocols >= 1.32
* wayl_surface_scale_explicit_width_height(): don’t assert width/height are valid for scaleDaniel Eklöf2023-07-29-7/+28
| | | | | | This function is only called directly when scaling the mouse pointer. The mouse pointer is never guaranteed to have a valid width and height, so skip the width/height assertions for it.
* fractional scaling: another round(!) of rounding fixesDaniel Eklöf2023-07-28-3/+4
| | | | | | | * Ensure buffer sizes are valid. That is, ensure that size / scale * scale == size. * Do size calculation of the window geometry in the same way we calculate the CSD offsets.
* wayland: don't try to use a non-existing viewporter interfaceDaniel Eklöf2023-07-28-10/+14
| | | | | | | | | | | When instantiating the viewport for a pointer surface, we didn't first check if the compositor implements the viewporter interface. This triggered a crash when a) foot was compiled with fractional scaling, and b) the compositor did not implement the viewporter interface. Closes #1444
* scaling: always round the scaling factor when converting to intDaniel Eklöf2023-07-25-21/+9
| | | | | | | | | * In all calls to wl_subsurface_set_position() * (wp_viewport_set_destination() already does this) * Whenever we use the scale to calculate margins (search box, scrollback indicator etc) * Since the scaling factor is stored as a float (and not a double), use roundf() instead of round()
* wayland: update terminals (fonts etc) on xdg_output_handle_done()Daniel Eklöf2023-07-23-0/+2
| | | | | | | | | | | | | | | | | Monitor DPI depends on information from both the wl_output and the xdg_output interfaces. Before this patch, terminals were only updated after changes to the wl_output interfaces (thus depending on xdg output changes being pushed by the compositor before wl_output changes). That assumption (xdg_output happening before wl_output) isn’t always true. This patch fixes the issue by updating the terminals in the xdg_output’s “done” event. Closes #1431
* wayland: fix pointer cap lost handlingxdavidwu2023-07-18-2/+4
| | | | | Before this, on compositor without cursor-shape support, a pointer capability lost of the seat makes foot crash.
* terminal: break out scaling factor updating, and reduce number of calls to render_resize()Daniel Eklöf2023-07-18-8/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Break out the logic that updates the terminal’s scaling factor value, from render_resize(), to a new function, term_update_scale(). This allows us to update the scaling factor without a full grid resize. We also change how we pick the scaling factor (when fractional scaling is not in use). Before, we’d use the highest scaling factor from all monitors we were mapped on. Now, we use the scaling factor from the monitor we were *last* mapped on. Then, add a boolean parameter to term_set_fonts(), and when false, *don’t* call render_resize_force(). Also change term_font_dpi_changed() to only return true if the font was changed in any way. Finally, rewrite update_term_for_output_change() to: * Call term_update_scale() before doing anything else * Call render_resize{,_force} *last*, and *only* if either the scale or the fonts were updated. This fixes several things: * A bug where we failed to update the fonts when fractional scaling was in use, and we guessed the initial scale/DPI wrong. The bug happened because updated the internal "preferred" scale value, and a later call to render_resize() updated the terminal’s scale value, but since that code path didn’t call term_font_dpi_changed() (and it shouldn’t), the fonts weren’t resized properly. * It ensures we only resize the grid *once* when the scaling factor, or DPI is changed. Before this, we’d resize it twice. And this happened when e.g. dragging the window between monitors.
* wayland: error out if there aren’t any monitors availableDaniel Eklöf2023-07-18-0/+5
|
* wayland: use physical DPI on fractional-scale capable compositorsDaniel Eklöf2023-07-18-18/+28
| | | | | | | | | | | | | | | | | | | | | 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-4/+9
| | | | Also, drop wl_window::have_preferred_scale. Check for scale > 0 instead.
* render: use rounding for fractional scaleRonan Pigott2023-07-16-1/+3
| | | | | If we truncate the buffer dimensions we may accidentally submit a buffer with inappropriate size.
* input: add basic support for touchscreen inputCismonX2023-07-05-2/+21
| | | | Closes #517
* cursor-shape: use server-side cursors for custom (OSC-22), if possibleDaniel Eklöf2023-07-03-0/+1
| | | | | | | | | | | | 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-0/+46
| | | | | | | | | | | | | 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
* wayland: handle enum value XDG_TOPLEVEL_STATE_SUSPENDEDDaniel Eklöf2023-07-03-8/+15
| | | | Added in wayland-protocols-1.32
* wayland: typo: ‘.’ -> ‘;’Daniel Eklöf2023-06-30-1/+1
| | | | Closes #1392
* wayland: surface_scale(): reset buffer scale when using fractional scalingDaniel Eklöf2023-06-29-0/+1
| | | | | Since the first frame uses legacy scaling, the surface may have a buffer scale > 1, which isn’t allowed.
* wayland: surface_scale(): improve debug loggingDaniel Eklöf2023-06-29-2/+5
|
* wayland: use legacy scaling until fractional_scale::preferred_scale() has been calledDaniel Eklöf2023-06-29-1/+2
| | | | | | | | | | 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-6/+5
|
* wayland: surface_scale(): assert surface width/height is a multiple of scaleDaniel Eklöf2023-06-29-0/+7
| | | | | When doing legacy scaling (non-fractional scaling), assert the surface’s width and height are multiples of the (integer) scale.
* wayland: warn when fractional scaling isn’t availableDaniel Eklöf2023-06-29-0/+8
|
* config: dpi-aware: remove ‘auto’ value, and default to ‘no’Daniel Eklöf2023-06-29-5/+0
| | | | | | | | | | We now default to scaling fonts using the scaling factor, not monitor DPI. The ‘auto’ value for dpi-aware has been removed. Documentation (man pages and README) have been updated to reflect the new default.
* wayland: update terminal when preferred scaling factor changesDaniel Eklöf2023-06-29-0/+2
| | | | | | When the window’s preferred scaling factor is changed (through the fractional-scaling protocol), update the terminal; resize font, resize sub-surfaces etc.
* wayland: surface_scale(): implement fractional scalingDaniel Eklöf2023-06-29-2/+11
| | | | This is done by setting the surface’s viewport destination
* wayland: initialize window scale to -1Daniel Eklöf2023-06-29-0/+1
|
* wayland: instantiate+destroy viewport for pointer surfaceDaniel Eklöf2023-06-29-1/+20
|
* wayland: refactor: add a buffer argument to wayl_*_scale() functionsDaniel Eklöf2023-06-29-4/+13
| | | | | 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-3/+3
| | | | | | | | 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-59/+66
| | | | | | | | | 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-2/+25
|
* wayland: add wayl_surface_scale(), and wayl_win_scale()Daniel Eklöf2023-06-29-10/+34
| | | | | | | 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/+10
| | | | Returns true if fractional scaling is available.
* wayland: csd_reload_font(): ‘scale’ is now a floatDaniel Eklöf2023-06-29-7/+7
|
* wayland: pointer.scale: convert to floatDaniel Eklöf2023-06-29-2/+2
|
* wayland: plumbing for wp-fractional-scaleDaniel Eklöf2023-06-29-0/+61
| | | | | | | * 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-10/+19
| | | | | | | | | | | | | | | | | | | | | 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/+11
| | | | | | | | | | | | 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.
* wayland: avoid passing NULL to log_msg() in wayl_reload_xcursor_theme()Craig Barnes2023-01-06-1/+2
| | | | | | This pointer ends up being passed to various printf-family functions, where passing a NULL pointer for an "%s" format specifier invokes undefined behaviour.
* wayland: force monitor DPI to 96 when it’s unreasonably highDaniel Eklöf2022-11-04-0/+8
| | | | | | | | | If an output has a bogus physical width or height, the DPI can become so high that the cell width/height is too large for pixman_image_fill_rectangles(), resulting in a crash in pixman_fill(). Since it doesn’t make any sense to use a DPI that is obviously bogus, don’t. Force it 96 instead.
* wayland: use fp math all the way when calculating DPIDaniel Eklöf2022-11-04-3/+3
| | | | | This fixes an FPE when the monitor’s physical width/height is so small that the conversion from mm to inch resulted in inches being zero.
* wayland: use BUG() instead of xassert(false)Craig Barnes2022-11-01-1/+1
| | | | | The latter will expand to the former anyway, so we may as well provide an explicit error message instead of "assertion failed: 'false'".
* wayland: don’t crash with a division-by-zero when monitor dimensions are negativeDaniel Eklöf2022-09-23-1/+1
| | | | Some compositors set the physical dimensions to -1...
* wayland: #ifdef on XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSIONDaniel Eklöf2022-08-12-0/+4
| | | | This enables us to compile against wayland-protocols < 1.25