Handle global workspaces
This commit is contained in:
parent
69a877894a
commit
4e2ef433fd
7 changed files with 87 additions and 40 deletions
|
|
@ -57,17 +57,20 @@ pub enum Event {
|
|||
ToplevelManager(zcosmic_toplevel_manager_v1::ZcosmicToplevelManagerV1),
|
||||
WorkspaceManager(zcosmic_workspace_manager_v1::ZcosmicWorkspaceManagerV1),
|
||||
// XXX Output name rather than `WlOutput`
|
||||
Workspaces(Vec<(String, cctk::workspace::Workspace)>),
|
||||
Workspaces(Vec<(Vec<String>, cctk::workspace::Workspace)>),
|
||||
WorkspaceCapture(
|
||||
zcosmic_workspace_handle_v1::ZcosmicWorkspaceHandleV1,
|
||||
String,
|
||||
image::Handle,
|
||||
),
|
||||
NewToplevel(
|
||||
zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1,
|
||||
Option<String>,
|
||||
ToplevelInfo,
|
||||
),
|
||||
UpdateToplevel(
|
||||
zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1,
|
||||
Option<String>,
|
||||
ToplevelInfo,
|
||||
),
|
||||
CloseToplevel(zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use cctk::{
|
||||
cosmic_protocols::screencopy::v1::client::zcosmic_screencopy_session_v1,
|
||||
screencopy::{BufferInfo, ScreencopyHandler, ScreencopyState},
|
||||
wayland_client::{protocol::wl_shm, Connection, QueueHandle, WEnum},
|
||||
wayland_client::{protocol::wl_shm, Connection, Proxy, QueueHandle, WEnum},
|
||||
};
|
||||
|
||||
use super::{AppData, Buffer, Capture, CaptureSource, Event};
|
||||
|
|
@ -71,13 +71,20 @@ impl ScreencopyHandler for AppData {
|
|||
|
||||
let mut buffer = capture.buffer.lock().unwrap();
|
||||
let image = unsafe { buffer.as_mut().unwrap().to_image() };
|
||||
let event = match &capture.source {
|
||||
CaptureSource::Toplevel(toplevel) => Event::ToplevelCapture(toplevel.clone(), image),
|
||||
CaptureSource::Workspace(workspace, _) => {
|
||||
Event::WorkspaceCapture(workspace.clone(), image)
|
||||
match &capture.source {
|
||||
CaptureSource::Toplevel(toplevel) => {
|
||||
self.send_event(Event::ToplevelCapture(toplevel.clone(), image))
|
||||
}
|
||||
CaptureSource::Workspace(workspace, output) => {
|
||||
if let Some(Some(output_name)) = self.output_names.get(&output.id()) {
|
||||
self.send_event(Event::WorkspaceCapture(
|
||||
workspace.clone(),
|
||||
output_name.clone(),
|
||||
image,
|
||||
));
|
||||
}
|
||||
}
|
||||
};
|
||||
self.send_event(event);
|
||||
session.destroy();
|
||||
|
||||
// Capture again on damage
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use cctk::{
|
|||
},
|
||||
toplevel_info::{ToplevelInfoHandler, ToplevelInfoState},
|
||||
toplevel_management::{ToplevelManagerHandler, ToplevelManagerState},
|
||||
wayland_client::{Connection, QueueHandle, WEnum},
|
||||
wayland_client::{Connection, Proxy, QueueHandle, WEnum},
|
||||
};
|
||||
|
||||
use super::{AppData, CaptureSource, Event};
|
||||
|
|
@ -23,7 +23,15 @@ impl ToplevelInfoHandler for AppData {
|
|||
toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1,
|
||||
) {
|
||||
let info = self.toplevel_info_state.info(toplevel).unwrap();
|
||||
self.send_event(Event::NewToplevel(toplevel.clone(), info.clone()));
|
||||
let output_name = info
|
||||
.output
|
||||
.as_ref()
|
||||
.and_then(|o| self.output_names.get(&o.id()).cloned()?);
|
||||
self.send_event(Event::NewToplevel(
|
||||
toplevel.clone(),
|
||||
output_name,
|
||||
info.clone(),
|
||||
));
|
||||
|
||||
self.add_capture_source(CaptureSource::Toplevel(toplevel.clone()));
|
||||
}
|
||||
|
|
@ -35,7 +43,15 @@ impl ToplevelInfoHandler for AppData {
|
|||
toplevel: &zcosmic_toplevel_handle_v1::ZcosmicToplevelHandleV1,
|
||||
) {
|
||||
let info = self.toplevel_info_state.info(toplevel).unwrap();
|
||||
self.send_event(Event::UpdateToplevel(toplevel.clone(), info.clone()));
|
||||
let output_name = info
|
||||
.output
|
||||
.as_ref()
|
||||
.and_then(|o| self.output_names.get(&o.id()).cloned()?);
|
||||
self.send_event(Event::UpdateToplevel(
|
||||
toplevel.clone(),
|
||||
output_name,
|
||||
info.clone(),
|
||||
));
|
||||
}
|
||||
|
||||
fn toplevel_closed(
|
||||
|
|
|
|||
|
|
@ -18,11 +18,15 @@ impl WorkspaceHandler for AppData {
|
|||
|
||||
for group in self.workspace_state.workspace_groups() {
|
||||
for workspace in &group.workspaces {
|
||||
if let Some(output) = group.output.as_ref() {
|
||||
if let Some(output_name) = self.output_names.get(&output.id()).unwrap().clone()
|
||||
{
|
||||
workspaces.push((output_name, workspace.clone()));
|
||||
let output_names: Vec<_> = group
|
||||
.outputs
|
||||
.iter()
|
||||
.filter_map(|output| self.output_names.get(&output.id()).cloned()?)
|
||||
.collect();
|
||||
if !output_names.is_empty() {
|
||||
workspaces.push((output_names, workspace.clone()));
|
||||
|
||||
for output in &group.outputs {
|
||||
self.add_capture_source(CaptureSource::Workspace(
|
||||
workspace.handle.clone(),
|
||||
output.clone(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue