1
0
Fork 0
forked from wry/wry

config: workspace display order

This commit is contained in:
Stipe Kotarac 2025-07-26 10:52:46 +02:00 committed by Julian Orth
parent 40328d7c4a
commit e570152dde
17 changed files with 237 additions and 11 deletions

View file

@ -83,6 +83,7 @@ use {
jay_config::{
_private::DEFAULT_SEAT_NAME,
video::{GfxApi, Transform},
workspace::WorkspaceDisplayOrder,
},
std::{cell::Cell, env, future::Future, ops::Deref, rc::Rc, sync::Arc, time::Duration},
thiserror::Error,
@ -357,6 +358,7 @@ fn start_compositor2(
show_bar: Cell::new(true),
enable_primary_selection: Cell::new(true),
xdg_surface_configure_events: Default::default(),
workspace_display_order: Cell::new(WorkspaceDisplayOrder::Manual),
});
state.tracker.register(ClientId::from_raw(0));
create_dummy_output(&state);

View file

@ -74,6 +74,7 @@ use {
Transform, VrrMode as ConfigVrrMode,
},
window::{TileState, Window, WindowMatcher},
workspace::WorkspaceDisplayOrder,
xwayland::XScalingMode,
},
kbvm::Keycode,
@ -1353,6 +1354,13 @@ impl ConfigProxyHandler {
}
}
fn handle_set_workspace_display_order(&self, order: WorkspaceDisplayOrder) {
self.state.workspace_display_order.set(order);
for output in self.state.root.outputs.lock().values() {
output.handle_workspace_display_order_update();
}
}
fn handle_get_seat_float_pinned(&self, seat: Seat) -> Result<(), CphError> {
let seat = self.get_seat(seat)?;
self.respond(Response::GetFloatPinned {
@ -3098,6 +3106,9 @@ impl ConfigProxyHandler {
ClientMessage::SetMiddleClickPasteEnabled { enabled } => {
self.handle_set_middle_click_paste_enabled(enabled)
}
ClientMessage::SetWorkspaceDisplayOrder { order } => {
self.handle_set_workspace_display_order(order)
}
ClientMessage::SeatCreateMark { seat, kc } => self
.handle_seat_create_mark(seat, kc)
.wrn("seat_create_mark")?,

View file

@ -128,6 +128,7 @@ use {
PciId,
video::{GfxApi, Transform},
window::TileState,
workspace::WorkspaceDisplayOrder,
},
std::{
cell::{Cell, RefCell},
@ -275,6 +276,7 @@ pub struct State {
pub show_bar: Cell<bool>,
pub enable_primary_selection: Cell<bool>,
pub xdg_surface_configure_events: AsyncQueue<XdgSurfaceConfigureEvent>,
pub workspace_display_order: Cell<WorkspaceDisplayOrder>,
}
// impl Drop for State {

View file

@ -48,17 +48,27 @@ use {
WorkspaceDragDestination, WorkspaceNode, WorkspaceNodeId, walker::NodeVisitor,
},
utils::{
asyncevent::AsyncEvent, bitflags::BitflagsExt, clonecell::CloneCell,
copyhashmap::CopyHashMap, errorfmt::ErrorFmt, event_listener::EventSource,
hash_map_ext::HashMapExt, linkedlist::LinkedList, on_drop_event::OnDropEvent,
scroller::Scroller, transform_ext::TransformExt,
asyncevent::AsyncEvent,
bitflags::BitflagsExt,
clonecell::CloneCell,
copyhashmap::CopyHashMap,
errorfmt::ErrorFmt,
event_listener::EventSource,
hash_map_ext::HashMapExt,
linkedlist::{LinkedList, NodeRef},
on_drop_event::OnDropEvent,
scroller::Scroller,
transform_ext::TransformExt,
},
wire::{
ExtImageCopyCaptureSessionV1Id, JayOutputId, JayScreencastId, ZwlrScreencopyFrameV1Id,
},
},
ahash::AHashMap,
jay_config::video::{TearingMode as ConfigTearingMode, Transform, VrrMode as ConfigVrrMode},
jay_config::{
video::{TearingMode as ConfigTearingMode, Transform, VrrMode as ConfigVrrMode},
workspace::WorkspaceDisplayOrder,
},
smallvec::SmallVec,
std::{
cell::{Cell, RefCell},
@ -712,6 +722,17 @@ impl OutputNode {
true
}
pub fn find_workspace_insertion_point(&self, name: &str) -> Option<NodeRef<Rc<WorkspaceNode>>> {
if self.state.workspace_display_order.get() == WorkspaceDisplayOrder::Sorted {
for existing_ws in self.workspaces.iter() {
if name < existing_ws.name.as_str() {
return Some(existing_ws);
}
}
}
None
}
pub fn create_workspace(self: &Rc<Self>, name: &str) -> Rc<WorkspaceNode> {
let ws = Rc::new(WorkspaceNode {
id: self.state.node_ids.next(),
@ -740,7 +761,12 @@ impl OutputNode {
});
ws.opt.set(Some(ws.clone()));
ws.update_has_captures();
*ws.output_link.borrow_mut() = Some(self.workspaces.add_last(ws.clone()));
let link = if let Some(before) = self.find_workspace_insertion_point(name) {
before.prepend(ws.clone())
} else {
self.workspaces.add_last(ws.clone())
};
*ws.output_link.borrow_mut() = Some(link);
self.state.workspaces.set(name.to_string(), ws.clone());
if self.workspace.is_none() {
self.show_workspace(&ws);
@ -1048,6 +1074,18 @@ impl OutputNode {
}
}
pub fn handle_workspace_display_order_update(self: &Rc<Self>) {
if self.state.workspace_display_order.get() == WorkspaceDisplayOrder::Sorted {
let mut workspaces: Vec<_> = self.workspaces.iter().collect();
workspaces.sort_by(|a, b| a.name.cmp(&b.name));
for ws_ref in workspaces {
ws_ref.detach();
self.workspaces.add_last_existing(&ws_ref);
}
}
self.schedule_update_render_data();
}
pub fn update_visible(&self) {
let mut visible = self.state.root_visible();
if self.state.lock.locked.get() {
@ -1285,6 +1323,16 @@ impl OutputNode {
if y_abs - rect.y1() > th + 1 {
return None;
}
if self.state.workspace_display_order.get() == WorkspaceDisplayOrder::Sorted {
if self.workspaces.iter().any(|ws| ws.id == source) {
return None;
}
return Some(WorkspaceDragDestination {
highlight: Rect::new_sized(rect.x1(), rect.y1(), rect.width(), th)?,
output: self.clone(),
before: None,
});
}
let rd = &*self.render_data.borrow();
let (x, _) = rect.translate(x_abs, y_abs);
let mut prev_is_source = false;

View file

@ -35,6 +35,7 @@ use {
},
wire::JayWorkspaceId,
},
jay_config::workspace::WorkspaceDisplayOrder,
std::{
cell::{Cell, RefCell},
fmt::Debug,
@ -491,8 +492,15 @@ pub fn move_ws_to_output(
}
}
ws.set_output(&target);
let before = if target.state.workspace_display_order.get() == WorkspaceDisplayOrder::Sorted {
target
.find_workspace_insertion_point(&ws.name)
.map(|nr| nr.deref().clone())
} else {
config.before
};
'link: {
if let Some(before) = config.before
if let Some(before) = before
&& let Some(link) = &*before.output_link.borrow()
{
link.prepend_existing(ws);