Commit graph

2805 commits

Author SHA1 Message Date
tokyo4j
773bdc3823 osd: prevent preview outlines to be above OSD
86c3597 raised server->menu_tree above layer shell surfaces, but it caused
preview outlines for window switcher to be placed above the OSD because
the preview outlines are placed just above server->menu_tree.

So this commit fixes it by placing server->osd_tree above server->menu.
This also prevents layer-shell surfaces from covering the OSD.

Before (higher-first):
- preview outlines (just above menu)
- menu
- layer-shell (top/overlay/popup)
- osd

After (higher-first):
- osd
- preview outlines (just above menu)
- menu
- layer-shell (top/overlay/popup)
2025-01-06 21:02:22 +00:00
Johan Malm
8d9bd2d747 theme: use 'labwc' directory
as well as 'openbox-3', for example: /usr/share/themes/foo/labwc/themerc

Give 'labwc' higher precedence than 'openbox-3' if both exist.

For several reasons not all themes designed for labwc render well on
Openbox:

1. Labwc support some features like SVG/PNG icons and #rrggbbaa color
   definitions which Openbox does not.

2. Openbox generally defaults to black/white colors and will not render
   themes accurate without certain options specified in themerc. For
   example, in Openbox the following will just render as black:

       window.active.title.bg.color: #589bda

   ...because Openbox defaults the texture to "Gradient Vertical" and
   therefore either needs:

      window.active.title.bg.colorTo: #3c7cb7

   ...or remove 'Gradient' from the bg definition and just use something
   like:

      window.active.title.bg: Flat Border

Whilst none of this is a problem when using labwc, it causes problems for
setups with both Openbox and labwc because themes designed for labwc only
will now show up in obconf, lxappearance, etc causing confusion for users.
2025-01-06 20:15:26 +00:00
tokyo4j
cacf11fc90 set: prevent possible segfault when keycode 0 is released
lab_set_remove() didn't expect keycode 0 as the first branch
(set->values[i] == value) was taken over and over.
2025-01-06 14:50:14 +09:00
Consolatis
b58f8dab21 scaled_{img,scene}_buffer: add architecture graph 2025-01-06 04:39:09 +01:00
Consolatis
5d287ebda4 img: rename lab_img_cache to lab_img_data 2025-01-06 04:39:09 +01:00
tokyo4j
7364de2ac5 img: don't abort with non-ARGB32 PNG files
Cairo surfaces loaded with cairo_image_surface_create_from_png() are not
always ARGB32 format.
2025-01-06 06:38:35 +09:00
tokyo4j
a1e2e19a8f src/server.c: delete a comment which was missed to erase 2025-01-04 17:42:44 +09:00
tokyo4j
6feb6589ea img: apply padding around window icon only horizontally
16dbdc64 changed the padding around the app icon in the titlebar to be
applied both vertically and horizontally rather than only horizontally
because it was more natural from a developer's perspective, but some users
complained about the smaller icons in certain configurations.

So let's undo the change in 16dbdc64 and apply the icon padding only
horizontally for now.

We can add configurations for the icon padding (or icon size independent
from window.button.{width,height}?) later.
2025-01-04 08:32:02 +00:00
tokyo4j
70fb713874 img: fix UAF on Reconfigure by refcounting
Before this commit, there was a use-after-free bug on Reconfigure:
- theme_finish() destroys lab_imgs for titlebar icons
- For some reason, undecorate() calls _create_buffer() in
  scaled-img-buffer.c, which calls img_render() on a destroyed lab_img.

So in this commit, the lifetime of lab_img is expanded to when the
scaled_img_buffers referencing it are all destroyed. This is achieved by
calling lab_img_copy() when setting a lab_img to scaled_img_buffer and
calling lab_img_destroy() when clearing a lab_img.

Now that scaled_img_buffer.img are always different, lab_img_equal() is
added to compare the content of scaled_img_buffer.img.
2025-01-04 09:10:02 +01:00
tokyo4j
90a8c3e793 img: remove "theme" member from lab_img
lab_img.theme member was referenced by "modifier" functions when drawing a
hover effect on button buffers or rounding the button buffer for corner
buttons, but this can be prone to use-after-free and was not very clean
because theme and lab_img were referencing each other.

Instead, let's just reference rc.theme in the modifier functions and
remove theme from lab_img.
2025-01-04 09:10:02 +01:00
Johan Malm
956b271f9b menu: support pipemenu with the toplevel <menu> element
For example:

    <?xml version="1.0"?>
    <openbox_menu>
      <menu id="root-menu" label="" execute="obmenu-generator"/>
    </openbox_menu>

Fixes: #2238

Co-Authored-By: @Consolatis
2025-01-03 04:41:25 +01:00
tokyo4j
a93eb84335 Add default Alt-Shift-Tab keybind for PreviousWindow 2025-01-03 10:51:26 +09:00
tokyo4j
713b1d8a13 osd: make window switcher more Openbox-like in terms of key precessing
Before this commit, keystrokes were interpreted based on following
hard-coded rules while the window switcher is active:

  1. Up/Left arrow keys cycle the window forward.
  2. Down/Right arrow keys cycle the window backward.
  3. Other keystrokes cycle the window in the initial direction specified
     by NextWindow/PreviousWindow actions. But while Shift key is pressed,
     the direction is inverted.

...and keybind actions were never executed.

However, this lead to a counter-intuitive behavior for new, especially
pre-Openbox users. For example, in the following keybinds, after the user
activates the window switcher with Super+n, Super+p cycles the window
_forward_:

  <keybind key="W-n">
    <action name="NextWindow" />
  </keybind>
  <keybind key="W-p">
    <action name="PreviousWindow" />
  </keybind>

This is because the key 'n' is recognized just as a normal key in the
third hard-coded rule.

So this commit changes the rules to be more Openbox-like:

  1. Up/Left arrow keys cycles the window forward.
  2. Down/Right arrow keys cycles the window backward.
  3. Other keystrokes are matched against keybinds and execute their
     actions. If they include NextWindow/PreviousWindow action, it cycles
     the selected window forward/backward even while the window switcher
     is active.
2025-01-03 10:51:26 +09:00
Weblate
1043cbcca9 Translation updates from weblate
Co-authored-by: NorwayFun <temuri.doghonadze@gmail.com>
Translate-URL: https://translate.lxqt-project.org/projects/labwc/labwc/ka/
Translation: Labwc/labwc
2025-01-01 21:35:11 +00:00
John Lindgren
398ca6f267 output: ignore wlr_output_state.mode/custom_mode except for client request
The wlr_output_state passed to the new_output signal sometimes has a
non-preferred mode set, which we were ignoring before 03be489eb9.
Ignore it again to prevent the wrong mode from being set.
2025-01-01 16:09:27 +00:00
John Lindgren
96b2ad569d output: add debugging output to output_test_mode() 2025-01-01 16:09:27 +00:00
Consolatis
ae8012a580 CI: add non-feature (svg, libsfdo, xwayland) build for arch 2024-12-31 16:40:19 +00:00
John Lindgren
dc826fef81 rcxml: add core.autoEnableOutputs option
Currently, labwc automatically enables outputs at startup and when new
outputs are connected. Make this behavior optional (but still enabled by
default).

With autoEnableOutputs disabled, tools such as kanshi can be used to
give finer-grained control of which outputs are enabled and when.
2024-12-31 16:32:42 +00:00
John Lindgren
49eeee387b output: handle outputs that are enabled but not yet added
output_config_apply() currently assumes that any enabled outputs have
already been added to the wlr_output_layout. However, at startup,
wlroots will report that outputs are enabled if they were previously in
use by e.g. the Linux console - but they are not yet in the layout.

output_config_apply() never encountered this case before now because the
initial modeset was performed by another code path, but now with the new
autoEnableOutputs option (next commit), it needs to be able to handle
the initial modeset as well.
2024-12-31 16:32:42 +00:00
John Lindgren
03be489eb9 output: auto-select mode when enabling output by client request
If e.g. kanshi requests us to enable an output but does not specify the
mode, and the output has not previously been modeset, then the width +
height + refresh rate will all be zero. In this case, we should select
the best mode just as when auto-configuring a new output.

We need to do the mode auto-selection in both the test & commit stages
for consistency, so factor out a new output_test_auto() function to help
with this.

Remove a guard against a refresh rate of zero, which was a workaround
for wlroots 0.17 and is no longer needed -- it is incompatible with mode
auto-selection since the refresh rate is zero in that case.
2024-12-31 16:32:42 +00:00
Johan Malm
a5973c3b48 keyboard: do not set numlock by default
Only force on|off if users specifically requests it in the config file.

Related-to: #2463
2024-12-31 16:23:47 +00:00
Johan Malm
6457cbccda Make enum three_state public 2024-12-31 16:23:47 +00:00
Consolatis
663f913ee4 keyboard: cancel keybind_repeat on reconfigure
Currently we may end up in an endless loop of Reconfigure requests
if the Reconfigure action was called by a keybind. If the reconfigure
takes too long (which may happen on slow systems with libsfdo full
debug logging for example) the reconfigure might be triggered again
and again.

To prevent that, simply cancel all keybind_repeat timers on reconfigure.
2024-12-31 19:53:34 +09:00
tokyo4j
7a6ecca804 Remove cruft related to window switcher and keyboard focus
This commit cleans up the comments and cruft from e45fe08.

Background:

- With e45fe08, the keyboard focus is always moved to the switched window
  on finishing window switcher, even with <focus followMouse="yes">.
  Since followMouseRequiresMovement was not implemented at that time
  (behaved like it was always "no"), e45fe08 was necessary to allow users
  users who use followMouse="yes" to move the keyboard focus with window
  switcher.
- 9a9e20d added followMouseRequiresMovement, but it kept the behavior
  described above even with followMouse="yes" and
  followMouseRequiresMovement="no".
- 398b80b accidentally invalidated e45fe08, which means the keyboard focus
  is now always moved to the window below the cursor on finishing window
  switcher with followMouse="yes" and followMouseRequiresMovement="no".

Although the invalidation was a accident, I think always setting the
keyboard focus on the window below the cursor is what users expect from
followMouse="yes" and followMouseRequiresMovement="no".
2024-12-31 06:59:25 +01:00
Johan Malm
304a94e716 desktop-entry: demote libsfdo error-logging
...to WLR_INFO to avoid logging issues with .desktop files as errors, for
example:

    [sfdo-desktop] 1:1: Name is unset
    [sfdo-desktop] Failed to load /usr/share/applications/lxqt-panel.desktop
    [sfdo-desktop] 1:1: Exec is unset while DBusActivatable is unset or false
    [sfdo-desktop] Failed to load /usr/share/applications/qemu.desktop

Also make libsfdo debug/info logging depend on environment variable
LABWC_DEBUG_LIBSFDO being set to avoid disproportionately verbose logging
by default for one particular sub-system.

Add an 'ENVIRONMENT VARIABLES' section to labwc(1) to describe the above
as well as other hitherto undocumented env vars with prefix LABWC_DEBUG_.
2024-12-30 23:39:02 +01:00
Consolatis
cd3d88974c src/debug.c: fix inverted string_null_or_empty() check
Reported-By: Domo via IRC
2024-12-30 22:34:30 +00:00
tokyo4j
a98b535362 osd: make desktop_cycle_view() private in osd.c 2024-12-30 18:07:45 +09:00
tokyo4j
6fe688b3e4 osd: refactor to not write server->osd_state outside osd.c 2024-12-30 18:07:45 +09:00
tokyo4j
8f8e734405 src/seat.c: small refactor
The condition server->input_mode != LAB_INPUT_STATE_PASSTHROUGH is enough
to catch when window switcher is active.
2024-12-30 18:07:45 +09:00
tokyo4j
0ef9906557 src/osd.c: make osd_preview_restore() private in osd.c 2024-12-30 18:07:45 +09:00
tokyo4j
1e0a7e2562 src/desktop.c: remove osd_review_restore() call in desktop_cycle_view()
It was a cruft from days when we used to walk scene-nodes to get the next
view to cycle.
2024-12-30 18:07:45 +09:00
Johan Malm
bb982dc0af keyboard: set numlock to off by default
...to avoid surprises on Acer Aspire One laptops where the numeric
keyboard does not physically exist but "overlaps" the qwerty keyboard.

Reported-by: staryvyr on IRC

Note: We do not like changing defaults, but feel that there is a good
reason for this one.
2024-12-29 21:34:41 +00:00
Consolatis
968dc89277 wlr-foreign-toplevel: send initial pre-map state
Fixes: #2460
2024-12-29 13:08:54 +00:00
Consolatis
c772224a54 project wide: adapt to new non-NULL value of view_get_string_prop() 2024-12-29 13:06:30 +00:00
Johan Malm
023427b4f4 view: fix NULL string_prop crash
...when app_id is NULL.

Make sure view_get_string_prop() never returns NULL because it is so easy
to misuse. Same for the respective xwayland/xdg impl methods in case
anyone decides to (incorrectly) call them directly in future.

Fixes: #2453
2024-12-29 13:06:30 +00:00
tokyo4j
bad788ccdd Clear keyboard/pointer focus on Move/Resize, window switcher and menu
The previous revert fixed the problem of stuck modifier keys with
keybinds in Blender, but made Firefox show its menu bar with Alt-*
keybinds. This is fundamentally inevitable due to the limitation of
wayland protocol, but at least for the default Alt-Tab keybind for
window switcher, we can mitigate this problem by clearing the keyboard
focus when the window switcher is activated. This is what KWin does, and
we decided to follow that.

