fix
This commit is contained in:
parent
c67f6fdb2d
commit
554bdfe19b
5 changed files with 30 additions and 19 deletions
|
|
@ -5,7 +5,7 @@ use std::path::PathBuf;
|
|||
use gtk4::glib;
|
||||
use std::future::Future;
|
||||
|
||||
pub type Activate = u32;
|
||||
pub type Activate = String;
|
||||
|
||||
pub fn data_path() -> PathBuf {
|
||||
let mut path = glib::user_data_dir();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use crate::utils::{Activate};
|
|||
use std::{env, os::unix::net::UnixStream, path::PathBuf};
|
||||
use tokio::sync::mpsc;
|
||||
use wayland_client::{
|
||||
protocol::{wl_output::WlOutput, wl_registry},
|
||||
protocol::{wl_output::{WlOutput, self}, wl_registry},
|
||||
ConnectError,
|
||||
};
|
||||
|
||||
|
|
@ -40,11 +40,11 @@ pub fn spawn_workspaces(tx: mpsc::Sender<State>) -> mpsc::Sender<Activate> {
|
|||
let (workspaces_tx, mut workspaces_rx) = mpsc::channel(100);
|
||||
if let Ok(Ok(conn)) = std::env::var("HOST_WAYLAND_DISPLAY")
|
||||
.map_err(anyhow::Error::msg)
|
||||
.map(|fd| {
|
||||
.map(|display_str| {
|
||||
let mut socket_path = env::var_os("XDG_RUNTIME_DIR")
|
||||
.map(Into::<PathBuf>::into)
|
||||
.ok_or(ConnectError::NoCompositor)?;
|
||||
socket_path.push(env::var_os("WAYLAND_DISPLAY").ok_or(ConnectError::NoCompositor)?);
|
||||
socket_path.push(display_str);
|
||||
|
||||
Ok(UnixStream::connect(socket_path).map_err(|_| ConnectError::NoCompositor)?)
|
||||
})
|
||||
|
|
@ -128,6 +128,10 @@ impl Dispatch<wl_registry::WlRegistry, ()> for State {
|
|||
.unwrap();
|
||||
self.workspace_manager = Some(workspace_manager);
|
||||
}
|
||||
"wl_output" => {
|
||||
println!("binding to output");
|
||||
registry.bind::<WlOutput, _, _>(name, 1, qh, ()).unwrap();
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
@ -267,3 +271,14 @@ impl Dispatch<ZextWorkspaceHandleV1, ()> for State {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Dispatch<WlOutput, ()> for State {
|
||||
fn event(
|
||||
&mut self,
|
||||
_: &WlOutput,
|
||||
_: wl_output::Event,
|
||||
_: &(),
|
||||
_: &Connection,
|
||||
_: &QueueHandle<Self>,
|
||||
) {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@ impl WorkspaceButton {
|
|||
self.remove(&old_button);
|
||||
|
||||
let id = obj.id();
|
||||
let new_button = ToggleButton::with_label(&format!("{}", id));
|
||||
let new_button = ToggleButton::with_label(&id);
|
||||
new_button.set_active(obj.active());
|
||||
self.append(&new_button);
|
||||
new_button.connect_clicked(move |_| {
|
||||
let _ = TX.get().unwrap().send(id);
|
||||
let _ = TX.get().unwrap().send(id.clone());
|
||||
});
|
||||
|
||||
imp.button.replace(new_button);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
// SPDX-License-Identifier: MPL-2.0-only
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::cell::{RefCell, Cell};
|
||||
|
||||
use glib::{ParamFlags, ParamSpec, Value};
|
||||
use gtk4::gdk::glib::ParamSpecBoolean;
|
||||
use gtk4::glib;
|
||||
use gtk4::glib::{self, ParamSpecString};
|
||||
use gtk4::glib::ParamSpecUInt;
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
|
|
@ -13,7 +13,7 @@ use once_cell::sync::Lazy;
|
|||
// Object holding the state
|
||||
#[derive(Default)]
|
||||
pub struct WorkspaceObject {
|
||||
pub(crate) id: Cell<u32>,
|
||||
pub(crate) id: RefCell<String>,
|
||||
pub(crate) active: Cell<bool>,
|
||||
}
|
||||
|
||||
|
|
@ -30,19 +30,15 @@ impl ObjectImpl for WorkspaceObject {
|
|||
fn properties() -> &'static [ParamSpec] {
|
||||
static PROPERTIES: Lazy<Vec<ParamSpec>> = Lazy::new(|| {
|
||||
vec![
|
||||
ParamSpecUInt::new(
|
||||
ParamSpecString::new(
|
||||
// Name
|
||||
"id",
|
||||
// Nickname
|
||||
"id",
|
||||
// Short description
|
||||
"id",
|
||||
// Minimum value
|
||||
u32::MIN,
|
||||
// Maximum value
|
||||
u32::MAX,
|
||||
// Default value
|
||||
0,
|
||||
None,
|
||||
// The property can be read and written to
|
||||
ParamFlags::READWRITE,
|
||||
),
|
||||
|
|
@ -74,7 +70,7 @@ impl ObjectImpl for WorkspaceObject {
|
|||
|
||||
fn property(&self, _obj: &Self::Type, _id: usize, pspec: &ParamSpec) -> Value {
|
||||
match pspec.name() {
|
||||
"id" => self.id.get().to_value(),
|
||||
"id" => self.id.borrow().to_value(),
|
||||
"active" => self.active.get().to_value(),
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,12 +13,12 @@ impl WorkspaceObject {
|
|||
glib::Object::new(&[]).unwrap()
|
||||
}
|
||||
|
||||
pub fn from_id_active(id: u32, active: bool) -> Self {
|
||||
pub fn from_id_active(id: String, active: bool) -> Self {
|
||||
glib::Object::new(&[("id", &id), ("active", &active)]).unwrap()
|
||||
}
|
||||
|
||||
pub fn id(&self) -> u32 {
|
||||
imp::WorkspaceObject::from_instance(&self).id.get()
|
||||
pub fn id(&self) -> String {
|
||||
imp::WorkspaceObject::from_instance(&self).id.borrow().clone()
|
||||
}
|
||||
|
||||
pub fn active(&self) -> bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue