1
0
Fork 0
forked from wry/wry

config: add Window

This commit is contained in:
Julian Orth 2025-04-29 15:29:39 +02:00
parent ab095b89cf
commit 9977f9dfdf
19 changed files with 1172 additions and 203 deletions

View file

@ -30,6 +30,7 @@ use {
Transform, VrrMode,
connector_type::{CON_UNKNOWN, ConnectorType},
},
window::{Window, WindowType},
xwayland::XScalingMode,
},
bincode::Options,
@ -342,6 +343,74 @@ impl ConfigClient {
self.send(&ClientMessage::SeatMove { seat, direction });
}
pub fn window_move(&self, window: Window, direction: Direction) {
self.send(&ClientMessage::WindowMove { window, direction });
}
pub fn window_exists(&self, window: Window) -> bool {
let res = self.send_with_response(&ClientMessage::WindowExists { window });
get_response!(res, false, WindowExists { exists });
exists
}
pub fn window_client(&self, window: Window) -> Client {
let res = self.send_with_response(&ClientMessage::GetWindowClient { window });
get_response!(res, Client(0), GetWindowClient { client });
client
}
pub fn get_workspace_window(&self, workspace: Workspace) -> Window {
let res = self.send_with_response(&ClientMessage::GetWorkspaceWindow { workspace });
get_response!(res, Window(0), GetWorkspaceWindow { window });
window
}
pub fn get_seat_keyboard_window(&self, seat: Seat) -> Window {
let res = self.send_with_response(&ClientMessage::GetSeatKeyboardWindow { seat });
get_response!(res, Window(0), GetSeatKeyboardWindow { window });
window
}
pub fn focus_window(&self, seat: Seat, window: Window) {
self.send(&ClientMessage::SeatFocusWindow { seat, window });
}
pub fn window_title(&self, window: Window) -> String {
let res = self.send_with_response(&ClientMessage::GetWindowTitle { window });
get_response!(res, String::new(), GetWindowTitle { title });
title
}
pub fn window_type(&self, window: Window) -> WindowType {
let res = self.send_with_response(&ClientMessage::GetWindowType { window });
get_response!(res, WindowType(0), GetWindowType { kind });
kind
}
pub fn window_id(&self, window: Window) -> String {
let res = self.send_with_response(&ClientMessage::GetWindowId { window });
get_response!(res, String::new(), GetWindowId { id });
id
}
pub fn window_parent(&self, window: Window) -> Window {
let res = self.send_with_response(&ClientMessage::GetWindowParent { window });
get_response!(res, Window(0), GetWindowParent { window });
window
}
pub fn window_children(&self, window: Window) -> Vec<Window> {
let res = self.send_with_response(&ClientMessage::GetWindowChildren { window });
get_response!(res, vec![], GetWindowChildren { windows });
windows
}
pub fn window_is_visible(&self, window: Window) -> bool {
let res = self.send_with_response(&ClientMessage::GetWindowIsVisible { window });
get_response!(res, false, GetWindowIsVisible { visible });
visible
}
pub fn unbind<T: Into<ModifiedKeySym>>(&self, seat: Seat, mod_sym: T) {
let mod_sym = mod_sym.into();
if let Entry::Occupied(mut oe) = self.key_handlers.borrow_mut().entry((seat, mod_sym)) {
@ -374,6 +443,12 @@ impl ConfigClient {
mono
}
pub fn window_mono(&self, window: Window) -> bool {
let res = self.send_with_response(&ClientMessage::GetWindowMono { window });
get_response!(res, false, GetWindowMono { mono });
mono
}
pub fn get_timer(&self, name: &str) -> Timer {
let res = self.send_with_response(&ClientMessage::GetTimer { name });
get_response!(res, Timer(0), GetTimer { timer });
@ -421,6 +496,12 @@ impl ConfigClient {
workspace
}
pub fn get_window_workspace(&self, window: Window) -> Workspace {
let res = self.send_with_response(&ClientMessage::GetWindowWorkspace { window });
get_response!(res, Workspace(0), GetWindowWorkspace { workspace });
workspace
}
pub fn get_seat_keyboard_workspace(&self, seat: Seat) -> Workspace {
let res = self.send_with_response(&ClientMessage::GetSeatKeyboardWorkspace { seat });
get_response!(res, Workspace(0), GetSeatKeyboardWorkspace { workspace });
@ -455,12 +536,22 @@ impl ConfigClient {
self.send(&ClientMessage::SetSeatWorkspace { seat, workspace });
}
pub fn set_window_workspace(&self, window: Window, workspace: Workspace) {
self.send(&ClientMessage::SetWindowWorkspace { window, workspace });
}
pub fn seat_split(&self, seat: Seat) -> Axis {
let res = self.send_with_response(&ClientMessage::GetSeatSplit { seat });
get_response!(res, Axis::Horizontal, GetSplit { axis });
axis
}
pub fn window_split(&self, window: Window) -> Axis {
let res = self.send_with_response(&ClientMessage::GetWindowSplit { window });
get_response!(res, Axis::Horizontal, GetWindowSplit { axis });
axis
}
pub fn disable_pointer_constraint(&self, seat: Seat) {
self.send(&ClientMessage::DisablePointerConstraint { seat });
}
@ -482,6 +573,16 @@ impl ConfigClient {
fullscreen
}
pub fn set_window_fullscreen(&self, window: Window, fullscreen: bool) {
self.send(&ClientMessage::SetWindowFullscreen { window, fullscreen });
}
pub fn get_window_fullscreen(&self, window: Window) -> bool {
let res = self.send_with_response(&ClientMessage::GetWindowFullscreen { window });
get_response!(res, false, GetWindowFullscreen { fullscreen });
fullscreen
}
pub fn reset_font(&self) {
self.send(&ClientMessage::ResetFont);
}
@ -510,6 +611,16 @@ impl ConfigClient {
self.set_seat_floating(seat, !self.get_seat_floating(seat));
}
pub fn get_window_floating(&self, window: Window) -> bool {
let res = self.send_with_response(&ClientMessage::GetWindowFloating { window });
get_response!(res, false, GetWindowFloating { floating });
floating
}
pub fn set_window_floating(&self, window: Window, floating: bool) {
self.send(&ClientMessage::SetWindowFloating { window, floating });
}
pub fn reset_colors(&self) {
self.send(&ClientMessage::ResetColors);
}
@ -553,6 +664,10 @@ impl ConfigClient {
self.send(&ClientMessage::SetSeatMono { seat, mono });
}
pub fn set_window_mono(&self, window: Window, mono: bool) {
self.send(&ClientMessage::SetWindowMono { window, mono });
}
pub fn set_env(&self, key: &str, val: &str) {
self.send(&ClientMessage::SetEnv { key, val });
}
@ -587,14 +702,26 @@ impl ConfigClient {
self.send(&ClientMessage::SetSeatSplit { seat, axis });
}
pub fn set_window_split(&self, window: Window, axis: Axis) {
self.send(&ClientMessage::SetWindowSplit { window, axis });
}
pub fn create_seat_split(&self, seat: Seat, axis: Axis) {
self.send(&ClientMessage::CreateSeatSplit { seat, axis });
}
pub fn create_window_split(&self, window: Window, axis: Axis) {
self.send(&ClientMessage::CreateWindowSplit { window, axis });
}
pub fn seat_close(&self, seat: Seat) {
self.send(&ClientMessage::SeatClose { seat });
}
pub fn close_window(&self, window: Window) {
self.send(&ClientMessage::WindowClose { window });
}
pub fn focus_seat_parent(&self, seat: Seat) {
self.send(&ClientMessage::FocusSeatParent { seat });
}
@ -802,6 +929,16 @@ impl ConfigClient {
self.send(&ClientMessage::SetSeatFloatPinned { seat, pinned });
}
pub fn get_window_pinned(&self, window: Window) -> bool {
let res = self.send_with_response(&ClientMessage::GetWindowFloatPinned { window });
get_response!(res, false, GetWindowFloatPinned { pinned });
pinned
}
pub fn set_window_pinned(&self, window: Window, pinned: bool) {
self.send(&ClientMessage::SetWindowFloatPinned { window, pinned });
}
pub fn connector_connected(&self, connector: Connector) -> bool {
let res = self.send_with_response(&ClientMessage::ConnectorConnected { connector });
get_response!(res, false, ConnectorConnected { connected });

View file

@ -15,6 +15,7 @@ use {
ColorSpace, Connector, DrmDevice, Format, GfxApi, TearingMode, TransferFunction,
Transform, VrrMode, connector_type::ConnectorType,
},
window::{Window, WindowType},
xwayland::XScalingMode,
},
serde::{Deserialize, Serialize},
@ -576,6 +577,93 @@ pub enum ClientMessage<'a> {
ClientIsXwayland {
client: Client,
},
WindowExists {
window: Window,
},
GetWindowClient {
window: Window,
},
GetWorkspaceWindow {
workspace: Workspace,
},
GetSeatKeyboardWindow {
seat: Seat,
},
SeatFocusWindow {
seat: Seat,
window: Window,
},
GetWindowTitle {
window: Window,
},
GetWindowType {
window: Window,
},
GetWindowId {
window: Window,
},
GetWindowIsVisible {
window: Window,
},
GetWindowParent {
window: Window,
},
GetWindowWorkspace {
window: Window,
},
GetWindowChildren {
window: Window,
},
GetWindowSplit {
window: Window,
},
SetWindowSplit {
window: Window,
axis: Axis,
},
GetWindowMono {
window: Window,
},
SetWindowMono {
window: Window,
mono: bool,
},
WindowMove {
window: Window,
direction: Direction,
},
CreateWindowSplit {
window: Window,
axis: Axis,
},
WindowClose {
window: Window,
},
GetWindowFloating {
window: Window,
},
SetWindowFloating {
window: Window,
floating: bool,
},
SetWindowWorkspace {
window: Window,
workspace: Workspace,
},
SetWindowFullscreen {
window: Window,
fullscreen: bool,
},
GetWindowFullscreen {
window: Window,
},
GetWindowFloatPinned {
window: Window,
},
SetWindowFloatPinned {
window: Window,
pinned: bool,
},
}
#[derive(Serialize, Deserialize, Debug)]
@ -748,6 +836,54 @@ pub enum Response {
ClientIsXwayland {
is_xwayland: bool,
},
WindowExists {
exists: bool,
},
GetWindowClient {
client: Client,
},
GetSeatKeyboardWindow {
window: Window,
},
GetWorkspaceWindow {
window: Window,
},
GetWindowParent {
window: Window,
},
GetWindowChildren {
windows: Vec<Window>,
},
GetWindowTitle {
title: String,
},
GetWindowType {
kind: WindowType,
},
GetWindowId {
id: String,
},
GetWindowWorkspace {
workspace: Workspace,
},
GetWindowFloating {
floating: bool,
},
GetWindowSplit {
axis: Axis,
},
GetWindowMono {
mono: bool,
},
GetWindowFullscreen {
fullscreen: bool,
},
GetWindowFloatPinned {
pinned: bool,
},
GetWindowIsVisible {
visible: bool,
},
}
#[derive(Serialize, Deserialize, Debug)]