Skip to content

Commit a1b7f8f

Browse files
committed
deduplicate
1 parent 186c4a7 commit a1b7f8f

2 files changed

Lines changed: 13 additions & 15 deletions

File tree

src/bar/status.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,17 @@ pub(crate) fn enqueue_internal_status(text: String) {
588588
}
589589
}
590590

591+
pub(crate) fn apply_status_update(wm: &mut crate::wm::Wm, text: String) {
592+
if !text.starts_with("instantwm-") {
593+
CUSTOM_STATUS_RECEIVED.store(true, std::sync::atomic::Ordering::Relaxed);
594+
}
595+
596+
wm.g.bar_runtime.status_text = text;
597+
wm.bar
598+
.request_async_status_parse(&wm.g.bar_runtime.status_text);
599+
wm.bar.mark_dirty();
600+
}
601+
591602
pub(crate) fn drain_internal_status_updates(wm: &mut crate::wm::Wm) -> bool {
592603
let runtime = internal_status_runtime();
593604
let Ok(receiver) = runtime.receiver.lock() else {
@@ -606,11 +617,7 @@ pub(crate) fn drain_internal_status_updates(wm: &mut crate::wm::Wm) -> bool {
606617
return false;
607618
};
608619

609-
if !text.starts_with("instantwm-") {
610-
CUSTOM_STATUS_RECEIVED.store(true, std::sync::atomic::Ordering::Relaxed);
611-
}
612-
wm.g.bar_runtime.status_text = text;
613-
wm.bar.mark_dirty();
620+
apply_status_update(wm, text);
614621
true
615622
}
616623

src/ipc/general.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,7 @@ pub fn set_special_next_cmd(wm: &mut Wm, mode: SpecialNext) -> Response {
9999
}
100100

101101
pub fn update_status(wm: &mut Wm, text: String) -> Response {
102-
if !text.starts_with("instantwm-") {
103-
crate::bar::status::CUSTOM_STATUS_RECEIVED
104-
.store(true, std::sync::atomic::Ordering::Relaxed);
105-
}
106-
107-
wm.g.bar_runtime.status_text = text;
108-
wm.bar
109-
.request_async_status_parse(&wm.g.bar_runtime.status_text);
110-
wm.bar.mark_dirty();
111-
102+
crate::bar::status::apply_status_update(wm, text);
112103
Response::ok()
113104
}
114105

0 commit comments

Comments
 (0)