Commit graph

1107 commits

Author SHA1 Message Date
tokyo4j
4b0903cfa9 view: deduplicate foreign-toplevel creation code 2025-11-27 01:26:55 -05:00
tokyo4j
3c0e010c58 Remove view_impl->map and view_impl->unmap
jlindgren: data parameter to handle_unmap() is NULL
2025-11-27 01:26:55 -05:00
John Lindgren
e96f4a032b output: avoid use of wlr_scene_output.WLR_PRIVATE.index
We were only using it to allow quick bitset comparisons of sets of
outputs (such as view->outputs). We can maintain our own bit IDs for
this purpose and avoid using the private wlroots field.

Note: from my reading of wlr_scene_output_create(), it appears to
always take the lowest unused index, resulting in aggressive re-use of
index values when outputs are disconnected and reconnected. I've tried
to make re-use as infrequent as possible. This could theoretically
reduce the chance of a mix-up in view_update_outputs(), although I'm
not aware of any practical scenario where it matters.

v2: prevent adding more than 64 outputs
2025-11-26 06:49:17 +01:00
John Lindgren
b5e2eb216e view: separate (un)minimize and (un)map logic
Map/unmap logic is currently re-used for minimize/unminimize, but lots
of it doesn't actually apply in that case. This is both confusing and
creates some extra complexity, such as:

 - extra "client_request" parameter to unmap(), in which case it has to
   still do some cleanup even if view->mapped is already false

 - various "view->mapped || view->minimized" checks when we really just
   mean "is the view mapped"

To clean this all up, let's put the logic that really is common into
a new view_update_visiblity() function, and stop using map/unmap for
minimize/unminimize.

Note that this changes the meaning of "view->mapped", which used to
mean "mapped and not minimized" but now really just means "mapped".
I left some "view->mapped" conditions as-is (rather than changing to
"view->mapped && !view->minimized") where it seemed to make sense.

v2: add view_update_visibility() as suggested by tokyo4j
2025-11-21 14:01:48 +09:00
John Lindgren
5543affe35 view: factor out view_impl_init_foreign_toplevel() 2025-11-13 00:07:11 +01:00
Samet Aylak
d65caf8bfd
osd: add multi-monitor support
Some checks failed
labwc.github.io / notify (push) Has been cancelled
Adds `output` attribute to control which monitor(s) display the window
switcher OSD. Supports three modes:
- "all": display on all monitors (default)
- "pointer": display on monitor with mouse cursor
- "keyboard": display on monitor with keyboard focus

The configuration structure is also refactored to nest OSD-specific
settings (show, style, output, thumbnailLabelFormat) under an <osd>
element within <windowSwitcher>, improving logical organization.
2025-11-10 05:16:26 +01:00
John Lindgren
87da3f6588 output: factor out output_set_has_fullscreen_view() 2025-11-09 06:46:59 +01:00
elviosak
c8167c8ee0
osd: add thumbnailLabelFormat to windowSwitcher (#3187)
Some checks failed
labwc.github.io / notify (push) Has been cancelled
This commit adds `<windowSwitcher thumbnailLabelFormat="%T">` to configure the label text in each item in the thumbnail-style window switcher. Its format follows `<fields><field content="custom" format="">`.
2025-11-05 18:23:15 +09:00
tokyo4j
9197eb468a osd: allow clicking an osd item to focus the window 2025-11-04 21:29:13 +00:00
tokyo4j
00f0a46ef7 osd: generalize osd_{classic,thumbnail}_item
This allows us to share common codes for dealing with osd items.
For example:
- Get the clicked osd item to focus its associated window
- Scroll the items when their total height is taller than output height
2025-11-04 21:29:13 +00:00
tokyo4j
2c0552004a osd: move end_cycling() into osd_finish()
...so that we can use `osd_finish()` to support clicking an osd item to
focus its associated window.
2025-11-02 21:30:35 +00:00
tokyo4j
cd1a823fee seat: use CONNECT_SIGNAL() for new_virtual_pointer event 2025-10-25 20:41:38 +02:00
tokyo4j
7f67b9c866 Don't remove newlines when parsing config, menu and XBM
Removing newlines in rc.xml and menu.xml caused parser error with
following content:

<!--
 -
 - Some comments
 -
-->

...though it is a valid XML.

Let's not do that. I moved `grab_file()` to `buf.c` and renamed it to
`buf_from_file()`, because it now directly touches `struct buf` and
I don't like having a source file only for one function.
2025-10-17 22:08:41 +09:00
tokyo4j
89fab2d449 theme: replace THEME_(IN)ACTIVE with SSD_(IN)ACTIVE
Some checks failed
labwc.github.io / notify (push) Has been cancelled
2025-10-14 07:48:27 +02:00
tokyo4j
2b3aadb6af labnag: s/LAB_EXIT_TIMEOUT/LAB_EXIT_CANCELLED/ 2025-10-13 19:03:43 +01:00
Consolatis
364a1d5207 osd: allow window switcher to temporary unshade windows
This can be configured with a new unshade="yes|no"
argument for windowSwitcher in rc.xml

Fixes: #3111
2025-10-13 19:45:46 +02:00
tokyo4j
babd7af8f8 view: store title/app_id in view
This simplifies our codes and eliminates duplicated
`view.events.new_{title,app_id}` events. This should not change any
behaviors.
2025-10-14 02:27:13 +09:00
tokyo4j
5e8df27f84 osd-classic: add theme options for selected window item
This commit adds new theme options:
- osd.window-switcher.style-classic.item.active.border.color
- osd.window-switcher.style-classic.item.active.bg.color

These theme options configures the border/background of selected window
item in the `classic` style window switcher. Their default values are
identical to `thumbnail` style window switcher, which means the default
border color is now `osd.label.text.color` with 50% opacity and the
default background color is now `osd.label.text.color` with 15% opacity.
2025-10-13 01:46:43 +09:00
tokyo4j
5f981226c2 action: simplify action_prompt_command() 2025-10-11 23:53:02 +09:00
Johan Malm
0d0d1075cc include/common/scene-helpers: fix declaration/definition arg name difference 2025-10-01 21:18:44 +01:00
Johan Malm
4c1e66f6c8 include/common/buf.h: fix declaration/definition arg name difference 2025-10-01 21:18:44 +01:00
Johan Malm
389cef9c3b include/common/box.h: fix declaration/definition arg name difference 2025-10-01 21:18:44 +01:00
Johan Malm
c8581b3fed include/common/xml.h: fix declaration/definition arg name difference 2025-09-30 02:38:13 +02:00
Johan Malm
60d536304b Privatize view_append_children() 2025-09-29 20:22:46 +01:00
Johan Malm
9ec49144ac Privatize desktop_topmost_focusable_view() 2025-09-29 20:22:46 +01:00
Johan Malm
eb41c6a3b0 Privatize view_contains_window_type() 2025-09-29 20:22:46 +01:00
Johan Malm
2ea0f6fff4 Privatize output_manager_init() 2025-09-29 20:22:46 +01:00
Johan Malm
950c634cea Privatize xwayland_surface_from_view() 2025-09-29 20:22:46 +01:00
Johan Malm
286005e121 Privatize rcxml_parse_xml() 2025-09-29 20:22:46 +01:00
Johan Malm
040e25f38e Privatize private view_get_root() 2025-09-29 20:22:46 +01:00
Johan Malm
94c980c6be action: fix UAF when using prompt during reconfigure
Reported-by: @jlindgren90

Fixes #3106
2025-09-26 21:25:34 +01:00
Johan Malm
26bd02d457 Add translate.h for HAVE_NLS includes/defines
...to shrink labwc.h footprint
2025-09-26 10:43:23 -04:00
Johan Malm
1692c47fa0 Remove unused function key_state_nr_pressed_keys() 2025-09-26 10:41:21 -04:00
Johan Malm
bdc8e1c546 Remove unused function lab_xml_get_node() 2025-09-26 10:41:21 -04:00
Johan Malm
ee87b4fc30 Remove unused function trim_last_field() 2025-09-26 10:41:21 -04:00
Johan Malm
34e52a40c7 Remove unused function node_layer_popup_from_node() 2025-09-26 10:41:21 -04:00
Johan Malm
139a5f0383 Remove unused function output_max_scale() 2025-09-26 10:41:21 -04:00
Johan Malm
0bf2678f9d Remove unused function scaled_font_buffer_set_max_width() 2025-09-26 10:41:21 -04:00
Johan Malm
6bbdc3c6dc Remove unused function menu_call_actions() 2025-09-26 10:41:21 -04:00
Johan Malm
7a5b7aa378 rcxml.h: minor tweaks to order of variables 2025-09-25 21:12:36 +01:00
Johan Malm
5765586636 config: add <core><promptCommand>
...to enable configuration of the action prompt command.

Also set some better defaults for labnag.

The new default command is:

    labnag \
        --message '%m' \
        --button-dismiss '%n' \
        --button-dismiss '%y' \
        --background '%b' \
        --text '%t' \
        --border '%t' \
        --border-bottom '%t' \
        --button-background '%b' \
        --button-text '%t' \
        --border-bottom-size 1 \
        --button-border-size 3 \
        --timeout 0

...where the conversion specifiers are defined as follows:

    %m: the `<prompt>` message option
    %n: _("No")
    %y: _("Yes")
    %b: osd.bg.color
    %t: osd.label.text.color

This config options also enables the use of a different dialog client, for
example like this:

    <core>
      <promptCommand>zenity --question --text="%m"</promptCommand>
    </core>
2025-09-24 20:13:51 +01:00
tokyo4j
24f39e3a41 default-bindings.h: set combine="yes" for SnapToEdge keybinds
Some checks failed
labwc.github.io / notify (push) Has been cancelled
2025-09-19 16:23:23 +09:00
tokyo4j
2ac48116e1 action: allow SnapToEdge to combine two cardinal directions
This patch adds `combine` argument to (Toggle)SnapToEdge actions.
This allows to snap a window to e.g. up-left by running two actions:
- `<action name="SnapToEdge" direction="left" combine="yes" />`
- `<action name="SnapToEdge" direction="up" combine="yes" />`

Then running `<action name="SnapToEdge" direction="down" combine="yes" />`
snaps it to left again. This behavior is almost the same as KWin, except
that snapping a up-right-tiled window to right doesn't move it to the
right-adjacent output, but makes it right-tiled first.
2025-09-19 16:23:23 +09:00
John Lindgren
bca0ec07ac rcxml: use fixed arrays for rc.title_buttons_*
These are just lists of enum lab_node_type, with a bounded size and
no middle-insertions/removals, so linked lists are overkill.

Also, the use of wl_list_for_each[_reverse] just to access the first or
last entry in the list (corner button) was weird.
2025-09-13 12:06:52 +01:00
tokyo4j
9f7e532852 desktop: refactor get_cursor_context()
This patch should not change any behaviors.

This clarifies the semantics of cursor_context returned by
get_cursor_context() as I described in cursor.h; when cursor is on a
subsurface (e.g. xdg/x11/layer/session-lock), the returned ctx.surface
and ctx.node points to the subsurface rather than its parent.
2025-09-09 18:50:20 +09:00
tokyo4j
3d670b772d desktop: don't use LAB_NODE_LAYER_SUBSURFACE node type
Instead, set ctx.type = LAB_NODE_LAYER_SURFACE for both layer-surfaces
and layer-subsurfaces.

This patch preserves the existing behaviors:
- Pressing a subsurface of an on-demand layer-surface gives pointer
  focus to the subsurface, but gives keyboard focus to the parent
  layer-surface (related: a5fcbfaf).
- Pressing a subsurface of a layer-surface doesn't close a popup
  (related: a89bcc3c).
2025-09-09 18:50:20 +09:00
tokyo4j
574b20fbff ssd: attach LAB_NODE_SSD_ROOT to ssd->tree
This doesn't change any behaviors.

Attaching LAB_NODE_NONE node-descriptor to ssd->tree looks strange, this
patch uses new LAB_NODE_SSD_ROOT instead. The node-descriptor attached to
ssd->tree is needed for get_cursor_context() to detect cursor hovering on
borders/extents.

I also updated get_cursor_context() to make my intent clearer.
2025-09-08 15:46:36 +09:00
tokyo4j
b9b23f5931 output: remove node descriptors 2025-09-08 15:46:36 +09:00
tokyo4j
fb3dcb7959 scaled-buffer: remove *_from_node() functions 2025-09-08 15:46:36 +09:00
John Lindgren
d2ce31fcc9 tree-wide: use forward declarations for wlr types 2025-09-07 19:34:30 +09:00