|
|
@@ -322,8 +322,7 @@ impl WindowManager { |
| 322 |
322 |
pub fn show_migration_overlay(&mut self) { |
| 323 |
323 |
let message = "We are on version 0.8.0 now.\n\n\ |
| 324 |
324 |
Your config file has been deprecated once again.\n\ |
| 325 |
|
- We apologize for this, but we have provided you\n\ |
| 326 |
|
- with a new default config.\n\n\ |
|
325 |
+ Backup your current config, and run oxwm --init to generate a new one with correct values.\n\n\ |
| 327 |
326 |
Please reach out to Tony, or check out the\n\ |
| 328 |
327 |
documentation for help with migration.\n\n\ |
| 329 |
328 |
We appreciate you testing oxwm!\n\n\ |
|
|
@@ -790,6 +789,11 @@ impl WindowManager { |
| 790 |
789 |
self.focusstack(*direction)?; |
| 791 |
790 |
} |
| 792 |
791 |
} |
|
792 |
+ KeyAction::MoveStack => { |
|
793 |
+ if let Arg::Int(direction) = arg { |
|
794 |
+ self.move_stack(*direction)?; |
|
795 |
+ } |
|
796 |
+ } |
| 793 |
797 |
KeyAction::Quit | KeyAction::Restart => { |
| 794 |
798 |
// Handled in handle_event |
| 795 |
799 |
} |
|
|
@@ -2282,6 +2286,139 @@ impl WindowManager { |
| 2282 |
2286 |
Ok(()) |
| 2283 |
2287 |
} |
| 2284 |
2288 |
|
|
2289 |
+ pub fn move_stack(&mut self, direction: i32) -> WmResult<()> { |
|
2290 |
+ let monitor_index = self.selected_monitor; |
|
2291 |
+ let monitor = match self.monitors.get(monitor_index) { |
|
2292 |
+ Some(m) => m.clone(), |
|
2293 |
+ None => return Ok(()), |
|
2294 |
+ }; |
|
2295 |
+ |
|
2296 |
+ let selected = match monitor.selected_client { |
|
2297 |
+ Some(win) => win, |
|
2298 |
+ None => return Ok(()), |
|
2299 |
+ }; |
|
2300 |
+ |
|
2301 |
+ let selected_client = match self.clients.get(&selected) { |
|
2302 |
+ Some(c) => c, |
|
2303 |
+ None => return Ok(()), |
|
2304 |
+ }; |
|
2305 |
+ |
|
2306 |
+ let target = if direction > 0 { |
|
2307 |
+ let next = self.next_tiled(selected_client.next, &monitor); |
|
2308 |
+ if next.is_some() { |
|
2309 |
+ next |
|
2310 |
+ } else { |
|
2311 |
+ self.next_tiled(monitor.clients_head, &monitor) |
|
2312 |
+ } |
|
2313 |
+ } else { |
|
2314 |
+ let mut previous = None; |
|
2315 |
+ let mut current = monitor.clients_head; |
|
2316 |
+ while let Some(window) = current { |
|
2317 |
+ if window == selected { |
|
2318 |
+ break; |
|
2319 |
+ } |
|
2320 |
+ if let Some(client) = self.clients.get(&window) { |
|
2321 |
+ let visible_tags = client.tags & monitor.tagset[monitor.selected_tags_index]; |
|
2322 |
+ if visible_tags != 0 && !client.is_floating { |
|
2323 |
+ previous = Some(window); |
|
2324 |
+ } |
|
2325 |
+ current = client.next; |
|
2326 |
+ } else { |
|
2327 |
+ break; |
|
2328 |
+ } |
|
2329 |
+ } |
|
2330 |
+ if previous.is_none() { |
|
2331 |
+ let mut last = None; |
|
2332 |
+ let mut current = monitor.clients_head; |
|
2333 |
+ while let Some(window) = current { |
|
2334 |
+ if let Some(client) = self.clients.get(&window) { |
|
2335 |
+ let visible_tags = client.tags & monitor.tagset[monitor.selected_tags_index]; |
|
2336 |
+ if visible_tags != 0 && !client.is_floating { |
|
2337 |
+ last = Some(window); |
|
2338 |
+ } |
|
2339 |
+ current = client.next; |
|
2340 |
+ } else { |
|
2341 |
+ break; |
|
2342 |
+ } |
|
2343 |
+ } |
|
2344 |
+ last |
|
2345 |
+ } else { |
|
2346 |
+ previous |
|
2347 |
+ } |
|
2348 |
+ }; |
|
2349 |
+ |
|
2350 |
+ let target = match target { |
|
2351 |
+ Some(t) if t != selected => t, |
|
2352 |
+ _ => return Ok(()), |
|
2353 |
+ }; |
|
2354 |
+ |
|
2355 |
+ let mut prev_selected = None; |
|
2356 |
+ let mut prev_target = None; |
|
2357 |
+ let mut current = monitor.clients_head; |
|
2358 |
+ |
|
2359 |
+ while let Some(window) = current { |
|
2360 |
+ if let Some(client) = self.clients.get(&window) { |
|
2361 |
+ if client.next == Some(selected) { |
|
2362 |
+ prev_selected = Some(window); |
|
2363 |
+ } |
|
2364 |
+ if client.next == Some(target) { |
|
2365 |
+ prev_target = Some(window); |
|
2366 |
+ } |
|
2367 |
+ current = client.next; |
|
2368 |
+ } else { |
|
2369 |
+ break; |
|
2370 |
+ } |
|
2371 |
+ } |
|
2372 |
+ |
|
2373 |
+ let selected_next = self.clients.get(&selected).and_then(|c| c.next); |
|
2374 |
+ let target_next = self.clients.get(&target).and_then(|c| c.next); |
|
2375 |
+ |
|
2376 |
+ let temp = if selected_next == Some(target) { |
|
2377 |
+ Some(selected) |
|
2378 |
+ } else { |
|
2379 |
+ selected_next |
|
2380 |
+ }; |
|
2381 |
+ |
|
2382 |
+ if let Some(client) = self.clients.get_mut(&selected) { |
|
2383 |
+ client.next = if target_next == Some(selected) { |
|
2384 |
+ Some(target) |
|
2385 |
+ } else { |
|
2386 |
+ target_next |
|
2387 |
+ }; |
|
2388 |
+ } |
|
2389 |
+ |
|
2390 |
+ if let Some(client) = self.clients.get_mut(&target) { |
|
2391 |
+ client.next = temp; |
|
2392 |
+ } |
|
2393 |
+ |
|
2394 |
+ if let Some(prev) = prev_selected { |
|
2395 |
+ if prev != target { |
|
2396 |
+ if let Some(client) = self.clients.get_mut(&prev) { |
|
2397 |
+ client.next = Some(target); |
|
2398 |
+ } |
|
2399 |
+ } |
|
2400 |
+ } |
|
2401 |
+ |
|
2402 |
+ if let Some(prev) = prev_target { |
|
2403 |
+ if prev != selected { |
|
2404 |
+ if let Some(client) = self.clients.get_mut(&prev) { |
|
2405 |
+ client.next = Some(selected); |
|
2406 |
+ } |
|
2407 |
+ } |
|
2408 |
+ } |
|
2409 |
+ |
|
2410 |
+ if let Some(monitor) = self.monitors.get_mut(monitor_index) { |
|
2411 |
+ if monitor.clients_head == Some(selected) { |
|
2412 |
+ monitor.clients_head = Some(target); |
|
2413 |
+ } else if monitor.clients_head == Some(target) { |
|
2414 |
+ monitor.clients_head = Some(selected); |
|
2415 |
+ } |
|
2416 |
+ } |
|
2417 |
+ |
|
2418 |
+ self.apply_layout()?; |
|
2419 |
+ Ok(()) |
|
2420 |
+ } |
|
2421 |
+ |
| 2285 |
2422 |
pub fn focus_monitor(&mut self, direction: i32) -> WmResult<()> { |
| 2286 |
2423 |
if self.monitors.len() <= 1 { |
| 2287 |
2424 |
return Ok(()); |
|
|
@@ -3669,6 +3806,22 @@ impl WindowManager { |
| 3669 |
3806 |
None |
| 3670 |
3807 |
} |
| 3671 |
3808 |
|
|
3809 |
+ fn next_tagged(&self, start: Option<Window>, tags: u32) -> Option<Window> { |
|
3810 |
+ let mut current = start; |
|
3811 |
+ while let Some(window) = current { |
|
3812 |
+ if let Some(client) = self.clients.get(&window) { |
|
3813 |
+ let visible_on_tags = (client.tags & tags) != 0; |
|
3814 |
+ if !client.is_floating && visible_on_tags { |
|
3815 |
+ return Some(window); |
|
3816 |
+ } |
|
3817 |
+ current = client.next; |
|
3818 |
+ } else { |
|
3819 |
+ break; |
|
3820 |
+ } |
|
3821 |
+ } |
|
3822 |
+ None |
|
3823 |
+ } |
|
3824 |
+ |
| 3672 |
3825 |
fn attach(&mut self, window: Window, monitor_index: usize) { |
| 3673 |
3826 |
if let Some(monitor) = self.monitors.get_mut(monitor_index) { |
| 3674 |
3827 |
if let Some(client) = self.clients.get_mut(&window) { |
|
|
@@ -3684,40 +3837,24 @@ impl WindowManager { |
| 3684 |
3837 |
None => return, |
| 3685 |
3838 |
}; |
| 3686 |
3839 |
|
| 3687 |
|
- if monitor.clients_head.is_none() { |
|
3840 |
+ let new_window_tags = self.clients.get(&window).map(|c| c.tags).unwrap_or(0); |
|
3841 |
+ let first_tagged = self.next_tagged(monitor.clients_head, new_window_tags); |
|
3842 |
+ |
|
3843 |
+ if first_tagged.is_none() { |
| 3688 |
3844 |
self.attach(window, monitor_index); |
| 3689 |
3845 |
return; |
| 3690 |
3846 |
} |
| 3691 |
3847 |
|
| 3692 |
|
- let num_master = monitor.num_master.max(1) as usize; |
| 3693 |
|
- let mut current = monitor.clients_head; |
| 3694 |
|
- let mut position = 0; |
| 3695 |
|
- |
| 3696 |
|
- while position < num_master - 1 { |
| 3697 |
|
- if let Some(current_window) = current { |
| 3698 |
|
- if let Some(current_client) = self.clients.get(¤t_window) { |
| 3699 |
|
- current = current_client.next; |
| 3700 |
|
- position += 1; |
| 3701 |
|
- } else { |
| 3702 |
|
- break; |
| 3703 |
|
- } |
| 3704 |
|
- } else { |
| 3705 |
|
- break; |
| 3706 |
|
- } |
| 3707 |
|
- } |
| 3708 |
|
- |
| 3709 |
|
- if let Some(insert_after) = current { |
| 3710 |
|
- if let Some(after_client) = self.clients.get(&insert_after) { |
|
3848 |
+ if let Some(insert_after_window) = first_tagged { |
|
3849 |
+ if let Some(after_client) = self.clients.get(&insert_after_window) { |
| 3711 |
3850 |
let old_next = after_client.next; |
| 3712 |
3851 |
if let Some(new_client) = self.clients.get_mut(&window) { |
| 3713 |
3852 |
new_client.next = old_next; |
| 3714 |
3853 |
} |
| 3715 |
|
- if let Some(after_client_mut) = self.clients.get_mut(&insert_after) { |
|
3854 |
+ if let Some(after_client_mut) = self.clients.get_mut(&insert_after_window) { |
| 3716 |
3855 |
after_client_mut.next = Some(window); |
| 3717 |
3856 |
} |
| 3718 |
3857 |
} |
| 3719 |
|
- } else { |
| 3720 |
|
- self.attach(window, monitor_index); |
| 3721 |
3858 |
} |
| 3722 |
3859 |
} |
| 3723 |
3860 |
|