almlost works
This commit is contained in:
parent
440dc1a0f9
commit
306baec220
4 changed files with 46 additions and 57 deletions
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ pkgs.mkShell {
|
|||
})
|
||||
];
|
||||
|
||||
RUST_BACKTRACE = 1;
|
||||
LD_LIBRARY_PATH =
|
||||
let
|
||||
plugins = "./build/linux/x64/debug/plugins";
|
||||
|
|
|
|||
12
rust/Cargo.lock
generated
12
rust/Cargo.lock
generated
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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<u32, Workspace>,
|
||||
pub sink: StreamSink<Vec<Workspace>>,
|
||||
|
|
@ -19,9 +17,6 @@ impl AppState {
|
|||
}
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
// wl_registry
|
||||
// ------------------------
|
||||
impl Dispatch<wl_registry::WlRegistry, ()> for AppState {
|
||||
fn event(
|
||||
_state: &mut Self,
|
||||
|
|
@ -38,9 +33,9 @@ impl Dispatch<wl_registry::WlRegistry, ()> for AppState {
|
|||
} = event
|
||||
{
|
||||
if interface == "ext_workspace_manager_v1" {
|
||||
registry.bind::<ext_workspace_manager_v1::ExtWorkspaceManagerV1, _, _>(
|
||||
registry.bind::<ext_workspace_manager_v1::ExtWorkspaceManagerV1, (), AppState>(
|
||||
name,
|
||||
version.min(1),
|
||||
version,
|
||||
qh,
|
||||
(),
|
||||
);
|
||||
|
|
@ -49,8 +44,6 @@ impl Dispatch<wl_registry::WlRegistry, ()> for AppState {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl Dispatch<ext_workspace_manager_v1::ExtWorkspaceManagerV1, ()> for AppState {
|
||||
fn event(
|
||||
_state: &mut Self,
|
||||
|
|
@ -60,7 +53,6 @@ impl Dispatch<ext_workspace_manager_v1::ExtWorkspaceManagerV1, ()> for AppState
|
|||
_conn: &Connection,
|
||||
_qh: &QueueHandle<Self>,
|
||||
) {
|
||||
// unused for now
|
||||
}
|
||||
|
||||
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 {
|
||||
fn event(
|
||||
state: &mut Self,
|
||||
|
|
@ -87,35 +77,42 @@ impl Dispatch<ext_workspace_handle_v1::ExtWorkspaceHandleV1, ()> for AppState {
|
|||
_conn: &Connection,
|
||||
_qh: &QueueHandle<Self>,
|
||||
) {
|
||||
println!("workspace event: {:?}", event);
|
||||
match event {
|
||||
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 } => {
|
||||
let active = matches!(
|
||||
flags,
|
||||
wayland_client::WEnum::Value(ext_workspace_handle_v1::State::Active)
|
||||
);
|
||||
// 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();
|
||||
}
|
||||
|
||||
// ext_workspace_handle_v1::Event::Removed => {
|
||||
// let id: u32 = id.parse().unwrap_or(0);
|
||||
|
||||
// state.workspaces.remove(&id);
|
||||
// state.emit();
|
||||
// for ws in state.workspaces.values_mut() {
|
||||
// ws.activated = active;
|
||||
// }
|
||||
|
||||
// state.emit();
|
||||
}
|
||||
|
||||
ext_workspace_handle_v1::Event::Removed => {
|
||||
// state.workspaces.clear();
|
||||
// state.emit();
|
||||
}
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue