|
|
@@ -42,6 +42,7 @@ struct AtomCache { |
| 42 |
42 |
net_wm_window_type_dialog: Atom, |
| 43 |
43 |
wm_name: Atom, |
| 44 |
44 |
net_wm_name: Atom, |
|
45 |
+ utf8_string: Atom, |
| 45 |
46 |
wm_normal_hints: Atom, |
| 46 |
47 |
wm_hints: Atom, |
| 47 |
48 |
wm_transient_for: Atom, |
|
|
@@ -94,6 +95,7 @@ impl AtomCache { |
| 94 |
95 |
|
| 95 |
96 |
let wm_name = AtomEnum::WM_NAME.into(); |
| 96 |
97 |
let net_wm_name = connection.intern_atom(false, b"_NET_WM_NAME")?.reply()?.atom; |
|
98 |
+ let utf8_string = connection.intern_atom(false, b"UTF8_STRING")?.reply()?.atom; |
| 97 |
99 |
let wm_normal_hints = AtomEnum::WM_NORMAL_HINTS.into(); |
| 98 |
100 |
let wm_hints = AtomEnum::WM_HINTS.into(); |
| 99 |
101 |
let wm_transient_for = AtomEnum::WM_TRANSIENT_FOR.into(); |
|
|
@@ -111,6 +113,7 @@ impl AtomCache { |
| 111 |
113 |
net_wm_window_type_dialog, |
| 112 |
114 |
wm_name, |
| 113 |
115 |
net_wm_name, |
|
116 |
+ utf8_string, |
| 114 |
117 |
wm_normal_hints, |
| 115 |
118 |
wm_hints, |
| 116 |
119 |
wm_transient_for, |
|
|
@@ -690,23 +693,23 @@ impl WindowManager { |
| 690 |
693 |
fn update_tab_bars(&mut self) -> WmResult<()> { |
| 691 |
694 |
for (monitor_index, monitor) in self.monitors.iter().enumerate() { |
| 692 |
695 |
if let Some(tab_bar) = self.tab_bars.get_mut(monitor_index) { |
| 693 |
|
- let visible_windows: Vec<Window> = self |
|
696 |
+ let visible_windows: Vec<(Window, String)> = self |
| 694 |
697 |
.windows |
| 695 |
698 |
.iter() |
| 696 |
|
- .filter(|&&window| { |
|
699 |
+ .filter_map(|&window| { |
| 697 |
700 |
if let Some(client) = self.clients.get(&window) { |
| 698 |
701 |
if client.monitor_index != monitor_index |
| 699 |
702 |
|| self.floating_windows.contains(&window) |
| 700 |
703 |
|| self.fullscreen_windows.contains(&window) |
| 701 |
704 |
{ |
| 702 |
|
- return false; |
|
705 |
+ return None; |
|
706 |
+ } |
|
707 |
+ if (client.tags & monitor.tagset[monitor.selected_tags_index]) != 0 { |
|
708 |
+ return Some((window, client.name.clone())); |
| 703 |
709 |
} |
| 704 |
|
- (client.tags & monitor.tagset[monitor.selected_tags_index]) != 0 |
| 705 |
|
- } else { |
| 706 |
|
- false |
| 707 |
710 |
} |
|
711 |
+ None |
| 708 |
712 |
}) |
| 709 |
|
- .copied() |
| 710 |
713 |
.collect(); |
| 711 |
714 |
|
| 712 |
715 |
let focused_window = monitor.selected_client; |
|
|
@@ -2274,6 +2277,7 @@ impl WindowManager { |
| 2274 |
2277 |
}; |
| 2275 |
2278 |
|
| 2276 |
2279 |
self.focus(Some(next_window))?; |
|
2280 |
+ self.update_tab_bars()?; |
| 2277 |
2281 |
|
| 2278 |
2282 |
Ok(()) |
| 2279 |
2283 |
} |
|
|
@@ -2768,6 +2772,7 @@ impl WindowManager { |
| 2768 |
2772 |
} |
| 2769 |
2773 |
} |
| 2770 |
2774 |
self.focus(Some(event.event))?; |
|
2775 |
+ self.update_tab_bars()?; |
| 2771 |
2776 |
} |
| 2772 |
2777 |
} |
| 2773 |
2778 |
Event::MotionNotify(event) => { |
|
|
@@ -2785,6 +2790,7 @@ impl WindowManager { |
| 2785 |
2790 |
let visible = self.visible_windows_on_monitor(monitor_index); |
| 2786 |
2791 |
if let Some(&win) = visible.first() { |
| 2787 |
2792 |
self.focus(Some(win))?; |
|
2793 |
+ self.update_tab_bars()?; |
| 2788 |
2794 |
} |
| 2789 |
2795 |
} |
| 2790 |
2796 |
} |
|
|
@@ -2885,24 +2891,24 @@ impl WindowManager { |
| 2885 |
2891 |
self.selected_monitor = monitor_index; |
| 2886 |
2892 |
} |
| 2887 |
2893 |
|
| 2888 |
|
- let visible_windows: Vec<Window> = self |
|
2894 |
+ let visible_windows: Vec<(Window, String)> = self |
| 2889 |
2895 |
.windows |
| 2890 |
2896 |
.iter() |
| 2891 |
|
- .filter(|&&window| { |
|
2897 |
+ .filter_map(|&window| { |
| 2892 |
2898 |
if let Some(client) = self.clients.get(&window) { |
| 2893 |
2899 |
if client.monitor_index != monitor_index |
| 2894 |
2900 |
|| self.floating_windows.contains(&window) |
| 2895 |
2901 |
|| self.fullscreen_windows.contains(&window) |
| 2896 |
2902 |
{ |
| 2897 |
|
- return false; |
|
2903 |
+ return None; |
| 2898 |
2904 |
} |
| 2899 |
2905 |
let monitor_tags = self.monitors.get(monitor_index).map(|m| m.tagset[m.selected_tags_index]).unwrap_or(0); |
| 2900 |
|
- (client.tags & monitor_tags) != 0 |
| 2901 |
|
- } else { |
| 2902 |
|
- false |
|
2906 |
+ if (client.tags & monitor_tags) != 0 { |
|
2907 |
+ return Some((window, client.name.clone())); |
|
2908 |
+ } |
| 2903 |
2909 |
} |
|
2910 |
+ None |
| 2904 |
2911 |
}) |
| 2905 |
|
- .copied() |
| 2906 |
2912 |
.collect(); |
| 2907 |
2913 |
|
| 2908 |
2914 |
if let Some(clicked_window) = tab_bar.get_clicked_window(&visible_windows, event.event_x) { |
|
|
@@ -2915,6 +2921,7 @@ impl WindowManager { |
| 2915 |
2921 |
} |
| 2916 |
2922 |
} else if event.child != x11rb::NONE { |
| 2917 |
2923 |
self.focus(Some(event.child))?; |
|
2924 |
+ self.update_tab_bars()?; |
| 2918 |
2925 |
|
| 2919 |
2926 |
if event.detail == ButtonIndex::M1.into() { |
| 2920 |
2927 |
self.drag_window(event.child)?; |
|
|
@@ -3474,19 +3481,42 @@ impl WindowManager { |
| 3474 |
3481 |
} |
| 3475 |
3482 |
|
| 3476 |
3483 |
fn update_window_title(&mut self, window: Window) -> WmResult<()> { |
| 3477 |
|
- let name = self.connection |
|
3484 |
+ let net_name = self.connection |
|
3485 |
+ .get_property( |
|
3486 |
+ false, |
|
3487 |
+ window, |
|
3488 |
+ self.atoms.net_wm_name, |
|
3489 |
+ self.atoms.utf8_string, |
|
3490 |
+ 0, |
|
3491 |
+ 256, |
|
3492 |
+ ) |
|
3493 |
+ .ok() |
|
3494 |
+ .and_then(|cookie| cookie.reply().ok()); |
|
3495 |
+ |
|
3496 |
+ if let Some(name) = net_name { |
|
3497 |
+ if !name.value.is_empty() { |
|
3498 |
+ if let Ok(title) = String::from_utf8(name.value.clone()) { |
|
3499 |
+ if let Some(client) = self.clients.get_mut(&window) { |
|
3500 |
+ client.name = title; |
|
3501 |
+ return Ok(()); |
|
3502 |
+ } |
|
3503 |
+ } |
|
3504 |
+ } |
|
3505 |
+ } |
|
3506 |
+ |
|
3507 |
+ let wm_name = self.connection |
| 3478 |
3508 |
.get_property( |
| 3479 |
3509 |
false, |
| 3480 |
3510 |
window, |
| 3481 |
|
- x11rb::protocol::xproto::AtomEnum::WM_NAME, |
|
3511 |
+ self.atoms.wm_name, |
| 3482 |
3512 |
x11rb::protocol::xproto::AtomEnum::STRING, |
| 3483 |
3513 |
0, |
| 3484 |
3514 |
256, |
| 3485 |
3515 |
)? |
| 3486 |
3516 |
.reply()?; |
| 3487 |
3517 |
|
| 3488 |
|
- if !name.value.is_empty() { |
| 3489 |
|
- if let Ok(title) = String::from_utf8(name.value.clone()) { |
|
3518 |
+ if !wm_name.value.is_empty() { |
|
3519 |
+ if let Ok(title) = String::from_utf8(wm_name.value.clone()) { |
| 3490 |
3520 |
if let Some(client) = self.clients.get_mut(&window) { |
| 3491 |
3521 |
client.name = title; |
| 3492 |
3522 |
} |