migrate: 0.16.1 to 0.18.1 (thanks claude!)

This commit is contained in:
2026-05-25 12:17:42 +01:00
parent 97dfe31197
commit 64e1e5481e
12 changed files with 1126 additions and 719 deletions
+1
View File
@@ -0,0 +1 @@
use flake
+1
View File
@@ -20,3 +20,4 @@ logs.txt
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
/.direnv
Generated
+796 -687
View File
File diff suppressed because it is too large Load Diff
Generated
+94
View File
@@ -0,0 +1,94 @@
{
"nodes": {
"advisory-db": {
"flake": false,
"locked": {
"lastModified": 1779575509,
"narHash": "sha256-wXKYURZz76ZC5lbuDA1oVQA/MxSB3pSJ1raF1HG0oIc=",
"owner": "rustsec",
"repo": "advisory-db",
"rev": "831c50f4a4304068f125e603add6a8839f08b3eb",
"type": "github"
},
"original": {
"owner": "rustsec",
"repo": "advisory-db",
"type": "github"
}
},
"crane": {
"locked": {
"lastModified": 1779130139,
"narHash": "sha256-BLrtr42azquO7MdGFU5a7KiMl3YpFlTeIXqy1fT5GlQ=",
"owner": "ipetkov",
"repo": "crane",
"rev": "edb38893982a3338972bb4a2ec7ce7c29ba10fd9",
"type": "github"
},
"original": {
"owner": "ipetkov",
"repo": "crane",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1779536132,
"narHash": "sha256-q+fF42iv/geEbHfgSzy3tS0FF/EyD6XTZ98E6yxiBO8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3d8f0f3f72a6cd4d93d0ad13203f2ea1cb7e1456",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"advisory-db": "advisory-db",
"crane": "crane",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}
+191
View File
@@ -0,0 +1,191 @@
{
description = "Build a cargo project";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
advisory-db = {
url = "github:rustsec/advisory-db";
flake = false;
};
};
outputs = {
self,
nixpkgs,
crane,
flake-utils,
advisory-db,
...
}:
flake-utils.lib.eachDefaultSystem (
system: let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
craneLib = crane.mkLib pkgs;
src = craneLib.cleanCargoSource ./.;
# Common arguments can be set here to avoid repeating them later
commonArgs = {
inherit src;
strictDeps = true;
buildInputs = with pkgs;
[
mold
# for Linux
# Audio (Linux only)
alsa-lib
# Cross Platform 3D Graphics API
vulkan-loader
# For debugging around vulkan
vulkan-tools
# Other dependencies
libudev-zero
libx11
libxcursor
libxi
libxrandr
libxkbcommon
wayland
]
++ lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.libiconv
];
# Additional environment variables can be set directly
# MY_CUSTOM_VAR = "some value";
};
# Build *just* the cargo dependencies, so we can reuse
# all of that work (e.g. via cachix) when running in CI
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# Build the actual crate itself, reusing the dependency
# artifacts from above.
my-crate = craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
}
);
in {
checks = {
# Build the crate as part of `nix flake check` for convenience
inherit my-crate;
# Run clippy (and deny all warnings) on the crate source,
# again, reusing the dependency artifacts from above.
#
# Note that this is done as a separate derivation so that
# we can block the CI if there are issues here, but not
# prevent downstream consumers from building our crate by itself.
my-crate-clippy = craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
}
);
my-crate-doc = craneLib.cargoDoc (
commonArgs
// {
inherit cargoArtifacts;
# This can be commented out or tweaked as necessary, e.g. set to
# `--deny rustdoc::broken-intra-doc-links` to only enforce that lint
env.RUSTDOCFLAGS = "--deny warnings";
}
);
# Check formatting
my-crate-fmt = craneLib.cargoFmt {
inherit src;
};
my-crate-toml-fmt = craneLib.taploFmt {
src = pkgs.lib.sources.sourceFilesBySuffices src [".toml"];
# taplo arguments can be further customized below as needed
# taploExtraArgs = "--config ./taplo.toml";
};
# Audit dependencies
my-crate-audit = craneLib.cargoAudit {
inherit src advisory-db;
};
# Audit licenses
my-crate-deny = craneLib.cargoDeny {
inherit src;
};
# Run tests with cargo-nextest
# Consider setting `doCheck = false` on `my-crate` if you do not want
# the tests to run twice
my-crate-nextest = craneLib.cargoNextest (
commonArgs
// {
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
cargoNextestPartitionsExtraArgs = "--no-tests=pass";
}
);
};
packages = {
default = my-crate;
};
apps.default = flake-utils.lib.mkApp {
drv = my-crate;
};
devShells.default = craneLib.devShell {
# Inherit inputs from checks.
checks = self.checks.${system};
# Additional dev-shell environment variables can be set directly
# MY_CUSTOM_DEVELOPMENT_VAR = "something else";
# Extra inputs can be added here; cargo and rustc are provided by default.
packages = with pkgs; [
pkgs.clang
mold
# for Linux
# Audio (Linux only)
alsa-lib
# Cross Platform 3D Graphics API
vulkan-loader
# For debugging around vulkan
vulkan-tools
# Other dependencies
libudev-zero
libx11
libxcursor
libxi
libxrandr
libxkbcommon
wayland
pkg-config
];
LD_LIBRARY_PATH = lib.makeLibraryPath [
pkgs.vulkan-loader
pkgs.libx11
pkgs.libxi
pkgs.libxcursor
pkgs.libxkbcommon
pkgs.wayland
];
# PKG_CONFIG_PATH = "${pkgs.wayland}/lib/pkgconfig:${pkgs.alsa-lib}/lib";
};
}
);
}
+4 -4
View File
@@ -1,6 +1,6 @@
use bevy::prelude::*;
use smithay_client_toolkit::{
reexports::client::{event_created_child, Dispatch, QueueHandle},
reexports::client::{Dispatch, QueueHandle, event_created_child},
registry::RegistryState,
};
use wayland_protocols_wlr::foreign_toplevel::v1::client::{
@@ -9,7 +9,7 @@ use wayland_protocols_wlr::foreign_toplevel::v1::client::{
};
use crate::WaylandState;
#[derive(Debug, Copy, Clone, Event)]
#[derive(Debug, Copy, Clone, Message)]
pub enum ForeignToplevelEvent {
MinimizeOthers,
}
@@ -28,7 +28,7 @@ impl Plugin for ForeignToplevelManagerPlugin {
info!("Foreign toplevel manager was bound!");
app.insert_non_send_resource(foreign_top_level_manager);
app.insert_non_send_resource(ForeignToplevels::default());
app.add_event::<ForeignToplevelEvent>();
app.add_message::<ForeignToplevelEvent>();
app.add_systems(Update, foreign_top_level_event_handler);
} else {
let bind_error = foreign_top_level_manager.err().unwrap();
@@ -39,7 +39,7 @@ impl Plugin for ForeignToplevelManagerPlugin {
fn foreign_top_level_event_handler(
foreign_top_levels: NonSendMut<ForeignToplevels>,
mut events: EventReader<ForeignToplevelEvent>,
mut events: MessageReader<ForeignToplevelEvent>,
) {
for event in events.read() {
match event {
+6 -6
View File
@@ -409,9 +409,9 @@ impl KeyboardHandler for WaylandState {
let active_window_entity = **self.world().resource::<ActiveWindow>();
let keyboard_event =
convert_keyboard_event(event, active_window_entity, ButtonState::Pressed);
self.world_mut().send_event(keyboard_event.clone());
self.world_mut().write_message(keyboard_event.clone());
self.world_mut()
.send_event(WindowEvent::KeyboardInput(keyboard_event));
.write_message(WindowEvent::KeyboardInput(keyboard_event));
}
fn repeat_key(
@@ -426,9 +426,9 @@ impl KeyboardHandler for WaylandState {
let mut keyboard_event =
convert_keyboard_event(event, active_window_entity, ButtonState::Pressed);
keyboard_event.repeat = true;
self.world_mut().send_event(keyboard_event.clone());
self.world_mut().write_message(keyboard_event.clone());
self.world_mut()
.send_event(WindowEvent::KeyboardInput(keyboard_event));
.write_message(WindowEvent::KeyboardInput(keyboard_event));
}
fn release_key(
@@ -442,9 +442,9 @@ impl KeyboardHandler for WaylandState {
let active_window_entity = **self.world().resource::<ActiveWindow>();
let keyboard_event =
convert_keyboard_event(event, active_window_entity, ButtonState::Released);
self.world_mut().send_event(keyboard_event.clone());
self.world_mut().write_message(keyboard_event.clone());
self.world_mut()
.send_event(WindowEvent::KeyboardInput(keyboard_event));
.write_message(WindowEvent::KeyboardInput(keyboard_event));
}
fn update_modifiers(
+7 -7
View File
@@ -101,26 +101,26 @@ impl PointerHandler for WaylandState {
let window_event: WindowEvent = pointer_event;
match window_event.clone() {
WindowEvent::CursorEntered(e) => {
self.world_mut().send_event(e);
self.world_mut().write_message(e);
}
WindowEvent::CursorLeft(e) => {
self.world_mut().send_event(e);
self.world_mut().write_message(e);
}
WindowEvent::CursorMoved(e) => {
self.world_mut().send_event(e);
self.world_mut().write_message(e);
}
WindowEvent::MouseButtonInput(e) => {
self.world_mut().send_event(e);
self.world_mut().write_message(e);
}
WindowEvent::MouseMotion(e) => {
self.world_mut().send_event(e);
self.world_mut().write_message(e);
}
WindowEvent::MouseWheel(e) => {
self.world_mut().send_event(e);
self.world_mut().write_message(e);
}
_ => {}
}
self.world_mut().send_event::<WindowEvent>(window_event);
self.world_mut().write_message::<WindowEvent>(window_event);
}
}
}
+5 -2
View File
@@ -11,7 +11,7 @@ use smithay_client_toolkit::{
};
use crate::{
surface_handler::{create_windows, SurfaceConfigured, WaylandSurfaces},
surface_handler::{SurfaceConfigured, SurfaceHandlerSystems, WaylandSurfaces},
WaylandState,
};
@@ -121,7 +121,10 @@ impl Default for LayerShellSettings {
pub struct LayerShellPlugin;
impl Plugin for LayerShellPlugin {
fn build(&self, app: &mut App) {
app.add_systems(PreUpdate, assign_layer_shell_role.after(create_windows))
app.add_systems(
PreUpdate,
assign_layer_shell_role.after(SurfaceHandlerSystems::CreateWindows),
)
.add_systems(Update, update_layer_shell_settings)
.insert_non_send_resource(LayerShellWindows::default());
}
+3 -4
View File
@@ -8,9 +8,9 @@ use smithay_client_toolkit::{
delegate_registry,
output::OutputState,
reexports::{
calloop::{self, channel::Sender, EventLoop},
calloop::{self, EventLoop, channel::Sender},
calloop_wayland_source::WaylandSource,
client::{globals::registry_queue_init, Connection},
client::{Connection, globals::registry_queue_init},
},
registry::{ProvidesRegistryState, RegistryState},
registry_handlers,
@@ -26,10 +26,9 @@ pub mod session_lock;
mod surface_handler;
pub mod prelude {
pub use crate::WaylandPlugin;
pub use crate::input_region::InputRegion;
pub use crate::layer_shell::{LayerShellSettings, LayerShellWindowSize};
pub use crate::session_lock::{SessionLockEvent, SessionLockWindow};
pub use crate::WaylandPlugin;
pub use smithay_client_toolkit::shell::wlr_layer::{Anchor, KeyboardInteractivity, Layer};
}
+6 -6
View File
@@ -7,7 +7,7 @@ use smithay_client_toolkit::{
};
use crate::{
surface_handler::{create_windows, SurfaceConfigured, WaylandSurfaces},
surface_handler::{SurfaceConfigured, SurfaceHandlerSystems, WaylandSurfaces},
WaylandState,
};
@@ -30,7 +30,7 @@ impl SessionLockUnconfiguredWindow {
}
}
#[derive(Clone, Copy, Event)]
#[derive(Clone, Copy, Message)]
pub enum SessionLockEvent {
Lock,
Unlock,
@@ -46,12 +46,12 @@ impl Plugin for SessionLockPlugin {
app.insert_non_send_resource(session_lock_state);
app.insert_non_send_resource(SessionLockWindows::default());
app.insert_non_send_resource(SessionLockWrapper::default());
app.add_event::<SessionLockEvent>();
app.add_message::<SessionLockEvent>();
app.add_systems(
PreUpdate,
(
session_lock_event_handler.before(create_windows),
configure_lock_surfaces.after(create_windows),
session_lock_event_handler.before(SurfaceHandlerSystems::CreateWindows),
configure_lock_surfaces.after(SurfaceHandlerSystems::CreateWindows),
),
);
}
@@ -61,7 +61,7 @@ impl Plugin for SessionLockPlugin {
struct SessionLockWrapper(Option<SessionLock>);
fn session_lock_event_handler(
mut commands: Commands,
mut session_lock_event_reader: EventReader<SessionLockEvent>,
mut session_lock_event_reader: MessageReader<SessionLockEvent>,
session_lock_state: NonSend<SessionLockState>,
mut session_lock_wrapper: NonSendMut<SessionLockWrapper>,
queue_handle: NonSend<QueueHandle<WaylandState>>,
+12 -3
View File
@@ -13,7 +13,7 @@ use smithay_client_toolkit::{
compositor::{CompositorHandler, CompositorState},
delegate_compositor,
reexports::client::{
backend::ObjectId, protocol::wl_surface::WlSurface, Connection, Proxy, QueueHandle,
Connection, Proxy, QueueHandle, backend::ObjectId, protocol::wl_surface::WlSurface,
},
};
@@ -21,6 +21,12 @@ use crate::WaylandState;
#[derive(Component)]
pub struct SurfaceConfigured;
#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
pub enum SurfaceHandlerSystems {
CreateWindows,
}
pub struct SurfaceHandlerPlugin;
impl Plugin for SurfaceHandlerPlugin {
fn build(&self, app: &mut App) {
@@ -30,7 +36,10 @@ impl Plugin for SurfaceHandlerPlugin {
CompositorState::bind(globals, queue_handle).expect("failed to bind compositor!"),
);
app.insert_non_send_resource(WaylandSurfaces::default());
app.add_systems(PreUpdate, create_windows);
app.add_systems(
PreUpdate,
create_windows.in_set(SurfaceHandlerSystems::CreateWindows),
);
}
}
@@ -173,7 +182,7 @@ pub fn create_windows(
connection: NonSend<Connection>,
queue_handle: NonSend<QueueHandle<WaylandState>>,
bevy_windows: Query<(Entity, Option<&RawHandleWrapperHolder>), With<Window>>,
mut window_created_event: EventWriter<WindowCreated>,
mut window_created_event: MessageWriter<WindowCreated>,
) {
for (entity, handle_holder) in &bevy_windows {
if wayland_surfaces.get_window_wrapper(entity).is_some() {