aboutsummaryrefslogtreecommitdiff
path: root/wayland.c (follow)
Commit message (Collapse)AuthorAgeLines
* wayland: {xdg_,}output_*(): free old strings before assigning new onesDaniel Eklöf2021-04-18-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.
* wayland: rename variable ‘main’ to ‘main_surface’Daniel Eklöf2021-02-25-6/+8
| | | | | | Some compilers don’t think we know what we’re doing: ../wayland.c:1554:24: error: ‘main’ is usually a function
* wayland: csd_instantiate(): remove TODODaniel Eklöf2021-02-17-21/+0
| | | | The sub-surfaces are working just fine without the initial commit.
* wayland: drop ‘_surface’ suffix from subsurface struct instancesDaniel Eklöf2021-02-17-13/+13
|
* render-timer: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-14/+5
|
* scrollback-indicator: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-7/+4
|
* search: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-7/+5
|
* csd: use wayl_win_subsurface_new/destroy()Daniel Eklöf2021-02-17-12/+23
|
* url-mode: convert struct wl_url to use wayl_win_subsurface_new()Daniel Eklöf2021-02-17-4/+1
|
* wayland: add wayl_win_subsurface_new() and wayl_win_subsurface_destroy()Daniel Eklöf2021-02-17-0/+47
| | | | | These are utility functions to create a Wayland subsurface associated with the window.
* Merge branch 'refactor-key-bindings'Daniel Eklöf2021-02-08-11/+12
|\
| * key-bindings: refactor: use a single type for all key bindingsDaniel Eklöf2021-02-08-11/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* | misc: when free:ing tll lists, prefer tll_remove() over tll_free()Daniel Eklöf2021-02-08-5/+7
|/ | | | | | | | | | | | | | | | | | | In many places we have the following pattern: tll_foreach(list, it) free(it->item.thing); tll_free(list); Since all tll functions are macros, and thus inlined, and since tll_free in itself expands to a tll_foreach(), the above pattern expands to more native code than necessary. This is somewhat smaller: tll_foreach(list, it) { free(it->item.thing); tll_remove(list, it); }
* urls: initial support for detecting URLs and rendering jump-labelsDaniel Eklöf2021-02-07-0/+8
| | | | The jump labels work, but is currently hardcoded to use xdg-open
* config: free URL bindingsDaniel Eklöf2021-02-07-0/+4
|
* render: don’t center content while doing an interactive resizeDaniel Eklöf2021-01-26-0/+3
|
* render: delay TIOCSWINSZ while doing an interactive resizeDaniel Eklöf2021-01-26-0/+17
| | | | | | | | | | | | | | | | | | | 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: force a resize on the final configure event after an interactive resizeDaniel Eklöf2021-01-26-2/+5
| | | | | | | | This is needed to apply content centering after an interactive resize, as otherwise we’d just ignore the last configure event since the only difference between that event and the next to last event is that the is-resizing bit has been cleared. I.e. the window size is identical to what we already have, and our resize code would thus ignore the event.
* wayland: track is-resizing stateDaniel Eklöf2021-01-26-5/+4
|
* debug: rename assert() to xassert(), to avoid clashing with <assert.h>Craig Barnes2021-01-16-9/+9
|
* wayland: take rotation into account when calculating the logical PPIDaniel Eklöf2021-01-11-0/+20
|
* wayland: log warning when compositor does not implement text-inputDaniel Eklöf2020-12-26-0/+7
|
* input: rework mouse button/motion handlingDaniel Eklöf2020-12-12-0/+2
| | | | | | | | | | | | | | | | | | | Store a list of currently pressed buttons, and which surface they belong to (i.e. which surface that received the press). Then, in motion events (with a button pressed, aka drag operations), send the event to the “original” surface (that received the press). Also send release events to the originating surface. This means a surface receiving a press will always receive a corresponding release. And no one will receive a release event without a corresponding press event. Motion events with a button pressed will *always* use the *first* button that was pressed. I.e. if you press a button, start dragging, and then press another button, we keep generating motion events for the *first* button.
* ime: make IME compile-time optionalDaniel Eklöf2020-12-07-2/+12
|
* ime: render pre-edit textDaniel Eklöf2020-12-07-2/+2
| | | | | | | | | | | | | | This is done by allocating cells for the pre-edit text when receiving the text-input::done() call, and populating them by converting the utf-8 formatted pre-edit text to wchars. We also convert the pre-edit cursor position to cell positions (it can cover multiple cells). When rendering, we simply render the pre-edit cells on-top off the regular grid. While doing so, we also mark the underlying, “real”, cells as dirty, to ensure they are re-rendered when the pre-edit text is modified or removed.
* ime: wip: commit all changes in ‘done()’Daniel Eklöf2020-12-07-0/+2
|
* ime: wip: add text-input object to seatDaniel Eklöf2020-12-07-0/+36
|
* wayland: Use wl_output_release with wl_output v3Kenny Levinsen2020-11-24-4/+9
| | | | | | | | | | | | | wl_output_release, the use of which was recently introduced, is not available until wl_output interface version 3. However, only wl_output version 2 was bound. This lead to protocol errors when a display was disconnected, causing foot to terminate. Instead, only use wl_output_release if wl_output version 3 is provided and bound. Otherwise, just use wl_output_destroy. Closes: https://codeberg.org/dnkl/foot/issues/219
* wayland: preempt render scheduling in ‘configure’ eventsDaniel Eklöf2020-11-10-5/+14
| | | | | | | | | | | | | | | | | | | | | | | | A configure event must be “committed”. In case of resizing, that means rendering a new frame and committing that surface. render_resize() will resize the grid and *schedule* a render refresh. However, if one is already pending, the refresh will take a very (relatively) long time - until the next frame callback is received. This poses a problem when the window is hidden, since in this case, the frame callback *never* comes. This in turn means we fail to commit a new surface in response to the ‘configure’ event. And that means the compositor needs to wait for a transaction timeout before continuing. The end effect is very slow and jerky window resizing when a hidden foot window is being resized. This can happen in tiled compositors, like Sway, where a window can be tabbed (and thus invisible), but still resized when its container is resized. Closes #190
* wayland: use wl_*_release() instead of wl_*_destroy()Daniel Eklöf2020-11-09-7/+9
| | | | This lets the compositor free up internal state.
* wayland: output removed: only call surface_leave() if term is actually mapped on that outputDaniel Eklöf2020-11-06-3/+9
|
* wayland: bind to data-device-manager version 3, for drag-and-drop supportDaniel Eklöf2020-10-26-1/+1
|
* wayland: properly restore window size when being un-tiledDaniel Eklöf2020-10-20-9/+29
| | | | | | | | Bind to xdg-shell version 2 if available, as this enables us to track our window’s ‘tiled’ state in the ‘configure’ events. This in turn allows us to stash the ‘old’ window size when being tiled, to be used again when restoring the window size when un-tiled.
* wayland: don’t instantiate a decoration object when user disabled decorationsDaniel Eklöf2020-10-11-25/+19
| | | | | | | | | | | | | | | An application opts *in* for being compositor-decorated by instantiating a decoration object. This means, even if we request e.g. CSDs, the compositor can choose to use SSDs. By *not* instantiating a decorator object, the compositor *must* not decorate the window for us. So, when the user has set csd.preferred=none, we absolute do not want the compositor to decorate us. Thus, we refrain from instantiating a decoration object.
* conf: csd.preferred can now be set to ‘none’Daniel Eklöf2020-10-10-14/+24
| | | | | | | | | | | When csd.preferred == none, we will request CSDs from the compositor, but internally render as if we are using SSDs. That is, we don’t render any window decorations at all. Note that some compositors may ignore our request to use CSDs, and still render SSDs for us. Closes #163
* wayland: register xdg-output interface on pre-existing output objectsDaniel Eklöf2020-09-04-0/+7
| | | | | | | | | The XDG output manager object may arrive *after* output objects. In this case, we need to register the pre-existing output objects with the XDG output manager. This fixes an issue with some monitors having a DPI value of 0 on Gnome/mutter, which resulted in incorrect font sizes.
* render: render-timer: position sub-surface similar to the scrollback indicatorDaniel Eklöf2020-08-14-1/+0
|
* wayland: global-remove: return after finding a matching seatDaniel Eklöf2020-08-13-0/+1
|
* wayland: global-remove: fix call to pointer_listener.leave()Daniel Eklöf2020-08-13-5/+9
| | | | | Don't call it when we have keyboard focus, call it when we have mouse focus.
* config: wip: add support for modifiers in mouse bindingsDaniel Eklöf2020-08-13-3/+2
| | | | | | | Mouse bindings can now include modifiers. They are specified in pretty much the same way as in keyboard bindings: Control+BTN_LEFT
* config: add tweak.render-timer optionDaniel Eklöf2020-08-13-0/+23
| | | | | | | | | This can be set to 'none' (the default), 'osd', 'log' or 'both'. When 'osd' is enabled, we'll render the frame rendering time to a sub-surface after each frame. When 'log' is enabled, the frame rendering time is logged on stderr.
* Handle allocation failures explicitly in *_init() functionsCraig Barnes2020-08-09-2/+12
|
* Convert most dynamic allocations to use functions from xmalloc.hCraig Barnes2020-08-08-7/+8
|
* Merge branch 'master' into diagonal-dpiDaniel Eklöf2020-07-28-0/+9
|\
| * wayland: add scrollback indicator surface + sub-surface to wl_windowDaniel Eklöf2020-07-26-0/+9
| |
* | wayland: calculate a single, scaled DPI valueDaniel Eklöf2020-07-26-2/+11
|/ | | | | | | | | | | | Previously, we calculated the monitors horizontal and vertical PPI values. For font sizing, we used the vertical PPI value. It seems however, that using the diagonal PPI value, i.e. diagonal_px / diagonal_inch, gives more consistent results. This is still a PPI value, but since it is intended to be used as a FontConfig DPI value, name it 'dpi'.
* wayland: don't assume data-device globals are added before seatsDaniel Eklöf2020-07-16-18/+51
| | | | | | | | | | | | | | When we're handling the initial set of globals, the data-device and primary-selection-device objects may, or may not be registered before the seat(s). We need to handle both cases. When adding a seat, instantiate the data-device and primary-selection-device **if available**. When adding the device objects, instantiate them on **all** currently available seats.
* wayland: configure: do a regular resize instead of a force resizeDaniel Eklöf2020-07-13-2/+6
| | | | | | | | | | | | | The commit log says that was needed to get tiling in GNOME working. However, I don't know *which* extension that was. Force resizing in a configure event means we'll trash a perfectly valid buffer on e.g. 'activated' state changes. So, let's revert this for now, and if this breaks GNOME, let's try to find another solution. If worse comes to worse, we can detect if we're running under GNOME and do a force-resize then, but not on sane compositors.
* wayland: destroy cursor theme when removing pointer capabilityDaniel Eklöf2020-07-10-0/+4
|
* wayland: seat: instantiate pointer surface in capabilities eventDaniel Eklöf2020-07-10-6/+12
| | | | | This way we only instantiate the surface for seats that actually have a pointer.
* wayland: read XCURSOR_{THEME,SIZE} in reload_xcursor themeDaniel Eklöf2020-07-10-27/+15
|
* wayland: globals: destroy: seat: use keyboard/pointer listener interfacesDaniel Eklöf2020-07-09-17/+9
|
* wayland: globals: destroy: handle seats being destroyedDaniel Eklöf2020-07-09-2/+39
|
* wayland: log: be clear that these are the XCRUSOR_* environment variablesDaniel Eklöf2020-07-08-2/+1
|
* xcursor: trigger theme reload in pointer-enter eventDaniel Eklöf2020-07-08-9/+11
| | | | | | | | | | | | | | | | Previously, we triggered a theme reload on output changes. This is completely wrong. We may get a new output with a scale different from the output the pointer is actually on. Now, we store the current scale along with the theme. We then trigger a call to reload the xcursor theme *every* time the pointer enters a surface. When it does, we use the current scale factor of the terminal that owns that surface. If the terminal covers multiple outputs, with different scale factors, we'll use the largest scale factor. This may not be 100% correct. But to fix that, we'd need to track which regions of a surface are mapped on which outputs. Too complicated I say.
* wayland: seat: log keyboard/pointer capabilityDaniel Eklöf2020-07-08-1/+4
|
* multi-seat: re-enable selection support (excluding OSC 52)Daniel Eklöf2020-07-08-0/+8
|
* multi-seat: re-enable scrollback search supportDaniel Eklöf2020-07-08-3/+1
|
* multi-seat: enable xcursor theme support againDaniel Eklöf2020-07-08-79/+43
|
* wip: multi-seat supportDaniel Eklöf2020-07-08-102/+166
| | | | | Compiles and runs, but mouse, clipboard and other things have been disabled.
* wayland: use xdg_output's description if there's no 'model'Daniel Eklöf2020-06-25-3/+7
|
* wayland: force-trigger a resize on 'configured' eventDaniel Eklöf2020-05-12-1/+2
| | | | | | | | | This ensures we _always_ commit a **new** buffer in response to a configured event. This fixes an issue in Gnome where e.g. tiling the window (on the left/right side) only worked if that caused the windows size to change.
* util.h: new header file defining commonly used macrosDaniel Eklöf2020-05-01-4/+1
|
* term: don't enable ptmx FDM callback until Wayland window has been configuredDaniel Eklöf2020-04-30-0/+4
| | | | | | | | | | | | | The way things works right now, we cannot enable the ptmx FDM callback right away. We need to wait for the Wayland window to have been configured. Before the window is configured, we don't have a size, and no grid. Thus, if we try to process ptmx data we'll crash since we have no where to write it to. So, registering the ptmx fd with the FDM is now delayed until we've received the first 'configure' event from Wayland.
* wayland: monitor unplug: call surface_leave() to handle terminal unmappingDaniel Eklöf2020-04-28-14/+7
|
* wayland: handle outputs disappearingDaniel Eklöf2020-04-27-11/+50
| | | | | | | | | That is, deal with monitors being unplugged. At least on Sway 1.4, surfaces are not unmapped before the output is removed. Thus, in addition to free:ing the monitor resources, we also need to update all terminals that are mapped on this output - remove the output from their "mapped on" list.
* wayland: group handle_global() together with handle_global_removed()Daniel Eklöf2020-04-27-131/+131
|
* render: use output's subpixel mode when rasterizing glyphsDaniel Eklöf2020-04-20-0/+2
|
* conf: add app-id config option and --app-id command line optionDaniel Eklöf2020-04-01-2/+2
|
* search: replace hard-coded key bindings with "user configurable" onesDaniel Eklöf2020-03-18-2/+2
| | | | | | | | They aren't really user configurable. At least not yet. However, with this, we now handle raw key codes just like the normal key bindings. Meaning, e.g. ctrl+g, ctrl+a, ctrl+e etc now works while searching with e.g. a russian layout.
* input: bind key bindings to raw key codes tooDaniel Eklöf2020-03-18-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | Before, when looking for a matching user key binding, we only matched *symbols*. This means that the physical keys that generate a specific key binding is layout dependent. What's worse, it may not even be possible to generate the key binding at all. Russian is one such layout, where all the "normal" (us) symbols are replaced. By using raw key codes, we can get around this - the key code has a direct mapping to the physical key. However, matching raw key codes **only** doesn't always make sense either. For now, match **both** symbols _and_ key codes. Symbols take precedence. TODO: we might have to make this configurable _per binding_. Note: 'search' mode still uses mostly hardcoded shortcuts that still have this problem (i.e. ctrl+g doesn't work with a russian layout).
* wayland: add FDs to FDM as soon as the FDs are readyDaniel Eklöf2020-03-15-6/+6
|
* wayland: store display FD in wayland structDaniel Eklöf2020-03-15-6/+6
| | | | | | | | This way we: * Don't have to call wl_display_get_fd() all the time * No longer call fdm_del_no_close() even though the FD hasn't been added to the FDM.
* Merge branch 'scale-fonts-using-logical-dpi-plus-scale-factor'Daniel Eklöf2020-03-13-14/+25
|\
| * term: use logical DPI+scale factor when scaling fontsDaniel Eklöf2020-03-11-14/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes an issue where the fonts were rendered too small when the output had fractional scaling. For integral scaling, using the logical (scaled) DPI multiplied with the scaling factor results in the same final DPI value as if we had used the physical DPI. But for fractional scaling, this works around the fact that the compositor downscales the surface after we've rendered it. Closes #5
* | Merge branch 'master' into bindingsDaniel Eklöf2020-03-10-1/+0
|\|
| * wayland: remove empty lineDaniel Eklöf2020-03-10-1/+0
| |
* | Merge branch 'master' into bindingsDaniel Eklöf2020-03-09-8/+9
|\|
| * wayland: make a missing presentation time interface an errorDaniel Eklöf2020-03-09-3/+4
| | | | | | | | | | If the user wanted to do presentation timing, and the interface isn't there, then this is an error.
| * wayland: register FDM hook early, to avoid unregister errors when failingDaniel Eklöf2020-03-09-5/+5
| |
* | wayland: free 'search' key bindings on destroyDaniel Eklöf2020-03-08-0/+1
| |
* | input: convert the rest of the normal key bindings to configurable bindingsDaniel Eklöf2020-03-08-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New actions defined and implemented: * scrollback up/down * font size up/down/reset * spawn terminal Break out key combo parsing to a new function, parse_key_binding_for_action(). This function parses a string containing one or more space separated key combo definitions on the form (mod1+mod2+...+key), where key is a XKB key name (e.g. KP_Add). Convert all hardcoded key bindings to configuration based bindings. These still cannot actually be configured by the user, but at least lives in the conf struct.
* | wip: initial framework for dealing with key/mouse bindings in different modesDaniel Eklöf2020-03-08-0/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds initial support for defining key and mouse bindings that are applied in different terminal modes/states. For example, there are two arrays dealing with key and mouse bindings in the "normal" mode. Most bindings will go here. There's also an array for "search" mode. These bindings will be used when the user has started a scrollback search. In the future, there may be a model selection mode as well. Or maybe "search" and "modal selection" will be combined into a single "keyboard" mode. We'll see. Since the keyboard bindings depend on the current XKB keymap, translation from the user specified key combination string cannot be done when loading the configuration, but must be done when we've received a keymap from the wayland server. We should explore if it's possible to load some kind of default keymap just to be able to verify the validity of the key combination strings at configuration load time, to be able to reject the configuration at startup. A couple of key bindings have been added as proof of concept. Mouse bindings aren't handled at all yet, and is likely to be re-written. For example, we can probably translate the configuration strings at configuration load time.
* wayland: remove debug logsDaniel Eklöf2020-03-06-4/+0
|
* wayland: log: say 'requesting' instead of 'referring' client/server decorationsDaniel Eklöf2020-03-06-1/+1
|
* wayland: set window geometry to exclude the invisible CSD bordersDaniel Eklöf2020-03-03-53/+8
| | | | | | | | | | | | | But it *does* include the title bar. This simplifies the 'adjustment' needed to be done to the configured window size. It also fixes a number of issues: * the compositor will now properly snap the window to screen edges (before, there was an empty space between the edge and the window - the CSD border). * This also removes the need for the mutter 'commit' workaround. We must be doing something right now.
* wayland: don't destroy keyboard/pointer if they haven't been removedDaniel Eklöf2020-03-03-14/+22
| | | | | | | | | | When the seat capabilities change, we used to destroy all pointers and keyboards, and then re-creating them as necessary. This caused a crash on mutter - probably because we removed a keyboard device the compositor had already sent an event for (or was about to). Now, we only destroy and create devices when it's needed.
* csd: initial implementation of minimize/maximize/close buttonsDaniel Eklöf2020-03-02-1/+5
|
* wayland: log whether CSDs or SSDs are used at info level, not debugDaniel Eklöf2020-03-02-2/+2
|
* config: make CSD user configurableDaniel Eklöf2020-03-02-15/+20
| | | | | | | | | | | | | | The user can now configure the following: * Whether to prefer CSDs or SSDs. But note that this is only a hint to the compositor - it may deny our request. Furthermore, not all compositors implement the decoration manager protocol, meaning CSDs will be used regardless of the user configuration (GNOME/mutter being the most prominent one). * Title bar size and color, including transparency * Border size and color, including transparency Also drop support for rendering the CSDs inside the main surface.
* wayland: always update window->is_fullscreen, not just when using CSDsDaniel Eklöf2020-02-29-1/+1
|
* wayland: don't resize when we're not mapped anywhereDaniel Eklöf2020-02-29-0/+3
| | | | | | | | | | | | | | | | | | | | | Normally, we resize and update the font's DPI whenever our window enters or leaves an output. This is since a change in the outputs we're mapped on means the scale factor to use, or the DPI to use for the fonts may have changed. However, a special case is when we're removed from the last output. This should only happen at shutdown, when we're un-mapping ourselves. In this case, we typically don't have a access to e.g. the PTMX fd (often, the reason we're shutting down is because the client exited). This resulted in (harmless) error messages when emitting the TIOCSWINSZ event. Since we're shutting down anyway, we can simply skip the resize and everything. This gets rid of the error message, and also means we're shutting down faster.
* input: csd: add a small delay before initiating a moveDaniel Eklöf2020-02-29-0/+4
| | | | | This ensures the user has time to double-click to toggle the maximized state.
* wayland: remove all usages of wayl_terminal_from_surface()Daniel Eklöf2020-02-29-13/+0
| | | | Use the 'user data' pointer from the wayland surface instead.
* wayland: store pointer to window instance in all surfacesDaniel Eklöf2020-02-29-0/+1
|
* wayland: configure: work around GNOME/mutter weirdnessDaniel Eklöf2020-02-28-4/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | When resizing the window under mutter, mutter seems to expect a configure ack *and* a surface commit *right* away, or things get out of sync. Unlike kwin, which is requires a commit for each configure ack, but is fine with having the commit arrive later (after we've rendered it), mutter is not. I even tried delaying the configure ack until just before the commit, but still no go. So for now, detect when we're running under mutter and always do a surface commit right away. This can *not* be done on any other compositor as it breaks the CSD and main surface synchronization; we've resized the CSDs, but not the main surface. I.e. this *should* not work, but for some reason is the *only* way to make things work on mutter. Interestingly, doing it any other way on mutter causes visual glitches; window jumping around when resizing, or de-synchronized CSDs/main surface.
* wayland: fix window size adjustment for CSDs placed outside main surfaceDaniel Eklöf2020-02-28-10/+18
| | | | | | | * Do this both in XDG configure, and when the decoration manager switches between CSDs/SSDs at run-time. * Exclude CSD borders when we're maximized
* wayland: warn when compositor doesn't implement the decoration manager interfaceDaniel Eklöf2020-02-28-0/+1
|
* wayland: request server side decorationsDaniel Eklöf2020-02-28-2/+0
|