Commit graph

221 commits

Author SHA1 Message Date
Shawn Wallace
52cc06e6c6 server: activate toplevels after mapping
This behavior was removed a while back, because we were also trying to activate
popups and this was causing issues on some compositors. However, I think
activating toplevels after they're mapped is the behavior that X11 apps tend to
expect - in Steam Big Picture for example, when launching a game in Niri while
fullscreened, the focus doesn't automatically switch to the game. This may need
to be reevaluated and refined in the future though.
2025-10-25 11:50:46 -04:00
En-En
04816e2a36 fix: factor out some unwraps in xstate::selection
Brought to my attention by #252, several `unwrap`s exist on code whose
failure does not justify the termination of the program, so I took some
time to replace them with proper error handling.

The request for TARGETS in `handle_selection_request` used `unwrap`.
Since the code for a failure of responsing to `SelectionRequest` exists,
it simply uses that.

`handle_target_list` now early returns if receiving the
`GetProperty` request fails.

`handle_new_owner` does not update the timestamp for the last selection
on failure.

`set_owner` now returns a `bool` to indicate whether the
`SetSelectionOwner` and `GetSelectionOwner` requests succeeded and
whether they transferred ownership successfully or not. The call spots
have also been modified to not change the `selection_state` if this call
fails.
2025-10-24 18:40:12 -04: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
cdf405fac5 refactor: swap WaylandIncrInfo from range to start
Since the range end was always encoded in the data length, calculating
the end of the selection is a bit cleaner and removes a potentially
confusing slice operation on a slice.
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
yuko1101
a9188e70bd nix: upgrade nixpkgs to 25.05 to fix build issue 2025-10-05 19:31:24 -04:00
ToxicMushroom
da6693c88a fix: don't print unapplicable warnings when a popup surface has its viewport set. 2025-10-02 19:52:48 -04:00
Shawn Wallace
03368548ba server: raise windows to top on tablet proximity_in
Fixes #238
2025-09-22 17:43:43 -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
Shawn Wallace
41e865c8d3 Document _JAVA_AWT_WM_NONREPARENTING
Closes #231
2025-09-02 23:11:56 -04:00
Shawn Wallace
2c30ea7863 xstate: always stack newly mapped windows below
I can't figure out a way to actually test this, but this seems to work in manual testing.
Fixes #146
2025-09-02 23:08:00 -04:00
En-En
0fd0dd75e9 tests: only use PipeWriter if rust-version >= 1.87
By using conditional compilation, we now support running the test suite
with Rust versions 1.83 to 1.86 again. This allows us to lower the
`rust-version` specified in the root Cargo.toml (because it was
controlling the toolchain used in CI) to 1.83, resolving #230.

This solution keeps tests operational on our MSRV while also lowering
it. It would have been unsatisfying to have an MSRV which could not
compile the tests.

`rustversion` was selected as the dependency to control the conditional
compilation since it was already a build dependency needed by
`vergen-gitcl`, so no new dependencies were added.
2025-09-02 20:38:01 -04:00
En-En
c0497c990d deps: use pretty_env_logger as env_logger dep 2025-08-31 18:30:14 -04:00
Supreeeme
1d156aa8d3
Create FUNDING.yml 2025-08-30 12:08:06 -04:00
En-En
bb044a88c6 fix: properly specify subprojects' required features 2025-08-30 12:03:45 -04:00
En-En
8b74001a13 fix: prevent copy tests from failing in Rust 1.90
Issue where changed: https://github.com/rust-lang/rust/issues/139956

Comment noting breakage of non-socket converted to UnixStream: 'https://github.com/rust-lang/rust/pull/140005#issuecomment-2853932531'

Bumps MSRV from 1.83.0 to 1.87.0 by use of PipeWriter
2025-08-30 12:03:15 -04:00
En-En
af33f7eb12 ci: comment logic of set-vars.sh 2025-08-26 22:02:53 -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
En-En
d759c64681 dep: bump xcb to 1.6.0
switch from the deprecated API we found unsoundness in to the one introduced in 1.6.0
2025-08-23 11:39:05 -04:00
Shawn Wallace
388d291e82 Bump version 2025-08-18 00:24:57 -04:00
Shawn Wallace
5a184d4359 Support primary selection
This was more tedious than expected.
Fixes #103
2025-08-14 20:59:01 -04:00
Shawn Wallace
13469566b0 Fix Rust 1.89 mismatched_lifetime_syntaxes lint
https://blog.rust-lang.org/2025/08/07/Rust-1.89.0/#mismatched-lifetime-syntaxes-lint
2025-08-14 01:29:17 -04:00
En-En
e0d1dad25a server: clean unneeded deref_mut calls 2025-08-06 22:32:00 -04:00
En-En
cbabd591a3 server: impl Deref(Mut) for ServerState to Inner coercion 2025-08-06 22:32:00 -04:00
En-En
fe28bcb880 fix(test): stabilize integration tests 2025-08-06 22:32:00 -04:00
En-En
be9d573fd6 server: make state's client and connection mandatory
The goal of the previous commits being to remove these unwraps. The `unwrap_or_skip_bad_window` changes needed to make a singular debug conditional
2025-08-06 22:32:00 -04:00
En-En
4280639df8 server: give uninitialized and initialized xstate with unique types 2025-08-06 22:32:00 -04:00
En-En
56d5cce2d0 server: split XConnection from rest of State refactor 2025-08-06 22:32:00 -04:00
Shawn Wallace
ecbe57e7be Document -listenfd support 2025-08-05 00:12:22 -04:00
Johannes Horner
ba78881a68 nix: Set mainProgram attribute 2025-07-12 12:33:20 -04:00
Shawn Wallace
e4bb8c3f9d cargo clippy everywhere 2025-07-12 12:32:20 -04:00
Shawn Wallace
07847e11d7 server: unscale locked pointer cursor hint
Fix #199, fix #202, fix #204
2025-07-12 12:20:21 -04:00
Shawn Wallace
557ebeb616 xstate/settings: Clamp scale to >=1
Avoids crashing, and GTK apps also seem to generally dislike
when the reported DPI is less than the default.

Fixes #181
2025-06-29 16:24:45 -04:00
skyrelia
ef24bce5d9 Recognize drag and drop window type
Fixes #166
2025-06-29 16:15:20 -04:00
Shawn Wallace
0b2a139f98 server: verify window still exists when processing surface serial
Should fix #191
2025-06-29 16:02:02 -04:00
Shawn Wallace
91d463851e server: fix selection cancellation
oopsie
2025-06-29 01:49:11 -04:00
Shawn Wallace
cf1fae1eae server: verify selection offer is still valid when handling clipboard
Should fix #170, fix #183
2025-06-29 01:37:24 -04:00
Shawn Wallace
2e7c318ac2 server: check if connected to x server when output offset updates
Caused by the compositor reporting negative output coordinates to start.

Fixes #187
2025-06-24 23:21:20 -04:00
En-En
117af56a83 Refactor double let else blocks to use as_mut 2025-06-23 09:54:29 -04:00
En-En
8dc4538662 Removed additional dubious unwraps
The wl_keyboard Enter event, wl_keyboard Leave event, the wl_touch
Self::Down event and the ServerState::reconfigure_window function had
similar uses of `unwrap` which appear to not consider the distinct
query preparation and query execution stages.
2025-06-23 09:54:29 -04:00
En-En
da3b2838d2 Fixed stale surface check unwrapping
Regression from 799027d1. Unwraps on a None value when doing the stale surface generation technique in Chatterino7 as described in #74, very consistent
2025-06-23 09:54:29 -04:00
Shawn Wallace
03cbb2ee3a server: scale tablet_tool motion events
Also add missing Distance event handler.
Closes #179, closes #123
2025-06-19 23:05:15 -04:00
Shawn Wallace
70f15d5085 server: scale wl_touch events
Fixes #172
2025-06-19 21:06:51 -04:00
Shawn Wallace
b98fa84524 Use fractional scaling when setting scale through xsettings
Fixes #168
2025-06-19 17:02:42 -04:00