-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from mahkoh/jorth/dialog2
wayland: implement xdg-dialog-v1
- Loading branch information
Showing
9 changed files
with
210 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# Unreleased | ||
|
||
- Add support for wp-security-manager-v1. | ||
- Add support for xdg-dialog-v1. | ||
|
||
# 1.1.0 (2024-04-22) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/ifs/wl_surface/xdg_surface/xdg_toplevel/xdg_dialog_v1.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use { | ||
crate::{ | ||
client::{Client, ClientError}, | ||
ifs::wl_surface::xdg_surface::xdg_toplevel::XdgToplevel, | ||
leaks::Tracker, | ||
object::{Object, Version}, | ||
wire::{xdg_dialog_v1::*, XdgDialogV1Id, XdgToplevelId}, | ||
}, | ||
std::{fmt::Debug, rc::Rc}, | ||
thiserror::Error, | ||
}; | ||
|
||
pub struct XdgDialogV1 { | ||
pub id: XdgDialogV1Id, | ||
pub client: Rc<Client>, | ||
pub toplevel: Rc<XdgToplevel>, | ||
pub tracker: Tracker<Self>, | ||
pub version: Version, | ||
} | ||
|
||
impl XdgDialogV1 { | ||
fn detach(&self) { | ||
self.toplevel.dialog.take(); | ||
} | ||
|
||
pub fn install(self: &Rc<Self>) -> Result<(), XdgDialogV1Error> { | ||
if self.toplevel.dialog.is_some() { | ||
return Err(XdgDialogV1Error::AlreadyAttached(self.toplevel.id)); | ||
} | ||
self.toplevel.dialog.set(Some(self.clone())); | ||
Ok(()) | ||
} | ||
} | ||
|
||
impl XdgDialogV1RequestHandler for XdgDialogV1 { | ||
type Error = XdgDialogV1Error; | ||
|
||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> { | ||
self.detach(); | ||
self.client.remove_obj(self)?; | ||
Ok(()) | ||
} | ||
|
||
fn set_modal(&self, _req: SetModal, _slf: &Rc<Self>) -> Result<(), Self::Error> { | ||
Ok(()) | ||
} | ||
|
||
fn unset_modal(&self, _req: UnsetModal, _slf: &Rc<Self>) -> Result<(), Self::Error> { | ||
Ok(()) | ||
} | ||
} | ||
|
||
object_base! { | ||
self = XdgDialogV1; | ||
version = self.version; | ||
} | ||
|
||
impl Object for XdgDialogV1 { | ||
fn break_loops(&self) { | ||
self.detach(); | ||
} | ||
} | ||
|
||
simple_add_obj!(XdgDialogV1); | ||
|
||
#[derive(Debug, Error)] | ||
pub enum XdgDialogV1Error { | ||
#[error(transparent)] | ||
ClientError(Box<ClientError>), | ||
#[error("Toplevel {0} already has an xdg_dialog_v1")] | ||
AlreadyAttached(XdgToplevelId), | ||
} | ||
efrom!(XdgDialogV1Error, ClientError); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
use { | ||
crate::{ | ||
client::{Client, ClientError}, | ||
globals::{Global, GlobalName}, | ||
ifs::wl_surface::xdg_surface::xdg_toplevel::xdg_dialog_v1::{ | ||
XdgDialogV1, XdgDialogV1Error, | ||
}, | ||
leaks::Tracker, | ||
object::{Object, Version}, | ||
wire::{xdg_wm_dialog_v1::*, XdgWmDialogV1Id}, | ||
}, | ||
std::rc::Rc, | ||
thiserror::Error, | ||
}; | ||
|
||
pub struct XdgWmDialogV1Global { | ||
name: GlobalName, | ||
} | ||
|
||
impl XdgWmDialogV1Global { | ||
pub fn new(name: GlobalName) -> Self { | ||
Self { name } | ||
} | ||
|
||
fn bind_( | ||
self: Rc<Self>, | ||
id: XdgWmDialogV1Id, | ||
client: &Rc<Client>, | ||
version: Version, | ||
) -> Result<(), XdgWmDialogV1Error> { | ||
let obj = Rc::new(XdgWmDialogV1 { | ||
id, | ||
client: client.clone(), | ||
tracker: Default::default(), | ||
version, | ||
}); | ||
track!(client, obj); | ||
client.add_client_obj(&obj)?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
global_base!(XdgWmDialogV1Global, XdgWmDialogV1, XdgWmDialogV1Error); | ||
|
||
impl Global for XdgWmDialogV1Global { | ||
fn singleton(&self) -> bool { | ||
true | ||
} | ||
|
||
fn version(&self) -> u32 { | ||
1 | ||
} | ||
} | ||
|
||
simple_add_global!(XdgWmDialogV1Global); | ||
|
||
pub struct XdgWmDialogV1 { | ||
pub id: XdgWmDialogV1Id, | ||
pub client: Rc<Client>, | ||
pub tracker: Tracker<Self>, | ||
pub version: Version, | ||
} | ||
|
||
impl XdgWmDialogV1RequestHandler for XdgWmDialogV1 { | ||
type Error = XdgWmDialogV1Error; | ||
|
||
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> { | ||
self.client.remove_obj(self)?; | ||
Ok(()) | ||
} | ||
|
||
fn get_xdg_dialog(&self, req: GetXdgDialog, _slf: &Rc<Self>) -> Result<(), Self::Error> { | ||
let tl = self.client.lookup(req.toplevel)?; | ||
let obj = Rc::new(XdgDialogV1 { | ||
id: req.id, | ||
client: self.client.clone(), | ||
toplevel: tl, | ||
tracker: Default::default(), | ||
version: self.version, | ||
}); | ||
track!(self.client, obj); | ||
self.client.add_client_obj(&obj)?; | ||
obj.install()?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
object_base! { | ||
self = XdgWmDialogV1; | ||
version = self.version; | ||
} | ||
|
||
impl Object for XdgWmDialogV1 {} | ||
|
||
simple_add_obj!(XdgWmDialogV1); | ||
|
||
#[derive(Debug, Error)] | ||
pub enum XdgWmDialogV1Error { | ||
#[error(transparent)] | ||
ClientError(Box<ClientError>), | ||
#[error(transparent)] | ||
XdgDialogV1Error(#[from] XdgDialogV1Error), | ||
} | ||
efrom!(XdgWmDialogV1Error, ClientError); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
request destroy { | ||
|
||
} | ||
|
||
request set_modal { | ||
|
||
} | ||
|
||
request unset_modal { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
request destroy { | ||
|
||
} | ||
|
||
request get_xdg_dialog { | ||
id: id(xdg_dialog_v1), | ||
toplevel: id(xdg_toplevel), | ||
} |