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