aboutsummaryrefslogtreecommitdiff
path: root/wayland.c (follow)
Commit message (Collapse)AuthorAgeLines
* 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
* Add support for xdg_toplevel.wm_capabilitiesSimon Ser2022-08-04-3/+43
| | | | See https://gitlab.freedesktop.org/wayland/wayland-protocols/-/merge_requests/122
* Add no-op xdg_toplevel.configure_bounds handlerSimon Ser2022-08-03-1/+10
| | | | Next commit uses v5.
* wayland: log human readable SHM format names in debug buildsDaniel Eklöf2022-06-20-0/+17
|
* wayland: throttle xdg activation token requests for window urgencyDaniel Eklöf2022-05-11-3/+15
| | | | | | | | | | | | | | | | | 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-35/+78
| | | | | | | | | | | | | | | | | | | | | | | | | 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: refactor: remove ‘struct config’ pointer from wayland structDaniel Eklöf2022-04-17-7/+7
| | | | | | | | | | | | | | 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-22/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* render: implement ‘flash’ and search mode’s ‘dimming’ with a sub-surfaceDaniel Eklöf2022-04-16-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-6/+17
| | | | | | | | | | | | | | | | 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.
* config: add [csd].hide-when-maximized=yes|noDaniel Eklöf2022-04-16-1/+2
| | | | | | | When enabled, the CSD titlebar will be hidden when the window is maximized. Closes #1019
* wayland: add helper functions wayl_win_csd_{titlebar,borders}_visible()Daniel Eklöf2022-04-16-2/+18
|
* wayland: take (visible) border width into account on configure eventsDaniel Eklöf2022-04-16-1/+7
| | | | | | | | | | | When the compositor is asking us to resize ourselves, take our (visible) CSD borders into account. This is similar to how we already take the titlebar size into account. This fixes an issue where the window size “jumps” when the user starts an interactive resize, when csd.border-width > 0. This as been observed in GNOME.
* wayland: add wayl_bindings_reset()Daniel Eklöf2022-02-09-5/+11
| | | | | This function resets (clears) all key- and mouse-bindings associated with the seat.
* wayland: use key_bindings_destroy() to destroy the mouse bindingsDaniel Eklöf2022-02-09-3/+7
|
* wayland: unify key- and mouse-binding structsDaniel Eklöf2022-02-09-1/+1
|
* wayland: remove workaround for sway-1.5 bug - slow resizing of hidden windowsDaniel Eklöf2022-02-03-37/+0
| | | | | | | | | | | | | | | | | | | | In Sway-1.5, sway waits for configure ACKs from hidden windows when views are being resized. I.e. if you have e.g. a stacked view, with one or more windows currently not visible, and you resize the stack, then sway will emit configure events to all windows, and then wait for ACKs before rendering the resized view. The problem with this is that sway also does **not** call frame callbacks on hidden windows. So if we have rendered one frame, and thus registered a frame callback, we’ll never render any more frames until the window becomes visible again. Ergo, if you resize the view interactively, only the first resize actually happens. After that, all hidden views are “stuck”, causing ACK timeouts. We worked around this in foot by preempting the frame callback. I.e. destroying it, and rendering the frame anyway. This has fixed in sway-1.6, and thus we can remove the workaround.
* wayland: use strtol() to parse xcursor_sizePranjal Kole2022-01-29-3/+9
| | | | | | sscanf is not very robust. For example, $ XCURSOR_SIZE="36asdf" foot works without any errors, and xcursor_size is parsed as 36.
* wayland: use getenv() according to specPranjal Kole2022-01-29-1/+2
| | | | | | | | | | From the NOTES section of getenv(3): The string pointed to by the return value of getenv() may be statically allocated, and can be modified by a subsequent call to getenv()... So, previously xcursor_theme could be modified by libc to contain xcursor_size. This has been fixed by getting xcursor_theme after computing the value of xcursor_size.
* config: convert tweak.render_timer to an enumDaniel Eklöf2022-01-13-1/+9
|
* wayland: don’t try to bind wl_output version 4 unconditionallyDaniel Eklöf2022-01-06-1/+9
| | | | | | | | | | | The compositor may offer version 4, while we’re still linked against an old libwayland that does not implement version 4. While we properly #ifdef the callbacks from version 4, we were still requesting version 4 (if offered by the compositor), even when compiled against a too old libwayland. Closes #876
* wayland: add wl_output.name() and wl_output.description()Daniel Eklöf2021-12-13-1/+28
| | | | | | | | These are new in version 4 of the wl_output interface (first included in wayland-1.20). This allows us to get the name and description of the outputs, also on compositors without the XDG output interface.
* wayland: estimate scaled (logical) width/height, if not providedDaniel Eklöf2021-12-13-5/+11
| | | | | | | | | | | This makes us slightly more resilient against a missing XDG output interface. We use the “real” (the physical) dimensions, combined with the scaling factor, to estimate the logical dimensions. This works out correctly with non-fractional scaling, but not otherwise.
* wayland: guard XDG startup notification with HAVE_XDG_ACTIVATIONDaniel Eklöf2021-11-09-0/+2
| | | | Fixes compilation on systems with “too old” wayland-protocols
* wayland: error out if there aren’t any seats availableDaniel Eklöf2021-11-07-0/+4
| | | | | | | | | | | | If there aren’t any seats available, input is not possible (neither keyboard nor mouse input). Note that this is not the same thing as e.g. no keyboard being plugged in. In this case, there will be a seat, but without the keybaord capability. Input may not be possible _right now_, but may be later, if the user plugs in a keyboard. Closes #779
* foot/client: implement xdga client activationRonan Pigott2021-11-01-1/+5
| | | | | | | | | | | 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.
* term: only scale using DPI if *all* monitors have a scaling factor or oneDaniel Eklöf2021-09-24-0/+5
| | | | | | | | | | | | | | | | | | | | With dpi-aware=auto (the default), scale fonts using DPI *only* if *all* available monitors have a scaling factor of one. The idea is this: if a user, with multiple monitors, have enabled scaling on *at least* one monitor, he/she has most likely done so to match the size of his/hers other monitors. For example, if the user has one monitor with a scaling factor of one, and another one with a scaling factor of two, he/she expects things to be twice as large on the second monitor. If we (foot) scale using DPI on the first monitor, and using the scaling factor on the second monitor, foot will *not* look twice as big on the second monitor (this was the old behavior of dpi-aware=auto). Part of #714
* wayland: set scale to 1 by defaultNihal Jere2021-07-26-0/+1
| | | | | The wl_output protocol specifies that the client should assume that scale is 1 if not set by the compositor.
* wayland: prevent hang when terminating due to broken Wayland connectionDaniel Eklöf2021-07-24-1/+9
| | | | | | | | | | | | | | | | | | | | | If the call to fdm_wayl() with EPOLLHUP was followed by calls to wayl_roundtrip(), foot would hang. The reason for this is that the EPOLLHUP handler in fdm_wayl() would call wl_display_cancel_read(). wayl_roundtrip() also calls wl_display_cancel_read() (since we normally have called wl_display_prepare_read()), before calling wl_display_roundtrip(). When calling wl_display_cancel_read() two times in a row, without a wl_display_prepare_read() in between, wl_display_roundtrip() hangs. Fix by not calling wl_display_cancel_read() in fdm_wayl(). This ensures our invariant holds: wl_display_prepare_read() is *always* in effect outside of fdm_wayl(). Closes #651
* config: add csd.font optionDaniel Eklöf2021-07-24-3/+6
|
* render: csd_title(): use a custom font, sized based on the title bar’s heightDaniel Eklöf2021-07-24-0/+33
| | | | | | | | 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.
* render: use a single backing SHM pool for CSD surface buffersDaniel Eklöf2021-07-18-7/+4
|
* shm: refactor: move away from a single, global, buffer listDaniel Eklöf2021-07-17-9/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up until now, *all* buffers have been tracked in a single, global buffer list. We've used 'cookies' to separate buffers from different contexts (so that shm_get_buffer() doesn't try to re-use e.g. a search-box buffer for the main grid). This patch refactors this, and completely removes the global list. Instead of cookies, we now use 'chains'. A chain tracks both the properties to apply to newly created buffers (scrollable, number of pixman instances to instantiate etc), as well as the instantiated buffers themselves. This means there's strictly speaking not much use for shm_fini() anymore, since its up to the chain owner to call shm_chain_free(), which will also purge all buffers. However, since purging a buffer may be deferred, if the buffer is owned by the compositor at the time of the call to shm_purge() or shm_chain_free(), we still keep a global 'deferred' list, on to which deferred buffers are pushed. shm_fini() iterates this list and destroys the buffers _even_ if they are still owned by the compositor. This only happens at program termination, and not when destroying a terminal instance. I.e. closing a window in a “foot --server” does *not* trigger this. Each terminal instatiates a number of chains, and these chains are destroyed when the terminal instance is destroyed. Note that some buffers may be put on the deferred list, as mentioned above.
* wayland: win_destroy: unmap URL labelsDaniel Eklöf2021-07-15-0/+6
|
* wayland: explicitly purge all SHM pixmaps when destroying windowDaniel Eklöf2021-07-11-0/+8
| | | | | | All SHM pixmap cookies depend on the terminal instance’s memory address. Thus, after a terminal instance has been destroyed, shm pixmaps that belonged to it will never be purged automatically.
* wayland: purge CSD pixmaps when destroying the CSDsDaniel Eklöf2021-07-11-1/+6
| | | | | | CSDs aren’t typically toggled on and off. Thus, when disabled, immediately purge their corresponding pixmap buffers, to free up some memory, and release file descriptors.
* url-mode: purge SHM pixmaps when destroying URLsDaniel Eklöf2021-07-11-0/+5
| | | | | | | | | | Unlike other surface types, the SHM cookie depends on the address of each URL instance. This means if we enable, disable, and then enable URL mode again (thus showing exactly the same URLs as the first time), the URLs will have new addresses, and thus the old SHM pixmaps will not get purged automatically. So, manually purge them when destroying the URLs.
* wayland: regression: properly instantiate CSDs when there’s no decoration managerDaniel Eklöf2021-06-24-2/+1
| | | | | | | | | | * Set win->configure.csd_mode, not win->csd_mode. Otherwise our ‘configure’ handler will swap out the CSD_YES we set, for CSD_UNKNOWN(?), resulting in no CSDs at all. * Don’t instantiate the CSDs in wayl_win_init(), let the ‘configure’ event handler do that. Just like it does when we have a decoration manager emitting decoration configure events.
* wayland: apply CSD/SSD changes in the surface configure eventDaniel Eklöf2021-06-23-38/+25
| | | | | | | | | | | | | | | | | | 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.
* wayland: fdm callback: check return value of wl_display_dispatch_pending()Daniel Eklöf2021-05-25-2/+6
| | | | | Since it’s inside a while-loop, we’d better handle failures, or we risk getting stuck.
* wayland: roundtrip: log error and abort when wl_display_roundtrip() failsDaniel Eklöf2021-05-25-3/+10
| | | | | | | | | | | | | | | | | | | | ayl_roundtrip() has the following code: wl_display_roundtrip(wayl->display); while (wl_display_prepare_read(wayl->display) != 0) wl_display_dispatch_pending(wayl->display); wayl_flush(wayl); If the first wl_display_roundtrip() fails, for example because the Wayland socket has been closed, we may get stuck in the while-loop. This happens if the read queue isn’t empty, in which case wl_display_prepare_read() will return -1 and we’ll continue trying to dispatch the pending events forever, never succeeding since the socket is gone. Closes #542
* term: get rid of term->font_scale, use term->scale onlyDaniel Eklöf2021-05-17-1/+3
| | | | | | | | | We only needed term->font_scale to be able to detect scaling factor changes (term->font_scale != term->scale). But, we already have the old scaling factor in all places where term_font_dpi_changed() is called, so let’s pass the old scaling factor as an argument instead.
* wayland: workaround epoll-shim defining the macro closeDaniel Eklöf2021-05-14-1/+1
|
* meson: add xdg-activation-v1.xml conditionallyDaniel Eklöf2021-05-14-0/+16
| | | | | | | | | | 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.
* wayland: set xdg activation token surface to our top-levelDaniel Eklöf2021-05-14-1/+3
|
* xdg-activation: initial support for setting urgency using XDG activationDaniel Eklöf2021-05-14-4/+63
|
* wayland: codespell: pre-empt -> preemptDaniel Eklöf2021-05-11-1/+1
|
* wayland: add comment describing the configure preempt workaroundDaniel Eklöf2021-05-10-1/+26
|
* wayland: {xdg_,}output_*(): free old strings before assigning new onesDaniel Eklöf2021-04-07-0/+7
| | | | | | Defensive programming; output_geometry() etc are typically only called once for an output instance. But let’s ensure we’re not leaking memory if it’s called more than once.
* ime: move preedit state from terminal struct to the seat structDaniel Eklöf2021-03-25-1/+1
| | | | | | | | | | | | | | | | | 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.