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