Skip to content

Commit a344c5a

Browse files
committed
Update for i3 4.13
Add I3Connection::get_binding_modes from i3/i3@b1d70f2 Add WindowChange::Mark from i3/i3@e51a89e
1 parent a549ee8 commit a344c5a

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ serde_json = "0.6.0"
1414

1515
[features]
1616
i3-4-12 = []
17+
i3-4-13 = ["i3-4-12"]

src/event.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ impl FromStr for WindowEventInfo {
131131
"move" => WindowChange::Move,
132132
"floating" => WindowChange::Floating,
133133
"urgent" => WindowChange::Urgent,
134+
135+
#[cfg(feature = "i3-4-13")]
136+
"mark" => WindowChange::Mark,
137+
134138
other => {
135139
warn!(target: "i3ipc", "Unknown WindowChange {}", other);
136140
WindowChange::Unknown
@@ -251,6 +255,11 @@ pub mod inner {
251255
Floating,
252256
/// The window has become urgent or lost its urgent status.
253257
Urgent,
258+
259+
/// A mark has been added to or removed from the window.
260+
#[cfg(feature = "i3-4-13")]
261+
Mark,
262+
254263
/// A WindowChange we don't support yet.
255264
Unknown,
256265
}

src/lib.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,23 @@ impl I3Connection {
467467
.unwrap().to_owned()
468468
})
469469
}
470+
471+
/// Gets the list of currently configured binding modes.
472+
#[cfg(feature = "i3-4-13")]
473+
pub fn get_binding_modes(&mut self) -> Result<reply::BindingModes, MessageError> {
474+
if let Err(e) = self.stream.send_i3_message(8, "") {
475+
return Err(MessageError::Send(e));
476+
}
477+
let payload = match self.stream.receive_i3_message() {
478+
Ok((_, payload)) => payload,
479+
Err(e) => { return Err(MessageError::Receive(e)); },
480+
};
481+
let modes: Vec<String> = match json::from_str(&payload) {
482+
Ok(v) => v,
483+
Err(e) => { return Err(MessageError::JsonCouldntParse(e)); },
484+
};
485+
Ok(reply::BindingModes { modes: modes })
486+
}
470487
}
471488

472489

@@ -556,6 +573,12 @@ mod test {
556573
I3Connection::connect().unwrap().get_version().unwrap();
557574
}
558575

576+
#[cfg(feature = "i3-4-13")]
577+
#[test]
578+
fn get_binding_modes() {
579+
I3Connection::connect().unwrap().get_binding_modes().unwrap();
580+
}
581+
559582
#[test]
560583
fn event_subscribe() {
561584
let s = I3EventListener::connect().unwrap().subscribe(&[Subscription::Workspace]).unwrap();

src/reply.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,3 +354,11 @@ pub struct Version {
354354
/// The current config path.
355355
pub loaded_config_file_name: String
356356
}
357+
358+
/// The reply to the `get_binding_modes` request.
359+
#[cfg(feature = "i3-4-13")]
360+
#[derive(Debug)]
361+
pub struct BindingModes {
362+
/// A vector of all currently configured binding modes.
363+
pub modes: Vec<String>,
364+
}

0 commit comments

Comments
 (0)