Commit graph

371 commits

Author SHA1 Message Date
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
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
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
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
tokyo4j
75bd188592 Strictly use handle_ prefix for signal handlers 2025-06-28 19:36:29 +09: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
85388d194e server: eliminate use of global vars 2025-06-09 21:57:51 +01: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
John Lindgren
8010f6e659 chase wlroots: remove #include <wlr/types/wlr_matrix.h>
Ref: 9b55737cf512ae5132b10633b83e099d46fa259f
("Make wlr_matrix private API")
2025-05-21 06:36:08 +01:00
Jens Peters
3331fcba6f action: add scroll-wheel-emulation actions 2025-05-07 03:47:37 +09:00
Jens Peters
cec2e03954 cursor: use CONNECT_SIGNAL macro
Rename functions accordingly.
2025-05-03 05:34:05 +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
75eb370d31 osd: draw window switcher with scene-nodes
...rather than drawing it onto a single texture.
2025-03-16 11:15:00 +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
tinyboxvk
1a6dd845a2 Fix typos
Signed-off-by: tinyboxvk <13696594+tinyboxvk@users.noreply.github.com>
2025-01-09 06:59:57 +00:00
tokyo4j
713b1d8a13 osd: make window switcher more Openbox-like in terms of key precessing
Before this commit, keystrokes were interpreted based on following
hard-coded rules while the window switcher is active:

  1. Up/Left arrow keys cycle the window forward.
  2. Down/Right arrow keys cycle the window backward.
  3. Other keystrokes cycle the window in the initial direction specified
     by NextWindow/PreviousWindow actions. But while Shift key is pressed,
     the direction is inverted.

...and keybind actions were never executed.

However, this lead to a counter-intuitive behavior for new, especially
pre-Openbox users. For example, in the following keybinds, after the user
activates the window switcher with Super+n, Super+p cycles the window
_forward_:

  <keybind key="W-n">
    <action name="NextWindow" />
  </keybind>
  <keybind key="W-p">
    <action name="PreviousWindow" />
  </keybind>

This is because the key 'n' is recognized just as a normal key in the
third hard-coded rule.

So this commit changes the rules to be more Openbox-like:

  1. Up/Left arrow keys cycles the window forward.
  2. Down/Right arrow keys cycles the window backward.
  3. Other keystrokes are matched against keybinds and execute their
     actions. If they include NextWindow/PreviousWindow action, it cycles
     the selected window forward/backward even while the window switcher
     is active.
2025-01-03 10:51:26 +09:00
tokyo4j
a98b535362 osd: make desktop_cycle_view() private in osd.c 2024-12-30 18:07:45 +09:00
tokyo4j
bad788ccdd Clear keyboard/pointer focus on Move/Resize, window switcher and menu
The previous revert fixed the problem of stuck modifier keys with
keybinds in Blender, but made Firefox show its menu bar with Alt-*
keybinds. This is fundamentally inevitable due to the limitation of
wayland protocol, but at least for the default Alt-Tab keybind for
window switcher, we can mitigate this problem by clearing the keyboard
focus when the window switcher is activated. This is what KWin does, and
we decided to follow that.

So in this commit, keyboard and pointer focus are temporarily cleared
while Move/Resize, window switcher and menu interactions and restored
after them. We slightly deviate from KWin as KWin doesn't clear the
keyboard focus while Move/Resize, but it solves our existing problem
that Firefox shows its menu bar after dragging it with default Alt-Drag
mousebind, and this is what Mutter does.

We considered other solutions, but they don't work well:
1. Send wl_keyboard.{leave,enter} every time keybinds/mousebinds are
   triggered. This solves the Firefox's menu bar problem, but that
   sounds like a workaround and sending unnecessary events every time is
   not desirable.
2. Send release events for both modifiers and keys even when they are
   bound to keybinds. This is what Mutter is doing, but it looks like an
   implementation issue and violates wayland protocol.
