From 306baec2209ed85a15ed339c5bc704eda9f66c92 Mon Sep 17 00:00:00 2001 From: Henry-Hiles Date: Sun, 19 Apr 2026 12:13:57 -0400 Subject: [PATCH] almlost works --- lib/widgets/bar.dart | 9 ----- linux/nix/devshell.nix | 1 + rust/Cargo.lock | 12 +++---- rust/src/internal/wayland.rs | 67 +++++++++++++++++------------------- 4 files changed, 39 insertions(+), 50 deletions(-) diff --git a/lib/widgets/bar.dart b/lib/widgets/bar.dart index 4db9ba2..2641de2 100644 --- a/lib/widgets/bar.dart +++ b/lib/widgets/bar.dart @@ -1,8 +1,5 @@ -import 'dart:developer'; - import 'package:flight/controllers/time_controller.dart'; import 'package:flight/controllers/workspaces_controller.dart'; -import 'package:flight/widgets/loading.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:intl/intl.dart'; @@ -19,18 +16,12 @@ class Bar extends ConsumerWidget { crossAxisAlignment: CrossAxisAlignment.center, children: [ - [ - Icon(Icons.circle), - Icon(Icons.circle_outlined), - Icon(Icons.circle_outlined), - ].map((e) => IconButton(onPressed: () {}, icon: e)).toList(), ref .watch(WorkspacesController.provider) .whenOrNull( error: (error, stackTrace) => [ Text(error.toString()), ], - loading: () => [Text("loading")], data: (value) { return value .map( diff --git a/linux/nix/devshell.nix b/linux/nix/devshell.nix index b65e322..eb2c01e 100644 --- a/linux/nix/devshell.nix +++ b/linux/nix/devshell.nix @@ -18,6 +18,7 @@ pkgs.mkShell { }) ]; + RUST_BACKTRACE = 1; LD_LIBRARY_PATH = let plugins = "./build/linux/x64/debug/plugins"; diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 0cf0503..b597838 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -543,9 +543,9 @@ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" [[package]] name = "proc-macro2" -version = "1.0.70" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] @@ -561,9 +561,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.33" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] @@ -700,9 +700,9 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" [[package]] name = "syn" -version = "2.0.39" +version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", diff --git a/rust/src/internal/wayland.rs b/rust/src/internal/wayland.rs index dda561f..53fb7f2 100644 --- a/rust/src/internal/wayland.rs +++ b/rust/src/internal/wayland.rs @@ -3,11 +3,9 @@ use crate::{frb_generated::StreamSink, workspace_api::Workspace}; use std::collections::HashMap; use wayland_client::{self, Connection, Dispatch, QueueHandle, event_created_child, protocol::{__interfaces::{WL_OUTPUT_INTERFACE, wl_output_interface}, wl_output, wl_registry}}; - wayland_scanner::generate_interfaces!("protocols/ext-workspace-v1.xml"); wayland_scanner::generate_client_code!("protocols/ext-workspace-v1.xml"); - pub struct AppState { pub workspaces: HashMap, pub sink: StreamSink>, @@ -19,9 +17,6 @@ impl AppState { } } -// ------------------------ -// wl_registry -// ------------------------ impl Dispatch for AppState { fn event( _state: &mut Self, @@ -31,16 +26,16 @@ impl Dispatch for AppState { _conn: &Connection, qh: &QueueHandle, ) { - if let wl_registry::Event::Global { + if let wl_registry::Event::Global { name, interface, version, } = event { if interface == "ext_workspace_manager_v1" { - registry.bind::( + registry.bind::( name, - version.min(1), + version, qh, (), ); @@ -49,8 +44,6 @@ impl Dispatch for AppState { } } - - impl Dispatch for AppState { fn event( _state: &mut Self, @@ -60,7 +53,6 @@ impl Dispatch for AppState _conn: &Connection, _qh: &QueueHandle, ) { - // unused for now } event_created_child!( @@ -75,9 +67,7 @@ impl Dispatch for AppState ); } -// ------------------------ -// workspace handle -// ------------------------ + impl Dispatch for AppState { fn event( state: &mut Self, @@ -87,34 +77,41 @@ impl Dispatch for AppState { _conn: &Connection, _qh: &QueueHandle, ) { - match event { - ext_workspace_handle_v1::Event::Id { id } => { - let id: u32 = id.parse().unwrap_or(0); + println!("workspace event: {:?}", event); + match event { + ext_workspace_handle_v1::Event::Id { id } => { + // let id: u32 = id.parse().unwrap_or(0); - state.workspaces.insert(id, Workspace { activated: false }); + // state.workspaces.insert( + // id, + // Workspace { activated: false } + // ); - state.emit(); - } + // state.emit(); + } - ext_workspace_handle_v1::Event::State { state: flags } => { - let active = matches!( - flags, - wayland_client::WEnum::Value(ext_workspace_handle_v1::State::Active) - ); + ext_workspace_handle_v1::Event::State { state: flags } => { + // let active = matches!( + // flags, + // wayland_client::WEnum::Value( + // ext_workspace_handle_v1::State::Active + // ) + // ); - for ws in state.workspaces.values_mut() { - ws.activated = active; - } + // // IMPORTANT: we don't know which workspace this refers to reliably + // // so we treat it as a refresh signal OR update heuristically - state.emit(); - } + // for ws in state.workspaces.values_mut() { + // ws.activated = active; + // } -// ext_workspace_handle_v1::Event::Removed => { -// let id: u32 = id.parse().unwrap_or(0); + // state.emit(); + } -// state.workspaces.remove(&id); -// state.emit(); -// } + ext_workspace_handle_v1::Event::Removed => { + // state.workspaces.clear(); + // state.emit(); + } _ => {} }