Render fullscreen scrolling windows on top of floating
Browse files at this commit4b9ecdd11d146df44320eba12bead3e9677a2060Parent: e31e4092 changed files +138 -75
- src/layout/mod.rs +4 -4
- src/layout/workspace.rs +134 -71
src/layout/mod.rsmodified+4 -4
| @@ -3157,9 +3157,9 @@ impl<W: LayoutElement> Layout<W> { | |||
| 3157 | return false; | 3157 | return false; |
| 3158 | } | 3158 | } |
| 3159 | 3159 | ||
| 3160 | - let (tile, tile_offset) = ws | 3160 | + let (tile, tile_offset, _visible) = ws |
| 3161 | .tiles_with_render_positions() | 3161 | .tiles_with_render_positions() |
| 3162 | - .find(|(tile, _)| tile.window().id() == &window_id) | 3162 | + .find(|(tile, _, _)| tile.window().id() == &window_id) |
| 3163 | .unwrap(); | 3163 | .unwrap(); |
| 3164 | let window_offset = tile.window_loc(); | 3164 | let window_offset = tile.window_loc(); |
| 3165 | 3165 | ||
| @@ -3258,9 +3258,9 @@ impl<W: LayoutElement> Layout<W> { | |||
| 3258 | .map(|rv| (mon, rv)) | 3258 | .map(|rv| (mon, rv)) |
| 3259 | }) { | 3259 | }) { |
| 3260 | if mon.output() == &output { | 3260 | if mon.output() == &output { |
| 3261 | - let (_, tile_offset) = ws | 3261 | + let (_, tile_offset, _) = ws |
| 3262 | .tiles_with_render_positions() | 3262 | .tiles_with_render_positions() |
| 3263 | - .find(|(tile, _)| tile.window().id() == window) | 3263 | + .find(|(tile, _, _)| tile.window().id() == window) |
| 3264 | .unwrap(); | 3264 | .unwrap(); |
| 3265 | 3265 | ||
| 3266 | tile_pos = Some(ws_offset + tile_offset); | 3266 | tile_pos = Some(ws_offset + tile_offset); |
src/layout/workspace.rsmodified+134 -71
| @@ -37,7 +37,7 @@ pub struct Workspace<W: LayoutElement> { | |||
| 37 | floating: FloatingSpace<W>, | 37 | floating: FloatingSpace<W>, |
| 38 | 38 | ||
| 39 | /// Whether the floating layout is active instead of the scrolling layout. | 39 | /// Whether the floating layout is active instead of the scrolling layout. |
| 40 | - floating_is_active: bool, | 40 | + floating_is_active: FloatingActive, |
| 41 | 41 | ||
| 42 | /// The original output of this workspace. | 42 | /// The original output of this workspace. |
| 43 | /// | 43 | /// |
| @@ -142,6 +142,21 @@ pub enum ResolvedSize { | |||
| 142 | Window(f64), | 142 | Window(f64), |
| 143 | } | 143 | } |
| 144 | 144 | ||
| 145 | +/// Whether the floating space is active. | ||
| 146 | +#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
| 147 | +enum FloatingActive { | ||
| 148 | + /// The scrolling space is active. | ||
| 149 | + No, | ||
| 150 | + /// The scrolling space is active, but the floating space should render on top, even if the | ||
| 151 | + /// active scrolling window is fullscreen. | ||
| 152 | + /// | ||
| 153 | + /// This is necessary for focus-follows-mouse that activates but doesn't raise the window to | ||
| 154 | + /// avoid being annoying. | ||
| 155 | + NoButRaised, | ||
| 156 | + /// The floating space is active. | ||
| 157 | + Yes, | ||
| 158 | +} | ||
| 159 | + | ||
| 145 | impl OutputId { | 160 | impl OutputId { |
| 146 | pub fn new(output: &Output) -> Self { | 161 | pub fn new(output: &Output) -> Self { |
| 147 | let output_name = output.user_data().get::<OutputName>().unwrap(); | 162 | let output_name = output.user_data().get::<OutputName>().unwrap(); |
| @@ -149,6 +164,12 @@ impl OutputId { | |||
| 149 | } | 164 | } |
| 150 | } | 165 | } |
| 151 | 166 | ||
| 167 | +impl FloatingActive { | ||
| 168 | + fn get(self) -> bool { | ||
| 169 | + self == Self::Yes | ||
| 170 | + } | ||
| 171 | +} | ||
| 172 | + | ||
| 152 | impl<W: LayoutElement> Workspace<W> { | 173 | impl<W: LayoutElement> Workspace<W> { |
| 153 | pub fn new(output: Output, clock: Clock, options: Rc<Options>) -> Self { | 174 | pub fn new(output: Output, clock: Clock, options: Rc<Options>) -> Self { |
| 154 | Self::new_with_config(output, None, clock, options) | 175 | Self::new_with_config(output, None, clock, options) |
| @@ -191,7 +212,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 191 | Self { | 212 | Self { |
| 192 | scrolling, | 213 | scrolling, |
| 193 | floating, | 214 | floating, |
| 194 | - floating_is_active: false, | 215 | + floating_is_active: FloatingActive::No, |
| 195 | original_output, | 216 | original_output, |
| 196 | scale, | 217 | scale, |
| 197 | transform: output.current_transform(), | 218 | transform: output.current_transform(), |
| @@ -243,7 +264,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 243 | Self { | 264 | Self { |
| 244 | scrolling, | 265 | scrolling, |
| 245 | floating, | 266 | floating, |
| 246 | - floating_is_active: false, | 267 | + floating_is_active: FloatingActive::No, |
| 247 | output: None, | 268 | output: None, |
| 248 | scale, | 269 | scale, |
| 249 | transform: Transform::Normal, | 270 | transform: Transform::Normal, |
| @@ -297,11 +318,11 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 297 | 318 | ||
| 298 | pub fn update_render_elements(&mut self, is_active: bool) { | 319 | pub fn update_render_elements(&mut self, is_active: bool) { |
| 299 | self.scrolling | 320 | self.scrolling |
| 300 | - .update_render_elements(is_active && !self.floating_is_active); | 321 | + .update_render_elements(is_active && !self.floating_is_active.get()); |
| 301 | 322 | ||
| 302 | let view_rect = Rectangle::from_loc_and_size((0., 0.), self.view_size); | 323 | let view_rect = Rectangle::from_loc_and_size((0., 0.), self.view_size); |
| 303 | self.floating | 324 | self.floating |
| 304 | - .update_render_elements(is_active && self.floating_is_active, view_rect); | 325 | + .update_render_elements(is_active && self.floating_is_active.get(), view_rect); |
| 305 | } | 326 | } |
| 306 | 327 | ||
| 307 | pub fn update_config(&mut self, base_options: Rc<Options>) { | 328 | pub fn update_config(&mut self, base_options: Rc<Options>) { |
| @@ -359,7 +380,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 359 | } | 380 | } |
| 360 | 381 | ||
| 361 | pub fn active_window(&self) -> Option<&W> { | 382 | pub fn active_window(&self) -> Option<&W> { |
| 362 | - if self.floating_is_active { | 383 | + if self.floating_is_active.get() { |
| 363 | self.floating.active_window() | 384 | self.floating.active_window() |
| 364 | } else { | 385 | } else { |
| 365 | self.scrolling.active_window() | 386 | self.scrolling.active_window() |
| @@ -501,7 +522,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 501 | .add_tile(col_idx, tile, activate, width, is_full_width, None); | 522 | .add_tile(col_idx, tile, activate, width, is_full_width, None); |
| 502 | 523 | ||
| 503 | if activate { | 524 | if activate { |
| 504 | - self.floating_is_active = false; | 525 | + self.floating_is_active = FloatingActive::No; |
| 505 | } | 526 | } |
| 506 | } | 527 | } |
| 507 | 528 | ||
| @@ -515,7 +536,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 515 | self.floating.add_tile(tile, pos, activate); | 536 | self.floating.add_tile(tile, pos, activate); |
| 516 | 537 | ||
| 517 | if activate || self.scrolling.is_empty() { | 538 | if activate || self.scrolling.is_empty() { |
| 518 | - self.floating_is_active = true; | 539 | + self.floating_is_active = FloatingActive::Yes; |
| 519 | } | 540 | } |
| 520 | } | 541 | } |
| 521 | 542 | ||
| @@ -531,7 +552,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 531 | .add_tile_to_column(col_idx, tile_idx, tile, activate); | 552 | .add_tile_to_column(col_idx, tile_idx, tile, activate); |
| 532 | 553 | ||
| 533 | if activate { | 554 | if activate { |
| 534 | - self.floating_is_active = false; | 555 | + self.floating_is_active = FloatingActive::No; |
| 535 | } | 556 | } |
| 536 | } | 557 | } |
| 537 | 558 | ||
| @@ -587,7 +608,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 587 | 608 | ||
| 588 | self.floating.add_tile(tile, Some(pos), activate); | 609 | self.floating.add_tile(tile, Some(pos), activate); |
| 589 | if activate { | 610 | if activate { |
| 590 | - self.floating_is_active = true; | 611 | + self.floating_is_active = FloatingActive::Yes; |
| 591 | } | 612 | } |
| 592 | } | 613 | } |
| 593 | } else { | 614 | } else { |
| @@ -604,19 +625,19 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 604 | self.scrolling.add_column(None, column, activate, None); | 625 | self.scrolling.add_column(None, column, activate, None); |
| 605 | 626 | ||
| 606 | if activate { | 627 | if activate { |
| 607 | - self.floating_is_active = false; | 628 | + self.floating_is_active = FloatingActive::No; |
| 608 | } | 629 | } |
| 609 | } | 630 | } |
| 610 | 631 | ||
| 611 | fn update_focus_floating_tiling_after_removing(&mut self, removed_from_floating: bool) { | 632 | fn update_focus_floating_tiling_after_removing(&mut self, removed_from_floating: bool) { |
| 612 | if removed_from_floating { | 633 | if removed_from_floating { |
| 613 | if self.floating.is_empty() { | 634 | if self.floating.is_empty() { |
| 614 | - self.floating_is_active = false; | 635 | + self.floating_is_active = FloatingActive::No; |
| 615 | } | 636 | } |
| 616 | } else { | 637 | } else { |
| 617 | // Scrolling should remain focused if both are empty. | 638 | // Scrolling should remain focused if both are empty. |
| 618 | if self.scrolling.is_empty() && !self.floating.is_empty() { | 639 | if self.scrolling.is_empty() && !self.floating.is_empty() { |
| 619 | - self.floating_is_active = true; | 640 | + self.floating_is_active = FloatingActive::Yes; |
| 620 | } | 641 | } |
| 621 | } | 642 | } |
| 622 | } | 643 | } |
| @@ -640,8 +661,8 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 640 | } | 661 | } |
| 641 | 662 | ||
| 642 | pub fn remove_active_tile(&mut self, transaction: Transaction) -> Option<RemovedTile<W>> { | 663 | pub fn remove_active_tile(&mut self, transaction: Transaction) -> Option<RemovedTile<W>> { |
| 643 | - let from_floating = self.floating_is_active; | 664 | + let from_floating = self.floating_is_active.get(); |
| 644 | - let removed = if self.floating_is_active { | 665 | + let removed = if from_floating { |
| 645 | self.floating.remove_active_tile()? | 666 | self.floating.remove_active_tile()? |
| 646 | } else { | 667 | } else { |
| 647 | self.scrolling.remove_active_tile(transaction)? | 668 | self.scrolling.remove_active_tile(transaction)? |
| @@ -657,8 +678,8 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 657 | } | 678 | } |
| 658 | 679 | ||
| 659 | pub fn remove_active_column(&mut self) -> Option<Column<W>> { | 680 | pub fn remove_active_column(&mut self) -> Option<Column<W>> { |
| 660 | - let from_floating = self.floating_is_active; | 681 | + let from_floating = self.floating_is_active.get(); |
| 661 | - if self.floating_is_active { | 682 | + if from_floating { |
| 662 | return None; | 683 | return None; |
| 663 | } | 684 | } |
| 664 | 685 | ||
| @@ -752,7 +773,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 752 | } | 773 | } |
| 753 | 774 | ||
| 754 | pub fn focus_left(&mut self) -> bool { | 775 | pub fn focus_left(&mut self) -> bool { |
| 755 | - if self.floating_is_active { | 776 | + if self.floating_is_active.get() { |
| 756 | self.floating.focus_left() | 777 | self.floating.focus_left() |
| 757 | } else { | 778 | } else { |
| 758 | self.scrolling.focus_left() | 779 | self.scrolling.focus_left() |
| @@ -760,7 +781,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 760 | } | 781 | } |
| 761 | 782 | ||
| 762 | pub fn focus_right(&mut self) -> bool { | 783 | pub fn focus_right(&mut self) -> bool { |
| 763 | - if self.floating_is_active { | 784 | + if self.floating_is_active.get() { |
| 764 | self.floating.focus_right() | 785 | self.floating.focus_right() |
| 765 | } else { | 786 | } else { |
| 766 | self.scrolling.focus_right() | 787 | self.scrolling.focus_right() |
| @@ -768,7 +789,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 768 | } | 789 | } |
| 769 | 790 | ||
| 770 | pub fn focus_column_first(&mut self) { | 791 | pub fn focus_column_first(&mut self) { |
| 771 | - if self.floating_is_active { | 792 | + if self.floating_is_active.get() { |
| 772 | self.floating.focus_leftmost(); | 793 | self.floating.focus_leftmost(); |
| 773 | } else { | 794 | } else { |
| 774 | self.scrolling.focus_column_first(); | 795 | self.scrolling.focus_column_first(); |
| @@ -776,7 +797,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 776 | } | 797 | } |
| 777 | 798 | ||
| 778 | pub fn focus_column_last(&mut self) { | 799 | pub fn focus_column_last(&mut self) { |
| 779 | - if self.floating_is_active { | 800 | + if self.floating_is_active.get() { |
| 780 | self.floating.focus_rightmost(); | 801 | self.floating.focus_rightmost(); |
| 781 | } else { | 802 | } else { |
| 782 | self.scrolling.focus_column_last(); | 803 | self.scrolling.focus_column_last(); |
| @@ -796,7 +817,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 796 | } | 817 | } |
| 797 | 818 | ||
| 798 | pub fn focus_down(&mut self) -> bool { | 819 | pub fn focus_down(&mut self) -> bool { |
| 799 | - if self.floating_is_active { | 820 | + if self.floating_is_active.get() { |
| 800 | self.floating.focus_down() | 821 | self.floating.focus_down() |
| 801 | } else { | 822 | } else { |
| 802 | self.scrolling.focus_down() | 823 | self.scrolling.focus_down() |
| @@ -804,7 +825,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 804 | } | 825 | } |
| 805 | 826 | ||
| 806 | pub fn focus_up(&mut self) -> bool { | 827 | pub fn focus_up(&mut self) -> bool { |
| 807 | - if self.floating_is_active { | 828 | + if self.floating_is_active.get() { |
| 808 | self.floating.focus_up() | 829 | self.floating.focus_up() |
| 809 | } else { | 830 | } else { |
| 810 | self.scrolling.focus_up() | 831 | self.scrolling.focus_up() |
| @@ -812,7 +833,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 812 | } | 833 | } |
| 813 | 834 | ||
| 814 | pub fn focus_down_or_left(&mut self) { | 835 | pub fn focus_down_or_left(&mut self) { |
| 815 | - if self.floating_is_active { | 836 | + if self.floating_is_active.get() { |
| 816 | self.floating.focus_down(); | 837 | self.floating.focus_down(); |
| 817 | } else { | 838 | } else { |
| 818 | self.scrolling.focus_down_or_left(); | 839 | self.scrolling.focus_down_or_left(); |
| @@ -820,7 +841,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 820 | } | 841 | } |
| 821 | 842 | ||
| 822 | pub fn focus_down_or_right(&mut self) { | 843 | pub fn focus_down_or_right(&mut self) { |
| 823 | - if self.floating_is_active { | 844 | + if self.floating_is_active.get() { |
| 824 | self.floating.focus_down(); | 845 | self.floating.focus_down(); |
| 825 | } else { | 846 | } else { |
| 826 | self.scrolling.focus_down_or_right(); | 847 | self.scrolling.focus_down_or_right(); |
| @@ -828,7 +849,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 828 | } | 849 | } |
| 829 | 850 | ||
| 830 | pub fn focus_up_or_left(&mut self) { | 851 | pub fn focus_up_or_left(&mut self) { |
| 831 | - if self.floating_is_active { | 852 | + if self.floating_is_active.get() { |
| 832 | self.floating.focus_up(); | 853 | self.floating.focus_up(); |
| 833 | } else { | 854 | } else { |
| 834 | self.scrolling.focus_up_or_left(); | 855 | self.scrolling.focus_up_or_left(); |
| @@ -836,7 +857,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 836 | } | 857 | } |
| 837 | 858 | ||
| 838 | pub fn focus_up_or_right(&mut self) { | 859 | pub fn focus_up_or_right(&mut self) { |
| 839 | - if self.floating_is_active { | 860 | + if self.floating_is_active.get() { |
| 840 | self.floating.focus_up(); | 861 | self.floating.focus_up(); |
| 841 | } else { | 862 | } else { |
| 842 | self.scrolling.focus_up_or_right(); | 863 | self.scrolling.focus_up_or_right(); |
| @@ -844,7 +865,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 844 | } | 865 | } |
| 845 | 866 | ||
| 846 | pub fn move_left(&mut self) -> bool { | 867 | pub fn move_left(&mut self) -> bool { |
| 847 | - if self.floating_is_active { | 868 | + if self.floating_is_active.get() { |
| 848 | self.floating.move_left(); | 869 | self.floating.move_left(); |
| 849 | true | 870 | true |
| 850 | } else { | 871 | } else { |
| @@ -853,7 +874,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 853 | } | 874 | } |
| 854 | 875 | ||
| 855 | pub fn move_right(&mut self) -> bool { | 876 | pub fn move_right(&mut self) -> bool { |
| 856 | - if self.floating_is_active { | 877 | + if self.floating_is_active.get() { |
| 857 | self.floating.move_right(); | 878 | self.floating.move_right(); |
| 858 | true | 879 | true |
| 859 | } else { | 880 | } else { |
| @@ -862,21 +883,21 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 862 | } | 883 | } |
| 863 | 884 | ||
| 864 | pub fn move_column_to_first(&mut self) { | 885 | pub fn move_column_to_first(&mut self) { |
| 865 | - if self.floating_is_active { | 886 | + if self.floating_is_active.get() { |
| 866 | return; | 887 | return; |
| 867 | } | 888 | } |
| 868 | self.scrolling.move_column_to_first(); | 889 | self.scrolling.move_column_to_first(); |
| 869 | } | 890 | } |
| 870 | 891 | ||
| 871 | pub fn move_column_to_last(&mut self) { | 892 | pub fn move_column_to_last(&mut self) { |
| 872 | - if self.floating_is_active { | 893 | + if self.floating_is_active.get() { |
| 873 | return; | 894 | return; |
| 874 | } | 895 | } |
| 875 | self.scrolling.move_column_to_last(); | 896 | self.scrolling.move_column_to_last(); |
| 876 | } | 897 | } |
| 877 | 898 | ||
| 878 | pub fn move_down(&mut self) -> bool { | 899 | pub fn move_down(&mut self) -> bool { |
| 879 | - if self.floating_is_active { | 900 | + if self.floating_is_active.get() { |
| 880 | self.floating.move_down(); | 901 | self.floating.move_down(); |
| 881 | true | 902 | true |
| 882 | } else { | 903 | } else { |
| @@ -885,7 +906,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 885 | } | 906 | } |
| 886 | 907 | ||
| 887 | pub fn move_up(&mut self) -> bool { | 908 | pub fn move_up(&mut self) -> bool { |
| 888 | - if self.floating_is_active { | 909 | + if self.floating_is_active.get() { |
| 889 | self.floating.move_up(); | 910 | self.floating.move_up(); |
| 890 | true | 911 | true |
| 891 | } else { | 912 | } else { |
| @@ -894,35 +915,39 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 894 | } | 915 | } |
| 895 | 916 | ||
| 896 | pub fn consume_or_expel_window_left(&mut self, window: Option<&W::Id>) { | 917 | pub fn consume_or_expel_window_left(&mut self, window: Option<&W::Id>) { |
| 897 | - if window.map_or(self.floating_is_active, |id| self.floating.has_window(id)) { | 918 | + if window.map_or(self.floating_is_active.get(), |id| { |
| 919 | + self.floating.has_window(id) | ||
| 920 | + }) { | ||
| 898 | return; | 921 | return; |
| 899 | } | 922 | } |
| 900 | self.scrolling.consume_or_expel_window_left(window); | 923 | self.scrolling.consume_or_expel_window_left(window); |
| 901 | } | 924 | } |
| 902 | 925 | ||
| 903 | pub fn consume_or_expel_window_right(&mut self, window: Option<&W::Id>) { | 926 | pub fn consume_or_expel_window_right(&mut self, window: Option<&W::Id>) { |
| 904 | - if window.map_or(self.floating_is_active, |id| self.floating.has_window(id)) { | 927 | + if window.map_or(self.floating_is_active.get(), |id| { |
| 928 | + self.floating.has_window(id) | ||
| 929 | + }) { | ||
| 905 | return; | 930 | return; |
| 906 | } | 931 | } |
| 907 | self.scrolling.consume_or_expel_window_right(window); | 932 | self.scrolling.consume_or_expel_window_right(window); |
| 908 | } | 933 | } |
| 909 | 934 | ||
| 910 | pub fn consume_into_column(&mut self) { | 935 | pub fn consume_into_column(&mut self) { |
| 911 | - if self.floating_is_active { | 936 | + if self.floating_is_active.get() { |
| 912 | return; | 937 | return; |
| 913 | } | 938 | } |
| 914 | self.scrolling.consume_into_column(); | 939 | self.scrolling.consume_into_column(); |
| 915 | } | 940 | } |
| 916 | 941 | ||
| 917 | pub fn expel_from_column(&mut self) { | 942 | pub fn expel_from_column(&mut self) { |
| 918 | - if self.floating_is_active { | 943 | + if self.floating_is_active.get() { |
| 919 | return; | 944 | return; |
| 920 | } | 945 | } |
| 921 | self.scrolling.expel_from_column(); | 946 | self.scrolling.expel_from_column(); |
| 922 | } | 947 | } |
| 923 | 948 | ||
| 924 | pub fn center_column(&mut self) { | 949 | pub fn center_column(&mut self) { |
| 925 | - if self.floating_is_active { | 950 | + if self.floating_is_active.get() { |
| 926 | self.floating.center_window(); | 951 | self.floating.center_window(); |
| 927 | } else { | 952 | } else { |
| 928 | self.scrolling.center_column(); | 953 | self.scrolling.center_column(); |
| @@ -931,7 +956,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 931 | 956 | ||
| 932 | pub fn toggle_width(&mut self) { | 957 | pub fn toggle_width(&mut self) { |
| 933 | // TODO | 958 | // TODO |
| 934 | - if self.floating_is_active { | 959 | + if self.floating_is_active.get() { |
| 935 | return; | 960 | return; |
| 936 | } | 961 | } |
| 937 | self.scrolling.toggle_width(); | 962 | self.scrolling.toggle_width(); |
| @@ -939,14 +964,14 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 939 | 964 | ||
| 940 | pub fn toggle_full_width(&mut self) { | 965 | pub fn toggle_full_width(&mut self) { |
| 941 | // TODO | 966 | // TODO |
| 942 | - if self.floating_is_active { | 967 | + if self.floating_is_active.get() { |
| 943 | return; | 968 | return; |
| 944 | } | 969 | } |
| 945 | self.scrolling.toggle_full_width(); | 970 | self.scrolling.toggle_full_width(); |
| 946 | } | 971 | } |
| 947 | 972 | ||
| 948 | pub fn set_column_width(&mut self, change: SizeChange) { | 973 | pub fn set_column_width(&mut self, change: SizeChange) { |
| 949 | - if self.floating_is_active { | 974 | + if self.floating_is_active.get() { |
| 950 | self.floating.set_window_width(None, change, true); | 975 | self.floating.set_window_width(None, change, true); |
| 951 | } else { | 976 | } else { |
| 952 | self.scrolling.set_column_width(change); | 977 | self.scrolling.set_column_width(change); |
| @@ -954,7 +979,9 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 954 | } | 979 | } |
| 955 | 980 | ||
| 956 | pub fn set_window_height(&mut self, window: Option<&W::Id>, change: SizeChange) { | 981 | pub fn set_window_height(&mut self, window: Option<&W::Id>, change: SizeChange) { |
| 957 | - if window.map_or(self.floating_is_active, |id| self.floating.has_window(id)) { | 982 | + if window.map_or(self.floating_is_active.get(), |id| { |
| 983 | + self.floating.has_window(id) | ||
| 984 | + }) { | ||
| 958 | self.floating.set_window_height(window, change, true); | 985 | self.floating.set_window_height(window, change, true); |
| 959 | } else { | 986 | } else { |
| 960 | self.scrolling.set_window_height(window, change); | 987 | self.scrolling.set_window_height(window, change); |
| @@ -962,14 +989,18 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 962 | } | 989 | } |
| 963 | 990 | ||
| 964 | pub fn reset_window_height(&mut self, window: Option<&W::Id>) { | 991 | pub fn reset_window_height(&mut self, window: Option<&W::Id>) { |
| 965 | - if window.map_or(self.floating_is_active, |id| self.floating.has_window(id)) { | 992 | + if window.map_or(self.floating_is_active.get(), |id| { |
| 993 | + self.floating.has_window(id) | ||
| 994 | + }) { | ||
| 966 | return; | 995 | return; |
| 967 | } | 996 | } |
| 968 | self.scrolling.reset_window_height(window); | 997 | self.scrolling.reset_window_height(window); |
| 969 | } | 998 | } |
| 970 | 999 | ||
| 971 | pub fn toggle_window_height(&mut self, window: Option<&W::Id>) { | 1000 | pub fn toggle_window_height(&mut self, window: Option<&W::Id>) { |
| 972 | - if window.map_or(self.floating_is_active, |id| self.floating.has_window(id)) { | 1001 | + if window.map_or(self.floating_is_active.get(), |id| { |
| 1002 | + self.floating.has_window(id) | ||
| 1003 | + }) { | ||
| 973 | // TODO | 1004 | // TODO |
| 974 | return; | 1005 | return; |
| 975 | } | 1006 | } |
| @@ -1034,9 +1065,9 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1034 | return; | 1065 | return; |
| 1035 | }; | 1066 | }; |
| 1036 | 1067 | ||
| 1037 | - let (_, render_pos) = self | 1068 | + let (_, render_pos, _) = self |
| 1038 | .tiles_with_render_positions() | 1069 | .tiles_with_render_positions() |
| 1039 | - .find(|(tile, _)| *tile.window().id() == id) | 1070 | + .find(|(tile, _, _)| *tile.window().id() == id) |
| 1040 | .unwrap(); | 1071 | .unwrap(); |
| 1041 | 1072 | ||
| 1042 | if self.floating.has_window(&id) { | 1073 | if self.floating.has_window(&id) { |
| @@ -1051,7 +1082,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1051 | None, | 1082 | None, |
| 1052 | ); | 1083 | ); |
| 1053 | if target_is_active { | 1084 | if target_is_active { |
| 1054 | - self.floating_is_active = false; | 1085 | + self.floating_is_active = FloatingActive::No; |
| 1055 | } | 1086 | } |
| 1056 | } else { | 1087 | } else { |
| 1057 | let mut removed = self.scrolling.remove_tile(&id, Transaction::new()); | 1088 | let mut removed = self.scrolling.remove_tile(&id, Transaction::new()); |
| @@ -1063,7 +1094,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1063 | self.floating | 1094 | self.floating |
| 1064 | .add_tile(removed.tile, Some(pos), target_is_active); | 1095 | .add_tile(removed.tile, Some(pos), target_is_active); |
| 1065 | if target_is_active { | 1096 | if target_is_active { |
| 1066 | - self.floating_is_active = true; | 1097 | + self.floating_is_active = FloatingActive::Yes; |
| 1067 | } | 1098 | } |
| 1068 | } | 1099 | } |
| 1069 | 1100 | ||
| @@ -1084,7 +1115,11 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1084 | return; | 1115 | return; |
| 1085 | } | 1116 | } |
| 1086 | 1117 | ||
| 1087 | - self.floating_is_active = !self.floating_is_active; | 1118 | + self.floating_is_active = if self.floating_is_active.get() { |
| 1119 | + FloatingActive::No | ||
| 1120 | + } else { | ||
| 1121 | + FloatingActive::Yes | ||
| 1122 | + }; | ||
| 1088 | } | 1123 | } |
| 1089 | 1124 | ||
| 1090 | pub fn has_windows(&self) -> bool { | 1125 | pub fn has_windows(&self) -> bool { |
| @@ -1105,9 +1140,14 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1105 | 1140 | ||
| 1106 | pub fn tiles_with_render_positions( | 1141 | pub fn tiles_with_render_positions( |
| 1107 | &self, | 1142 | &self, |
| 1108 | - ) -> impl Iterator<Item = (&Tile<W>, Point<f64, Logical>)> { | 1143 | + ) -> impl Iterator<Item = (&Tile<W>, Point<f64, Logical>, bool)> { |
| 1109 | let scrolling = self.scrolling.tiles_with_render_positions(); | 1144 | let scrolling = self.scrolling.tiles_with_render_positions(); |
| 1145 | + let scrolling = scrolling.map(|(tile, pos)| (tile, pos, true)); | ||
| 1146 | + | ||
| 1110 | let floating = self.floating.tiles_with_render_positions(); | 1147 | let floating = self.floating.tiles_with_render_positions(); |
| 1148 | + let visible = self.is_floating_visible(); | ||
| 1149 | + let floating = floating.map(move |(tile, pos)| (tile, pos, visible)); | ||
| 1150 | + | ||
| 1111 | floating.chain(scrolling) | 1151 | floating.chain(scrolling) |
| 1112 | } | 1152 | } |
| 1113 | 1153 | ||
| @@ -1121,7 +1161,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1121 | } | 1161 | } |
| 1122 | 1162 | ||
| 1123 | pub fn active_tile_visual_rectangle(&self) -> Option<Rectangle<f64, Logical>> { | 1163 | pub fn active_tile_visual_rectangle(&self) -> Option<Rectangle<f64, Logical>> { |
| 1124 | - if self.floating_is_active { | 1164 | + if self.floating_is_active.get() { |
| 1125 | self.floating.active_tile_visual_rectangle() | 1165 | self.floating.active_tile_visual_rectangle() |
| 1126 | } else { | 1166 | } else { |
| 1127 | self.scrolling.active_tile_visual_rectangle() | 1167 | self.scrolling.active_tile_visual_rectangle() |
| @@ -1145,19 +1185,29 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1145 | let scrolling = self.scrolling.render_elements(renderer, scale, target); | 1185 | let scrolling = self.scrolling.render_elements(renderer, scale, target); |
| 1146 | let scrolling = scrolling.into_iter().map(WorkspaceRenderElement::from); | 1186 | let scrolling = scrolling.into_iter().map(WorkspaceRenderElement::from); |
| 1147 | 1187 | ||
| 1148 | - let view_rect = Rectangle::from_loc_and_size((0., 0.), self.view_size); | 1188 | + let floating = self.is_floating_visible().then(|| { |
| 1149 | - let floating = self | 1189 | + let view_rect = Rectangle::from_loc_and_size((0., 0.), self.view_size); |
| 1150 | - .floating | 1190 | + let floating = self |
| 1151 | - .render_elements(renderer, view_rect, scale, target); | 1191 | + .floating |
| 1152 | - let floating = floating.into_iter().map(WorkspaceRenderElement::from); | 1192 | + .render_elements(renderer, view_rect, scale, target); |
| 1193 | + floating.into_iter().map(WorkspaceRenderElement::from) | ||
| 1194 | + }); | ||
| 1153 | 1195 | ||
| 1154 | - floating.chain(scrolling) | 1196 | + floating.into_iter().flatten().chain(scrolling) |
| 1155 | } | 1197 | } |
| 1156 | 1198 | ||
| 1157 | pub fn render_above_top_layer(&self) -> bool { | 1199 | pub fn render_above_top_layer(&self) -> bool { |
| 1158 | self.scrolling.render_above_top_layer() | 1200 | self.scrolling.render_above_top_layer() |
| 1159 | } | 1201 | } |
| 1160 | 1202 | ||
| 1203 | + pub fn is_floating_visible(&self) -> bool { | ||
| 1204 | + // If the focus is on a fullscreen scrolling window, hide the floating windows. | ||
| 1205 | + matches!( | ||
| 1206 | + self.floating_is_active, | ||
| 1207 | + FloatingActive::Yes | FloatingActive::NoButRaised | ||
| 1208 | + ) || !self.render_above_top_layer() | ||
| 1209 | + } | ||
| 1210 | + | ||
| 1161 | pub fn store_unmap_snapshot_if_empty(&mut self, renderer: &mut GlesRenderer, window: &W::Id) { | 1211 | pub fn store_unmap_snapshot_if_empty(&mut self, renderer: &mut GlesRenderer, window: &W::Id) { |
| 1162 | let output_scale = Scale::from(self.scale.fractional_scale()); | 1212 | let output_scale = Scale::from(self.scale.fractional_scale()); |
| 1163 | let view_size = self.view_size(); | 1213 | let view_size = self.view_size(); |
| @@ -1213,7 +1263,11 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1213 | pos: Point<f64, Logical>, | 1263 | pos: Point<f64, Logical>, |
| 1214 | ) -> Option<(&W, Option<Point<f64, Logical>>)> { | 1264 | ) -> Option<(&W, Option<Point<f64, Logical>>)> { |
| 1215 | self.tiles_with_render_positions() | 1265 | self.tiles_with_render_positions() |
| 1216 | - .find_map(|(tile, tile_pos)| { | 1266 | + .find_map(|(tile, tile_pos, visible)| { |
| 1267 | + if !visible { | ||
| 1268 | + return None; | ||
| 1269 | + } | ||
| 1270 | + | ||
| 1217 | let pos_within_tile = pos - tile_pos; | 1271 | let pos_within_tile = pos - tile_pos; |
| 1218 | 1272 | ||
| 1219 | if tile.is_in_input_region(pos_within_tile) { | 1273 | if tile.is_in_input_region(pos_within_tile) { |
| @@ -1229,11 +1283,15 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1229 | 1283 | ||
| 1230 | pub fn resize_edges_under(&self, pos: Point<f64, Logical>) -> Option<ResizeEdge> { | 1284 | pub fn resize_edges_under(&self, pos: Point<f64, Logical>) -> Option<ResizeEdge> { |
| 1231 | self.tiles_with_render_positions() | 1285 | self.tiles_with_render_positions() |
| 1232 | - .find_map(|(tile, tile_pos)| { | 1286 | + .find_map(|(tile, tile_pos, visible)| { |
| 1233 | - let pos_within_tile = pos - tile_pos; | ||
| 1234 | - | ||
| 1235 | // This logic should be consistent with window_under() in when it returns Some vs. | 1287 | // This logic should be consistent with window_under() in when it returns Some vs. |
| 1236 | // None. | 1288 | // None. |
| 1289 | + if !visible { | ||
| 1290 | + return None; | ||
| 1291 | + } | ||
| 1292 | + | ||
| 1293 | + let pos_within_tile = pos - tile_pos; | ||
| 1294 | + | ||
| 1237 | if tile.is_in_input_region(pos_within_tile) | 1295 | if tile.is_in_input_region(pos_within_tile) |
| 1238 | || tile.is_in_activation_region(pos_within_tile) | 1296 | || tile.is_in_activation_region(pos_within_tile) |
| 1239 | { | 1297 | { |
| @@ -1269,8 +1327,9 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1269 | 1327 | ||
| 1270 | pub fn refresh(&mut self, is_active: bool) { | 1328 | pub fn refresh(&mut self, is_active: bool) { |
| 1271 | self.scrolling | 1329 | self.scrolling |
| 1272 | - .refresh(is_active && !self.floating_is_active); | 1330 | + .refresh(is_active && !self.floating_is_active.get()); |
| 1273 | - self.floating.refresh(is_active && self.floating_is_active); | 1331 | + self.floating |
| 1332 | + .refresh(is_active && self.floating_is_active.get()); | ||
| 1274 | } | 1333 | } |
| 1275 | 1334 | ||
| 1276 | pub fn scroll_amount_to_activate(&self, window: &W::Id) -> f64 { | 1335 | pub fn scroll_amount_to_activate(&self, window: &W::Id) -> f64 { |
| @@ -1283,10 +1342,10 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1283 | 1342 | ||
| 1284 | pub fn activate_window(&mut self, window: &W::Id) -> bool { | 1343 | pub fn activate_window(&mut self, window: &W::Id) -> bool { |
| 1285 | if self.floating.activate_window(window) { | 1344 | if self.floating.activate_window(window) { |
| 1286 | - self.floating_is_active = true; | 1345 | + self.floating_is_active = FloatingActive::Yes; |
| 1287 | true | 1346 | true |
| 1288 | } else if self.scrolling.activate_window(window) { | 1347 | } else if self.scrolling.activate_window(window) { |
| 1289 | - self.floating_is_active = false; | 1348 | + self.floating_is_active = FloatingActive::No; |
| 1290 | true | 1349 | true |
| 1291 | } else { | 1350 | } else { |
| 1292 | false | 1351 | false |
| @@ -1295,10 +1354,14 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1295 | 1354 | ||
| 1296 | pub fn activate_window_without_raising(&mut self, window: &W::Id) -> bool { | 1355 | pub fn activate_window_without_raising(&mut self, window: &W::Id) -> bool { |
| 1297 | if self.floating.activate_window_without_raising(window) { | 1356 | if self.floating.activate_window_without_raising(window) { |
| 1298 | - self.floating_is_active = true; | 1357 | + self.floating_is_active = FloatingActive::Yes; |
| 1299 | true | 1358 | true |
| 1300 | } else if self.scrolling.activate_window(window) { | 1359 | } else if self.scrolling.activate_window(window) { |
| 1301 | - self.floating_is_active = false; | 1360 | + self.floating_is_active = match self.floating_is_active { |
| 1361 | + FloatingActive::No => FloatingActive::No, | ||
| 1362 | + FloatingActive::NoButRaised => FloatingActive::NoButRaised, | ||
| 1363 | + FloatingActive::Yes => FloatingActive::NoButRaised, | ||
| 1364 | + }; | ||
| 1302 | true | 1365 | true |
| 1303 | } else { | 1366 | } else { |
| 1304 | false | 1367 | false |
| @@ -1370,7 +1433,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1370 | } | 1433 | } |
| 1371 | 1434 | ||
| 1372 | pub fn floating_is_active(&self) -> bool { | 1435 | pub fn floating_is_active(&self) -> bool { |
| 1373 | - self.floating_is_active | 1436 | + self.floating_is_active.get() |
| 1374 | } | 1437 | } |
| 1375 | 1438 | ||
| 1376 | #[cfg(test)] | 1439 | #[cfg(test)] |
| @@ -1405,17 +1468,17 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1405 | 1468 | ||
| 1406 | if self.floating.is_empty() { | 1469 | if self.floating.is_empty() { |
| 1407 | assert!( | 1470 | assert!( |
| 1408 | - !self.floating_is_active, | 1471 | + !self.floating_is_active.get(), |
| 1409 | "when floating is empty it must never be active" | 1472 | "when floating is empty it must never be active" |
| 1410 | ); | 1473 | ); |
| 1411 | } else if self.scrolling.is_empty() { | 1474 | } else if self.scrolling.is_empty() { |
| 1412 | assert!( | 1475 | assert!( |
| 1413 | - self.floating_is_active, | 1476 | + self.floating_is_active.get(), |
| 1414 | "when scrolling is empty but floating isn't, floating should be active" | 1477 | "when scrolling is empty but floating isn't, floating should be active" |
| 1415 | ); | 1478 | ); |
| 1416 | } | 1479 | } |
| 1417 | 1480 | ||
| 1418 | - for (tile, tile_pos) in self.tiles_with_render_positions() { | 1481 | + for (tile, tile_pos, _visible) in self.tiles_with_render_positions() { |
| 1419 | if Some(tile.window().id()) != move_win_id { | 1482 | if Some(tile.window().id()) != move_win_id { |
| 1420 | assert_eq!(tile.interactive_move_offset, Point::from((0., 0.))); | 1483 | assert_eq!(tile.interactive_move_offset, Point::from((0., 0.))); |
| 1421 | } | 1484 | } |