|
|
@@ -900,11 +900,21 @@ impl WindowManager { |
| 900 |
900 |
self.view_tag(*tag_index as usize)?; |
| 901 |
901 |
} |
| 902 |
902 |
} |
|
903 |
+ KeyAction::ToggleView => { |
|
904 |
+ if let Arg::Int(tag_index) = arg { |
|
905 |
+ self.toggleview(*tag_index as usize)?; |
|
906 |
+ } |
|
907 |
+ } |
| 903 |
908 |
KeyAction::MoveToTag => { |
| 904 |
909 |
if let Arg::Int(tag_index) = arg { |
| 905 |
910 |
self.move_to_tag(*tag_index as usize)?; |
| 906 |
911 |
} |
| 907 |
912 |
} |
|
913 |
+ KeyAction::ToggleTag => { |
|
914 |
+ if let Arg::Int(tag_index) = arg { |
|
915 |
+ self.toggletag(*tag_index as usize)?; |
|
916 |
+ } |
|
917 |
+ } |
| 908 |
918 |
KeyAction::ToggleGaps => { |
| 909 |
919 |
self.gaps_enabled = !self.gaps_enabled; |
| 910 |
920 |
self.apply_layout()?; |
|
|
@@ -1041,25 +1051,112 @@ impl WindowManager { |
| 1041 |
1051 |
Ok(()) |
| 1042 |
1052 |
} |
| 1043 |
1053 |
|
|
1054 |
+ fn showhide(&mut self, window: Option<Window>) -> WmResult<()> { |
|
1055 |
+ let Some(window) = window else { |
|
1056 |
+ return Ok(()); |
|
1057 |
+ }; |
|
1058 |
+ |
|
1059 |
+ let Some(client) = self.clients.get(&window).cloned() else { |
|
1060 |
+ return Ok(()); |
|
1061 |
+ }; |
|
1062 |
+ |
|
1063 |
+ let monitor = match self.monitors.get(client.monitor_index) { |
|
1064 |
+ Some(m) => m, |
|
1065 |
+ None => return Ok(()), |
|
1066 |
+ }; |
|
1067 |
+ |
|
1068 |
+ let is_visible = (client.tags & monitor.tagset[monitor.selected_tags_index]) != 0; |
|
1069 |
+ |
|
1070 |
+ if is_visible { |
|
1071 |
+ self.connection.configure_window( |
|
1072 |
+ window, |
|
1073 |
+ &ConfigureWindowAux::new() |
|
1074 |
+ .x(client.x_position as i32) |
|
1075 |
+ .y(client.y_position as i32), |
|
1076 |
+ )?; |
|
1077 |
+ |
|
1078 |
+ let is_floating = client.is_floating; |
|
1079 |
+ let is_fullscreen = client.is_fullscreen; |
|
1080 |
+ let has_no_layout = self.layout.name() == LayoutType::Normie.as_str(); |
|
1081 |
+ |
|
1082 |
+ if (has_no_layout || is_floating) && !is_fullscreen { |
|
1083 |
+ self.connection.configure_window( |
|
1084 |
+ window, |
|
1085 |
+ &ConfigureWindowAux::new() |
|
1086 |
+ .x(client.x_position as i32) |
|
1087 |
+ .y(client.y_position as i32) |
|
1088 |
+ .width(client.width as u32) |
|
1089 |
+ .height(client.height as u32), |
|
1090 |
+ )?; |
|
1091 |
+ } |
|
1092 |
+ |
|
1093 |
+ self.showhide(client.stack_next)?; |
|
1094 |
+ } else { |
|
1095 |
+ self.showhide(client.stack_next)?; |
|
1096 |
+ |
|
1097 |
+ let width = client.width_with_border() as i32; |
|
1098 |
+ self.connection.configure_window( |
|
1099 |
+ window, |
|
1100 |
+ &ConfigureWindowAux::new() |
|
1101 |
+ .x(width * -2) |
|
1102 |
+ .y(client.y_position as i32), |
|
1103 |
+ )?; |
|
1104 |
+ } |
|
1105 |
+ |
|
1106 |
+ Ok(()) |
|
1107 |
+ } |
|
1108 |
+ |
| 1044 |
1109 |
pub fn view_tag(&mut self, tag_index: usize) -> WmResult<()> { |
| 1045 |
1110 |
if tag_index >= self.config.tags.len() { |
| 1046 |
1111 |
return Ok(()); |
| 1047 |
1112 |
} |
| 1048 |
1113 |
|
| 1049 |
|
- if let Some(monitor) = self.monitors.get_mut(self.selected_monitor) { |
| 1050 |
|
- monitor.tagset[monitor.selected_tags_index] = tag_mask(tag_index); |
|
1114 |
+ let monitor = match self.monitors.get_mut(self.selected_monitor) { |
|
1115 |
+ Some(m) => m, |
|
1116 |
+ None => return Ok(()), |
|
1117 |
+ }; |
|
1118 |
+ |
|
1119 |
+ let new_tagset = tag_mask(tag_index); |
|
1120 |
+ |
|
1121 |
+ if new_tagset == monitor.tagset[monitor.selected_tags_index] { |
|
1122 |
+ return Ok(()); |
| 1051 |
1123 |
} |
| 1052 |
1124 |
|
|
1125 |
+ monitor.selected_tags_index ^= 1; |
|
1126 |
+ monitor.tagset[monitor.selected_tags_index] = new_tagset; |
|
1127 |
+ |
| 1053 |
1128 |
self.save_selected_tags()?; |
| 1054 |
|
- self.update_window_visibility()?; |
| 1055 |
|
- self.apply_layout()?; |
|
1129 |
+ self.focus(None)?; |
|
1130 |
+ self.apply_layout()?; |
| 1056 |
1131 |
self.update_bar()?; |
| 1057 |
1132 |
|
| 1058 |
|
- let visible = self.visible_windows_on_monitor(self.selected_monitor); |
| 1059 |
|
- if let Some(&win) = visible.first() { |
| 1060 |
|
- self.focus(Some(win))?; |
|
1133 |
+ Ok(()) |
|
1134 |
+ } |
|
1135 |
+ |
|
1136 |
+ pub fn toggleview(&mut self, tag_index: usize) -> WmResult<()> { |
|
1137 |
+ if tag_index >= self.config.tags.len() { |
|
1138 |
+ return Ok(()); |
| 1061 |
1139 |
} |
| 1062 |
1140 |
|
|
1141 |
+ let monitor = match self.monitors.get_mut(self.selected_monitor) { |
|
1142 |
+ Some(m) => m, |
|
1143 |
+ None => return Ok(()), |
|
1144 |
+ }; |
|
1145 |
+ |
|
1146 |
+ let mask = tag_mask(tag_index); |
|
1147 |
+ let new_tagset = monitor.tagset[monitor.selected_tags_index] ^ mask; |
|
1148 |
+ |
|
1149 |
+ if new_tagset == 0 { |
|
1150 |
+ return Ok(()); |
|
1151 |
+ } |
|
1152 |
+ |
|
1153 |
+ monitor.tagset[monitor.selected_tags_index] = new_tagset; |
|
1154 |
+ |
|
1155 |
+ self.save_selected_tags()?; |
|
1156 |
+ self.focus(None)?; |
|
1157 |
+ self.apply_layout()?; |
|
1158 |
+ self.update_bar()?; |
|
1159 |
+ |
| 1063 |
1160 |
Ok(()) |
| 1064 |
1161 |
} |
| 1065 |
1162 |
|
|
|
@@ -1093,23 +1190,70 @@ impl WindowManager { |
| 1093 |
1190 |
return Ok(()); |
| 1094 |
1191 |
} |
| 1095 |
1192 |
|
| 1096 |
|
- if let Some(focused) = self |
|
1193 |
+ let focused = match self |
| 1097 |
1194 |
.monitors |
| 1098 |
1195 |
.get(self.selected_monitor) |
| 1099 |
1196 |
.and_then(|m| m.selected_client) |
| 1100 |
1197 |
{ |
| 1101 |
|
- let mask = tag_mask(tag_index); |
| 1102 |
|
- self.window_tags.insert(focused, mask); |
|
1198 |
+ Some(win) => win, |
|
1199 |
+ None => return Ok(()), |
|
1200 |
+ }; |
| 1103 |
1201 |
|
| 1104 |
|
- if let Err(error) = self.save_client_tag(focused, mask) { |
| 1105 |
|
- eprintln!("Failed to save client tag: {:?}", error); |
| 1106 |
|
- } |
|
1202 |
+ let mask = tag_mask(tag_index); |
| 1107 |
1203 |
|
| 1108 |
|
- self.update_window_visibility()?; |
| 1109 |
|
- self.apply_layout()?; |
| 1110 |
|
- self.update_bar()?; |
|
1204 |
+ if let Some(client) = self.clients.get_mut(&focused) { |
|
1205 |
+ client.tags = mask; |
|
1206 |
+ } |
|
1207 |
+ |
|
1208 |
+ self.window_tags.insert(focused, mask); |
|
1209 |
+ |
|
1210 |
+ if let Err(error) = self.save_client_tag(focused, mask) { |
|
1211 |
+ eprintln!("Failed to save client tag: {:?}", error); |
| 1111 |
1212 |
} |
| 1112 |
1213 |
|
|
1214 |
+ self.focus(None)?; |
|
1215 |
+ self.apply_layout()?; |
|
1216 |
+ self.update_bar()?; |
|
1217 |
+ |
|
1218 |
+ Ok(()) |
|
1219 |
+ } |
|
1220 |
+ |
|
1221 |
+ pub fn toggletag(&mut self, tag_index: usize) -> WmResult<()> { |
|
1222 |
+ if tag_index >= self.config.tags.len() { |
|
1223 |
+ return Ok(()); |
|
1224 |
+ } |
|
1225 |
+ |
|
1226 |
+ let focused = match self |
|
1227 |
+ .monitors |
|
1228 |
+ .get(self.selected_monitor) |
|
1229 |
+ .and_then(|m| m.selected_client) |
|
1230 |
+ { |
|
1231 |
+ Some(win) => win, |
|
1232 |
+ None => return Ok(()), |
|
1233 |
+ }; |
|
1234 |
+ |
|
1235 |
+ let mask = tag_mask(tag_index); |
|
1236 |
+ let current_tags = self.clients.get(&focused).map(|c| c.tags).unwrap_or(0); |
|
1237 |
+ let new_tags = current_tags ^ mask; |
|
1238 |
+ |
|
1239 |
+ if new_tags == 0 { |
|
1240 |
+ return Ok(()); |
|
1241 |
+ } |
|
1242 |
+ |
|
1243 |
+ if let Some(client) = self.clients.get_mut(&focused) { |
|
1244 |
+ client.tags = new_tags; |
|
1245 |
+ } |
|
1246 |
+ |
|
1247 |
+ self.window_tags.insert(focused, new_tags); |
|
1248 |
+ |
|
1249 |
+ if let Err(error) = self.save_client_tag(focused, new_tags) { |
|
1250 |
+ eprintln!("Failed to save client tag: {:?}", error); |
|
1251 |
+ } |
|
1252 |
+ |
|
1253 |
+ self.focus(None)?; |
|
1254 |
+ self.apply_layout()?; |
|
1255 |
+ self.update_bar()?; |
|
1256 |
+ |
| 1113 |
1257 |
Ok(()) |
| 1114 |
1258 |
} |
| 1115 |
1259 |
|
|
|
@@ -2729,6 +2873,13 @@ impl WindowManager { |
| 2729 |
2873 |
let adjusted_x = geometry.x_coordinate + monitor_x; |
| 2730 |
2874 |
let adjusted_y = geometry.y_coordinate + monitor_y + bar_height as i32; |
| 2731 |
2875 |
|
|
2876 |
+ if let Some(client) = self.clients.get_mut(window) { |
|
2877 |
+ client.x_position = adjusted_x as i16; |
|
2878 |
+ client.y_position = adjusted_y as i16; |
|
2879 |
+ client.width = adjusted_width as u16; |
|
2880 |
+ client.height = adjusted_height as u16; |
|
2881 |
+ } |
|
2882 |
+ |
| 2732 |
2883 |
self.connection.configure_window( |
| 2733 |
2884 |
*window, |
| 2734 |
2885 |
&ConfigureWindowAux::new() |
|
|
@@ -2749,6 +2900,11 @@ impl WindowManager { |
| 2749 |
2900 |
} |
| 2750 |
2901 |
} |
| 2751 |
2902 |
|
|
2903 |
+ for monitor_index in 0..self.monitors.len() { |
|
2904 |
+ let stack_head = self.monitors[monitor_index].stack_head; |
|
2905 |
+ self.showhide(stack_head)?; |
|
2906 |
+ } |
|
2907 |
+ |
| 2752 |
2908 |
self.connection.flush()?; |
| 2753 |
2909 |
|
| 2754 |
2910 |
let is_tabbed = self.layout.name() == LayoutType::Tabbed.as_str(); |