Commit graph

2441 commits

Author SHA1 Message Date
John Lindgren
9d49d19cd2 include: add config/types.h 2025-08-21 16:55:25 +09:00
Marvin Dostal
6dea8c0dcc desktop-entry: fix partial string matching
Use the base instead of the full string for the comparison.
2025-08-20 21:15:35 +01:00
tokyo4j
d1d4037335 seat.c: reset libinput device config on reconfigure
Before this commit, setting empty values in <libinput> entires and
executing Reconfigure left libinput devices with old configurations.

This commit makes sure that default values are set in libinput devices
on every Reconfigure to make rc.xml more declarative.
2025-08-19 17:18:08 +09:00
tokyo4j
7041accb56 rcxml: allow empty values in <libinput>
This restores the old behavior prior to a0d2e6a6.
2025-08-19 17:18:08 +09:00
John Lindgren
6574c82aed keybind: refactor update_keycodes_iter() to reduce nesting
update_keycodes_iter() currently has 4(!) levels of nested loops, which
makes the logic (especially the break/continue statements) difficult to
understand. The logic also appears to continue looping uselessly after
a given keycode has already been added to a keybind.

Refactor by adding some small utility functions:

- keybind_contains_keycode()
- keybind_contains_keysym()
- keybind_contains_any_keysym()

No functional change intended.
2025-08-18 19:54:18 +01:00
Johan Malm
8bcea29a1c menu: fix leak in update_client_send_to_menu() 2025-08-16 14:54:48 +01:00
Johan Malm
6fe61f8846 menu: use client-send-to-menu as 'Workspace' submenu
...because that is more flexible and how it is in openbox.

I have had in mind that we should do this since the original
implementation, and #2994 just jogged my memory.
2025-08-16 14:54:48 +01:00
John Lindgren
d9f7ccf3aa menu: fix use-after-free at exit with sub-menu selected
Sequence of events:

- menu_finish() frees the sub-menu first
- the selection.menu of the parent menu is now dangling
- menu_finish() frees the parent menu
- menu_free() calls menu_close_root() on the parent menu
- menu_close_root() tries to close the (freed) sub-menu
- boom

Extending nullify_item_pointing_to_this_menu() avoids the crash.
2025-08-15 18:46:34 +09:00
John Lindgren
6e949e623a input/cursor: fix assignment/equality mix-up 2025-08-15 06:48:19 +01:00
tokyo4j
72e1945a4c menu: allow overwriting submenu icon
Allow overwriting the icon of item linking to another menu like below
(the icon for "krita" should be shown):

<openbox_menu>
  <menu id="static-menu" label="Static Menu" icon="mpv" />
  <menu id="root-menu" label="Root">
    <menu id="static-menu" icon="krita" />
  </menu>
</openbox_menu>

This commit also fixes my mistake in 17d66e5 (s/parent->icon/menu->icon/)
that showed incorrect icon in an item linking to another menu.
2025-08-14 20:47:43 +01:00
tokyo4j
2a039d4f24 menu: fix client-send-to-menu
Fixes 17d66e5
2025-08-13 20:29:23 +01:00
tokyo4j
2ce3f39c1f menu: allow client-{list-combined,send-to}-menu as submenu of static menu
Also, their labels are changed to "Windows" and "Send to desktop" which
are the same as Openbox.
2025-08-13 20:29:23 +01:00
Johan Malm
09b4e9605e labnag: return special value on timeout
...to avoid taking either of the <then> or <else> branches on timeout.
2025-08-12 03:10:14 +09:00
tokyo4j
073fd02300 osd: add null-check for output->osd_scene.tree
`wlr_scene_node_destroy(&output->osd_scene.tree->node);` does nothing
for null pointer, but ASAN is unhappy about accessing (NULL)->node.
2025-08-09 12:03:41 +01:00
Johan Malm
7c3a587015 action: fix labnag button order 2025-08-09 11:04:36 +01:00
Consolatis
fba73a0036 action: add support for <prompt> in 'If' actions
...and allow If Action without activator view.

For example:

    <action name="If">
      <prompt message="Toggle maximize?"/>
      <then>
        <action name="ToggleMaximize" />
      </then>
    </action>

Also revert the change in b9c84f9 that <else> branch is always taken when
no window is focused.

Co-Authored-by: johanmalm
Co-Authored-by: tokyo4j
2025-08-09 10:44:03 +01:00
Consolatis
32e308b5d5 scaled-icon-buffer: prevent accidental downcasting of scale
This causes blurry icons on non-integer scales and triggers
an assert within cairo when using a output scale < 1.

Fixes: #2983
2025-08-09 16:52:10 +09:00
tokyo4j
418f9cb059 ime: fix segfault when IME is killed
Fixes up e530f43.

When IME (e.g. fcitx5) is killed, relay->input_method is destroyed and
then relay->input_method->keyboard_grab is destroyed, which causes null
pointer dereference and crashes labwc.

Possible solutions are:
- Let wlroots keep emitting keyboard grab as `data` from keyboard grab's
  destroy handler just like before
- Let wlroots destroy keyboard grab before input method
- Let compositor store keyboard grab as relay->keyboard_grab

But let's just revert the change in e530f43 for now.
2025-08-08 20:52:23 +09:00
John Lindgren
02df0a15d7 foreign-toplevel: simplify and fully separate ext-foreign/wlr-foreign
Currently, the dependencies between foreign-toplevel[-internal],
ext-foreign, and wlr-foreign are cyclical and a bit complex.

I suggest we reorganize it into a simpler hierarchy:

  foreign-toplevel/
    -> foreign.c/h
      -> (depends on) ext-foreign.c/h
      -> (depends on) wlr-foreign.c/h

The refactored code is smaller and (IMO) easier to follow.

In detail:

- Add include/foreign-toplevel folder mirroring src/foreign-toplevel
- Split foreign-toplevel-internal.h to ext-foreign.h and wlr-foreign.h
- Eliminate ext-/wlr-foreign.c -> foreign.c reverse dependencies
  (including internal signals and foreign_request* functions)
- Make struct foreign_toplevel private to foreign.c

Lightly tested with qmpanel (which uses wlr-foreign-toplevel).

v2: reorder foreign-toplevel internal API funcs
2025-08-07 23:27:04 -04:00
John Lindgren
55b495f398 foreign-toplevel: disconnect internal signals from handle_handle_destroy()
If the handle gets destroyed from the wlroots side before the view
is destroyed, the internal signals (emitted from the view) are not
disconnected and will assert() if invoked.
2025-08-07 23:27:04 -04:00
Johan Malm
d87ef7568a common/xml.c: fix memory leak in lab_xml_get_bool() 2025-08-06 21:11:42 +01:00
John Lindgren
508df093c4 xdg: try to keep view on the same output in timeout case 2025-08-06 18:14:24 +09:00
John Lindgren
9557091a1a xdg: don't try to reposition unmapped view in timeout handler 2025-08-06 18:14:24 +09:00
tokyo4j
e530f43708 ime: don't use data argument in some signal handlers
In wlroots 0.20, the those data argument will be just NULL.
2025-08-05 11:43:09 +09:00
John Lindgren
2547f96984 view: assert internal signals are disconnected before destroy
If they are not empty, then we are headed for use-after-free shortly.
An assert() failure is easier to debug than UAF, so let's fail early.

Inspired by:
8f56f7ca43
2025-08-05 04:20:57 +02:00
John Lindgren
bc34461977 output: make autoEnableOutputs=no apply only to drm outputs
It is not really useful for other output backends and just results
in no outputs being enabled at all. (This is mainly an annoyance for
developers normally running with drm but occasionally nested.)
2025-08-05 04:18:43 +02:00
tokyo4j
17d66e5603 menu: refactor parser
...with the same approach as rcxml.c

