Commit graph

2212 commits

Author SHA1 Message Date
Johan Malm
4fc6bce3ea layer: try to set keyboard focus on map
...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
2024-03-24 23:00:13 +01:00
Johan Malm
f3b68b8fb5 menu: support pipe menus
See labwc-menu(5) for usage.

Co-authored-by: @Consolatis
2024-03-24 21:44:16 +00:00
Consolatis
e5488fefcb common/spawn.c: add spawn_piped() 2024-03-24 21:44:16 +00:00
Johan Malm
0671a3bfd3 menu: move already-on-selected-item check
...menu_process_item_selection() as the previous variant did not work.
2024-03-24 21:44:16 +00:00
Johan Malm
38a60b04d9 menu: minor refactor of menu_configure() 2024-03-24 21:44:16 +00:00
Johan Malm
138979c506 menu: s/menu_open/menu_open_root/
...to be consistent with the 'close' equivalent
2024-03-24 21:44:16 +00:00
Johan Malm
e79bbd3022
labwc-config(5): clarify applicability of element/attribute (#1655)
Co-authored-by: Andrew J. Hesford <ajh@sideband.org>
2024-03-24 21:32:27 +00:00
Consolatis
11b6836a38 CONTRIBUTING.md: add Gentoo overlay maintainer 2024-03-22 21:01:08 +00:00
Johan Malm
70e44afc7a NEWS.md: interim update 2024-03-22 18:19:00 +00:00
SnowNF
fe9af393b4 rcxml: add missing check for calibrationMatrix 2024-03-21 22:07:33 +00:00
SnowNF
91e3dc10e4 rcxml: improve parse calibrationMatrix 2024-03-20 22:52:19 +00:00
SnowNF
0e7c726be5 docs: fix format in calibrationMatrix section 2024-03-20 22:52:19 +00:00
SnowNF
6c8060ce14 docs: fix scdoc build 2024-03-20 22:52:19 +00:00
SnowNF
e311ff6466 docs: add calibrationMatrix section for libinput 2024-03-20 22:52:19 +00:00
SnowNF
fb921ab431 Optimize the code based on the suggestions 2024-03-20 22:52:19 +00:00
SnowNF
bd4d92bad8 libinput: add support for touchscreen set matrix
My android pad emit a strange touch input from libinput, need to rotate it in 270 degree clockwise to fix.
2024-03-20 22:52:19 +00:00
01micko
8b8652e2b3 workspaces.c: fix bug with RTL locales, closes #1633 2024-03-19 22:09:36 +00:00
tokyo4j
a3144cc5ea src/xdg-popup.c: unconstrain popup within usable area 2024-03-19 10:20:03 +01:00
Johan Malm
9d51107166 xwayland: fix segv bug when starting game
...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
2024-03-17 22:28:59 +01:00
Johan Malm
6990ff713b layer: do not focus on-demand clients in commit-handler
...because we should only try to focus them as part of normal input
handling semantics, for example when receiving a cursor-button-press.
2024-03-17 21:18:47 +00:00
Johan Malm
e67e8d6ed0 layer: do not change keyboard-focus in map-handler
If a client wants keyboard-interactivity this will be processed in the
commit handler.

Remove duplicate (and incorrect) requrests for focus.
2024-03-17 21:18:47 +00:00
Johan Malm
cb361fbb55 layer: change focus better on 'none' keyboard-interactivity request
...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).
2024-03-17 21:18:47 +00:00
Johan Malm
06bf71162e cursor: use layer_try_set_focus() on press
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.
2024-03-17 21:18:47 +00:00
Johan Malm
045dd8a378 seat: remove unecessary top/overlay check in seat_set_focus_layer()
Such checks should be made prior to calling the function (which they
are).
2024-03-17 21:18:47 +00:00
Johan Malm
36058a63e2 layer: change logic for giving 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.
2024-03-17 21:18:47 +00:00
John Lindgren
7e419f7584 xwayland: exclude unfocusable views from wlr-foreign-toplevel
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).
2024-03-17 20:26:38 +00:00
John Lindgren
4fa51b950c common: render text buffers with opaque background
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
2024-03-17 19:09:53 +00:00
M A
5a20014f50
NLS: translate "Workspaces" in rcxml.c
Fixes: #1630
2024-03-17 06:23:41 +01:00
Consolatis
631cd5ab28 CI: ensure Void has a font installed
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.
2024-03-16 18:42:47 +01:00
Consolatis
51cdefa93e CI: rewrite smoke test and support LABWC_RUNS env var 2024-03-16 18:42:47 +01:00
Consolatis
fc9cf5c931 src/common/buf.c: enhance the buffer API
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.
2024-03-16 15:45:46 +00:00
droc12345
b0c2ac1a6d
osd: add window-switcher field content types (#1623)
...`workspace`, `state`, `type_short` and `output`.

Example usage:

    <windowSwitcher allWorkspaces="yes">
      <fields>
        <field content="workspace" width="5%" />
        <field content="state" width="3%" />
        <field content="type_short" width="3%" />
        <field content="output" width="9%" />
        <field content="identifier" width="30%" />
        <field content="title" width="50%" />
      </fields>
    </windowSwitcher>
2024-03-16 15:28:37 +00:00
Weblate
901240b321 Translation updates from weblate
Co-authored-by: Hiroaki Yamamoto <hrak1529@gmail.com>
Translate-URL: https://translate.lxqt-project.org/projects/labwc/labwc/ja/
Translation: Labwc/labwc
2024-03-16 14:39:39 +00:00
Weblate
1597d683ca Translation updates from weblate
Co-authored-by: Abdullah Albaroty <albaroty@gmail.com>
Co-authored-by: Hiroaki Yamamoto <hrak1529@gmail.com>
Co-authored-by: Weblate <noreply@weblate.org>
Co-authored-by: alwanasary <baity.jannati@gmail.com>
Translate-URL: https://translate.lxqt-project.org/projects/labwc/labwc/ar/
Translate-URL: https://translate.lxqt-project.org/projects/labwc/labwc/id/
Translate-URL: https://translate.lxqt-project.org/projects/labwc/labwc/ja/
Translation: Labwc/labwc
2024-03-14 20:24:29 +00:00
tokyo4j
b6d576922b IME: support IME popup 2024-03-14 20:11:03 +00:00
Consolatis
53fc8d5e39 CI: add simple runtime test 2024-03-14 00:42:13 +01:00
Andrew J. Hesford
cdac800692 action: allow client-menu to open at mouse cursor 2024-03-13 10:51:50 -04:00
Scarcely There
bfa3a32ae3 session: Don't close a null dir in read_environment_dir
Closes: #1615 [via git-merge-pr]
2024-03-13 10:36:55 -04:00
Andrew J. Hesford
3460d5be98 session: abort process_line early if line contains no key 2024-03-13 11:47:11 +01:00
Johan Malm
5cb3583108 keyboard: use 'us' as fallback for XKB_DEFAULT_LAYOUT
...if keymap cannot be created for the provided XKB_DEFAULT_LAYOUT.

If keymap still cannot be created, exit with a helpful message to avoid
crash that is hard to understand.

Fixes: https://github.com/stefonarch/lxqt-labwc-session/issues/7
2024-03-12 20:59:39 +00:00
Simon Long
1e1e90d0bb
Reload cursor theme and size on reconfigure
Fixes: #1587
2024-03-12 20:53:41 +01:00
Andrew J. Hesford
9e0846ea14 docs/labwc-config.5: fix "environment directory" typo 2024-03-12 07:36:06 -04:00
droc12345
4ecac26548
workspaces: add ability to set prefix when using number argument 2024-03-11 23:19:03 +01:00
Andrew J. Hesford
e837445114 session: process environment.d and allow empty variables
1. All '*.env' files in an 'environment.d' directory alongside each
   potential 'environment' file will be parsed and added to the
   environment.

2. For the purposes of configuration merging, an environment definition
   exists at one level if either the 'environment' file is defined or
   its corresponding 'environment.d' contains any valid '*.env' file.

3. Variable declarations of the form "VARIABLE=", with no following
   value, will be written to the environment as empty strings.
2024-03-11 20:01:14 +00:00
Standreas
52cb643189
docs/labwc-config.5.scd: fix typo 2024-03-11 08:17:52 +01:00
Jens Peters
90823b3350 README.md: add alt-space binding
That one was missing in the default bindings.
2024-03-10 19:49:16 +01:00
Johan Malm
a5fcbfaf72 cursor: process layer subsurfaces in cursor_button_press()
...to give keyboard focus to layer-shell clients if exclusive or on-demand
interactivity is set, so that menu popups can be navigated with the
keyboard. This still only works if the client is in top (or overlay)
layers. Support for bottom and background to be done as a separate patch
set.

Revert 06b19f0 to process layer-shell subsurfaces in
`cursor_button_press()`, but only when their parent layer-shell surface
has keyboard interactivity.

Fix bug in `get_cursor_context()` which resulted in layer-surfaces not
being detected correctly.

Background:

Commit 06b19f0 (issue #1131) disabled processing of layer-shell
subsurfaces in cursor_button_press() because when pressing a task in
Waybar (Gtk panel using layer-shell subsurfaces) the foreign-toplevel
minimize-raise action did not work correctly as the action logic relied on
the recipient window being activated and by clicking on the panel, the
panel itself was both surface-focusd and activated (and thus the window
de-activated).

The un-intended consequence was that by not responding to layer-subsurface
cursor buttons presses, layer-shell clients (such as panels) were not
given keyboard focus if they indeed wanted it by setting exclusive or
on-demand keyboard interactivity.

The good news is that that following @jlindgren90's refactoring (various)
the only place where we call `view_set_actived()` is in
`focus_change_notify()` in `seat.c` and we now only do it for views
(bb8f0bc).

Another side-effect (positive) of 06b19f0 was that a Waybar dnd bug was
fixed (pointer-serial-number validation failure).

Have tested with sfwbar, waybar and tint (test-panel) the following
results:
- Minimize-raise works even when on-demand keyboard interactivity is set
- Keyboard interactivity is given popup-menus (sfwbar and tint) when the
  panels are in the top layer (support for bottom will be as a separate
  patch set)
- Waybar dnd still works (even when hard-coding keyboard-interactivity)

References:
- bb8f0bc960
- 40ce95a68c/src/seat.c (L481-L483)
- 40ce95a68c/src/dnd.c (L24)
- https://github.com/johanmalm/tint

Fixes: #1572
2024-03-09 00:44:19 +01:00
Hiroaki Yamamoto
be37f9a564
Fix various typos across the codebase 2024-03-08 13:59:20 +01:00
Consolatis
60aab98e8d Add optional headless fallback output
This allows configuring a headless fallback output that
is automatically created whenever there is no other output
around. It is destroyed when a new output is discovered.

It can be enabled by setting the environment variable
LABWC_FALLBACK_OUTPUT to the desired output name.

The feature benefits applications like wayvnc the most
as there is always an output available to connect to.

Co-Authored-By: Simon Long <simon@raspberrypi.com>
2024-03-08 13:54:13 +01:00
tokyo4j
e00f7cd6db view: validate move/resize request from clients
Move/resize requests from xwayland views and xdg toplevels should be
ignored when the view is not pressed.

This is relevant for touchpad taps with <tapAndDrag> disabled.

When the user taps the client surface (e.g. chromium and mpv) with the
setting above, libinput sends button press & release signals so quickly
that the compositor receives move/resize request from the client AFTER
the button release signal is processed, so `interactive_finish()` is
never called.
2024-03-07 20:30:50 +00:00