So in this commit, keyboard and pointer focus are temporarily cleared
while Move/Resize, window switcher and menu interactions and restored
after them. We slightly deviate from KWin as KWin doesn't clear the
keyboard focus while Move/Resize, but it solves our existing problem
that Firefox shows its menu bar after dragging it with default Alt-Drag
mousebind, and this is what Mutter does.

We considered other solutions, but they don't work well:
1. Send wl_keyboard.{leave,enter} every time keybinds/mousebinds are
   triggered. This solves the Firefox's menu bar problem, but that
   sounds like a workaround and sending unnecessary events every time is
   not desirable.
2. Send release events for both modifiers and keys even when they are
   bound to keybinds. This is what Mutter is doing, but it looks like an
   implementation issue and violates wayland protocol.
2024-12-29 16:27:34 +09:00
tokyo4j
bd7a533dd6 Revert "keyboard: include pressed modifiers in bound set"
This reverts commit 98bf316ee6.
2024-12-29 16:27:34 +09:00
tokyo4j
5bcc03db05 Revert "keyboard: add window rule to send release-events (#2377)"
This reverts commit 2f8afb2376.
2024-12-29 16:27:34 +09:00
tokyo4j
adccc3ec84 img: fix scaling for rendering large image in non-square rectangle
16dbdc6 caused a regression that the vscode icon (1024x1024) in the
titlebar is cut off with following configuraion:

  window.button.width: 26
  window.button.height: 16
2024-12-28 23:06:38 +00:00
tokyo4j
028e24dc13 src/output.c: remove output_usable_area_scaled() 2024-12-28 23:03:34 +00:00
tokyo4j
66a3beb98b Don't open menu or start window switching while other server interaction
This should make the transition of the server state more predictable and
prevent potential bugs.
2024-12-28 21:28:22 +00:00
tokyo4j
5d3ce3e190 Check input_mode to see whether window switcher is active or not
...rather than "if (server->osd_state.cycle_view){..}".
2024-12-28 21:28:22 +00:00
tokyo4j
398b80b26f Add LAB_INPUT_STATE_WINDOW_SWITCHER 2024-12-28 21:28:22 +00:00
Orfeas
1550eb9c26 action: add WarpCursor action 2024-12-26 10:27:02 +00:00
Johan Malm
af978c7ad7 theme: demote padding.height warning
...from WLR_ERROR to WLR_INFO to avoid 'false' logging when Openbox themes
contain the padding.height settings. Whilst this option is not supported,
the visual appearance is very close to that of Openbox with common themes.

The background to this is that Labwc theme specification has diverged
slightly from that of Openbox with respect to titlebar padding to support
more contemporary looks whilst avoiding breaking changes. For full details
see commit: e16e78e7a4

Suggested-by: @Consolatis
2024-12-24 14:58:25 +09:00
tokyo4j
16dbdc64e5 ssd: rework titlebar button rendering
- fix that icons for normal/hovered/rounded buttons are not placed
  exactly the same position
- fix blurry window button icons in scaled outputs

This commit introduces lab_img and scaled_img_buffer and uses them for
rendering icons in the window titlebar. Now the process of rendering
button icons are split into 2 phases: loading with lab_img_load() and
creating scene-nodes for them with scaled_img_buffer_create(). This
might incur some additional overhead since we no longer preload icon
textures, but the rendering of icon only happens for the first window
as backing buffers are shared and the overhead won't be noticeable.
This commit also simplifies the process of centering icon buffer in the
button, by creating icon buffers in a fixed geometry via
lab_img_render().
2024-12-23 18:11:32 +09:00
tokyo4j
9a3412324d node: add node_scaled_scene_buffer_from_node 2024-12-23 18:11:32 +09:00
Consolatis
8156b91306 ext-workspace protocol integration 2024-12-23 04:14:53 +01:00
Consolatis
acde3b4a8b ext-workspace protocol implementation 2024-12-23 04:14:53 +01:00
tokyo4j
b2a45ac8af cursor: fix focus when menu is closed by clicking its border
Before this commit, the pointer focus is cleared when a menu is closed
by clicking its border. This is because get_cursor_context() returns
type=LAB_SSD_NONE when the cursor is on the menu border and
cursor_update_common() clears the pointer focus. This commit fixes this
by replacing cursor_update_common() with cursor_update_focus(), which
calls get_cursor_context() again after the menu scene-node is hidden.
2024-12-20 00:43:06 +09:00