This fixes an issue detected by the static analyzer.
Rather than setting up the new popup as usual return
a wayland error to the client and destroy the popup.
This fixes an issue detected by the static analyzer.
It currently is not a real bug but it could become
one in the future if `add_toggled_icon()` is called
before `add_scene_button()`.
Rather than having `add_toggled_icon()` go through
the list, find the root button and then fetch its
node descriptor just supply the button as argument.
Fill with the background color first only if the background color is
opaque. This is necessary for subpixel rendering to work properly (it
does not work on top of transparency).
However, if the background color is not opaque, leave the buffer
unfilled (completely transparent) since the background is already
rendered by the scene element underneath. In this case we have to
disable subpixel rendering.
v2: use 0.999 alpha cutoff and fix CodeStyleCheck
Fixes: (the rest of) #1684
Add ability to set width with percentage of monitor instead of just pixels.
With this the OSD sizes itself properly on both my 4k and 2k monitors.
example: 50% or 75% instead of 600, max 100%
wlr_scene_rects expect their color to be pre-multiplied
while cairo_set_source_rgba() expects them to not be
pre-multiplied. With this patch we now use premultiplied
colors internally by default and then reverse it when
setting cairo colors.
This ensures the titlebar uses a consistent color in case
it was defined with some transparency by the user.
Fixes: #1684
...where dnd does not finish properly on cursor-button-release if there
is no surface under the cursor such as on the desktop when no background
client is running.
Written-by: @tokyo4j
Fixes: #1673
This fixes that, when a CSD window is dragged into below waybar and the cursor
button is released, the cursor focus is moved from the CSD window to waybar and
a release event is sent to waybar, not original CSD window.
...and unify region overlay and snap-to-edge overlay into overlay.c.
Snap-to-edge overlay is delayed for 500ms to prevent flickering when
the view is dragged from an output to another (demo in discussion labwc#1613).
This also fixes a bug that region overlay is not shown when a modifier
key is re-pressed.
...because click on different parts of a client should not be
interpreted as a double click.
Previously only cursor-button and view were validated to be the same
between clicks. This resulted in, for example a click on the client
surface itself quickly followed by a click on the SSD titlebar being
interpreted as a double-click on the titlebar.
Fixes: #1657
...for the following reasons:
1. We interpret 'normal input-focus semantics' for clients with on-demand
keyboard interactivity to means that a surface receives input focus on
cursor-button-press AND on map (the latter previously missing), just
like a normal window would. In this regard, we do not differentiate
between layers.
2. Most layer-surfaces set the keyboard interactivity at a similar time to
their first (and normally only) map, so the absence of an explicit
attempt to focus on map does not make a difference. However, for a
long-running layer-shell client (such as lxqt-runner) which sets the
interactivity on launch and then maps/unmaps many times throughout its
lifetime, a specific focus-attempt is required on map to avoid the
client itself having to keep resetting its interactivity to grab the
keyboard on map.
3. Compositors like sway and river process focus (for clients with
keyboard-interactivity) in their map-handlers, so this makes for a
common approach.
Fixes: #1653
...for example `Fall Guys`. It is believed to be caused by setting
override-redirect on an xwayland-surface with a child window, thus
breaking the way root-toplevels are obtained.
```
(threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0)
at pthread_kill.c:44
at pthread_kill.c:78
(fmt=0x7739d9f9bb68 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x5a76573f9222 "root", file=file@entry=0x5a76573f9606 "../labwc/src/view.c", line=line@entry=2013, function=function@entry=0x5a7657400320 <__PRETTY_FUNCTION__.14> "view_move_to_front") at assert.c:94
(assertion=assertion@entry=0x5a76573f9222 "root", file=file@entry=0x5a76573f9606 "../labwc/src/view.c", line=line@entry=2013, function=function@entry=0x5a7657400320 <__PRETTY_FUNCTION__.14> "view_move_to_front") at assert.c:103
at ../labwc/src/view.c:2013
at ../labwc/src/view-impl-common.c:30
at ../labwc/src/xwayland.c:677
at ../wayland-1.22.0/src/wayland-server.c:2241
(signal=signal@entry=0x5a7659025160, data=data@entry=0x5a7659024e90)
at ../wayland-1.22.0/src/wayland-server.c:2241
at ../subprojects/wlroots/types/wlr_compositor.c:493
(cif=cif@entry=0x7ffc74d32530, fn=<optimized out>, rvalue=<optimized out>, avalue=<optimized out>, closure=closure@entry=0x0) at ../src/x86/ffi64.c:673
(cif=cif@entry=0x7ffc74d32530, fn=<optimized out>, rvalue=rvalue@entry=0x0, avalue=avalue@entry=0x7ffc74d32600) at ../src/x86/ffi64.c:710
(closure=closure@entry=0x5a7658f5adc0, target=<optimized out>,
target@entry=0x5a7659025240, opcode=opcode@entry=6, data=<optimized out>,
data@entry=0x5a7658609820, flags=2) at ../wayland-1.22.0/src/connection.c:1025
(fd=<optimized out>, mask=<optimized out>, data=<optimized out>)
at ../wayland-1.22.0/src/wayland-server.c:438
(loop=0x5a7657816e60, timeout=timeout@entry=-1)
at ../wayland-1.22.0/src/event-loop.c:1027
at ../wayland-1.22.0/src/wayland-server.c:1493
at ../labwc/src/main.c:179
```
Reported-by: @kode54
...and on unmap.
Add `try_to_focus_next_layer_or_toplevel()` which does the following
(in order of precedence):
- Give focus to last added overlay/top layer-shell client with exclusive
interactivity on the output nearest the pointer (normally the one where
the users is currently working). The reason for not considering clients
on all outputs is that giving focus to a client on another output may be
confusing to the user.
- Give focus to topmost toplevel if one exists (this was done previously
anyway).
This means that the logic described in 2ff026b will be used when a
layer-surface is pressed on with a cursor button. For example, a surface
with on-demand keyboard interactivity will not steal focus from a client
with exclusive keyboard interactivity.
Use the following logic:
- Exclusive: Grant regardless of layer (previously it was only given if
in top or overlay layers) AND grant if in the same or higher layer
(nearer overlay) compared with other clients with exclusive
interactivity.
- On-demand: Grant only if no other layer-shell client has exclusive
keyboard interactivity. Previously it was treated the same as
exclusive.
- None: Unset focus if the commit associated with the 'none' came from
the currently focused layer. Previously it was just unset regardless.
These views (notifications, floating toolbars, etc.) should not be
shown in taskbars/docks/etc. (which are the stated use-case of the
wlr-foreign-toplevel protocol).
After a roundabout discussion[1] with wlroots devs, it's become apparent
that subpixel text rendering (a.k.a. "ClearType") does not work properly
when rendering over a transparent background, as labwc currently does.
Basically it comes down to the fact that the color of semi-transparent
pixels (which is adjusted redder or bluer to compensate for RGB subpixel
alignment) depends somewhat on background color. When rendering over
transparency, the text engine doesn't know the intended background color
and can't adjust the pixel colors correctly.
With Pango/Cairo, the end result can range from grayscale rendering (no
subpixel rendering at all) to wrong/oversaturated colors (for example,
bright pink pixels when rendering white text on blue background).
This change solves the issue by first filling the text buffer with an
opaque background color before rendering the text over it. Currently,
this is easy since the background is always a solid color. It may be a
little more complex (but doable) if we implement gradients in future.
Note that GTK 4 (and to some degree, recent versions of Microsoft
Windows) avoid this issue by disabling subpixel rendering altogether. I
would much prefer that labwc NOT do this -- it results in noticeably
blurrier text on non-retina LCD screens, which are still common.
[1] https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3822
Otherwise the runtime test randomly fails due to
strange pango behavior. This is a workaround for
the issue and not a permanent fix.
A full investigation into pango internals is required
to figure out why `pango_layout_get_extents()` returns
invalid data after the first call. See PR #1627 for a
testcase.
There is at least one user of the buffer API that reuse a single
buffer by just resetting `buf.len` to `0`. This works as long as
the new user of the buffer actually adds something to the buffer.
However, if we don't add anything but still provide `buf.buf` to
a consumer, the old content will be re-used.
This patch thus adds two new clearing variants to the buffer API:
- `buf_clear()` which doesn't reset the internal allocations
- `buf_reset()` which does free the internal allocations
Additionally, this patch makes `buffer_add_char()` public which
allows adding single characters to an existing buffer. This will
be used in a future PR which implements custom format strings for
the OSD.