2024-12-29 16:27:34 +09:00
tokyo4j
028e24dc13 src/output.c: remove output_usable_area_scaled() 2024-12-28 23:03:34 +00:00
tokyo4j
398b80b26f Add LAB_INPUT_STATE_WINDOW_SWITCHER 2024-12-28 21:28:22 +00:00
Orfeas
1550eb9c26 action: add WarpCursor action 2024-12-26 10:27:02 +00:00
Consolatis
8156b91306 ext-workspace protocol integration 2024-12-23 04:14:53 +01:00
tokyo4j
5e422a0bc2 action: fix menu position with "x"/"y" arguments in multi-monitor setup
Prior to this commit, output-relative coordinate was passed to
menu_open_root() as the menu position when it's designated via "x"/"y"
arguments in ShowMenu action, so menu can be misplaced to the output other
than the one in which the cursor is in.
2024-12-08 17:00:03 +00:00
Jens Peters
f69576f8a6
icon-loader: rename to desktop-entry
Also rename `struct icon_loader` to `struct sfdo`.
2024-11-19 18:36:08 +01:00
tokyo4j
3f2cc1b29f osd: fix memory leak of output->osd_buffer 2024-11-12 16:21:06 +09:00
Jens Peters
8a5608a3af input: add hold-begin/-end gestures 2024-11-11 15:06:25 +01:00
Jens Peters
fc774d0071 input: hide cursor when using touch input
Hide the cursor on touch input and keep the cursur invisible
until pointer or tablet input.
2024-11-10 17:08:38 +09:00
Jens Peters
d1cde3c435 input: close xdg-popups on touch down
Taken over and now shared from the tablet implementation.
2024-11-10 17:08:38 +09:00
Consolatis
d6a48ab7a7 foreign-toplevel: add ext-toplevel-list support 2024-11-09 20:06:19 +00:00
Consolatis
2a825008c6 foreign-toplevel: create generic abstraction 2024-11-09 20:06:19 +00:00
Ricardo Steijn
8f940358e4
tearing: avoid permanent disable due to rejected commits (#2295)
Currently, the cursor plane does not allow async page flips which causes tearing page flips to be rejected if the cursor was moved.

However, in games where no cursor image is present, the async page flips can still work as expected.

Instead of permanently disabling tearing after too many failures, test the output state first before each frame to see if we can commit with tearing_page_flip set to true.
2024-11-03 21:05:46 +00:00
John Lindgren
7912665b0f output: remove ported wlr_output functions
We have several wlr_output_* functions which are just wrappers around
corresponding wlr_output_state_* functions and don't actually touch the
wlr_output itself. These probably made some sense historically, but IMHO
they are just confusing now. So remove them and call wlr_output_state_*
directly.

Rename wlr_output_commit() (still useful) to output_state_commit().
2024-10-29 21:39:19 +00:00
tokyo4j
7cc79edd62 cursor: fix button release events sometimes not being sent
When `wlr_seat_pointer_notify_button()` is called on a button press event,
that funtion must also be called on the subsequent button release event
because otherwise wlroots thinks the button is kept pressed and it
causes issues with validating DnD requests from clients, where only one
button must be pressed. This was the case when a CSD client opens a
client-menu via `show_window_menu` request after pressing its window with
the right button because we were always not notifying button release
events while a menu is open.

So let's keep track of bound (pressed but not notified) buttons and notify
button release events only when the button is not bound, like we are doing
for key-state.
2024-10-13 20:45:16 +01:00
Jens Peters
c4aa3fe3e6 server: add dmabuf feedback
Co-authored-by: Consolatis <35009135+Consolatis@users.noreply.github.com>
2024-10-13 13:54:34 +01:00
John Lindgren
ddfaae98ad icon-loader: load SVG icons at max scale of any usable output
- Add a new function to get the maximum scale of all usable outputs
- Pass the maximum output scale through to img_svg_load(), which
  ultimately calls cairo_surface_set_device_scale() before rendering
2024-10-06 21:24:34 -04:00
Johan Malm
d18e67eea8
Merge pull request #2030 from Consolatis/wip/cosmic_workspaces
Initial implementation of cosmic-workspace-unstable-v1
2024-10-01 21:31:04 +01:00
tokyo4j
a745f91169 ssd: support window icons
The default `titleLayout` is updated to `icon:iconify,max,close` which
replaces the window menu button with the window icon.

When the icon file is not found or could not be loaded, the window menu
icon as before is shown.

The icon theme can be selected with `<theme><icon>`.

This commit adds libsfdo as an optional dependency. `-Dicon=disabled` can
be passsed to `meson setup` command in order to disable window icon, in
which case the window icon is always replaced with a window menu button.
2024-09-25 18:04:09 +09:00
tokyo4j
25f5cdd3a6 Refactor the logic of placing client-menu with ShowMenu action
Before this commit, we assumed `ShowMenu` action is not bound to any
buttons other than window menu button and always place the client-menu
under the window-menu button when atCursor="no". Also, it was going to be
difficult to distinguish whether the action is executed from the window
menu button or the window icon, which will be added soon.

This commit fixes it to open the menu under the actually-clicked button by
passing `cursor_context` to `actions_run()`, with some refactoring:
- `seat->pressed.resize_edges` is removed and it's calculated from the
  cursor position and `seat->pressed.type` just before running Resize
  action. This slightly changes the existing logic to determine the
  resizing edges with Alt-Right + Drag mousebinding, but
  `seat->pressed.type` is still stored on button press so it doesn't bring
  back the issue #543.
- `seat->pressed.toplevel` is removed and `get_toplevel()` in
  `update_pressed_surface()` may be called more often, but its overhead
  will be negligible.
2024-09-21 18:07:34 +01:00
tokyo4j
1f1bdad087 interactive: allow moving horizontally/vertically maximized window
Applies drag resistance unidirectionally for horizontally/vertically
maximized windows, allowing them to be dragged without being untiled
immediately. When the distance of cursor movement orthogonal to the
maximized direction exceeds <resistance><unMaximizeThreshold>.

While dragging a horizontally/vertically maximized window, edge/region
snapping is disabled to prevent unintentional snapping and overlays.

This commit also includes some refactoring to simplify the logic.
2024-08-26 20:30:22 +02:00
Orfeas
dda47a5e14 action: make "FocusOutput" behave like "MoveToOutput" 2024-08-24 14:59:42 -04:00
tokyo4j
b667107d1a input: move <scrollFactor> to <libinput> section
This allows per-device configuration of scroll factor (e.g. setting
different scroll factors for mice and touchpads).
2024-08-23 16:20:56 +09:00
Jens Peters
dd0cee02a4 input: move cursor event listeners from tablet to seat
Otherwise we would subscribe multiple times to the
same event when having multiple tablets.
2024-08-13 18:40:34 +02:00
tokyo4j
670cc0f511 Rename <snapping><dragResistance> to <resistance><unSnapThreshold>
As we already have <resistance><{screen,window}EdgeStrength>,
<resistance> will be a better place for this setting.
2024-08-08 09:49:53 +09: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
John Lindgren
1a339f9c7e xdg: account for drag resistance in do_late_positioning()
The position where the view should be anchored can now be slightly
different from the current cursor position.

Addresses a TODO from #2009.
2024-08-06 13:51:35 +09:00
Consolatis
904e0d2e97 cosmic-workspaces: labwc integration 2024-08-03 18:25:23 +02:00
tokyo4j
c202d77c2d Add resistance when dragging tiled windows
Adds a config option <snapping><dragResistance> with default value 20.
This prevents tiled/maximized windows from being unintentionally untiled.
2024-08-02 23:40:26 +02:00