almlost works

This commit is contained in:
Henry Hiles 2026-04-19 12:13:57 -04:00
commit 306baec220
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
4 changed files with 46 additions and 57 deletions

View file

@ -1,8 +1,5 @@
import 'dart:developer';
import 'package:flight/controllers/time_controller.dart'; import 'package:flight/controllers/time_controller.dart';
import 'package:flight/controllers/workspaces_controller.dart'; import 'package:flight/controllers/workspaces_controller.dart';
import 'package:flight/widgets/loading.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
@ -19,18 +16,12 @@ class Bar extends ConsumerWidget {
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
children: children:
[ [
[
Icon(Icons.circle),
Icon(Icons.circle_outlined),
Icon(Icons.circle_outlined),
].map((e) => IconButton(onPressed: () {}, icon: e)).toList(),
ref ref
.watch(WorkspacesController.provider) .watch(WorkspacesController.provider)
.whenOrNull( .whenOrNull(
error: (error, stackTrace) => [ error: (error, stackTrace) => [
Text(error.toString()), Text(error.toString()),
], ],
loading: () => [Text("loading")],
data: (value) { data: (value) {
return value return value
.map( .map(

View file

@ -18,6 +18,7 @@ pkgs.mkShell {
}) })
]; ];
RUST_BACKTRACE = 1;
LD_LIBRARY_PATH = LD_LIBRARY_PATH =
let let
plugins = "./build/linux/x64/debug/plugins"; plugins = "./build/linux/x64/debug/plugins";

12
rust/Cargo.lock generated
View file

@ -543,9 +543,9 @@ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.70" version = "1.0.106"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
@ -561,9 +561,9 @@ dependencies = [
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.33" version = "1.0.45"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@ -700,9 +700,9 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.39" version = "2.0.117"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",

View file

@ -3,11 +3,9 @@ use crate::{frb_generated::StreamSink, workspace_api::Workspace};
use std::collections::HashMap; 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}}; 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_interfaces!("protocols/ext-workspace-v1.xml");
wayland_scanner::generate_client_code!("protocols/ext-workspace-v1.xml"); wayland_scanner::generate_client_code!("protocols/ext-workspace-v1.xml");
pub struct AppState { pub struct AppState {
pub workspaces: HashMap<u32, Workspace>, pub workspaces: HashMap<u32, Workspace>,
pub sink: StreamSink<Vec<Workspace>>, pub sink: StreamSink<Vec<Workspace>>,
@ -19,9 +17,6 @@ impl AppState {
} }
} }
// ------------------------
// wl_registry
// ------------------------
impl Dispatch<wl_registry::WlRegistry, ()> for AppState { impl Dispatch<wl_registry::WlRegistry, ()> for AppState {
fn event( fn event(
_state: &mut Self, _state: &mut Self,
@ -38,9 +33,9 @@ impl Dispatch<wl_registry::WlRegistry, ()> for AppState {
} = event } = event
{ {
if interface == "ext_workspace_manager_v1" { if interface == "ext_workspace_manager_v1" {
registry.bind::<ext_workspace_manager_v1::ExtWorkspaceManagerV1, _, _>( registry.bind::<ext_workspace_manager_v1::ExtWorkspaceManagerV1, (), AppState>(
name, name,
version.min(1), version,
qh, qh,
(), (),
); );
@ -49,8 +44,6 @@ impl Dispatch<wl_registry::WlRegistry, ()> for AppState {
} }
} }
impl Dispatch<ext_workspace_manager_v1::ExtWorkspaceManagerV1, ()> for AppState { impl Dispatch<ext_workspace_manager_v1::ExtWorkspaceManagerV1, ()> for AppState {
fn event( fn event(
_state: &mut Self, _state: &mut Self,
@ -60,7 +53,6 @@ impl Dispatch<ext_workspace_manager_v1::ExtWorkspaceManagerV1, ()> for AppState
_conn: &Connection, _conn: &Connection,
_qh: &QueueHandle<Self>, _qh: &QueueHandle<Self>,
) { ) {
// unused for now
} }
event_created_child!( event_created_child!(
@ -75,9 +67,7 @@ impl Dispatch<ext_workspace_manager_v1::ExtWorkspaceManagerV1, ()> for AppState
); );
} }
// ------------------------
// workspace handle
// ------------------------
impl Dispatch<ext_workspace_handle_v1::ExtWorkspaceHandleV1, ()> for AppState { impl Dispatch<ext_workspace_handle_v1::ExtWorkspaceHandleV1, ()> for AppState {
fn event( fn event(
state: &mut Self, state: &mut Self,
@ -87,35 +77,42 @@ impl Dispatch<ext_workspace_handle_v1::ExtWorkspaceHandleV1, ()> for AppState {
_conn: &Connection, _conn: &Connection,
_qh: &QueueHandle<Self>, _qh: &QueueHandle<Self>,
) { ) {
println!("workspace event: {:?}", event);
match event { match event {
ext_workspace_handle_v1::Event::Id { id } => { ext_workspace_handle_v1::Event::Id { id } => {
let id: u32 = id.parse().unwrap_or(0); // 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 } => { ext_workspace_handle_v1::Event::State { state: flags } => {
let active = matches!( // let active = matches!(
flags, // flags,
wayland_client::WEnum::Value(ext_workspace_handle_v1::State::Active) // wayland_client::WEnum::Value(
); // ext_workspace_handle_v1::State::Active
// )
// );
for ws in state.workspaces.values_mut() { // // IMPORTANT: we don't know which workspace this refers to reliably
ws.activated = active; // // 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.workspaces.remove(&id);
// state.emit();
// } // }
// state.emit();
}
ext_workspace_handle_v1::Event::Removed => {
// state.workspaces.clear();
// state.emit();
}
_ => {} _ => {}
} }
} }