use std::cmp::Ordering;
use hyprrust::data::{Monitor, Workspace, WorkspaceBrief};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct OwnedMonitor {
name: String,
id: i64,
focused: bool,
active_workspace: OwnedWorkspace,
}
impl OwnedMonitor {
pub fn new(
name: String,
id: i64,
focused: bool,
active_workspace: OwnedWorkspace
) -> OwnedMonitor {
OwnedMonitor {
name,
id,
focused,
active_workspace
}
}
pub fn name(&self) -> String {
self.name.clone()
}
pub fn id(&self) -> i64 {
self.id
}
pub fn focused(&self) -> bool {
self.focused
}
pub fn active_workspace(&self) -> OwnedWorkspace {
self.active_workspace.clone()
}
}
impl From<&Monitor> for OwnedMonitor {
fn from(m: &Monitor) -> Self {
OwnedMonitor {
name: m.name.clone(),
id: m.id,
focused: m.focused,
active_workspace: OwnedWorkspace {
id: m.active_workspace.id,
monitor_name: m.name.clone()
},
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct OwnedWorkspace {
id: i64,
monitor_name: String
}
impl OwnedWorkspace {
pub fn new(id: i64, monitor_name: String) -> OwnedWorkspace {
OwnedWorkspace { id, monitor_name }
}
pub fn id(&self) -> i64 {
self.id
}
pub fn monitor_name(&self) -> String {
self.monitor_name.clone()
}
}
impl From<&Workspace> for OwnedWorkspace {
fn from(w: &Workspace) -> Self {
OwnedWorkspace { id: w.id, monitor_name: w.monitor.clone() }
}
}
impl From<&WorkspaceBrief> for OwnedWorkspace {
fn from(w: &WorkspaceBrief) -> Self {
OwnedWorkspace { id: w.id, monitor_name: String::new() }
}
}
impl Ord for OwnedWorkspace {
fn cmp(&self, other: &Self) -> Ordering {
self.id.cmp(&other.id)
}
}
impl PartialOrd for OwnedWorkspace {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}