Commit graph

340 commits

Author SHA1 Message Date
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
Consolatis
d9866aafa5 workspaces: slight struct reordering 2024-08-02 19:35:36 +02:00
Christopher Snowhill
3879f1f080 backend/drm: Implement support for renderer loss recovery
This implementation is nearly identical to Sway's, except that
it also reloads the configuration, to spur on reloading the
server-side decorations.

v2: Fix style.
v3: Add a reset to the magnifier.
v4: Oops, restructure reset handler a bit.
v5: Commit the magnifier reset immediately, before freeing the
    lost allocator and renderer.
v6: Also check for failed render pass, which may return NULL.
v7: Add a second NULL test, just in case.
2024-07-23 14:44:31 +02:00
Christopher Snowhill
d033a2fbf6 output: allow tearing with atomic mode setting
Additionally, track errors and abandon the tearing allowance when it
cannot be set for two-seconds' worth of consecutive frames.
2024-07-20 08:09:00 -04: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
Consolatis
40684bad9d magnifier: disable direct scanout when active
Fixes: #1980
2024-07-17 22:44:48 +02:00
Consolatis
36b0dc2db4 chase: output->pending
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4202
2024-07-17 21:28:59 +01:00
Consolatis
d2579a0088 chase: handle xdg new toplevel event
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4345
2024-07-17 21:28:59 +01:00
Consolatis
3e614814fe chase: input inhibit removal
https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4440
2024-07-17 21:28:59 +01:00
Consolatis
714511736b src/xdg.c: verify source surface for xdg_activation request
wlroots < 0.17 didn't allow to reliably check the source surface of
an xdg activation request as it reset the surface to NULL when it
was destroyed before the token was used. This happens regularly for
notifications for example. Thus we treated the token as valid even
without checking for the source surface.

wlroots 0.17 added a new_token signal where we can attach information
to the existing token which we can then use when evaluating activation
requests. This patch implements that check.
2024-07-14 22:11:12 +02:00
droc12345
f2755a4e2e
action: remember initial direction of PreviousView
...when cycling windows. Also make the toggling of direction when shift
is pressed relative to the initial direction. For example if W-j is
bound to PreviousWindow, subsequent key presses will continue to
cycle backwards unless shift if pressed.

Add documentation for using shift/arrow keys in Next/Previous
2024-06-26 22:03:56 +01:00
Jens Peters
61e5e0e4d9 input: track tablets and tablet-pads at seat 2024-06-13 21:23:37 +01:00
Jens Peters
2388f37cc7 input: prevent cursor notifications from pointer and tablet tool
... at the same time. Omit cursor notifications from
a pointer when a tablet tool (stylus/pen) is in
proximity. We expect to get cursor notifications
from the tablet tool instead.
2024-05-31 16:59:43 +02:00
tokyo4j
a39c8afc10 session-lock: refactor
- Replaced `session_lock` with `session_lock_manager` which is
  persistent throughout the session.
- Replaced `session_lock->abandoned` with `session_lock_manager->locked`.
  Old `session_lock->abandoned` is equal to
  `!session_lock_manager->lock && session_lock_manager->locked`.
- Eliminated the use of global variables in `session-lock.c`.
- Changed some function names.
2024-05-31 11:21:29 +09:00
Yuri Nesterov
65f7499f1c wayland: add support for security-context-v1 2024-05-29 22:28:06 +01:00
Jens Peters
9c219564be server: create tablet-v2-manager 2024-05-27 22:40:50 +02:00
Hiroaki Yamamoto
d64e3915a3
Fix some header includes detected by clangd
There were some missing headers like <stddef.h> for `NULL`, <wayland-util.h>
for `wl_link` and <stdbool.h> for `true`/`false`.

Also this commit fixes that `labwc.h` and `ime.h` included each other.
2024-04-21 21:58:57 +02:00
Johan Malm
c841a25acf Add -S|--session <command> option
...to start <command> on startup and to terminate the compositor when
<command> exits.

