Use x11rb features to improve code
This commit is contained in:
parent
19cb50404d
commit
57a2ec52dc
1 changed files with 6 additions and 28 deletions
|
|
@ -8,6 +8,7 @@ use x11rb::errors::ConnectError;
|
||||||
use x11rb::protocol::xproto::{self, Atom, AtomEnum, Window};
|
use x11rb::protocol::xproto::{self, Atom, AtomEnum, Window};
|
||||||
use x11rb::protocol::Event;
|
use x11rb::protocol::Event;
|
||||||
use x11rb::rust_connection::RustConnection as Connection;
|
use x11rb::rust_connection::RustConnection as Connection;
|
||||||
|
use x11rb::wrapper::ConnectionExt;
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
|
|
@ -385,39 +386,22 @@ impl Worker {
|
||||||
};
|
};
|
||||||
|
|
||||||
if event.target == self.context.atoms.targets {
|
if event.target == self.context.atoms.targets {
|
||||||
let data: Vec<u8> = {
|
let data = [self.context.atoms.targets, target];
|
||||||
let atom_target_bytes =
|
|
||||||
self.context.atoms.targets.to_le_bytes();
|
|
||||||
|
|
||||||
let target_bytes = target.to_le_bytes();
|
self.context.connection.change_property32(
|
||||||
|
|
||||||
atom_target_bytes
|
|
||||||
.iter()
|
|
||||||
.chain(target_bytes.iter())
|
|
||||||
.copied()
|
|
||||||
.collect()
|
|
||||||
};
|
|
||||||
|
|
||||||
xproto::change_property(
|
|
||||||
&self.context.connection,
|
|
||||||
xproto::PropMode::REPLACE,
|
xproto::PropMode::REPLACE,
|
||||||
event.requestor,
|
event.requestor,
|
||||||
event.property,
|
event.property,
|
||||||
xproto::AtomEnum::ATOM,
|
xproto::AtomEnum::ATOM,
|
||||||
32,
|
|
||||||
2,
|
|
||||||
&data,
|
&data,
|
||||||
)
|
)
|
||||||
.expect("Change property");
|
.expect("Change property");
|
||||||
} else if value.len() < max_length - 24 {
|
} else if value.len() < max_length - 24 {
|
||||||
let _ = xproto::change_property(
|
let _ = self.context.connection.change_property8(
|
||||||
&self.context.connection,
|
|
||||||
xproto::PropMode::REPLACE,
|
xproto::PropMode::REPLACE,
|
||||||
event.requestor,
|
event.requestor,
|
||||||
event.property,
|
event.property,
|
||||||
target,
|
target,
|
||||||
8,
|
|
||||||
value.len() as u32,
|
|
||||||
value,
|
value,
|
||||||
)
|
)
|
||||||
.expect("Change property");
|
.expect("Change property");
|
||||||
|
|
@ -430,14 +414,11 @@ impl Worker {
|
||||||
)
|
)
|
||||||
.expect("Change window attributes");
|
.expect("Change window attributes");
|
||||||
|
|
||||||
xproto::change_property(
|
self.context.connection.change_property32(
|
||||||
&self.context.connection,
|
|
||||||
xproto::PropMode::REPLACE,
|
xproto::PropMode::REPLACE,
|
||||||
event.requestor,
|
event.requestor,
|
||||||
event.property,
|
event.property,
|
||||||
self.context.atoms.incr,
|
self.context.atoms.incr,
|
||||||
32,
|
|
||||||
0,
|
|
||||||
&[],
|
&[],
|
||||||
)
|
)
|
||||||
.expect("Change property");
|
.expect("Change property");
|
||||||
|
|
@ -500,14 +481,11 @@ impl Worker {
|
||||||
value.len() - state.pos,
|
value.len() - state.pos,
|
||||||
);
|
);
|
||||||
|
|
||||||
let _ = xproto::change_property(
|
let _ = self.context.connection.change_property8(
|
||||||
&self.context.connection,
|
|
||||||
xproto::PropMode::REPLACE,
|
xproto::PropMode::REPLACE,
|
||||||
state.requestor,
|
state.requestor,
|
||||||
state.property,
|
state.property,
|
||||||
target,
|
target,
|
||||||
8,
|
|
||||||
len as u32,
|
|
||||||
&value[state.pos..][..len],
|
&value[state.pos..][..len],
|
||||||
)
|
)
|
||||||
.expect("Change property");
|
.expect("Change property");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue