Commit graph

1096 commits

Author SHA1 Message Date
John Lindgren
6d2140c4b7 view: expose view_set_maximized() instead of view_restore_to()
view_restore_to() (which is just set_maximized() + view_move_resize())
hasn't aged well and doesn't line up with typical usage anymore:

 - it's missing view_set_untiled(), which has to be called separately
 - it always forces view_move_resize() even when that's not needed
 - it doesn't allow un-maximizing only one axis (see next commit)
 - the fullscreen check is unnecessary (already checked in callers)

Eliminate it and just expose view_set_maximized() instead.

No functional change intended in this commit.
2025-09-01 20:44:09 +01:00
tokyo4j
e6b5d91b63 view: let view_set_fallback_natural_geometry() return wlr_box 2025-09-01 20:16:37 +01:00
tokyo4j
164b17c279 view: use fixed default window width
Now it's not very reasonable to determine the default window width based
on the titlebar geometry, as the titlebar can be shrunk to 1px.

Let's use the fixed value of 100px for simplification.
2025-09-01 20:13:00 +01:00
tokyo4j
66e26cd28a overlay: refactor
- Use a single `lab_scene_rect` for both overlay background and outlines,
  like I described in the TODO comment in ffd4005.
- Simplify the resource management by destroying the overlay tree when
  it's hidden. I think its overhead is pretty minimal.
- Share a single `lab_scene_rect` for both region/edge overlays.
2025-08-31 13:24:51 +01:00
tokyo4j
78d47c5c37 overlay.h: reduce included headers 2025-08-31 13:24:51 +01:00
tokyo4j
2e9292b7a3 osd: support window switcher with thumbnails
The new-style window switcher can be enabled with
<windowSwitcher style="thumbnail">.

New theme entries:

osd.window-switcher.style-thumbnail.width.max: 80%
osd.window-switcher.style-thumbnail.padding: 4
osd.window-switcher.style-thumbnail.item.width: 300
osd.window-switcher.style-thumbnail.item.height: 250
osd.window-switcher.style-thumbnail.item.padding: 10
osd.window-switcher.style-thumbnail.item.active.border.width: 2
osd.window-switcher.style-thumbnail.item.active.border.color: #589bda
osd.window-switcher.style-thumbnail.item.active.bg.color: #c7e2fc
osd.window-switcher.style-thumbnail.item.icon.size: 60
2025-08-29 20:42:01 +01:00
tokyo4j
6e2805f692 theme: move osd.window-switcher.* to osd.window-switcher.style-classic.*
Backward compatibility is preserved.
2025-08-29 20:42:01 +01:00
tokyo4j
92ee5083f0 osd: split to osd.c and osd-classic.c 2025-08-29 20:42:01 +01:00
tokyo4j
f347a818e3 ssd: clean up scene management
Our codebase for ssd scenes has grown with a lot of technical debts:
- We needed to call `ssd_get_part()` everywhere to get the scene node of a
  ssd part. We then needed to cast it to `wlr_scene_rect` and
  `wlr_scene_buffer`. This bloated our codebase and even blocked
  duplicated button types in `<titlebar><layout>`.
- `ssd_get_part_type()` was a dirty hack. It compared parent, grandparent
  and grandgrandparent of a node with each subtree in the ssd to get the
  part type of the node.

To resolve this issues, this commit changes how ssd scenes are managed:
- Access scene rects and scene buffers just as a member of `struct ssd`.
- `ssd_part` is now a attachment to a scene node that can be accessed via
  node_descriptor->data, with a new node-descriptor type
  `LAB_NODE_DESC_SSD_PART`. `LAB_NODE_DESC_SSD_BUTTON` is unified into it.

Now the scene graph under ssd->tree looks like below. The parentheses
indicate the type of ssd_part attached to the node:

ssd->tree (LAB_SSD_NONE)
+--titlebar (LAB_SSD_PART_TITLEBAR)
|  +--inactive
|  |  +--background bar
|  |  +--left corner
|  |  +--right corner
|  |  +--title (LAB_SSD_PART_TITLE)
|  |  +--iconify button (LAB_SSD_BUTTON_ICONIFY)
|  |  |  +--normal close icon image
|  |  |  +--hovered close icon image
|  |  |  +--...
|  |  +--window icon (LAB_SSD_BUTTON_WINDOW_ICON)
|  |  |  +--window icon image
|  |  +--...
|  +--active
|     +--...
+--border
|  +--inactive
|  |  +--top
|  |  +--...
|  +--active
|     +--top
|     +--...
+--shadow
|  +--inactive
|  |  +--top
|  |  +--...
|  +--active
|     +--top
|     +--...
+--extents
   +--top
   +--...

When hovering on SSD, `get_cursor_context()` traverses this scene node
from the leaf. If it finds a `ssd_part` attached to the node, it returns
`ssd_part_type` that represents the resizing direction, button types or
`Title`/`Titlebar`.
2025-08-28 21:06:51 +01:00
John Lindgren
c8943ca242 seat: improve debug logging when configuring input devices
Some checks failed
labwc.github.io / notify (push) Has been cancelled
I needed to debug an input configuration issue and found the debug
output not-super-helpful, so I made some improvements:

- Print the name and "sysname" (e.g. event11) of the device being
  configured. Note that the name alone isn't enough since there can
  be multiple identically-named devices.

- Print the config category matched for each device.

- Print the config values (if any) being applied. For enums, only the
  numeric value is printed since I'm lazy.

- Don't print "pointer acceleration configured" if neither a pointer
  speed nor acceleration profile is configured (it's confusing).
2025-08-27 13:07:01 -04:00
John Lindgren
80b28f16c7 tree-wide: use enum types/constants where appropriate
- add LAB_WINDOW_TYPE_INVALID in place of literal -1
- document more clearly that enum lab_view_criteria is a bitset
- other one-off replacements of integer values/types for consistency

Note: variables of type enum lab_view_criteria are already used
extensively throughout the code to contain combinations of the declared
enum values. I am not introducing any new usage here, just changing the
single uint32_t to be consistent with all the other usages.
2025-08-28 01:33:23 +09:00
John Lindgren
ef766d16f0 common: flesh out enum lab_edge and prefer over wlr_edges/wlr_direction
I like the new common/edge.h. I don't like how inconsistently we use it.

Current situation:

 - enum wlr_edges and wlr_direction are designed to be used as bitset,
   and are defined compatibly

 - enum lab_edge is *also* designed to be used as bitset, but
   incompatible with the others (LEFT/RIGHT come before UP/DOWN)

 - we use an inconsistent mix of all three *AND* uint32_t (usually with
   the WLR_EDGE constants rather than the LAB_EDGE constants), and
   convert between them on an ad-hoc basis, sometimes implicitly

Let's clean this up:

 - reorder enum lab_edge to be compatible with the two wlr enums
   (check this by static_assert)

 - use TOP/BOTTOM naming rather than UP/DOWN (matches wlr_edges)

 - add constants for the remaining possible combinations of the 4 edges

 - use lab_edge for all internal edge/direction fields, consistently

 - add lab_edge_is_cardinal() as a sanity check before casting to
   enum wlr_direction, and then eliminate all of direction.c/h

Instead of "enum wlr_edges direction", we now have
"enum lab_edge direction" which is not that much better. At least we
are now clear that we're overloading one enum with two meanings.
2025-08-26 20:36:43 -04:00
tokyo4j
888dbedeed ssd: allow hiding titlebar on maximization
<core disableMaximizedServerDecor="yes"> hides the titlebar when a window
is maximized.

Co-authored-by: @CosmicFusion
2025-08-24 12:41:41 +01:00
tokyo4j
943f5751ee view: unify ssd_enabled and ssd_titlebar_hidden to ssd_mode 2025-08-24 12:41:41 +01:00
tokyo4j
48ba23fc8d Add common/edge.c
Some checks failed
labwc.github.io / notify (push) Has been cancelled
2025-08-21 21:17:52 +01:00
John Lindgren
beb3c0fa09 config: add comment to enum lab_motion 2025-08-21 16:55:25 +09:00
John Lindgren
9d49d19cd2 include: add config/types.h 2025-08-21 16:55:25 +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
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
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
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
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
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
5a50d87ee2 common/xml: let LAB_XML_FOR_EACH() skip first child text nodes
Before this patch, first text nodes like the spaces between <a> and <b>
below were also travered by LAB_XML_FOR_EACH():

  <a>  <b>foo</b></a>
2025-08-03 15:05:53 +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
d5c03ab7fb include/edges.h: remove unimplemented function 2025-08-02 16:40:04 +09: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
ad970544e1 string-helper: add str_space_only() 2025-07-30 20:36:27 +01:00
tokyo4j
936c5f6df1 rcxml: rewrite <windowSwitcher><fields> parser 2025-07-30 20:36:27 +01:00
tokyo4j
8881841098 common/xml: add helpers to parse rc.xml 2025-07-30 20:36:27 +01:00
tokyo4j
503af10505 rcxml: convert dotted properties into nested nodes before processing
For example, the following node:

  <keybind name.action="ShowMenu" menu.action="root-menu"
            x.position.action="1" y.position.action="2" />

is converted to:

 <keybind>
   <action>
     <name>ShowMenu</name>
     <menu>root-menu</menu>
     <position>
       <x>1</x>
       <y>2</y>
     </position>
   </action>
 </keybind>

...before processing the entire xml tree. This is a preparation to prevent
breaking changes when we refactor rcxml.c to use recursion instead of
encoding nodes into dotted strings.
2025-07-30 20:36:27 +01:00
John Lindgren
c9b576982d include: add missing header dependencies
Ensure that headers compile correctly regardless of include order.
2025-07-29 21:51:56 +01:00
tokyo4j
024ab280a0 cursor: also toggle mousebinds with ToggleKeybinds
Mousebinds can still be applied when the cursor is over their decoration
2025-07-28 00:06:52 +09:00
tokyo4j
73095f75cb Remove seat->nr_inhibited_keybind_views 2025-07-28 00:06:52 +09:00
tokyo4j
cb79eccea1 cursor: prevent hi-res mice triggering scroll actions too often
Hi-res mice produces mulitple scroll events with `delta_discrete` != 0
during a single "click". This patch makes them trigger `Scroll` actions
only when the accumulated `delta_discrete` exceeds 120 (= 1 click).

See https://lists.freedesktop.org/archives/wayland-devel/2019-April/040377.html
for how hi-res scroll events are reported.
2025-07-22 19:31:55 +09:00
John Lindgren
407a29aa23 string-helpers: remove restrict qualifier
'restrict' is harmful as it encourages the compiler to make dangerous
assumptions while increasing cognitive load on the human programmer.

The extra 1% (or whatever) of performance here is not worth the cost.
2025-07-21 16:51:10 +02:00
lynxy
2bcd8277c4 comments: added short description to view_edge enum 2025-07-19 12:29:55 +09:00
lynxy
13ff64f6e4 actions: added query tiled=any comparison for rc.xml simplification 2025-07-19 12:29:55 +09:00
Consolatis
38a1a9bbbc Disable all output leasing due to a wlroots UAF 2025-07-06 19:59:43 +01:00
Consolatis
4699d446cb Fix UAF when granting an output lease
Wlroots now destroys the wlr_output when granting a lease.
So we can't iterate through the outputs in the request after
granting the lease. This is also not necessary anymore because
they are already destroyed and thus removed from the layout.
2025-07-06 19:59:43 +01:00
Andrew J. Hesford
476fd5f25e resistance: refactor snap constraints, use in interactive resistance 2025-07-06 18:45:21 +01:00
tokyo4j
3aab0c3b91 Replace alacritty in default keybind with lab-sensible-terminal 2025-07-06 14:11:27 +01:00
tokyo4j
75bd188592 Strictly use handle_ prefix for signal handlers 2025-06-28 19:36:29 +09:00
tokyo4j
6f70cd0d6e layers: don't send configure events in unmap handler
Alternative to 7bf08af which was reverted in the previous commit.

7bf08af fixed the problem that layer-shell clients are terminated when
it's unmapped, by sending configure events in node-destroy handler
rather than in unmap handler. But it caused a UAF bug when an output
with layer-shell clients is destroyed.

So this patch fixes the original issue by simply skipping the surface in
arrange_one_layer() if it's being unmapped.
2025-06-27 22:03:37 +01:00
tokyo4j
cc0fe78ceb Revert "layers: arrange layers on destroy"
This reverts commit 7bf08af210.
2025-06-27 22:03:37 +01:00