Move and split macros, rename client_window
This commit is contained in:
parent
4d18bf5994
commit
35a91427fd
7 changed files with 346 additions and 342 deletions
|
@ -2,7 +2,9 @@
|
||||||
//!
|
//!
|
||||||
//! see: <https://specifications.freedesktop.org/wm-spec/wm-spec-1.5.html#idm45446104426048>
|
//! see: <https://specifications.freedesktop.org/wm-spec/wm-spec-1.5.html#idm45446104426048>
|
||||||
|
|
||||||
use xcb::{Xid, XidNew};
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
use xcb::Xid;
|
||||||
|
|
||||||
use crate::ewmh::proto::util::{strings_to_x_buffer, x_buffer_to_strings};
|
use crate::ewmh::proto::util::{strings_to_x_buffer, x_buffer_to_strings};
|
||||||
use crate::ewmh::traits::*;
|
use crate::ewmh::traits::*;
|
||||||
|
@ -40,7 +42,7 @@ pub struct SetWmName {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SetWmName {
|
impl SetWmName {
|
||||||
pub fn new(connection: &Connection, window: xcb::x::Window, name: &str) -> SetWmName {
|
pub fn new(window: xcb::x::Window, name: &str) -> SetWmName {
|
||||||
SetWmName {
|
SetWmName {
|
||||||
window: window,
|
window: window,
|
||||||
data: strings_to_x_buffer(vec![name]),
|
data: strings_to_x_buffer(vec![name]),
|
||||||
|
@ -50,7 +52,7 @@ impl SetWmName {
|
||||||
|
|
||||||
ewmh_set_property! {
|
ewmh_set_property! {
|
||||||
request=SetWmName{
|
request=SetWmName{
|
||||||
window: client_window,
|
window: client,
|
||||||
property: _NET_WM_NAME,
|
property: _NET_WM_NAME,
|
||||||
xtype: UTF8_STRING
|
xtype: UTF8_STRING
|
||||||
}
|
}
|
||||||
|
@ -173,7 +175,7 @@ impl SetWmDesktop {
|
||||||
|
|
||||||
ewmh_set_property! {
|
ewmh_set_property! {
|
||||||
request=SetWmDesktop {
|
request=SetWmDesktop {
|
||||||
window: client_window,
|
window: client,
|
||||||
property: _NET_WM_DESKTOP,
|
property: _NET_WM_DESKTOP,
|
||||||
xtype: ATOM_CARDINAL
|
xtype: ATOM_CARDINAL
|
||||||
}
|
}
|
||||||
|
@ -196,7 +198,7 @@ impl SendWmDesktop {
|
||||||
}
|
}
|
||||||
|
|
||||||
ewmh_client_message! {
|
ewmh_client_message! {
|
||||||
request=SendWmDesktop{destination: root_window}
|
request=SendWmDesktop{destination: root}
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
|
@ -240,7 +242,7 @@ impl SetWmWindowType {
|
||||||
|
|
||||||
ewmh_set_property! {
|
ewmh_set_property! {
|
||||||
request=SetWmWindowType{
|
request=SetWmWindowType{
|
||||||
window: client_window,
|
window: client,
|
||||||
property: _NET_WM_WINDOW_TYPE,
|
property: _NET_WM_WINDOW_TYPE,
|
||||||
xtype: ATOM_ATOM
|
xtype: ATOM_ATOM
|
||||||
}
|
}
|
||||||
|
@ -303,6 +305,6 @@ impl SetWmState {
|
||||||
}
|
}
|
||||||
|
|
||||||
ewmh_client_message! {
|
ewmh_client_message! {
|
||||||
request=SetWmState{destination: root_window}
|
request=SetWmState{destination: root}
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
|
|
|
@ -1,320 +0,0 @@
|
||||||
macro_rules! _set_property_base {
|
|
||||||
(root_window, $property:ident, UTF8_STRING) => {
|
|
||||||
fn xcb_request(&'a self, con: &Connection) -> xcb::x::ChangeProperty<'a, u8> {
|
|
||||||
xcb::x::ChangeProperty {
|
|
||||||
mode: xcb::x::PropMode::Replace,
|
|
||||||
window: con.con.get_setup().roots().next().unwrap().root(),
|
|
||||||
property: con.atoms.$property,
|
|
||||||
r#type: con.atoms.UTF8_STRING,
|
|
||||||
data: &self.data,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
(root_window, $property:ident, $xtype:ident) => {
|
|
||||||
fn xcb_request(&'a self, con: &Connection) -> xcb::x::ChangeProperty<'a, u32> {
|
|
||||||
xcb::x::ChangeProperty {
|
|
||||||
mode: xcb::x::PropMode::Replace,
|
|
||||||
window: con.con.get_setup().roots().next().unwrap().root(),
|
|
||||||
property: con.atoms.$property,
|
|
||||||
r#type: xcb::x::$xtype,
|
|
||||||
data: &self.data,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
(client_window, $property:ident, UTF8_STRING) => {
|
|
||||||
fn xcb_request(&'a self, con: &Connection) -> xcb::x::ChangeProperty<'a, u8> {
|
|
||||||
xcb::x::ChangeProperty {
|
|
||||||
mode: xcb::x::PropMode::Replace,
|
|
||||||
window: self.window,
|
|
||||||
property: con.atoms.$property,
|
|
||||||
r#type: con.atoms.UTF8_STRING,
|
|
||||||
data: &self.data,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
(client_window, $property:ident, ATOM_CARDINAL) => {
|
|
||||||
fn xcb_request(&'a self, con: &Connection) -> xcb::x::ChangeProperty<'a, u32> {
|
|
||||||
xcb::x::ChangeProperty {
|
|
||||||
mode: xcb::x::PropMode::Replace,
|
|
||||||
window: self.window,
|
|
||||||
property: con.atoms.$property,
|
|
||||||
r#type: xcb::x::ATOM_CARDINAL,
|
|
||||||
data: &self.data,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
(client_window, $property:ident, ATOM_ATOM) => {
|
|
||||||
fn xcb_request(&'a self, con: &Connection) -> xcb::x::ChangeProperty<'a, xcb::x::Atom> {
|
|
||||||
xcb::x::ChangeProperty {
|
|
||||||
mode: xcb::x::PropMode::Replace,
|
|
||||||
window: self.window,
|
|
||||||
property: con.atoms.$property,
|
|
||||||
r#type: xcb::x::ATOM_ATOM,
|
|
||||||
data: &self.data,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! ewmh_set_property {
|
|
||||||
(request=$request:ident{
|
|
||||||
window: $window:ident,
|
|
||||||
property: $property:ident,
|
|
||||||
xtype: UTF8_STRING
|
|
||||||
}) => {
|
|
||||||
impl<'a> EwmhRequest<'a> for $request {
|
|
||||||
type XcbRequest = xcb::x::ChangeProperty<'a, u8>;
|
|
||||||
type EwmhCookie = xcb::VoidCookie;
|
|
||||||
|
|
||||||
_set_property_base! {$window, $property, UTF8_STRING}
|
|
||||||
|
|
||||||
fn convert_cookie(&'a self, xcb_cookie: xcb::VoidCookie) -> Self::EwmhCookie {
|
|
||||||
xcb_cookie
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> EwmhVoidRequestChecked<'a> for $request {
|
|
||||||
type XcbRequest = xcb::x::ChangeProperty<'a, u8>;
|
|
||||||
|
|
||||||
_set_property_base! {$window, $property, UTF8_STRING}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
(request=$request:ident{
|
|
||||||
window: $window:ident,
|
|
||||||
property: $property:ident,
|
|
||||||
xtype: ATOM_CARDINAL
|
|
||||||
}) => {
|
|
||||||
impl<'a> EwmhRequest<'a> for $request {
|
|
||||||
type XcbRequest = xcb::x::ChangeProperty<'a, u32>;
|
|
||||||
type EwmhCookie = xcb::VoidCookie;
|
|
||||||
|
|
||||||
_set_property_base! {$window, $property, ATOM_CARDINAL}
|
|
||||||
|
|
||||||
fn convert_cookie(&'a self, xcb_cookie: xcb::VoidCookie) -> Self::EwmhCookie {
|
|
||||||
xcb_cookie
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> EwmhVoidRequestChecked<'a> for $request {
|
|
||||||
type XcbRequest = xcb::x::ChangeProperty<'a, u32>;
|
|
||||||
|
|
||||||
_set_property_base! {$window, $property, ATOM_CARDINAL}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
(request=$request:ident{
|
|
||||||
window: $window:ident,
|
|
||||||
property: $property:ident,
|
|
||||||
xtype: ATOM_ATOM
|
|
||||||
}) => {
|
|
||||||
impl<'a> EwmhRequest<'a> for $request {
|
|
||||||
type XcbRequest = xcb::x::ChangeProperty<'a, xcb::x::Atom>;
|
|
||||||
type EwmhCookie = xcb::VoidCookie;
|
|
||||||
|
|
||||||
_set_property_base! {$window, $property, ATOM_ATOM }
|
|
||||||
|
|
||||||
fn convert_cookie(&'a self, xcb_cookie: xcb::VoidCookie) -> Self::EwmhCookie {
|
|
||||||
xcb_cookie
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> EwmhVoidRequestChecked<'a> for $request {
|
|
||||||
type XcbRequest = xcb::x::ChangeProperty<'a, xcb::x::Atom>;
|
|
||||||
|
|
||||||
_set_property_base! {$window, $property, ATOM_ATOM }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! _client_message_base {
|
|
||||||
(root_window) => {
|
|
||||||
fn xcb_request(&'a self, con: &Connection) -> Self::XcbRequest {
|
|
||||||
xcb::x::SendEvent {
|
|
||||||
propagate: false,
|
|
||||||
destination: xcb::x::SendEventDest::Window(
|
|
||||||
con.con.get_setup().roots().next().unwrap().root(),
|
|
||||||
),
|
|
||||||
event_mask: xcb::x::EventMask::SUBSTRUCTURE_NOTIFY
|
|
||||||
| xcb::x::EventMask::SUBSTRUCTURE_REDIRECT,
|
|
||||||
event: &self.client_message,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
($destination: ident) => {
|
|
||||||
fn xcb_request(&'a self, con: &Connection) -> Self::XcbRequest {
|
|
||||||
xcb::x::SendEvent {
|
|
||||||
propagate: false,
|
|
||||||
destination: xcb::x::SendEventDest::Window($destination),
|
|
||||||
event_mask: xcb::x::EventMask::SUBSTRUCTURE_NOTIFY
|
|
||||||
| xcb::x::EventMask::SUBSTRUCTURE_REDIRECT,
|
|
||||||
event: &self.client_message,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! ewmh_client_message {
|
|
||||||
(request=$request:ident{destination: $destination:ident}) => {
|
|
||||||
impl<'a> EwmhRequest<'a> for $request {
|
|
||||||
type XcbRequest = xcb::x::SendEvent<'a, xcb::x::ClientMessageEvent>;
|
|
||||||
type EwmhCookie = xcb::VoidCookie;
|
|
||||||
|
|
||||||
_client_message_base! {$destination}
|
|
||||||
|
|
||||||
fn convert_cookie(&'a self, xcb_cookie: xcb::VoidCookie) -> Self::EwmhCookie {
|
|
||||||
xcb_cookie
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> EwmhVoidRequestChecked<'a> for $request {
|
|
||||||
type XcbRequest = xcb::x::SendEvent<'a, xcb::x::ClientMessageEvent>;
|
|
||||||
_client_message_base! {$destination}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! _get_property_cookies {
|
|
||||||
(@private $request:ident, $reply:ident) => {
|
|
||||||
paste! {
|
|
||||||
impl EwmhCookie for [<$request Cookie>] {
|
|
||||||
type XcbCookie = xcb::x::GetPropertyCookie;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EwmhPropertyCookieChecked for [<$request Cookie>] {
|
|
||||||
type Reply = $reply;
|
|
||||||
|
|
||||||
fn inner(self) -> xcb::x::GetPropertyCookie {
|
|
||||||
self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EwmhPropertyCookieUnchecked for [<$request CookieUnchecked>] {
|
|
||||||
type Reply = $reply;
|
|
||||||
|
|
||||||
fn inner(self) -> xcb::x::GetPropertyCookieUnchecked {
|
|
||||||
self.0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! _get_property_request {
|
|
||||||
(@private root, $property:ident, UTF8_STRING) => {
|
|
||||||
fn xcb_request(&self, con: &Connection) -> xcb::x::GetProperty {
|
|
||||||
xcb::x::GetProperty {
|
|
||||||
delete: false,
|
|
||||||
window: con.con.get_setup().roots().next().unwrap().root(),
|
|
||||||
property: con.atoms.$property,
|
|
||||||
r#type: con.atoms.UTF8_STRING,
|
|
||||||
long_offset: 0,
|
|
||||||
long_length: u32::MAX,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
(@private root, $property:ident, $xtype:ident) => {
|
|
||||||
fn xcb_request(&self, con: &Connection) -> xcb::x::GetProperty {
|
|
||||||
xcb::x::GetProperty {
|
|
||||||
delete: false,
|
|
||||||
window: con.con.get_setup().roots().next().unwrap().root(),
|
|
||||||
property: con.atoms.$property,
|
|
||||||
r#type: xcb::x::$xtype,
|
|
||||||
long_offset: 0,
|
|
||||||
long_length: u32::MAX,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
(@private client, $property:ident, UTF8_STRING) => {
|
|
||||||
fn xcb_request(&self, con: &Connection) -> xcb::x::GetProperty {
|
|
||||||
xcb::x::GetProperty {
|
|
||||||
delete: false,
|
|
||||||
window: self.0,
|
|
||||||
property: con.atoms.$property,
|
|
||||||
r#type: con.atoms.UTF8_STRING,
|
|
||||||
long_offset: 0,
|
|
||||||
long_length: u32::MAX,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
(@private client, $property:ident, $xtype:ident) => {
|
|
||||||
fn xcb_request(&self, con: &Connection) -> xcb::x::GetProperty {
|
|
||||||
xcb::x::GetProperty {
|
|
||||||
delete: false,
|
|
||||||
window: self.0,
|
|
||||||
property: con.atoms.$property,
|
|
||||||
r#type: xcb::x::$xtype,
|
|
||||||
long_offset: 0,
|
|
||||||
long_length: u32::MAX,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! _get_property_structs {
|
|
||||||
(@private $request:ident, root) => {
|
|
||||||
paste! {
|
|
||||||
pub struct $request;
|
|
||||||
pub struct [<$request Cookie>](xcb::x::GetPropertyCookie);
|
|
||||||
pub struct [<$request CookieUnchecked>](xcb::x::GetPropertyCookieUnchecked);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
(@private $request:ident, client) => {
|
|
||||||
paste! {
|
|
||||||
pub struct $request(xcb::x::Window);
|
|
||||||
pub struct [<$request Cookie>](xcb::x::GetPropertyCookie);
|
|
||||||
pub struct [<$request CookieUnchecked>](xcb::x::GetPropertyCookieUnchecked);
|
|
||||||
|
|
||||||
impl $request {
|
|
||||||
fn new(window: xcb::x::Window) -> $request {
|
|
||||||
$request(window)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! ewmh_get_property {
|
|
||||||
(request=$request:ident{
|
|
||||||
window: $window:ident,
|
|
||||||
property: $property:ident,
|
|
||||||
xtype: $xtype: ident
|
|
||||||
},
|
|
||||||
reply=$reply:ident) => {
|
|
||||||
paste!{
|
|
||||||
_get_property_structs! {@private $request, $window}
|
|
||||||
|
|
||||||
impl<'a> EwmhRequest<'a> for $request {
|
|
||||||
type XcbRequest = xcb::x::GetProperty;
|
|
||||||
type EwmhCookie = [<$request Cookie>];
|
|
||||||
|
|
||||||
_get_property_request! {@private $window, $property, $xtype}
|
|
||||||
|
|
||||||
fn convert_cookie(&'a self, xcb_cookie: xcb::x::GetPropertyCookie) -> Self::EwmhCookie {
|
|
||||||
[<$request Cookie>](xcb_cookie)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EwmhPropertyRequestUnchecked for $request {
|
|
||||||
paste!{type EwmhCookie = [<$request CookieUnchecked>];}
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
|
||||||
fn convert_cookie(&self, xcb_cookie: xcb::x::GetPropertyCookieUnchecked) -> Self::EwmhCookie {
|
|
||||||
[<$request CookieUnchecked>](xcb_cookie)
|
|
||||||
}
|
|
||||||
|
|
||||||
_get_property_request! {@private $window, $property, $xtype}
|
|
||||||
}
|
|
||||||
|
|
||||||
_get_property_cookies! {@private $request, $reply}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
47
src/ewmh/proto/macros/client_message.rs
Normal file
47
src/ewmh/proto/macros/client_message.rs
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
macro_rules! _client_message_base {
|
||||||
|
(root) => {
|
||||||
|
fn xcb_request(&'a self, con: &Connection) -> Self::XcbRequest {
|
||||||
|
xcb::x::SendEvent {
|
||||||
|
propagate: false,
|
||||||
|
destination: xcb::x::SendEventDest::Window(
|
||||||
|
con.con.get_setup().roots().next().unwrap().root(),
|
||||||
|
),
|
||||||
|
event_mask: xcb::x::EventMask::SUBSTRUCTURE_NOTIFY
|
||||||
|
| xcb::x::EventMask::SUBSTRUCTURE_REDIRECT,
|
||||||
|
event: &self.client_message,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
($destination: ident) => {
|
||||||
|
fn xcb_request(&'a self, con: &Connection) -> Self::XcbRequest {
|
||||||
|
xcb::x::SendEvent {
|
||||||
|
propagate: false,
|
||||||
|
destination: xcb::x::SendEventDest::Window($destination),
|
||||||
|
event_mask: xcb::x::EventMask::SUBSTRUCTURE_NOTIFY
|
||||||
|
| xcb::x::EventMask::SUBSTRUCTURE_REDIRECT,
|
||||||
|
event: &self.client_message,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! ewmh_client_message {
|
||||||
|
(request=$request:ident{destination: $destination:ident}) => {
|
||||||
|
impl<'a> EwmhRequest<'a> for $request {
|
||||||
|
type XcbRequest = xcb::x::SendEvent<'a, xcb::x::ClientMessageEvent>;
|
||||||
|
type EwmhCookie = xcb::VoidCookie;
|
||||||
|
|
||||||
|
_client_message_base! {$destination}
|
||||||
|
|
||||||
|
fn convert_cookie(&'a self, xcb_cookie: xcb::VoidCookie) -> Self::EwmhCookie {
|
||||||
|
xcb_cookie
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> EwmhVoidRequestChecked<'a> for $request {
|
||||||
|
type XcbRequest = xcb::x::SendEvent<'a, xcb::x::ClientMessageEvent>;
|
||||||
|
_client_message_base! {$destination}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
139
src/ewmh/proto/macros/get_property.rs
Normal file
139
src/ewmh/proto/macros/get_property.rs
Normal file
|
@ -0,0 +1,139 @@
|
||||||
|
macro_rules! _get_property_cookies {
|
||||||
|
(@ewmh_priv $request:ident, $reply:ident) => {
|
||||||
|
paste! {
|
||||||
|
impl EwmhCookie for [<$request Cookie>] {
|
||||||
|
type XcbCookie = xcb::x::GetPropertyCookie;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EwmhPropertyCookieChecked for [<$request Cookie>] {
|
||||||
|
type Reply = $reply;
|
||||||
|
|
||||||
|
fn inner(self) -> xcb::x::GetPropertyCookie {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EwmhPropertyCookieUnchecked for [<$request CookieUnchecked>] {
|
||||||
|
type Reply = $reply;
|
||||||
|
|
||||||
|
fn inner(self) -> xcb::x::GetPropertyCookieUnchecked {
|
||||||
|
self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! _get_property_request {
|
||||||
|
(@ewmh_priv root, $property:ident, UTF8_STRING) => {
|
||||||
|
fn xcb_request(&self, con: &Connection) -> xcb::x::GetProperty {
|
||||||
|
xcb::x::GetProperty {
|
||||||
|
delete: false,
|
||||||
|
window: con.con.get_setup().roots().next().unwrap().root(),
|
||||||
|
property: con.atoms.$property,
|
||||||
|
r#type: con.atoms.UTF8_STRING,
|
||||||
|
long_offset: 0,
|
||||||
|
long_length: u32::MAX,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(@ewmh_priv root, $property:ident, $xtype:ident) => {
|
||||||
|
fn xcb_request(&self, con: &Connection) -> xcb::x::GetProperty {
|
||||||
|
xcb::x::GetProperty {
|
||||||
|
delete: false,
|
||||||
|
window: con.con.get_setup().roots().next().unwrap().root(),
|
||||||
|
property: con.atoms.$property,
|
||||||
|
r#type: xcb::x::$xtype,
|
||||||
|
long_offset: 0,
|
||||||
|
long_length: u32::MAX,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(@ewmh_priv client, $property:ident, UTF8_STRING) => {
|
||||||
|
fn xcb_request(&self, con: &Connection) -> xcb::x::GetProperty {
|
||||||
|
xcb::x::GetProperty {
|
||||||
|
delete: false,
|
||||||
|
window: self.0,
|
||||||
|
property: con.atoms.$property,
|
||||||
|
r#type: con.atoms.UTF8_STRING,
|
||||||
|
long_offset: 0,
|
||||||
|
long_length: u32::MAX,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(@ewmh_priv client, $property:ident, $xtype:ident) => {
|
||||||
|
fn xcb_request(&self, con: &Connection) -> xcb::x::GetProperty {
|
||||||
|
xcb::x::GetProperty {
|
||||||
|
delete: false,
|
||||||
|
window: self.0,
|
||||||
|
property: con.atoms.$property,
|
||||||
|
r#type: xcb::x::$xtype,
|
||||||
|
long_offset: 0,
|
||||||
|
long_length: u32::MAX,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! _get_property_structs {
|
||||||
|
(@ewmh_priv $request:ident, root) => {
|
||||||
|
paste! {
|
||||||
|
pub struct $request;
|
||||||
|
pub struct [<$request Cookie>](xcb::x::GetPropertyCookie);
|
||||||
|
pub struct [<$request CookieUnchecked>](xcb::x::GetPropertyCookieUnchecked);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
(@ewmh_priv $request:ident, client) => {
|
||||||
|
paste! {
|
||||||
|
pub struct $request(xcb::x::Window);
|
||||||
|
pub struct [<$request Cookie>](xcb::x::GetPropertyCookie);
|
||||||
|
pub struct [<$request CookieUnchecked>](xcb::x::GetPropertyCookieUnchecked);
|
||||||
|
|
||||||
|
impl $request {
|
||||||
|
fn new(window: xcb::x::Window) -> $request {
|
||||||
|
$request(window)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! ewmh_get_property {
|
||||||
|
(request=$request:ident{
|
||||||
|
window: $window:ident,
|
||||||
|
property: $property:ident,
|
||||||
|
xtype: $xtype: ident
|
||||||
|
},
|
||||||
|
reply=$reply:ident) => {
|
||||||
|
paste!{
|
||||||
|
_get_property_structs! {@ewmh_priv $request, $window}
|
||||||
|
|
||||||
|
impl<'a> EwmhRequest<'a> for $request {
|
||||||
|
type XcbRequest = xcb::x::GetProperty;
|
||||||
|
type EwmhCookie = [<$request Cookie>];
|
||||||
|
|
||||||
|
_get_property_request! {@ewmh_priv $window, $property, $xtype}
|
||||||
|
|
||||||
|
fn convert_cookie(&'a self, xcb_cookie: xcb::x::GetPropertyCookie) -> Self::EwmhCookie {
|
||||||
|
[<$request Cookie>](xcb_cookie)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl EwmhPropertyRequestUnchecked for $request {
|
||||||
|
paste!{type EwmhCookie = [<$request CookieUnchecked>];}
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
|
fn convert_cookie(&self, xcb_cookie: xcb::x::GetPropertyCookieUnchecked) -> Self::EwmhCookie {
|
||||||
|
[<$request CookieUnchecked>](xcb_cookie)
|
||||||
|
}
|
||||||
|
|
||||||
|
_get_property_request! {@ewmh_priv $window, $property, $xtype}
|
||||||
|
}
|
||||||
|
|
||||||
|
_get_property_cookies! {@ewmh_priv $request, $reply}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
8
src/ewmh/proto/macros/mod.rs
Normal file
8
src/ewmh/proto/macros/mod.rs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#[macro_use]
|
||||||
|
mod get_property;
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
mod set_property;
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
mod client_message;
|
132
src/ewmh/proto/macros/set_property.rs
Normal file
132
src/ewmh/proto/macros/set_property.rs
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
macro_rules! _set_property_base {
|
||||||
|
(root, $property:ident, UTF8_STRING) => {
|
||||||
|
fn xcb_request(&'a self, con: &Connection) -> xcb::x::ChangeProperty<'a, u8> {
|
||||||
|
xcb::x::ChangeProperty {
|
||||||
|
mode: xcb::x::PropMode::Replace,
|
||||||
|
window: con.con.get_setup().roots().next().unwrap().root(),
|
||||||
|
property: con.atoms.$property,
|
||||||
|
r#type: con.atoms.UTF8_STRING,
|
||||||
|
data: &self.data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(root, $property:ident, $xtype:ident) => {
|
||||||
|
fn xcb_request(&'a self, con: &Connection) -> xcb::x::ChangeProperty<'a, u32> {
|
||||||
|
xcb::x::ChangeProperty {
|
||||||
|
mode: xcb::x::PropMode::Replace,
|
||||||
|
window: con.con.get_setup().roots().next().unwrap().root(),
|
||||||
|
property: con.atoms.$property,
|
||||||
|
r#type: xcb::x::$xtype,
|
||||||
|
data: &self.data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(client, $property:ident, UTF8_STRING) => {
|
||||||
|
fn xcb_request(&'a self, con: &Connection) -> xcb::x::ChangeProperty<'a, u8> {
|
||||||
|
xcb::x::ChangeProperty {
|
||||||
|
mode: xcb::x::PropMode::Replace,
|
||||||
|
window: self.window,
|
||||||
|
property: con.atoms.$property,
|
||||||
|
r#type: con.atoms.UTF8_STRING,
|
||||||
|
data: &self.data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(client, $property:ident, ATOM_CARDINAL) => {
|
||||||
|
fn xcb_request(&'a self, con: &Connection) -> xcb::x::ChangeProperty<'a, u32> {
|
||||||
|
xcb::x::ChangeProperty {
|
||||||
|
mode: xcb::x::PropMode::Replace,
|
||||||
|
window: self.window,
|
||||||
|
property: con.atoms.$property,
|
||||||
|
r#type: xcb::x::ATOM_CARDINAL,
|
||||||
|
data: &self.data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(client, $property:ident, ATOM_ATOM) => {
|
||||||
|
fn xcb_request(&'a self, con: &Connection) -> xcb::x::ChangeProperty<'a, xcb::x::Atom> {
|
||||||
|
xcb::x::ChangeProperty {
|
||||||
|
mode: xcb::x::PropMode::Replace,
|
||||||
|
window: self.window,
|
||||||
|
property: con.atoms.$property,
|
||||||
|
r#type: xcb::x::ATOM_ATOM,
|
||||||
|
data: &self.data,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! ewmh_set_property {
|
||||||
|
(request=$request:ident{
|
||||||
|
window: $window:ident,
|
||||||
|
property: $property:ident,
|
||||||
|
xtype: UTF8_STRING
|
||||||
|
}) => {
|
||||||
|
impl<'a> EwmhRequest<'a> for $request {
|
||||||
|
type XcbRequest = xcb::x::ChangeProperty<'a, u8>;
|
||||||
|
type EwmhCookie = xcb::VoidCookie;
|
||||||
|
|
||||||
|
_set_property_base! {$window, $property, UTF8_STRING}
|
||||||
|
|
||||||
|
fn convert_cookie(&'a self, xcb_cookie: xcb::VoidCookie) -> Self::EwmhCookie {
|
||||||
|
xcb_cookie
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> EwmhVoidRequestChecked<'a> for $request {
|
||||||
|
type XcbRequest = xcb::x::ChangeProperty<'a, u8>;
|
||||||
|
|
||||||
|
_set_property_base! {$window, $property, UTF8_STRING}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(request=$request:ident{
|
||||||
|
window: $window:ident,
|
||||||
|
property: $property:ident,
|
||||||
|
xtype: ATOM_CARDINAL
|
||||||
|
}) => {
|
||||||
|
impl<'a> EwmhRequest<'a> for $request {
|
||||||
|
type XcbRequest = xcb::x::ChangeProperty<'a, u32>;
|
||||||
|
type EwmhCookie = xcb::VoidCookie;
|
||||||
|
|
||||||
|
_set_property_base! {$window, $property, ATOM_CARDINAL}
|
||||||
|
|
||||||
|
fn convert_cookie(&'a self, xcb_cookie: xcb::VoidCookie) -> Self::EwmhCookie {
|
||||||
|
xcb_cookie
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> EwmhVoidRequestChecked<'a> for $request {
|
||||||
|
type XcbRequest = xcb::x::ChangeProperty<'a, u32>;
|
||||||
|
|
||||||
|
_set_property_base! {$window, $property, ATOM_CARDINAL}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(request=$request:ident{
|
||||||
|
window: $window:ident,
|
||||||
|
property: $property:ident,
|
||||||
|
xtype: ATOM_ATOM
|
||||||
|
}) => {
|
||||||
|
impl<'a> EwmhRequest<'a> for $request {
|
||||||
|
type XcbRequest = xcb::x::ChangeProperty<'a, xcb::x::Atom>;
|
||||||
|
type EwmhCookie = xcb::VoidCookie;
|
||||||
|
|
||||||
|
_set_property_base! {$window, $property, ATOM_ATOM }
|
||||||
|
|
||||||
|
fn convert_cookie(&'a self, xcb_cookie: xcb::VoidCookie) -> Self::EwmhCookie {
|
||||||
|
xcb_cookie
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a> EwmhVoidRequestChecked<'a> for $request {
|
||||||
|
type XcbRequest = xcb::x::ChangeProperty<'a, xcb::x::Atom>;
|
||||||
|
|
||||||
|
_set_property_base! {$window, $property, ATOM_ATOM }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
|
@ -81,7 +81,7 @@ ewmh_get_property! {
|
||||||
property: _NET_CLIENT_LIST_STACKING,
|
property: _NET_CLIENT_LIST_STACKING,
|
||||||
xtype: ATOM_WINDOW
|
xtype: ATOM_WINDOW
|
||||||
},
|
},
|
||||||
reply=GetClientListStackingReply,
|
reply=GetClientListStackingReply
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ impl SetNumberOfDesktops {
|
||||||
}
|
}
|
||||||
|
|
||||||
ewmh_client_message! {
|
ewmh_client_message! {
|
||||||
request=SetNumberOfDesktops{destination: root_window}
|
request=SetNumberOfDesktops{destination: root}
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ impl SetDesktopGeometry {
|
||||||
}
|
}
|
||||||
|
|
||||||
ewmh_client_message! {
|
ewmh_client_message! {
|
||||||
request=SetDesktopGeometry{destination: root_window}
|
request=SetDesktopGeometry{destination: root}
|
||||||
}
|
}
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
@ -221,7 +221,7 @@ impl SetDesktopViewport {
|
||||||
}
|
}
|
||||||
|
|
||||||
ewmh_client_message! {
|
ewmh_client_message! {
|
||||||
request=SetDesktopViewport{destination: root_window}
|
request=SetDesktopViewport{destination: root}
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
|
@ -266,7 +266,7 @@ impl SetCurrentDesktop {
|
||||||
}
|
}
|
||||||
|
|
||||||
ewmh_client_message! {
|
ewmh_client_message! {
|
||||||
request=SetCurrentDesktop{destination: root_window}
|
request=SetCurrentDesktop{destination: root}
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ impl SetDesktopNames {
|
||||||
|
|
||||||
ewmh_set_property! {
|
ewmh_set_property! {
|
||||||
request=SetDesktopNames{
|
request=SetDesktopNames{
|
||||||
window: root_window,
|
window: root,
|
||||||
property: _NET_DESKTOP_NAMES,
|
property: _NET_DESKTOP_NAMES,
|
||||||
xtype: UTF8_STRING
|
xtype: UTF8_STRING
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ impl SetActiveWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
ewmh_client_message! {
|
ewmh_client_message! {
|
||||||
request=SetActiveWindow{destination: root_window}
|
request=SetActiveWindow{destination: root}
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
|
@ -494,11 +494,7 @@ pub struct GetShowingDesktopReply {
|
||||||
impl From<xcb::x::GetPropertyReply> for GetShowingDesktopReply {
|
impl From<xcb::x::GetPropertyReply> for GetShowingDesktopReply {
|
||||||
fn from(reply: xcb::x::GetPropertyReply) -> Self {
|
fn from(reply: xcb::x::GetPropertyReply) -> Self {
|
||||||
GetShowingDesktopReply {
|
GetShowingDesktopReply {
|
||||||
is_showing_desktop: if reply.value::<u32>()[0] == 1 {
|
is_showing_desktop: { reply.value::<u32>()[0] == 1 },
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -531,7 +527,7 @@ impl SetShowingDesktop {
|
||||||
}
|
}
|
||||||
|
|
||||||
ewmh_client_message! {
|
ewmh_client_message! {
|
||||||
request=SetShowingDesktop{destination: root_window}
|
request=SetShowingDesktop{destination: root}
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
|
@ -559,7 +555,7 @@ impl CloseWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
ewmh_client_message! {
|
ewmh_client_message! {
|
||||||
request=CloseWindow{destination: root_window}
|
request=CloseWindow{destination: root}
|
||||||
}
|
}
|
||||||
|
|
||||||
// // _NET_MOVERESIZE_WINDOW
|
// // _NET_MOVERESIZE_WINDOW
|
||||||
|
@ -602,6 +598,6 @@ impl RequestFrameExtents {
|
||||||
}
|
}
|
||||||
|
|
||||||
ewmh_client_message! {
|
ewmh_client_message! {
|
||||||
request=RequestFrameExtents{destination: root_window}
|
request=RequestFrameExtents{destination: root}
|
||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
|
|
Loading…
Reference in a new issue