Commit graph

2326 commits

Author SHA1 Message Date
tokyo4j
d8bd8c5a3e osd: consider item.padding.y when centoring workspace name 2025-04-01 21:14:20 +01:00
tokyo4j
81204b0537 xwayland: notify correct window stacking order to xwayland
Before this commit, when a normal window is raised, xwayland thought it's
above always-on-top (AOT) windows even though it's actually below AOT
windows in the scene. This means mouse scroll events may be unexpectedly
sent to normal windows below AOT windows even when the cursor is hovering
over a AOT window.

So this commit fixes it by notifying the correct stacking order (where AOT
windows are placed above normal windows) to xwayland every time the
stacking order is updated.

Other benefits of this commit are:
- It makes the code more readable and predictable by aggregating logic
  about stacking order management in xwayland (e.g. shaded windows or
  windows in other workspaces should be notified to xwayland as being
  placed at the bottom).
- As server->last_raised_view is removed in the previous commit, we were
  notifying the stacking order to xwayland every time a window with dialog
  windows is clicked (not when clicking a topmost window without dialogs,
  due to some optimization in wlroots). This commit fixes this by caching
  the window stacking order in xwayland_view->stacking_order and notifying
  it to xwayland only when it's updated.
2025-04-01 16:48:40 +09:00
tokyo4j
de49054d75 view: remove server->last_raised_view
We were skipping in view_move_to_front() if the raised view is already
cached as server->last_raised_view. But this was prone to bugs that
windows cannot be raised even though they are actually not placed at the
top in the scene.

This happened when a window is mapped but view_move_to_front() is not
called in view_impl_map() for some reason. Example cases were:
- a window is minimized before being mapped (#2627)
- a window is mapped while window switcher is active (#2629)

Also, this problem was the root cause of #1640 and #2582, though they are
already fixed.

Therefore, this commit removes server->last_raised_view. In order to
eliminate unnecessary communications between labwc and xwayland (ref:
db591d1), I'll introduce another caching mechanism in the next commit.
2025-04-01 16:48:40 +09:00
tokyo4j
3f56814497 magnifier: show magnifier only in one output
This may slightly degrade UX, but this prevents the temporary buffer from
being reallocated for every frame when the magnifier spans multiple
outputs with different scales/transforms.
2025-03-31 21:19:12 +01:00
tokyo4j
6dc8e279ec magnifier: scale/transform the magnifier
Before this commit, the magnifier wasn't scaled, and caused visual
artifacts when the output is transformed.
2025-03-31 21:19:12 +01:00
Consolatis
9f53d7ed25 src/magnifier: fix compile on ancient GCC versions
Fixes
```
../src/magnifier.c:153:3: error: missing initializer for field ‘clip’ of ‘struct wlr_render_rect_options’ [-Werror=missing-field-initializers]
  153 |   };
      |   ^
In file included from ../subprojects/wlroots/include/wlr/render/wlr_renderer.h:14,
                 from ../subprojects/wlroots/include/wlr/types/wlr_output.h:17,
                 from ../src/magnifier.c:5:
../subprojects/wlroots/include/wlr/render/pass.h:115:27: note: ‘clip’ declared here
  115 |  const pixman_region32_t *clip
```
2025-03-30 00:30:05 -04:00
Jens Peters
d6edb8b273 action: Add HideCursor action 2025-03-24 21:23:55 +00:00
tokyo4j
4ef881bb3e osd: support app icons in window switcher
Example configuration:

  <windowSwitcher>
    <fields>
      <field content="icon" width="5%" />
      <field content="title" width="95%" />
    </fields>
  </windowSwitcher>
2025-03-17 01:22:24 +09:00
Tomi Ollila
84ba60f453 string-helpers: rtrim() with just char *s, call it later in string_strip
char **s not needed to get trailing whitespace trimmed,
and rtrim() does not return anything

if there is leading whitespace in *s in call to string_strip(),
there is less chars left to scan in rtrim().
2025-03-16 11:18:39 +00:00
tokyo4j
75eb370d31 osd: draw window switcher with scene-nodes
...rather than drawing it onto a single texture.
2025-03-16 11:15:00 +00:00
tokyo4j
2be149064e osd: make osd_update() private 2025-03-16 11:15:00 +00:00
tokyo4j
140e913c44 project wide: clean up event listeners on shutdown (part 2) 2025-03-13 20:08:59 +00:00
Consolatis
9e6aaa689a project wide: clean up event listeners on shutdown
This ensures all event listeners are removed before the emitting
wlroots object is being destroyed. This will be enforced with asserts
in wlroots 0.19 but there is no reason to not do it right now either.

This change in wlroots 0.19 is implemented via commit
8f56f7ca43257cc05c7c4eb57a0f541e05cf9a79
"Assert (almost all) signals have no attached listeners on destroy"
2025-03-13 17:33:51 +09:00
Hiroaki Yamamoto
4750214d42
Merge pull request #2598 from tokyo4j/refactor-magnifier
magnifier: refactor
2025-03-13 15:20:34 +09:00
tokyo4j
e517b6808d menu: show app icons in client-list-combined-menu 2025-03-11 20:25:09 +00:00
tokyo4j
54186e5152 menu: dynamically generate top-level pipemenus
This eliminates code duplications and aligns the behavior of top-level
pipemenus with sub-pipemenus.
2025-03-10 19:42:03 +00:00
tokyo4j
40dfee7bd5 menu: don't fill default items in empty menus
This is needed to prevent pipemenus which usually contains no items
from being filled with default items in follow-up commits.
2025-03-10 19:42:03 +00:00
tokyo4j
ea4ea84499 menu: use item->parent->id for client-list-combined-menu
...instead of item->id.
2025-03-10 19:42:03 +00:00
tokyo4j
12f95543f0 menu: lazily generate menu scenes
This removes the need to call update_client_list_combined_menu()
and update_client_send_to_menu() every time a root menu is opened.

This commit also fixed the incorrect menu position with following
configuration:
  <menu id="foo" label="foo">
    <item label="aaaaaa"/>
    <item label="bbbbbb"/>
  </menu>
  <menu id="root-menu">
    <menu id="foo" />
    <menu id="foo" />
  </menu>
2025-03-10 16:16:20 +09:00
tokyo4j
514f1d4fc4 menu: assert server->menu_current != NULL in menu_close_root() 2025-03-10 16:16:20 +09:00
tokyo4j
d7b5555bf8 menu: s/menu_configure/menu_reposition/ 2025-03-10 16:16:20 +09:00
tokyo4j
853d71ee6d menu: remove menu_free_from() 2025-03-10 16:16:20 +09:00
tokyo4j
7cc0c47923 action: allow only Previous/NextWindow action while window switching
This commit prevents some actions like SendToDesktop from being executed
while window switching, which may mess up our scene-graph.
2025-03-09 20:41:26 +00:00
tokyo4j
270b45da88 desktop: harden window stacking order while window switching
This commit moves the check against server->input_mode from the callers
of desktop_focus_view() into desktop_focus_view() itself. This
eliminates code duplications and makes it harder to mess up the window
stacking order while window switching.

I also added the same check in view_minimize() so that minimize requests
from panels never messes up the window stacking order (I think only this
should be described in the release note).
2025-03-09 20:41:26 +00:00
tokyo4j
cf759ec183 osd: don't update cursor while window switching
cursor_update_focus() is no-op while server->input_mode is set. So we
should only call cursor_update_focus() at the beginning/end of window
switching.
2025-03-09 20:41:26 +00:00
Johan Malm
4eec0d2fc7 config: honor no content <desktops><prefix> node
...because users need a way to override the default "Workspace".

Fixes: #2601
2025-03-09 12:06:16 +09:00
Johan Malm
9ca0b111f4 config: increase default <snapping><range> to 10
...to make it easier to snap windows on the edge between two monitors.

Fixes: #2602
2025-03-08 22:36:53 +09:00
zeussuse
ba81866268 call selected actions with keypad enter 2025-03-06 21:42:05 +00:00
tokyo4j
c9eaecb3ee magnifier: refactor magnifier_draw() 2025-02-24 18:59:57 +09:00
tokyo4j
392db7c04d ssd-titlebar: show fallback icon when no app_id is set
Before this commit, nothing was rendered in window icon button if the
application doesn't set its app_id (e.g. nested kwin_wayland). This was my
oversight in dc474521.

This commit makes sure fallback icon (set via <theme><fallbackAppIcon>)
by removing ssd->state.app_id and the early-return in
ssd_update_window_icon(). This doesn't affect performance because
scaled_icon_buffer caches app_id and scaled_icon_buffer_set_app_id() does
nothing when a duplicated app_id is passed.
2025-02-23 22:56:03 +01:00
tokyo4j
a40c779e59 magnifier: make sure magnifier scale is bigger than 1.0 2025-02-23 14:22:39 +09:00
tokyo4j
f9d6fcb1e4 magnifier: use wlr_output.swapchain.format 2025-02-23 14:17:35 +09:00
tokyo4j
b66c0d8797 magnifier: rename some functions 2025-02-23 14:17:31 +09:00
tokyo4j
cfbe54e67a box: add box_to_fbox() 2025-02-22 20:38:03 +09:00
tokyo4j
a8cb8aad30 cursor: don't un-minimize previewed window while window switching
This commit restores the check removed in 7a6ecca.

Without the check, if followMouse="yes" and
followMouseRequiresMovement="no", osd_update() => cursor_update_focus() =>
desktop_focus_view() unexpectedly un-minimizes the window on cursor even
when the window is just a preview of window switcher. This caused some
strange behavior that a minimized window selected with window switcher is
immediately hidden after finishing window switching.
2025-02-18 01:33:21 +09:00
tokyo4j
fa6bffa6c6 osd: prevent preview outlines from overlapping OSD in first output
Following code didn't consider multi-monitor setup:

  wlr_scene_node_raise_to_top(&server->menu_tree->node);
  wlr_scene_node_raise_to_top(&output->osd_tree->node);

...because when executed twice, server->menu_tree is raised above
output->osd_tree for the first output. This resulted in a scene tree like
(higher to lower):

- output->osd_tree (for 2nd output)
- output->server->osd_state.preview_outline (placed just above menu_tree)
- sever->menu_tree
- output->osd_tree (for 1st output)

So the previous outline for window switcher is placed above the OSD in the
first output.
2025-02-17 15:41:44 +00:00
Consolatis
bf02598098 output: early return on wlopm if requested state is already set
This prevents a unnecessary output commit without buffer,
showing up as black flash when repeatedly calling wlopm --on.
2025-02-13 20:45:18 +00:00
Consolatis
c0526d856d output: set custom output mode on wlopm --on
This works around a wlroots issue:
https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/3946

Fixes: #2576
2025-02-13 14:19:50 +01:00
Consolatis
bb64dc81d6 src/layers: handle unmap without any outputs left 2025-02-12 15:38:18 +01:00
Consolatis
a4d1fcfef2 src/overlay.c: clean up timer on exit 2025-02-12 00:09:17 +09:00
tokyo4j
fb5e85f40f menu: remove ShowMenu action from menu items
Previous commits fixed some unexpected behaviors when ShowMenu action is
executed from menu items, but that was still prone to bugs because when
calling actions_run(), we allow an inconsistent state where all menus are
closed but pipemenus must not be destroyed.

So this commit simply removes ShowMenu actions from menu items on
initialization.
2025-02-07 17:58:55 +01:00
tokyo4j
8f5217c98b menu: assert no menu is opened in menu_open_root()
66a3beb added an early-return when the menu is opened, so we can guarantee
that no menu is opened there.
2025-02-07 17:58:55 +01:00
tokyo4j
4072a80eba menu: fix unexpected behavior when a menu is opened from another menu
server->menu_current should be cleared before calling actions_run() as
it may internally call menu_open_root(). Clearing it after actions_run()
leads to an inconsistent state where a menu is opened but
server->menu_current is NULL. It even lead to a segfault when the item
opening another menu is contained in a pipemenu, because
menu_open_root() calls destroy_pipemenu() when server->menu_current is
set, which makes accessing item->actions a UAF.
2025-02-07 17:58:55 +01:00
Andrew J. Hesford
6b9cc5dd64 ssd: make sizes of invisible SSD extents configurable 2025-02-04 18:55:31 -05:00
Consolatis
e47f9204b9 action.c: add SSD margin to MoveTo coordinates
Fixes: #2469
2025-02-04 21:56:40 +01:00
Consolatis
897799da5a server: on exit, destroy backends first
This fixes a UAF caused by trying to update the xcursor in a
output destroy handler, in turn caused by destroying the backend.

Fixes: #2539
2025-02-04 19:56:36 +00:00
tokyo4j
950337b895 ssd: fix resizing on border corners and add <resize><cornerRange>
Eliminate corner extents and instead use cursor position to map SSD
borders and extents to corner contexts, with a size configurable by the
<resize><cornerRange> parameter. This simplifies extent handling,
eliminates bugs in the detection of corner context, and allows users to
expand corner targets if they wish.

Co-authored-by: Andrew J. Hesford <ajh@sideband.org>
2025-02-04 11:13:32 -05:00
Orfeas
3e9c08871f query: encapsulate parser state into a struct 2025-02-03 20:00:22 +00:00
Consolatis
ed4553fc7e src/menu: add global config for menu.showIcons 2025-02-02 15:05:37 +00:00
Consolatis
1fa4070025 src/menu: add support for scalable menu icons 2025-02-02 15:05:37 +00:00