- `If` actions now works for menus
- `name` argument no longer have to be the first argument of <action>
- `label` argument no longer have to be the first argument of <item>
2025-08-04 21:41:14 +01:00
tokyo4j
bfaab101af Make append_actions() public
Also rename it to append_parsed_actions()
2025-08-04 21:41:14 +01:00
tokyo4j
2f183cdcb6 interactive: allow snapping to corner edges
In addition to <snapping><range>, <snapping><cornerRange> configures the
distance from the screen corner to trigger quater window snapping.

Also, new values "up-left", "up-right", "down-left" and "down-right" are
allowed for <action name="(Toggle)SnapToEdge" direction="[value]"> and
<query tiled="[value]">.
2025-08-04 21:24:12 +01:00
tokyo4j
b0ff2911b6 src/overlay.c: minor refactor 2025-08-04 21:24:12 +01:00
tokyo4j
6441bd58f3 view: don't use bitset for VIEW_EDGE_ALL
We will use bitset for views snapped to corner (e.g. top-left = TOP|LEFT)
2025-08-04 21:24:12 +01:00
tokyo4j
4b0ac0234c view: refactor view_edge_parse() 2025-08-04 21:24:12 +01:00
tokyo4j
03004cf44b menu: fix segfault with toplevel <separator>
Before this patch, labwc crashed menu.xml like this:

<openbox_menu>
  <separator />
</openbox_menu>
2025-08-03 15:07:35 +01:00
tokyo4j
00ed40454d common/xml: parse CDATA as text
Before this patch, <![CDATA[xxx]]> was ignored in many cases.

For example, this didn't work:

  <core>
    <gap><![CDATA[10]]></gap>
  </core>
2025-08-03 15:05:53 +01:00
tokyo4j
b9c84f9c38 action: allow if-action without activator view
..in preparation for If/ForEach action with <prompt>, which should be
executed whether or not any window is focused.

This patch makes <If> actions execute <else> branch if no window is
focused or hovered.
2025-08-02 13:19:35 +01:00
tokyo4j
15e3c32b5b action.c: split actions_run() 2025-08-02 13:19:35 +01:00
tokyo4j
6e7c4a181e overlay: take into account <core><gap> for region overlay 2025-08-02 12:31:16 +01:00
tokyo4j
38e57891b5 overlay: take into account <core><gap> for edge overlay
This also deduplicates get_edge_snap_box() in interactive.c and
view_get_edge_snap_box() in view.c.
2025-08-02 12:31:16 +01:00
tokyo4j
ca8d98e80f cursor: fix Scroll mousebinds not inhibited with ToggleKeybinds
fixup for 024ab280
2025-08-02 12:27:26 +01:00
John Lindgren
2e6b30eb50 include: move a few types from labwc.h to better locations 2025-07-30 21:04:31 +01:00
John Lindgren
e1475a1e47 include: reduce global includes in labwc.h 2025-07-30 21:04:31 +01:00
John Lindgren
e21fc065c4 include: split output.h from labwc.h 2025-07-30 21:04:31 +01:00
tokyo4j
2f414a438b rcxml: simplify the logic to traverse xml tree 2025-07-30 20:36:27 +01:00
tokyo4j
ad970544e1 string-helper: add str_space_only() 2025-07-30 20:36:27 +01:00
tokyo4j
67f36d9e13 rcxml: rewrite <tablet><map> parser 2025-07-30 20:36:27 +01:00
tokyo4j
619cae67fa rcxml: rewrite <theme><font> parser 2025-07-30 20:36:27 +01:00
tokyo4j
a865cc0777 rcxml: reorder functions 2025-07-30 20:36:27 +01:00
tokyo4j
ba00f57dad rcxml: rewrite <windowRules> parser 2025-07-30 20:36:27 +01:00
tokyo4j
936c5f6df1 rcxml: rewrite <windowSwitcher><fields> parser 2025-07-30 20:36:27 +01:00
tokyo4j
73dd3b8de1 rcxml: rewrite <region> parser 2025-07-30 20:36:27 +01:00