Commit graph

64 commits

Author SHA1 Message Date
GoranKovac
bf738fffbb
Detecting if UTILITY is popup (#323)
Ardour uses UTILITY atom all over the place for toplevel windows:
Plugins, Dialogs etc
However it does not provide any MOTIF_HINTS at all.

WeChat however uses them for popups and also provides MOTIF_HINTS with
flags 0x2 indicating that only decorations are active. MaterialMaker
also follows what WeChat is doing for right click menus.

This fix assigns UTILITY as popup ONLY if MOTIF_HINTS are provided and
functions are not active.

Couple of apps like Godot mark their windows
(_NET_WM_WINDOW_TYPE_UTILITY) with override_redirect which makes them
popup by default. Potentionally is_popup can be overriden in case MOTIF
functions exists with so no_function_motif would be false.

This fix prefers override_redirect in case that scenario comes up.

Closes #294
2025-12-21 19:30:50 -05:00
Shawn Wallace
2f9981ad08 Add test for WM_STATE on map/unmap 2025-12-08 08:52:26 -05:00
Shawn Wallace
e719ce746a xstate: mark _NET_WM_WINDOW_TYPE_UTILITY windows as popups
Fixes #277
2025-11-30 22:36:20 -05:00
Shawn Wallace
f379ff5722 server: redraw decorations on window reconfigure
Fixes #270
2025-11-21 00:55:21 -05:00
En-En
34bf07db05 fix: give clipboard/primary TARGETS unique atoms
The clipboard and primary selections previously used the same atom to
store TARGETS when queried for them by `handle_target_list`. When a
program requests both selections simultaneously, problems such as one
selection using the target list of the other, then deleting it and
requiring the second target to get the selection targets again could
occur. This was observed when using `wl-clip-persist` and could result
in selection desyncs.

This change gives a unique atom to each primary and clipboard selection
targets so they no longer compete over the same property. It also adds
updates to the `copy_from_x11` intergration to test for this issue.
2025-11-09 22:55:32 -05:00
Shawn Wallace
b39388d91a Add client side decorations to toplevels
These simple decorations will be rendered only when the host compositor doesn't
support server side decorations and the X11 window does not render its own
decorations.

Closes #31
2025-11-06 22:32:10 -05:00
En-En
e8079bc072 feat: popup POPUP & DROPDOWN _NET_WM_WINDOW_TYPE
Thanks for @SamSaffron for the implementation. I added the relevant
check to the `popup_heuristics` integration.
2025-11-05 21:47:10 -05:00
En-En
53b6072bd9 refactor: improve logs, unify integration log fmt
The catch-all case of `handle_client_message` now logs the atom's name
instead of its opaque atom id.

`get_atom_name` now warns there was an error and returns a filler name.
Since most the use of `get_atom_name` is in logging, this makes those
logs easier to read.

The integration tests now use `formatted_timed_builder` logger
constructor, which should unify the look of logs between the integration
tests and the main binary.
2025-11-04 19:20:24 -05:00
En-En
d621a0b37a fix: X-owned primary blocks clipboard INCR
Due to an oversight, if `XState` had both a valid primary selection
and a valid clipboard selection, `handle_selection_property_change`
would early return after `check_for_incr` determines the primary selection
existed but was not the recipient of the `PropertyNotifyEvent`, preventing
INCR events from ever reaching the clipboard. An addtion to the
`incr_copy_from_x11` integration test validates this fix.

Also fixed was a missing check in `WaylandSelection`'s `check_for_incr`
to confirm the property requesting more data is indeed the property the
selection is responsible for. I could not figure out how to write an
integration for this mistake, but it is obvious enough in hindsight.
2025-10-24 18:40:12 -04:00
En-En
cc011f3251 refactor: fix handle_selection_request 8/7 args
Resolve Clippy's `too_many_arguments` lint on
`handle_selection_request` by removing the `success` and `refuse`
parameters and returning a bool indicating which needs to be run.

Use the helper functions defined last commit to simplify
`incr_copy_from_x11`

Reduce the `match` statement checking if the target is the TARGET
atom to an if statement. Although using `match` statements as
`if`/`else if`/`else` chains occur elsewhere, this one is both only 2
cases, and already of particular relevance to the current work.

Refactor `paste_impl` to be much easier to read. I did this code algebra
way back while investigating #142, but since I never figured that out,
the change has just been sitting in my stash.

refactor: simplify paste_data logic, some unnests
2025-10-24 18:40:12 -04:00
En-En
1ec45141e6 feat: send huge Wayland-to-X selections via INCR
Since the connection handshake establishes the most data a request can
send, if the data length exceeds that limit, we can follow ICCCM 2.7.2
sending the INCR property and continuing to send data via PropertyNotify
events.

To test the changes, we create `XState::set_max_req_bytes` to forcefully
trigger the INCR mechanism in integration test runs with a constant,
substantially less amount of data.
2025-10-24 18:40:12 -04:00
En-En
334933b212 test: demo crash on huge Wayland to X transfer
I found an oversight where trying to transfer too much data (16 MiB
in my case) from a Wayland selection to an X window causes the X
connection to be unable to poll the event with a `ClosedReqLenExceed`
error.

To replicate, start `xwls`, use `wl-copy` to copy more data than the
`maximum-request-size` to the Wayland selection, then attempt to
transfer that selection to an X program. I found this easy to do
transferring a large, random `.bmp` file to Krita by creating its new
image from clipboard functionality.

This test replicates the observed behavior and obtains the same
panic, to be used as a starting point for implementing incremental
selections from Wayland to X.
2025-10-24 18:40:12 -04:00
En-En
bf745144ac fix: bump xcb-util-cursor to 0.3.5
xcb-util-cursor made another patch release to revert back to Rust 2021
edition, so we bump to that.

Also create a function, `timespec_from_millis` to make creating
`Timespec` for using in `poll` calls a lot more ergonomic.
2025-10-22 18:47:03 -04:00
En-En
e827c42d2d deps: bump rustix to version 1 2025-10-22 18:47:03 -04:00
Shawn Wallace
970728d0d9 Support client initiated window resizing
Closes #185
2025-09-06 13:29:18 -04:00
Shawn Wallace
0b94ae1eb8 Support client initiated window move (_NET_WM_MOVERESIZE)
Part of #185
2025-09-06 13:29:14 -04:00
En-En
c0497c990d deps: use pretty_env_logger as env_logger dep 2025-08-31 18:30:14 -04:00
En-En
fe1796cfa7 ci: restore dependency-storing dockerfile 2025-08-26 22:02:53 -04:00
En-En
9052dd556a ci: rewrite from ground up 2025-08-26 22:02:53 -04:00
Shawn Wallace
5a184d4359 Support primary selection
This was more tedious than expected.
Fixes #103
2025-08-14 20:59:01 -04:00
En-En
fe28bcb880 fix(test): stabilize integration tests 2025-08-06 22:32:00 -04:00
skyrelia
ef24bce5d9 Recognize drag and drop window type
Fixes #166
2025-06-29 16:15:20 -04:00
Shawn Wallace
b98fa84524 Use fractional scaling when setting scale through xsettings
Fixes #168
2025-06-19 17:02:42 -04:00
Ivan Molodetskikh
9e48795087 Accept -listenfd and pass on to Xwayland 2025-06-07 12:59:01 -04:00
Shawn Wallace
d7bc38e6e7 xstate: mark _NET_WM_WINDOW_TYPE_MENU/TOOLTIP as popups
Fixes #161
2025-05-27 20:01:12 -04:00
Shawn Wallace
5c0351ff33 Properly handle rotated outputs
Fixes #160
2025-05-27 19:35:10 -04:00
Shawn Wallace
572fa4a2bf Add Xsettings support, for setting scaling related settings
This allows for most GTK and Qt apps to be scaled properly.
In the case of mixed DPI, it will default to using the smallest monitor scale.
2025-05-23 23:25:33 -04:00
Shawn Wallace
4671f27282 Use _MOTIF_WM_HINTS to determine if window should be popup
Surely this won't go horribly wrong...
Fixes #155
2025-05-12 23:25:17 -04:00
Shawn Wallace
56a681bfec Mark windows with _NET_WM_STATE_SKIP_TASKBAR as popups
Also includes some light refactoring of the popup flow in general
and trimming down some unused code.

I suspect this may cause some windows to unexpectedly become popups when they
otherwise shouldn't, but that's a bridge we'll cross when we get there.

Fixes #110 and #112.
2025-04-27 01:10:55 -04:00
Shawn Wallace
0cd5059c42 Don't set viewport for 1x1 windows with scaling 2025-04-13 23:50:13 -04:00
Shawn Wallace
8188df0e70 Force buffers to be unscaled
Satellite will now force Xwayland to always render with the native
display resolution, and just scale surface sizes accordingly. As a result,
applications won't really respect DPI, but this can be adjusted through
the same means as with normal X11.

Part of #28.
2025-04-09 00:32:20 -04:00
bbb651
0559ace758 Support xdg decorations 2025-03-29 23:09:32 -04:00
bbb651
0fa13c6fb4 input_focus test: verify WmState::Normal on focus 2025-03-22 15:25:48 -04:00
bbb651
180efb0ba9 Support XDG Activation
Test XDG Activation
2025-03-20 09:05:24 -04:00
Shawn Wallace
beb7c3ebe0 Offset output positions to always have positive coordinates
Honestly, this is something that should probably be fixed in Xwayland itself,
but they don't seem interested in fixing it:
https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/395#note_555613

Fixes #15
2025-03-16 16:00:10 -04:00
En-En
f9ec97b007 Make Fixture::drop send a valid exit code ptr to the stream
Found a good way to avoid both an extra function to RunData and make calling `xwayland_exit_code` in other RunData types *less* prone to memory violations. Having a function with a non-empty default implementation being overridden by an empty implementation felt too awkward.
2025-03-15 20:09:40 -04:00
En-En
d4dcee4e8d Add error message if Xwayland dies out of tests & Refactors 2025-03-15 20:09:40 -04:00
En-En
eab4adc991 Fix most Broken Pipe IO aborts
Makes sure the xwayland_satellite main thread ends so that the file descriptors don't continue to be used after Fixture drops them
2025-03-13 20:00:13 -04:00
Shawn Wallace
f459c604f5 Make integration tests less flaky
- Send sigterm to Xwayland after the test has completed
- Before polling for a new event, try to just grab one from xcb

Fixes #118
2025-03-13 20:00:13 -04:00
Shawn Wallace
54a7ad9e13 server: Unmap popup on popup_done event
Seems some applications don't expect their popups to be unmapped without
their consent, so they make act strangely, but at least it doesn't
crash.
Fixes #117
2025-03-12 00:47:26 -04:00
Shawn Wallace
8f55e27f63 xstate: always advertise utf8 mime type as UTF8_STRING from Wayland selection
Fixes #87
2025-01-10 00:36:02 -05:00
Shawn Wallace
47e7357eab xstate: refactor clipboard selections
Before, every time the clipboard selection changed, satellite would copy
everything on it and force itself to be the clipboard owner, regardless
of X11 or Wayland. Now, satellite is only the owner when the clipboard
owner comes from Wayland, and uses the XFixes extension to watch for
changes in clipboard ownership X11 side. Satellite also now avoids
copying all of the clipboard contents into memory every time, instead
copying directly on request. This is a pretty big change, but should
hopefully help make the clipboard more stable.

Also added some misc test cleanup/using helper functions where possible.
Using the XFixes extension may also end up being necessary for
implementing drag and drop, so it's good the infrastructure is there
now.
2025-01-08 23:57:22 -05:00
Shawn Wallace
94da1af753 Handle INCR selections properly
Closes #82
2024-12-20 20:46:04 -05:00
Shawn Wallace
03a53b6ad7 Set primary output when window focused
Closes #80
2024-12-18 01:49:55 -05:00
Shawn Wallace
3e6f892d20 Avoid processing events from a reparented window
Should fix #71
2024-11-08 22:37:34 -05:00
Shawn Wallace
b0ee6db9fa Unfocus window on X11 side when keyboard focus is lost
Closes #69 (nice)
2024-10-29 23:24:44 -04:00
Shawn Wallace
67efa2c559 Kill clients missing WM_DELETE_WINDOW protocol on close
Allows the compositor to close glxgears and other similar apps.
2024-10-25 02:40:33 -04:00
Shawn Wallace
dc1f8a753d Use wl_keyboard instead of toplevel state for focus
Rare TODO comment actually done.
Fixes #64
2024-10-23 02:27:46 -04:00
Shawn Wallace
b962a0f33b Don't use MULTIPLE target atom for getting selections
The ICCCM claims this is a "required" target for selection owners,
however several GTK clients (zenity, winecfg) don't seem to support it.
(So much for required.) Just manually grab all the supported targets
individually from the selection owner instead.
Fix for #50
2024-09-15 01:28:32 -04:00
Shawn Wallace
cf439000a5 Prioritize xdg_output for updating window positions
Fixes #46
2024-08-08 01:32:18 -04:00