aboutsummaryrefslogtreecommitdiff
path: root/wayland.c (follow)
Commit message (Collapse)AuthorAgeLines
* term: use logical DPI+scale factor when scaling fontsDaniel Eklöf2020-03-14-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
* 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
|
* wayland: drop required wl_output interface version from 3 -> 2Daniel Eklöf2020-02-28-1/+1
| | | | We don't need version 3, and mutter 3.34 only implements version 2.
* wayland: resize main surface when enabling CSDs runtimeDaniel Eklöf2020-02-26-1/+11
| | | | | | | | | | When we position CSDs inside the main surface, and CSDs are switched on run-time, we need to force a grid resize, since the actual window content will now be smaller. Alternative solution: call resize with width/height increased, to account for the CSDs. This would increase the window size, but would keep the grid size fixed.
* wayland: track window maximized stateDaniel Eklöf2020-02-26-2/+5
|
* wayland: don't adjust size when CSDs are positioned inside main surfaceDaniel Eklöf2020-02-26-0/+5
|
* wayland: disable debug logsDaniel Eklöf2020-02-26-1/+1
|
* csd: don't draw CSDs in fullscreen modeDaniel Eklöf2020-02-26-42/+46
|
* wayland: decoration configure: no need to force a resize - just update the CSDsDaniel Eklöf2020-02-26-6/+2
|
* wayland: configure: adjust configured size when using CSDsDaniel Eklöf2020-02-26-1/+19
| | | | | | | | | | | | The size (width, height) arguments provided by the compositor in the XDG toplevel configure event *include* the surrounding CSDs. Since our code assumes the size is for the main surface only (and then positions the sub-surfaces *outside* the main surface), adjust the provided size when using CSDs. This ensures our actual window size ends up being what the compositor wants it to be, and it fixes resize-glitches when resizing using CSDs.
* wayland: instantiate sub-surfaces on-demandDaniel Eklöf2020-02-26-30/+50
| | | | | | | | | | | | | | | | | | | While most compositors handle instantiated but not-yet-mapped sub-surfaces correctly, e.g. kwin does not. For example, it will incorrectly offset the main surface both horizontally and vertically with a couple of pixels, leaving two transparent areas at the top and left, between the SSDs and the main surface. Note that a workaround is to position the sub-surfaces inside the main surface while they're unmapped. However, since the surfaces may be larger than the main surface (the CSDs, for examples, always are), this doesn't quite work since kwin, at least, resizes the window to include the sub-surfaces, even when unmapped. So, instead we instantiate all sub-surfaces on demand, when we know where to position them, and when they should be mapped.
* csd: position CSD sub-surfaces *outside* the main windowDaniel Eklöf2020-02-26-3/+3
| | | | | | | | | | | | | | | For now, this behavior is controlled with an ifdef. At least kwin seems very buggy when the decorations are positioned like this (but normally you'd use server-side decorations with kwin anyway). This commit also changes 'use_csd' to be a tri-state variable; when instantiating a window it is set to 'unknown'. If there's no decoration manager available (e.g. weston), we immediately set it to 'yes' (use CSDs). Otherwise, we wait for the decoration manager callback to indicate whether we should use CSDs or not.
* wayland: mark the whole search surface as opaqueDaniel Eklöf2020-02-25-0/+5
|
* wayland: synchronize the CSD surfaces to the main surfaceDaniel Eklöf2020-02-25-0/+1
|
* wayland: default to CSDsDaniel Eklöf2020-02-25-0/+1
| | | | | Only when the compositor implements the XDG decoration manager interface, and it tells us to use server side decorations to we do so.
* wayland: weston does not implement the xdg decoration manager interfaceDaniel Eklöf2020-02-25-6/+10
|
* wayland: xdg_surface_configure(): call wl_surface_commit()Daniel Eklöf2020-02-25-2/+11
| | | | | | | | | | | | It seems kwin expects a wl_surface_commit() for each xdg_surface_ack_configure(). We don't want to commit before we've rendered a resized surface. So, if we *did* change the window size, let the normal rendering path do the surface commit. Only when we did *not* change the window size do we need to explicitly commit the surface in xdg_surface_configure().
* wayland: decoration-configure: call render_resize() to add/remove CSDsDaniel Eklöf2020-02-25-0/+7
| | | | | | Call render_resize_force() when the decoration type changes run-time. This ensures the CSDs are drawn when changing from server -> client side decorations, and removed when going the other way.
* wayland: terminal_from_surface(): use term_surface_kind()Daniel Eklöf2020-02-24-4/+1
|
* csd: wip: something to get started...Daniel Eklöf2020-02-23-3/+28
|
* wayland: output_mode: update PPIDaniel Eklöf2020-02-15-0/+1
| | | | | Since we now use the width/height values from output_mode(), we also need to update the PPI here.
* wayland: debug: make sure state_str is properly NULL terminatedDaniel Eklöf2020-02-15-0/+2
|
* wayland: calculate DPI from physical size, not logical sizeDaniel Eklöf2020-02-15-4/+2
| | | | | | | | xdg_output_handle_logical_size() reports _logical_ output size. That is, it is scaled by the output's scale factor. We want the _actual_ DPI. The _real_ output size is reported by output_mode(), so use that instead.
* wayland: break out scale/resize updating to a new functionDaniel Eklöf2020-02-15-19/+29
| | | | | And call this function once from output_done(), rather than from each output_*() callback.
* term/wayland: use MONOTONIC timersDaniel Eklöf2020-01-10-1/+1
|
* wayland; fixupDaniel Eklöf2020-01-10-0/+1
|
* wayland: just to be sure, check return value of wl_display_read_events()Daniel Eklöf2020-01-10-1/+4
|
* wayland: make wayland socket non-blockingDaniel Eklöf2020-01-10-0/+6
|
* wayland: wayl_flush: re-initialize fd array before each pollDaniel Eklöf2020-01-04-5/+13
|
* wayland: add commentDaniel Eklöf2020-01-04-0/+4
|
* wayland: only call wl_display_prepare_read() if we read any eventsDaniel Eklöf2020-01-04-3/+4
| | | | | | That is, only call it if we have POLLIN. If not, then we never read any events and we still hold the read lock and thus we shouldn't try to acquire it again.
* wayland: use a low priority FDM hook to flush the wayland socketDaniel Eklöf2020-01-04-1/+14
| | | | | | | | This way, we don't have to manually insert flushes in code paths that may execute outside of a wl_display_dispatch_pending(). (Those that execute inside a wl_display_dispatch_pending() are subject to the flush performed at the end of the normal wayland FDM handler).
* render: throttle xcursor updatesDaniel Eklöf2020-01-04-51/+6
| | | | | | | | | | | | | | | | | | | | | | | With a bad behaving client (e.g. 'less' with mouse support enabled), we can end up with a *lot* of xcursor updates (so much, that we flooded the wayland socket before we implemented a blocking wayl_flush()). Since there's little point in updating the cursor more than once per frame interval, use frame callbacks to throttle the updates. This works more or lesslike normal terminal refreshes: render_xcursor_set() stores the last terminal (window) that had (and updated) the cursor. The renderer's FDM hook checks if we have such a pending terminal set, and if so, tries to refresh the cursor. This is done by first checking if we're already waiting for a callback from a previous cursor update, and if so we do nothing; the callback will update the cursor for the next frame. If we're *not* already waiting for a callback, we update the cursor immediately.
* wayland: wl_display_flush() never blocksDaniel Eklöf2020-01-04-3/+44
| | | | | | | | | | | | | | | | | | | Since it doesn't block, we need to detect EAGAIN failures and ensure we actually flush everything. If we don't, we sooner or later end up in a wayland client library call that aborts due to the socket buffer being full. Ideally, we'd simply enable POLLOUT in the FDM. However, we cannot write *anything* to the wayland socket until we've actually managed to send everything. This means enabling POLLOUT in the FDM wont work since we may (*will*) end up trying to write more data to it before we've flushed it. So, add a wrapper function, wayl_flush(), that acts as a blocking variant of wl_display_flush(), by detecting EAGAIN failiures and calling poll() itself, on the wayland socket only, until all data has been sent.
* wayland: window: optimize: set opaque regionDaniel Eklöf2020-01-03-0/+11
| | | | | | | When background alpha is 1.0 (0xffff), i.e. completely opaque, tell the compositor this, via wl_surface_set_opaque_region(). This allows it to optimize drawing of surfaces _behind_ our window.
* wayland: don't use wl_display_dispatch()Daniel Eklöf2020-01-03-5/+27
| | | | | | | | | | | | | | | | | | | | | | wl_display_dispatch() calls poll(), which is unnecessary since we already know the FD is readable. Use the more lower level wl_display_read_events() + wl_display_dispatch_pending(). These require wl_display_prepare_read() to have been called. The idea is to call wl_display_prepare_read() **before** calling poll(). Thus, we do this more or less last in wayl_init(), and at the **end** of the FDM handler. However, having taking this lock also means we no longer can call wl_display_roundtrip() directly (it will hang). So, add a wrapper, wayl_roundtrip(), that cancels the read intent, does the roundtrip, and then re-acquires the read intent.
* wayland: flush after commit new pointer surfaceDaniel Eklöf2020-01-03-0/+1
|
* wayland: configure: resize before changing visual focusDaniel Eklöf2020-01-03-2/+2
| | | | | | | | | | | | | | This hopefully fixes and issue where the visual focus in/out caused a render refresh with the *old* size. This caused the occasional flicker at startup, or when resizing the window. By placing the resize call before the visual focus in/out, we ensure the refresh uses the new size. This is a temporary workaround. The correct solution is to ensure we only call refresh() once.
* render: refresh: ensure window has been configuredDaniel Eklöf2020-01-03-0/+2
|
* render: remove 'refresh' from render_resize()Daniel Eklöf2020-01-03-4/+4
|
* wayland: window: apply all configure changes after acking the eventDaniel Eklöf2020-01-03-22/+19
|
* wayland: remove wayl_terminal_from_xdg_{surface,toplevel}Daniel Eklöf2020-01-03-26/+0
|
* wayland: window: pass window pointer to xdg toplevel callbacksDaniel Eklöf2020-01-03-6/+6
|
* wayland: window: pass window pointer to xdg-surface-listener callbacksDaniel Eklöf2020-01-03-3/+4
|
* wayland: window: pass window pointer to wl-surface callbacksDaniel Eklöf2020-01-03-8/+8
|
* wayland: window now keeps pointer to owning terminal, not waylandDaniel Eklöf2020-01-03-5/+7
|
* render: render_resize(): don't do anything if width or height is 0Daniel Eklöf2020-01-03-2/+1
|
* wayland: fix release buildDaniel Eklöf2020-01-03-2/+4
|
* wayland: debug log state changes in xdg-toplevel-configureDaniel Eklöf2020-01-03-3/+45
|
* wayland: xdg-surface-configure: refresh terminalDaniel Eklöf2020-01-03-1/+29
| | | | | | | | | | | | | | | Any changes done in any of the configure events are ignored before we've ack:ed the configure event. In particular, this means the resize done in xdg-toplevel-configure isn't displayed until the next time we call render_refresh(). Unless we do something ourselves, this can take quite some time, since we're basically need the slave to write something. So, in xdg-surface-configure, *after* having ack:ed the configure event, call render_refresh() to make the changes done in xdg-toplevel-configure visible as soon as possible.
* wayland: render_resize() now takes a 'refresh' argumentDaniel Eklöf2020-01-03-4/+8
|
* wayland: term_visual_focus_{in,out} handles already being focused/defocusedDaniel Eklöf2020-01-03-2/+2
|
* wayland: xdg-toplevel-configure: no need to detect early configure eventsDaniel Eklöf2020-01-03-7/+2
| | | | | | | | We can now lookup terminal instances at all times, making it unnecessary to detect "early" configure events. Note that we still need to prevent a resize from happening when width/height is 0.
* term: term_init() calls wl_display_roundtrip()Daniel Eklöf2020-01-03-2/+0
| | | | | | | | | | | | | Instead of having `wayl_win_init()` call `wl_display_roundtrip()` (which it itself doesn't need), call it from `term_init()`. This allows us to add ourselves (the new terminal instance) to the terminal list in the wayland backend, before triggering the wayland events caused by `wayl_win_init()`. This is turn allows the wayland backend to find/lookup the new terminal when those events occur..
* wayland: xdg-top-level-configure: call term_visual_focus_{in,out}Daniel Eklöf2020-01-02-1/+5
|
* wayland: xdg-toplevel-configure: check for stateless configure callsDaniel Eklöf2020-01-02-8/+11
| | | | | Ignore configure calls without state, instead of checking for width/height == 0.
* wayland: ignore early configure callsDaniel Eklöf2020-01-02-3/+4
| | | | | At this point, not everything has been setup and we crash when trying to convert the surface pointer to a terminal pointer.
* term: add visually focused attribute to terminal structDaniel Eklöf2020-01-02-4/+13
|
* wayland: rename focused/moused to kbd_focus/mouse_focusDaniel Eklöf2020-01-02-2/+2
|
* wayland: warn when presentation timings have been requested but is not supportedDaniel Eklöf2020-01-01-0/+4
|
* wayland: only bind to 'presentation' interface if -p,--presentation-timingsDaniel Eklöf2019-12-31-8/+12
|
* wayland: remove empty lineDaniel Eklöf2019-12-31-1/+0
|
* wayland: make zxdg_output_v1_listener struct constDaniel Eklöf2019-12-31-1/+1
|
* wayland: optionally use the presentation time protocol to measure input lagDaniel Eklöf2019-12-31-0/+28
| | | | | | | | | | | | | | | | | | | This adds a flag, -p,--presentation-timings, that enables input lag measuring using the presentation time Wayland protocol. When enabled, we store a timestamp when we *send* a key to the slave. Then, when we commit a frame for rendering to the compositor, we request presentation feedback. We also store a timestamp for when the frame was committed. The 'presented' callback then looks at the input and commit timestamps, and compares it with the presented timestamp. The delay is logged at INFO when the delay was less than one frame interval, at WARN when it was one frame interval, and at ERR when it was two or more frame intervals. We also update statistic counters that we log when foot is shut down.
* wayland: include more output (monitor) details in the log outputDaniel Eklöf2019-12-05-10/+22
|
* Add missing includesDaniel Eklöf2019-12-01-0/+1
|
* wayland: track current xcursor, and don't update if sameDaniel Eklöf2019-11-30-0/+10
| | | | | | | | | | | | | | | We may have many windows open, which tries to update/change the xcursor at various points. Track which cursor is currently loaded, regardless of which window it was set by. If someone tries to load that very same xcursor again, simply skip it. One example is when we've moused over a window that does *not* have keyboard focus, and then the user clicks, or by some other mean gives that window keyboard focus. In many cases it will then try to set the same cursor again (most of the times, the cursor is the same regardless of keyboard focus, but not always).
* wayland: terminal_from_surface: recognize scrollback search surfacesDaniel Eklöf2019-11-29-1/+5
| | | | | This fixes an assertion when hovering over the input field for scrollback searches.
* wayland: always flush after dispatching messagesDaniel Eklöf2019-11-29-1/+1
| | | | This means we don't have to e.g. roundtrip when setting the cursor.
* terminal: use the 'text' xcursor pointer whenever selection is possibleDaniel Eklöf2019-11-28-30/+41
|
* wayland: calculate output PPI (pixels-per-inch)Daniel Eklöf2019-11-26-3/+9
|
* wayland: change disconnected log type from err -> warnDaniel Eklöf2019-11-23-1/+1
|
* tllist: is now an external "library", so use <> includesDaniel Eklöf2019-11-17-1/+1
|
* wayland: verify xdg-output-manager interface versionDaniel Eklöf2019-11-03-1/+6
|
* wayland: verify server implements the required interface versionsDaniel Eklöf2019-11-03-18/+77
|
* Remove unneeded includeDaniel Eklöf2019-11-03-1/+0
|
* misc: fdm already logs failuresDaniel Eklöf2019-11-02-8/+3
|
* timerfd: read() returns -1 with errno == EAGAIN, not 0Daniel Eklöf2019-11-02-5/+3
| | | | | | When there hasn't been a timeout (or in our case, there was a timeout, but we reset the timer before we got to the read()), read() returns, not 0, but -1 with errno == EAGAIN.
* timerfd: use non-blocking mode, fixes dead lockDaniel Eklöf2019-11-02-1/+6
| | | | | | | | | | | Since we cancel the timers every now and then, there's a (small) chance that one handler cancels a timer that has triggered in the same epoll() iteration. When this happens, read() blocks. Fix by making the timer FDs non-blocking, and simply returning when we read 0 bytes.
* wayland: wayl_win_destroy(): looks like we need another roundtripDaniel Eklöf2019-11-01-0/+2
|
* wayland: wayl_destroy(): destroy any remaining terminalsDaniel Eklöf2019-11-01-0/+9
|
* Don't use non-blocking FDsDaniel Eklöf2019-11-01-14/+1
| | | | | We use epoll() to determine when we can read/write FDs so there's absolutely no need for non-blocking.
* wayland: wayl_win_destroy(): unmap windows before destroyingDaniel Eklöf2019-11-01-0/+21
| | | | | | | | | This will trigger e.d. keyboard_leave() and wl_pointer_leave() events, which ensures there aren't any references to the destroyed window from the global wayland struct. Call wl_display_roundtrip() to trigger those events *before* we destroy the window.
* wayland: wayl_init(): call wl_display_roundtrip() when doneDaniel Eklöf2019-11-01-2/+3
|
* wayland: fdm_del() now closes the FDDaniel Eklöf2019-11-01-4/+3
|