1
0
Fork 0
forked from wry/wry

config: add content-type window criteria

This commit is contained in:
Julian Orth 2025-07-17 11:02:32 +02:00
parent fb5c50467b
commit 4fd70f03e1
22 changed files with 327 additions and 18 deletions

View file

@ -9,7 +9,7 @@ use {
client::ClientMatcher,
input::Seat,
video::Mode,
window::{WindowMatcher, WindowType},
window::{ContentType, WindowMatcher, WindowType},
},
bincode::Options,
serde::{Deserialize, Serialize},
@ -119,6 +119,7 @@ pub enum WindowCriterionIpc {
Fullscreen,
JustMapped,
Workspace(Workspace),
ContentTypes(ContentType),
}
#[derive(Serialize, Deserialize, Clone, Debug, Hash, Eq, PartialEq)]

View file

@ -32,7 +32,10 @@ use {
Transform, VrrMode,
connector_type::{CON_UNKNOWN, ConnectorType},
},
window::{MatchedWindow, TileState, Window, WindowCriterion, WindowMatcher, WindowType},
window::{
ContentType, MatchedWindow, TileState, Window, WindowCriterion, WindowMatcher,
WindowType,
},
xwayland::XScalingMode,
},
bincode::Options,
@ -413,6 +416,12 @@ impl ConfigClient {
kind
}
pub fn content_type(&self, window: Window) -> ContentType {
let res = self.send_with_response(&ClientMessage::GetContentType { window });
get_response!(res, ContentType(0), GetContentType { 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 });
@ -1682,6 +1691,7 @@ impl ConfigClient {
WindowCriterion::Workspace(t) => WindowCriterionIpc::Workspace(t),
WindowCriterion::WorkspaceName(t) => string!(t, Workspace, false),
WindowCriterion::WorkspaceNameRegex(t) => string!(t, Workspace, true),
WindowCriterion::ContentTypes(t) => WindowCriterionIpc::ContentTypes(t),
};
let res = self.send_with_response(&ClientMessage::CreateWindowMatcher { criterion });
get_response!(

View file

@ -15,7 +15,7 @@ use {
ColorSpace, Connector, DrmDevice, Format, GfxApi, TearingMode, TransferFunction,
Transform, VrrMode, connector_type::ConnectorType,
},
window::{TileState, Window, WindowMatcher, WindowType},
window::{ContentType, TileState, Window, WindowMatcher, WindowType},
xwayland::XScalingMode,
},
serde::{Deserialize, Serialize},
@ -718,6 +718,9 @@ pub enum ClientMessage<'a> {
device: InputDevice,
enabled: bool,
},
GetContentType {
window: Window,
},
}
#[derive(Serialize, Deserialize, Debug)]
@ -944,6 +947,9 @@ pub enum Response {
CreateWindowMatcher {
matcher: WindowMatcher,
},
GetContentType {
kind: ContentType,
},
}
#[derive(Serialize, Deserialize, Debug)]

View file

@ -41,6 +41,21 @@ bitflags! {
}
}
bitflags! {
/// The content type of a window.
#[derive(Serialize, Deserialize, Copy, Clone, Hash, Eq, PartialEq)]
pub struct ContentType(pub u64) {
/// No content type.
pub const NO_CONTENT_TYPE = 1 << 0,
/// Photo content type.
pub const PHOTO_CONTENT = 1 << 1,
/// Video content type.
pub const VIDEO_CONTENT = 1 << 2,
/// Game content type.
pub const GAME_CONTENT = 1 << 3,
}
}
/// The tile state of a window.
#[non_exhaustive]
#[derive(Serialize, Deserialize, Copy, Clone, Debug, Hash, Eq, PartialEq)]
@ -86,6 +101,11 @@ impl Window {
get!(WindowType(0)).window_type(self)
}
/// Returns the content type of the window.
pub fn content_type(self) -> ContentType {
get!(ContentType(0)).content_type(self)
}
/// Returns the identifier of the window.
///
/// This is the identifier used in the `ext-foreign-toplevel-list-v1` protocol.
@ -292,6 +312,8 @@ pub enum WindowCriterion<'a> {
WorkspaceName(&'a str),
/// Matches the workspace name of the window with a regular expression.
WorkspaceNameRegex(&'a str),
/// Matches if the window has one of the content types.
ContentTypes(ContentType),
}
impl WindowCriterion<'_> {