1
0
Fork 0
forked from wry/wry

Merge pull request #511 from mahkoh/jorth/content-type-window-rules

config: add content-type window criteria
This commit is contained in:
mahkoh 2025-07-17 11:24:02 +02:00 committed by GitHub
commit 35adc21ca6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 327 additions and 18 deletions

View file

@ -26,6 +26,9 @@ impl SurfaceExt for XSurface {
fn after_apply_commit(self: Rc<Self>) {
if let Some(xwindow) = self.xwindow.get() {
xwindow.map_status_changed();
xwindow
.toplevel_data
.set_content_type(self.surface.content_type.get());
}
}

View file

@ -217,6 +217,7 @@ impl Xwindow {
weak,
);
tld.pos.set(surface.extents.get());
tld.content_type.set(surface.content_type.get());
Self {
id,
data: data.clone(),

View file

@ -146,6 +146,17 @@ impl XdgToplevel {
let data = Rc::new(XdgToplevelToplevelData {
tag: Default::default(),
});
let toplevel_data = ToplevelData::new(
state,
String::new(),
Some(surface.surface.client.clone()),
ToplevelType::XdgToplevel(data.clone()),
node_id,
slf,
);
toplevel_data
.content_type
.set(surface.surface.content_type.get());
Self {
id,
state: state.clone(),
@ -161,14 +172,7 @@ impl XdgToplevel {
max_width: Cell::new(None),
max_height: Cell::new(None),
tracker: Default::default(),
toplevel_data: ToplevelData::new(
state,
String::new(),
Some(surface.surface.client.clone()),
ToplevelType::XdgToplevel(data.clone()),
node_id,
slf,
),
toplevel_data,
drag: Default::default(),
is_mapped: Cell::new(false),
dialog: Default::default(),
@ -518,6 +522,8 @@ impl XdgToplevel {
self.state.tree_changed();
self.toplevel_data.broadcast(self.clone());
}
self.toplevel_data
.set_content_type(self.xdg.surface.content_type.get());
}
}

View file

@ -6,6 +6,10 @@ use {
object::{Object, Version},
wire::{WpContentTypeV1Id, wp_content_type_v1::*},
},
jay_config::window::{
ContentType as ConfigContentType, GAME_CONTENT, NO_CONTENT_TYPE, PHOTO_CONTENT,
VIDEO_CONTENT,
},
std::rc::Rc,
thiserror::Error,
};
@ -22,6 +26,21 @@ pub enum ContentType {
Game,
}
pub trait ContentTypeExt {
fn to_config(&self) -> ConfigContentType;
}
impl ContentTypeExt for Option<ContentType> {
fn to_config(&self) -> ConfigContentType {
match self {
None => NO_CONTENT_TYPE,
Some(ContentType::Photo) => PHOTO_CONTENT,
Some(ContentType::Video) => VIDEO_CONTENT,
Some(ContentType::Game) => GAME_CONTENT,
}
}
}
pub struct WpContentTypeV1 {
pub id: WpContentTypeV1Id,
pub client: Rc<Client>,