Commit graph

822 commits

Author SHA1 Message Date
Simon Long
c79b8ba8a7
Support hover icons in titlebar (#1280)
Allow both max_toggled_hover and max_hover_toggled names for icons
2023-12-06 20:33:26 +00:00
Consus
5d2f594626 Implement cursor-shape-v1 protocol
This protocol allows Wayland clients to request a buffer for a cursor
shape from a compositor.

Tested with foot.
2023-12-05 09:59:40 +01:00
nullableVoidPtr
bf326cc8f1 chase (dnd): refactor to use wlroot's scene_drag_icon 2023-12-03 18:24:26 +00:00
nullableVoidPtr
41891209fc chase: use wlroots tree node getters 2023-12-03 18:24:26 +00:00
Johan Malm
fcf21e1464 chase: handle gamma-control-v1 set_gamma events
References:
- https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4046
- https://github.com/swaywm/sway/pull/7494/files

Fixes: #1262
2023-12-01 22:30:17 +00:00
John Lindgren
83e67b32b6 xwayland: treat X11 panel views as if fixedPosition rule is set 2023-11-29 06:48:31 +00:00
John Lindgren
0a5255f062 output,xwayland: Add support for _NET_WM_STRUT_PARTIAL
Account for space taken up by XWayland panels (as indicated by the
_NET_WM_STRUT_PARTIAL property) in the usable_area calculation.

This makes it possible to use labwc in a "transitional" setup, where it
replaces the X11 window manager and compositor, but most other parts of
a existing X11 desktop environment can still be used via XWayland.

(Some remaining drawbacks of such a setup would be the lack of desktop
icons, and native Wayland clients not showing up in X11-based taskbars.)
2023-11-29 06:48:31 +00:00
Brandon Nason
bad8f334ea Add omnipresent flag for views 2023-11-28 21:41:30 +00:00
John Lindgren
6b8c79748a xwayland: set _NET_WORKAREA property based on usable area
XWayland clients use the _NET_WORKAREA root window property to determine
how much of the screen is not covered by panels/docks. The property is
used for example by Qt to determine areas of the screen that popup menus
should not overlap (see QScreen::availableVirtualGeometry).

Depends on wlroots MR:
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4406

v2: prevent calling wlr_xwayland_set_workareas() too early
v3: fix segfault at exit (server->xwayland == NULL)
2023-11-27 22:08:43 +00:00
John Lindgren
96c85051ae Chase wlroots: add output to scene_output_layout explicitly
Chases: f5917f0247600b65edec1735234d00de57d577a8
scene_output_layout: make output adding explicit
2023-11-27 21:01:53 +00:00
Consolatis
ddc9047a67 Restore nested resize
Chases: 756ecf8ee9f1e75bc7b8297dc84f97c7d699174b
backend/wayland: use request_state when toplevel is resized

Chases: 3ef68a484243555b020200c6f95246d994932c3f
backend/x11: use request_state when window is resized

Ref: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/2693

We now delay requested resolution changes by the backend until
the next frame event which causes us to render the new content
on the already enlarged buffer. Before this change, an empty
(black) buffer would have been shown instead before the next
frame event caused a new render of the actual contents.

Keep commiting the new state and then scheduling a frame event
would not help as due to the commit call it would still show an
empty buffer in the meantime.

Just modifying wlr_output->pending wouldn't work either because
wlr_scene_output_commit() *completely* ignores it (and it will
be removed in future wlroots commits). For this reason we move
to wlr_scene_output_build_state() directly because it allows us
to supply the current wlr_output->pending state and thus apply
any resolution change in lockstep with new rendering. Result:
No more flickering in the wayland backend and resizing is again
smooth as butter.

This prevents constant flicker while resizing
when running nested via the wayland backend.

For the X11 backend (can be tested via `WLR_BACKENDS=x11 labwc`),
it is still rather janky but at least doesn't cause endless self-
resizing anymore.
2023-11-27 21:01:53 +00:00
Christopher Snowhill
d7dc6e01b4 Chase wlroots: Unified mapping
Need to handle new unified mapping, where mapping is attached to the
wlr_surface objects instead of their parents. Also, most of them require
a new associate event for xsurface objects, their surface member will be
NULL before this event is received.

Refactored by jlindgren:
- add struct mappable
- unify map/unmap logic
2023-11-27 21:01:53 +00:00
Consolatis
46e3e29e26 Chase wlroots: wlr_session refactor
Chases 41b7acbab78597e2eb0724e415ed94b910d113c1
backend: return wlr_session in wlr_backend_autocreate() call
2023-11-27 21:01:53 +00:00
Consolatis
6c1ca61ee7 Keep xwayland stacking order in sync when switching workspaces
Until we expose the workspaces to xwayland we need a way to
ensure that xwayland views on the current workspace are always
stacked above xwayland views on other workspaces.

If we fail to do so, issues arise in scenarios where we change
the mouse focus but do not change the (xwayland) stacking order.

Reproducer:
- If followMouse is enabled, raiseOnFocus must be disabled
- Open at least two xwayland windows which allow scrolling
  (some X11 terminal with 'man man' for example)
- Switch to another workspace, open another xwayland window
  which allows scrolling and maximize it
- Switch back to the previous workspace with the two windows
- Move the mouse to the xwayland window that does *not* have
  focus
- Start scrolling
- All scroll events should end up on the maximized window on
  the other workspace

This patch fixes the issue by simply raising all windows from
the current workspace again in their original stacking order
when switching workspaces.

Reported-by: Domo via IRC (thanks!)
2023-11-21 22:31:05 +01:00
Consolatis
042215f856 common/array.h: add wl_array_for_each_reverse macro 2023-11-21 22:31:05 +01:00
Consolatis
4d679801ad src/view.c: add always_on_top criteria 2023-11-21 22:31:05 +01:00
Consolatis
13d0b14244 Update top layer visiblity on workspace switch
Fixes: #1158
2023-11-12 17:39:00 +00:00
John Lindgren
98bf316ee6 keyboard: include pressed modifiers in bound set
This prevents applications from seeing and handling the release event
for a modifier key that was part of a keybinding (e.g. Firefox displays
its menu bar for a lone Alt press + release).
2023-11-12 17:37:30 +00:00
John Lindgren
7571c4bed3 keyboard: avoid stuck keys due to keybindings (alternate approach)
Before commit e77330bc3f, there were issues with keys becoming "stuck"
if other keys were pressed at the time a keybinding was matched, because
those other keys were included in the "bound" set and the release events
were incorrectly eaten by labwc.

Commit e77330bc3f solved that issue with the "big hammer" approach of
preventing keybindings from working at all if other keys were pressed:

        if (key_state_nr_pressed_keys() > 1) {
                return false;
        }

This is an alternate approach to solving the original problem, by (1)
not including those other keys in the "bound" set and (2) making sure we
always forward release events for un-bound keys to clients (even if a
menu or OSD is displayed).

Details:

- Since we only ever want to store the single matched keycode as bound,
  key_state_store_pressed_keys_as_bound() doesn't really make sense in
  the plural, so rename it to key_state_store_pressed_key_as_bound() and
  pass in the keycode.

- The calls to key_state_store_pressed_keys_as_bound() within
  handle_keybinding() appear to be redundant since it is also called
  from the parent function (handle_compositor_keybindings()). So remove
  these calls.

- Finally, rework the logic for handling key-release events so that we
  always forward release events for keys not in the "bound" set.

This PR does not remove the "key_state_nr_pressed_keys() > 1" check, and
because of that should not result in any functional change. It should
however make it possible to relax or remove that check in future.
2023-11-12 17:37:30 +00:00
Johan Malm
368ede7460 window-rules: add fixedPosition property
...to address regression introduced by 57075ce and enables panel/desktop
clients which rely on window rules to remain in the same position when
the usable-area changes (normally because an exclusive layer-shell
clients is started/finished).

Also disallows interactive move/resize, for example by alt +
mouse-press.

Fixes: #1235
2023-11-10 21:46:15 +01:00
tokyo4j
9a8a2905ad interactive: Make window snapping with mouse more intuitive
1. Prevent window snapping triggered by mouse from moving the window
 into the adjacent output.
2. Make the coordinates used to check whether window snapping is
 triggered relative to the output the cursor is at, not the output the
 view is belonging to. This allows users to grab a tiled window and move
 it into another output or tile it again in another output in a single
 drag.
2023-11-10 19:41:36 +00:00
John Lindgren
57075ce864 view: ensure that floating views don't overlap top panels
The top_left_edge_boundary_check() function in xwayland.c ensures that
views trying to position themselves at 0,0 don't end up with a titlebar
offscreen. However, it doesn't take into account the usable area and
thus these views can still end up overlapping a top panel.

Also, there is no good reason for top_left_edge_boundary_check() to be
xwayland-specific. This logic should really be part of
view_adjust_for_layout_change().

To fix all this, add a new view_adjust_floating_geometry() function,
which replaces the existing similar (and duplicated) logic in
view_apply_natural_geometry() and view_adjust_for_layout_change().

view_adjust_for_layout_change() is already being called from xwayland's
set_initial_position(), so top_left_edge_boundary_check() is now
redundant and can just be deleted.

Lightly tested with waybar and feh --geometry 640x480+0+0. The feh
window is now correctly positioned below waybar, even if started before
waybar (in that case, the feh window is moved when waybar starts).
2023-11-05 15:03:13 +00:00
Consolatis
984aeb0b0b keyboard: allow applying keyboard layout per window
Fixes #1076

It can be enabled with a config like

~/.config/labwc/rc.xml:
<keyboard layoutScope="window">

~/.config/labwc/environment:
XKB_DEFAULT_LAYOUT=de,us
XKB_DEFAULT_OPTIONS=grp:alt_shift_toggle,grp_led:scroll

With a configuration like this each window should now remember
the active keyboard layout when switching between windows.

By default, the keyboard layout keeps being a global state.
2023-11-04 07:58:43 +00:00
John Lindgren
c5437b1153 cursor: allow re-focusing xwayland-unmanaged surfaces
We already allow some xwayland-unmanaged surfaces to take focus on map,
if indicated by wlr_xwayland_or_surface_wants_focus(). But once these
surfaces lose focus, they never regain it again.

Add desktop_focus_view_or_surface() and call it in the appropriate
places to allow these views to regain focus in the usual ways (e.g.
clicking on them or focus-follows-mouse).
2023-11-02 19:31:10 +00:00
Tomi Ollila
7aa1dc1ca5 view.h: changed the type of tiled in struct view to enum view_edge
The type enum view_edge used to be defined in a .c file, so a
structure member 'tiled' in struct view had to be defined to
use another type.

Later (2023-08-02, commit 1ee8715) the definition of enum view_edge
was moved to view.h, so now 'tiled' can be defined to use that type.
2023-10-31 21:58:20 +00:00
Consolatis
797e743c8a Move input handler init() and finish() functions to input/input.c 2023-10-30 21:14:04 +00:00
Consolatis
b359b1560c Move keyboard functions into input/keyboard.h 2023-10-30 21:14:04 +00:00
Consolatis
5e1562fae6 Make touch depend on cursor to prevent racing 2023-10-30 21:14:04 +00:00
Consolatis
8d0812d45a Move gesture handling out of cursor.c 2023-10-30 21:14:04 +00:00
Consolatis
67a8ae8561 Move input related source files into src/input/ 2023-10-30 21:14:04 +00:00
John Lindgren
0430f6f818 view: implement separate horizontal/vertical maximize
This is a useful (if lesser-known) feature of at least a few popular X11
window managers, for example Openbox and XFWM4. Typically right-click on
the maximize button toggles horizontal maximize, while middle-click
toggles vertical maximize.

Support in labwc uses the same configuration syntax as Openbox, where the
Maximize/ToggleMaximize actions have an optional "direction" argument:
horizontal, vertical, or both (default). The default mouse bindings match
the XFWM4 defaults (not sure what Openbox has by default).

Most of the external protocols still assume "maximized" is a Boolean,
which is no longer true internally. For the sake of the outside world,
a view is only "maximized" if maximized in both directions.

Internally, I've taken the following approach:

- SSD code decorates the view as "maximized" (i.e. hiding borders) only
  if maximized in both directions.

- Layout code (interactive move/resize, tiling, etc.) generally treats
  the view as "maximized" (with the restrictions that entails) if
  maximized in either direction. For example, moving a vertically-
  maximized view first restores the natural geometry (this differs from
  Openbox, which instead allows the view to move only horizontally.)

v2: use enum view_axis for view->maximized
v3:
  - update docs
  - allow resizing if partly maximized
  - add TODOs & corrections noted by Consolatis
2023-10-28 22:46:49 +02:00
John Lindgren
db591d1400 view: avoid raising same view over and over
Since view_move_to_front() now does more work than it used to
(updating XWayland server stacking order), try to avoid doing that
work unnecessarily.
2023-10-21 21:42:24 +01:00
John Lindgren
47e80a488e view: commonize sub-view logic in view_move_to_front/back()
The logic was the same for xdg-shell and xwayland views, so move it from
the view->impl layer out to the view_move_to_front/back() functions.

view->impl->move_to_front/back() still exist for now, in case we want to
add xdg/xwayland-specific logic in future, but they now move only one
view and not sub-views.
2023-10-21 15:40:56 +01:00
John Lindgren
048d22d473 common: move MIN and MAX to common/macros.h 2023-10-21 12:37:42 +01:00
John Lindgren
5cb1d0e83f common: add and use CONNECT_SIGNAL macro
This makes the code a bit more readable IMHO (and forces us to be
consistent with event handler function names).

Adjust scripts/checkpatch.pl to not complain.
2023-10-21 12:37:42 +01:00
John Lindgren
a036d985d7 common: rename array-size.h to macros.h 2023-10-21 12:37:42 +01:00
Johan Malm
7f30de1134 xdg: add xdg_shell_init()
...to have the event-handler functions in the same translation unit as
the signal connector.

No functional change intended.
2023-10-20 18:14:11 -04:00
Consolatis
8d17ab2d60 scaled_scene_buffer: make dropping the buffer optional
In preparation to also use the scaled_scene_buffer for
theme components like rounded corner images and button
icons.

No functional change intended.
2023-10-19 21:48:57 +01:00
Axel Burri
299fb83fcc GrowToEdge, ShrinkToEdge: Implement actions 2023-10-19 19:09:42 +01:00
Axel Burri
08cff6edcf MoveToEdge: Snap to window edge
Add configurable option (enabled by default) to snap to next window
edge instead of screen edge.
2023-10-19 19:09:42 +01:00
Axel Burri
1d72a08916 Add snap to window edge framework
Adds functions for calculation of distances between window edges, as
well as for window growing and shrinking.

All calculations are based on the "pending" geometry.

Ignored from snapping:

 - views that do not share the same output
 - minimized views
 - maximized views
 - views that are neither:
   - part of the current workspace
   - part of the always-on-top tree
2023-10-19 19:09:42 +01:00
Axel Burri
5176ac4f64 Move min/max view width/height to header
Preparatory for snap to window edge framework.
2023-10-19 19:09:42 +01:00
Axel Burri
afe92654fd Add output_usable_area_scaled() helper
Preparatory for snap to window edge framework.
2023-10-19 19:09:42 +01:00
John Lindgren
a1324c8cdc xwayland: center stored natural geometry for initially maximized views
For views that are initially maximized or fullscreen and have no
explicitly specified position, we need to center the stored natural
geometry, or the view may end up partially offscreen once unmaximized/
unfullscreened.
2023-10-18 19:49:53 +01:00
John Lindgren
f6e3527767 desktop: allow re-focus between "globally active" views of the same PID
Commit 7e72bf975f changed behavior to not automatically focus xwayland
views using the "Globally Active" input model (WM_HINTS.inputs = false
but WM_TAKE_FOCUS listed in WM_PROTOCOLS).

One undesired side effect of this change is that when a dialog is
closed, the parent window is not re-focused if "Globally Active". This
issue is seen for example with JDownloader. It can be solved taking a
similar approach to what is done for unmanaged xwayland views: allow
automatic re-focus between views sharing the same PID.

Note that it's difficult to completely solve all of the focus issues
with Globally Active views without proper WM_TAKE_FOCUS support.
Implementing proper support is difficult since it requires wlroots
changes and would also mean waiting for a message round-trip in
desktop_focus_topmost_view().

Fixes (partially): 7e72bf975f
("view/xwayland: avoid focusing views that don't want focus")
2023-10-16 20:28:18 +01:00
John Lindgren
dd7f563a50 view: add view_wants_focus enum (NEVER/ALWAYS/OFFER) and function
This allows identifying XWayland views using the ICCCM "Globally Active"
input model. Later commits will improve handling of these views.

No functional change in this commit.
2023-10-16 20:28:18 +01:00
John Lindgren
8bb2e2123f seat: move session-lock check down to seat_focus() level
We were checking for a locked session in desktop_focus_view(), but there
are several other call sites of seat_focus_surface() which were missing
such a check. Any one of those could cause the lock screen to lose focus
(making the session impossible to unlock) or another surface to gain it
(breaching the session lock).

To fix the issue, make any call to seat_focus_surface() no-op when the
session is locked. Add a specific seat_focus_lock_surface() function
which is the only way to bypass the check and is called only from
session-lock.c.
2023-10-15 21:32:41 +01:00
John Lindgren
b053c9e375 view: only focus topmost view if unmapped view was focused
The unmap() handlers should only call desktop_focus_topmost_view() if
the unmapped view was the focused view. Unmapping a view that was not
focused should not change the focus.

I expect this rarely had any effect in practice; it would only matter in
a focus-follows-mouse config where some view other than the one on top
was focused. But it still seems better to fix.

Rather than repeating the logic in two places, create a small
view_impl_unmap() helper. Perhaps more common "unmap" logic could be
moved there in future.
2023-10-15 21:15:11 +01:00
Arnaudv6
8920e546db Add MoveToCursor action 2023-10-15 20:36:37 +01:00
John Lindgren
5c4038493f view: add view_is_related()
Allows removing xwayland-specific stuff from seat.c.

Based on a suggestion from @Consolatis.

v2: add comments
2023-10-15 18:38:47 +02:00