Commit graph

159 commits

Author SHA1 Message Date
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
Johan Malm
60d536304b Privatize view_append_children() 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
040e25f38e Privatize private view_get_root() 2025-09-29 20:22:46 +01: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
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
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
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
9d49d19cd2 include: add config/types.h 2025-08-21 16:55:25 +09: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
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
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
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
John Lindgren
9782ffa868 desktop: give focus to a modal dialog rather than its parent
Fixes: #2722
2025-06-13 18:40:29 +01:00
John Lindgren
8fb2ecefcb xwayland: always offer focus in Globally Active case
In 9e3785f8cd, a heuristic was added to assume that NORMAL and DIALOG
window types were always focusable. (This was before we had the "offer
focus" mechanism in place.)

However, we should still call wlr_xwayland_surface_offer_focus() for
these views, in case they actually don't want focus. (This is uncommon
but has recently been seen with WeChat popups, which have both NORMAL
and UTILITY type.)

To make this possible, refine view_wants_focus() to return either
LIKELY or UNLIKELY for Globally Active input windows. This decouples
the question of "should we try to focus this view" from the actual
mechanism used to do so.
2025-06-10 11:03:54 -04:00
tokyo4j
ffd400503e Replace multi_rect with lab_scene_rect
lab_scene_rect accepts the arbitrary number of borders and a background
color.
2025-06-10 06:03:03 +09:00
tokyo4j
fb077c0095 Support xdg-toplevel-icon protocol
This patch also changes the semantics of scaled_icon_buffer: rather than
calling scaled_icon_buffer_set_app_id() every time an app_id is set, we
can now call scaled_icon_buffer_set_view() just once so that multiple
scaled_icon_buffers bound to a window are automatically updated when an
app_id is set or new icon is set via xdg-toplevel-icon-v1.
2025-06-07 02:12:56 +09:00
tokyo4j
0657a1d767 view: add destroy signal 2025-06-07 02:12:56 +09:00
DreamMaoMao
5cf4aa83e2 view.c: add new NO_OMNIPRESENT criteria 2025-06-06 18:35:32 +02:00
John Lindgren
fd5031731e xwayland: use wlr_xwayland_surface_has_window_type()
This eliminates a bit of logic, including an extra XWayland connection.

See also:
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4553
2025-05-22 23:09:41 +01:00
John Lindgren
c00baa1651 xwayland: use wlr_xwayland_surface_offer_focus()
Offer focus by sending WM_TAKE_FOCUS to a client window supporting it.
The client may accept or ignore the offer. If it accepts, the surface will
emit a focus_in signal notifying the compositor that it has received focus.
The compositor should then call wlr_xwayland_surface_activate(surface, true).

This is a more compatible method of giving focus to windows using the
Globally Active input model (see wlr_xwayland_icccm_input_model()) than
calling wlr_xwayland_surface_activate() unconditionally, since there is no
reliable way to know in advance whether these windows want to be focused.

v2: add caution not to use view_offer_focus() directly
v3: remove obsolete comment
2025-05-21 20:30:19 +02:00
Consolatis
1eaba4af33 chase wlroots: xwayland separate maximized axis MR 4670
Ref: ceb4fcedca30d323a05836b0872bfe773a047ccc
("xwm: expose individual axis for _set_maximized()")
2025-05-21 06:36:08 +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
4b7c502ace view: replace content_node with content_tree 2025-01-22 18:02:54 +01:00
Johan Malm
6457cbccda Make enum three_state public 2024-12-31 16:23:47 +00:00
tokyo4j
daae379433 view: s/scene_node/content_node/ 2024-12-14 12:03:58 +09:00
Consolatis
e274c588c0 view: add view_for_each_reverse() macro 2024-11-25 19:21:43 +00:00
Consolatis
2a825008c6 foreign-toplevel: create generic abstraction 2024-11-09 20:06:19 +00:00
Consolatis
5e1f91c9d1 view: add state change signals 2024-11-09 20:06:19 +00:00
Orfeas
96da82c085 query: support additional conditions for matching clients
Co-authored-by: Andrew J. Hesford <ajh@sideband.org>

Closes: #2245.
2024-10-30 14:30:26 -04:00
John Lindgren
452f45cd3d xdg: try to handle slow un-maximize with empty natural geometry better
In the case of an initially-maximized view which is taking a long time
to un-maximize (seen for example with Thunderbird on slow machines), we
may end up in handle_configure_timeout() with an empty pending geometry.
In that case we have no great options (we can't center the view since we
don't know the un-maximized size yet), so set a fallback position.

v2: check wlr_box_empty() before comparing pending and current

Fixes: #2191
2024-10-01 21:22:00 +01:00
Jens Peters
4fd7a8075c view: expose view_apply_natural_geometry()
Co-authored-by: tokyo4j <hrak1529@gmail.com>
2024-09-25 17:59:10 +09:00
tokyo4j
80e7b64a41 xdg: handle show_window_menu requests 2024-09-21 18:34:17 +01:00
Jens Peters
824b0fa4e3 theme: add button padding and spacing (#2127)
While at it, separate corner width from button
width. Both are independed and having them
separately improves readability.
2024-09-10 22:14:30 +01:00
Orfeas
dda47a5e14 action: make "FocusOutput" behave like "MoveToOutput" 2024-08-24 14:59:42 -04:00
Jens Peters
433a4509af
tearing: add fullscreen options (#1941)
Co-authored-by: Consolatis <35009135+Consolatis@users.noreply.github.com>
2024-08-06 21:23:10 +01:00
Consus
e4afa10fe4
theme: allow to set window button size (#1965)
This commit introduces new option "window.button.width". Despite the name
it currently affects both width and height.
2024-07-20 09:33:57 +01:00
John Lindgren
3be8fe25f3 xdg: handle initially maximized xdg-shell views better
Currently, initially maximized (or fullscreen) xdg-shell views exhibit
one of two issues:

 - some (e.g. GTK and Qt apps) paint an initial frame un-maximized
   (before the "map" event) and only maximize in a later commit

 - others (e.g. foot) maximize immediately without flicker, but never
   store a valid natural size, so we end up using a fallback (640x480)

Under KWin, neither of these issues occur, so I looked into what labwc
is doing wrong. It seems that:

 - wlroots internally sends an initial configure event with a size of
   0x0 to all xdg-shell views. This requests the client to set its own
   preferred (a.k.a. natural) size.

 - For an initially maximized/fullscreen view, the initial configure
   event should contain the maximized/fullscreen size rather than 0x0.
   In labwc, this means we have to call wlr_xdg_toplevel_set_size()
   earlier, i.e. from the new_surface event. Tracing with WAYLAND_DEBUG
   shows that the initial configure event now has the correct geometry,
   matching KWin behavior. With this change, GTK and Qt apps no longer
   paint an incorrect un-maximized frame.

 - However, this means that all xdg-shell views now suffer from the same
   issue as foot, where we never receive a commit with the un-maximized
   (natural) geometry. The correct way to get the natural geometry seems
   to be to wait until we want to un-maximize, and send a configure
   event of 0x0 at that point.

Sending a configure event of 0x0 when un-maximizing is a bit annoying as
it breaks some assumptions in labwc code. In particular:

 - view->natural_geometry may now be unknown (0x0), requiring various
   wlr_box_empty() checks sprinkled around. I added these in all the
   obvious places, but there could be some code paths that I missed.

 - Positioning the newly un-maximized view within view_maximize() no
   longer works since we don't know the natural size. Instead we have to
   run the positioning logic from the surface commit handler. This
   results in some extra complexity, especially for interactive move.
   See the new do_late_positioning() function in xdg.c.

Some TODOs/FIXMEs (non-blocking in my opinion):

 - The view_wants_decorations() check is now duplicated in both the
   new_surface and map event handlers. I'm not sure if this is necessary
   but it seemed like the safest approach for now. More testing would be
   nice, particularly with various combinations of config and client SSD
   preferences.

 - Aside from the interactive move case, the "late positioning" logic
   always centers the view when un-maximizing, and does not invoke any
   of the smart placement logic. If we want to invoke smart placement
   here, I'd appreciate someone with more knowledge of that code to take
   a look and figure out how to do that correctly.
2024-07-19 22:48:39 +01:00
Jens Peters
3b605b0142 ssd: set squared corners for tiled views conditionally
Respect the snapping settings for notify-client.
2024-06-27 22:29:11 +01:00
tokyo4j
bb1d0b4352 Implement <resize><drawContents>
<resize><drawContents>[yes|no] configures whether to let the clients
redraw its window content content while resizing.

When <resize><drawContents> is set to no, a multi-rect is shown to
indicate the geometry of the resized window.
2024-06-15 21:17:01 +01:00
Yuri Nesterov
65f7499f1c wayland: add support for security-context-v1 2024-05-29 22:28:06 +01:00
Consolatis
6f3f2aae27 ForEach: initialize view query window_type correctly
Before this patch, the window type would be checked even if
not actually requested to do so.

Fixes: #1852
2024-05-27 19:59:06 +01:00