xwm: handle _NET_WM_STATE_MODAL client messages
This commit is contained in:
parent
f949fa4865
commit
ba0063fbeb
2 changed files with 33 additions and 0 deletions
|
|
@ -425,6 +425,14 @@ pub trait XwmHandler {
|
|||
fn unfullscreen_request(&mut self, xwm: XwmId, window: X11Surface) {
|
||||
let _ = (xwm, window);
|
||||
}
|
||||
/// Window requests to be set as a modal dialog (see [`X11Surface::is_popup`]).
|
||||
fn modal_request(&mut self, xwm: XwmId, window: X11Surface) {
|
||||
let _ = (xwm, window);
|
||||
}
|
||||
/// Window requests to no longer be a modal dialog.
|
||||
fn unmodal_request(&mut self, xwm: XwmId, window: X11Surface) {
|
||||
let _ = (xwm, window);
|
||||
}
|
||||
/// Window requests to be minimized.
|
||||
fn minimize_request(&mut self, xwm: XwmId, window: X11Surface) {
|
||||
let _ = (xwm, window);
|
||||
|
|
@ -2517,6 +2525,18 @@ where
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
actions if actions.contains(&xwm.atoms._NET_WM_STATE_MODAL) => match data[0] {
|
||||
0 => state.unmodal_request(xwm_id, surface),
|
||||
1 => state.modal_request(xwm_id, surface),
|
||||
2 => {
|
||||
if surface.is_popup() {
|
||||
state.unmodal_request(xwm_id, surface)
|
||||
} else {
|
||||
state.modal_request(xwm_id, surface)
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
actions if actions.contains(&xwm.atoms._NET_WM_STATE_ABOVE) => match data[0] {
|
||||
0 => state.unabove_request(xwm_id, surface),
|
||||
1 => state.above_request(xwm_id, surface),
|
||||
|
|
|
|||
|
|
@ -1362,6 +1362,19 @@ impl X11Surface {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
/// Sets the window as a modal dialog or not.
|
||||
///
|
||||
/// Corresponds to the `_NET_WM_STATE_MODAL` state, also reflected
|
||||
/// by [`X11Surface::is_popup`].
|
||||
pub fn set_modal(&self, modal: bool) -> Result<(), ConnectionError> {
|
||||
if modal {
|
||||
self.change_net_state(&[self.atoms._NET_WM_STATE_MODAL], &[])?;
|
||||
} else {
|
||||
self.change_net_state(&[], &[self.atoms._NET_WM_STATE_MODAL])?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Sets the window as above (always on top) or not.
|
||||
///
|
||||
/// Allows the client to reflect this state in their UI.
|
||||
|
|
|
|||
Loading…
Reference in a new issue