This is useful for session management as it allows the session client (for
example `lxqt-session`) to terminate labwc - be exiting itself.

Under X, xinit starts the server and keeps it alive for as long as
lxqt-session runs. Thus either the session client starts the Window
Manager, or the Window Manager can be launched independently first.  On
Wayland, the Compositor is both Display Server and Window Manager, so the
described session management mechanisms do not work because the Compositor
needs to be running before the session can function.

As some session clients support both X11 and Wayland, this command line
option avoids re-writes and fragmentation.

Co-authored-by: @Consolatis
2024-04-14 13:05:25 +02:00
droc12345
d672765ea7
osd: add window-switcher custom field (#1670)
Add custom field with subset of printf style formatting
to replace the original field formats.

Example:

    <windowSwitcher preview="no" outlines="no" allWorkspaces="yes">
      <fields>
        <field content="custom" format="foobar %b %3s %-10o %-20W %-10i%t" width="100%" />
      </fields>
    </windowSwitcher>

Mono space font recommended. May need OSD width adjusted

Co-authored-by: @Consolatis (based on work done by them)
2024-04-10 23:39:31 +01:00
Hiroaki Yamamoto
5cc0757390
overlay: add snap-to-edge overlay (PR #1652)
...and unify region overlay and snap-to-edge overlay into overlay.c.

Snap-to-edge overlay is delayed for 500ms to prevent flickering when
the view is dragged from an output to another (demo in discussion labwc#1613).

This also fixes a bug that region overlay is not shown when a modifier
key is re-pressed.
2024-04-05 04:35:31 +02:00
Hiroaki Yamamoto
be37f9a564
Fix various typos across the codebase 2024-03-08 13:59:20 +01:00
tokyo4j
e00f7cd6db view: validate move/resize request from clients
Move/resize requests from xwayland views and xdg toplevels should be
ignored when the view is not pressed.

This is relevant for touchpad taps with <tapAndDrag> disabled.

When the user taps the client surface (e.g. chromium and mpv) with the
setting above, libinput sends button press & release signals so quickly
that the compositor receives move/resize request from the client AFTER
the button release signal is processed, so `interactive_finish()` is
never called.
2024-03-07 20:30:50 +00:00
Consolatis
95e8573388 src/output.c: refactor virtual output related functions
This commit moves the virtual output related functions
into their own file at `src/output-virtual.c` with its
own include file to reduce `include/labwc.h` bit by bit.

Additionally, it removes the need to keep the
`server->headless.pending_output_name` char array around
by temporarily disconnecting the handler when creating a
new virtual output. This allows to set the output name
right in the `output_virtual_add()` call rather than to
store the pending name until the new output event handler
has been called.

It also makes adding a virtual fallback output easier in
a follow-up PR.
2024-03-07 19:51:54 +00:00
Johan Malm
4d68ee424a osd: show preview for windows on other workspaces
Written-by: @Consolatis
2024-03-05 22:16:55 +01:00
tokyo4j
334cd09106 IME: support input method 2024-03-05 20:28:15 +00:00
Consolatis
a04b394e59 xwayland: support querying window types 2024-01-25 21:14:30 +00:00
Consolatis
396a4b93d1 src/output.c: expose output configuration test to clients 2024-01-23 20:14:24 +00:00
Jens Peters
17e15ed987 seat: re-map tablet to output on output change 2024-01-10 21:10:11 +00:00
Ph42oN
bce0c6ce56
Add tearing support (#1390)
Co-authored-by: Andrew J. Hesford <ajh@sideband.org>
2024-01-08 20:58:58 +00:00
Tomi Ollila
785a34e8ad Fixed some typos 2024-01-04 19:32:51 +00:00
Ph42oN
08045d7843 config: add adaptive sync fullscreen option 2023-12-30 15:46:35 +00:00
Johan Malm
3a959cc74b s/focused_view/active_view/ 2023-12-19 20:34:07 +00:00