Skip to content

Commit a38a0e5

Browse files
authored
bugfix: fullscreen windows were some times broken (#308)
1 parent 4477bdd commit a38a0e5

7 files changed

+13
-72
lines changed

src/leaf_container.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ void LeafContainer::handle_ready()
140140
{
141141
tree->handle_container_ready(*this);
142142
get_workspace()->handle_ready_hack(*this);
143-
auto const& info = window_controller.info_for(window_);
144143
if (window_controller.is_fullscreen(window_))
145144
toggle_fullscreen();
146145
}

src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ int main(int argc, char const* argv[])
6868
MirRunner runner { argc, argv };
6969
miracle::CompositorState compositor_state;
7070

71-
std::function<void()> shutdown_hook { [] {} };
71+
std::function<void()> shutdown_hook { [] { } };
7272
runner.add_stop_callback([&]
7373
{ shutdown_hook(); });
7474

src/policy.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1384,5 +1384,5 @@ bool Policy::can_set_layout() const
13841384
if (!state.active())
13851385
return false;
13861386

1387-
return true;
1387+
return !state.active()->is_fullscreen();
13881388
}

src/tiling_window_tree.cpp

+7-58
Original file line numberDiff line numberDiff line change
@@ -106,25 +106,13 @@ void TilingWindowTree::graft(std::shared_ptr<LeafContainer> const& leaf)
106106

107107
bool TilingWindowTree::resize_container(miracle::Direction direction, Container& container)
108108
{
109-
if (is_active_window_fullscreen)
110-
{
111-
mir::log_warning("Unable to resize the next window: fullscreened");
112-
return false;
113-
}
114-
115109
handle_resize(container, direction, config->get_resize_jump());
116110
return true;
117111
}
118112

119113
bool TilingWindowTree::select_next(
120114
miracle::Direction direction, Container& container)
121115
{
122-
if (is_active_window_fullscreen)
123-
{
124-
mir::log_warning("Unable to select the next window: fullscreened");
125-
return false;
126-
}
127-
128116
auto node = handle_select(container, direction);
129117
if (!node)
130118
{
@@ -138,10 +126,10 @@ bool TilingWindowTree::select_next(
138126

139127
bool TilingWindowTree::toggle_fullscreen(LeafContainer& container)
140128
{
141-
if (is_active_window_fullscreen)
142-
advise_restored_container(container);
143-
else
129+
if (container.is_fullscreen())
144130
advise_fullscreen_container(container);
131+
else
132+
advise_restored_container(container);
145133
return true;
146134
}
147135

@@ -156,27 +144,8 @@ geom::Rectangle TilingWindowTree::get_area() const
156144
return root_lane->get_logical_area();
157145
}
158146

159-
std::shared_ptr<LeafContainer> TilingWindowTree::select_window_from_point(int x, int y)
160-
{
161-
if (is_active_window_fullscreen)
162-
return active_container();
163-
164-
auto node = root_lane->find_where([&](std::shared_ptr<Container> const& node)
165-
{
166-
return node->is_leaf() && node->get_logical_area().contains(geom::Point(x, y));
167-
});
168-
169-
return Container::as_leaf(node);
170-
}
171-
172147
bool TilingWindowTree::move_container(miracle::Direction direction, Container& container)
173148
{
174-
if (is_active_window_fullscreen)
175-
{
176-
mir::log_warning("Unable to move active window: fullscreen");
177-
return false;
178-
}
179-
180149
auto traversal_result = handle_move(container, direction);
181150
switch (traversal_result.traversal_type)
182151
{
@@ -286,12 +255,6 @@ void TilingWindowTree::toggle_layout(Container& container, bool cycle_thru_all)
286255

287256
void TilingWindowTree::handle_layout_scheme(LayoutScheme scheme, Container& container)
288257
{
289-
if (is_active_window_fullscreen)
290-
{
291-
mir::log_warning("Unable to handle direction request: fullscreen");
292-
return;
293-
}
294-
295258
auto parent = container.get_parent().lock();
296259
if (!parent)
297260
{
@@ -312,21 +275,14 @@ void TilingWindowTree::handle_layout_scheme(LayoutScheme scheme, Container& cont
312275

313276
void TilingWindowTree::advise_focus_gained(LeafContainer& container)
314277
{
315-
if (is_active_window_fullscreen)
278+
if (container.is_fullscreen())
316279
window_controller.raise(container.window().value());
317280
else if (auto const& parent = container.get_parent().lock())
318281
parent->on_focus_gained();
319282
}
320283

321284
void TilingWindowTree::advise_delete_window(std::shared_ptr<Container> const& container)
322285
{
323-
auto active = active_container();
324-
if (active == container)
325-
{
326-
if (is_active_window_fullscreen)
327-
is_active_window_fullscreen = false;
328-
}
329-
330286
auto parent = handle_remove(container);
331287
parent->commit_changes();
332288
}
@@ -650,16 +606,14 @@ bool TilingWindowTree::advise_fullscreen_container(LeafContainer& container)
650606
auto window = container.window().value();
651607
window_controller.select_active_window(window);
652608
window_controller.raise(window);
653-
is_active_window_fullscreen = true;
654609
return true;
655610
}
656611

657612
bool TilingWindowTree::advise_restored_container(LeafContainer& container)
658613
{
659-
auto active = active_container();
660-
if (active && active->window() == container.window().value() && is_active_window_fullscreen)
614+
auto active = state.active();
615+
if (active && active->window() == container.window().value())
661616
{
662-
is_active_window_fullscreen = false;
663617
container.set_logical_area(container.get_logical_area());
664618
container.commit_changes();
665619
}
@@ -670,7 +624,7 @@ bool TilingWindowTree::advise_restored_container(LeafContainer& container)
670624
bool TilingWindowTree::handle_container_ready(LeafContainer& container)
671625
{
672626
constrain(container);
673-
if (is_active_window_fullscreen)
627+
if (state.active() && state.active()->is_fullscreen())
674628
return true;
675629

676630
auto window = container.window().value();
@@ -796,8 +750,3 @@ Workspace* TilingWindowTree::get_workspace() const
796750
{
797751
return tree_interface->get_workspace();
798752
}
799-
800-
std::shared_ptr<LeafContainer> TilingWindowTree::active_container() const
801-
{
802-
return Container::as_leaf(state.active());
803-
}

src/tiling_window_tree.h

-7
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ class TilingWindowTree
8383
/// Toggle the active window between fullscreen and not fullscreen
8484
bool toggle_fullscreen(LeafContainer&);
8585

86-
bool has_fullscreen_window() const { return is_active_window_fullscreen; }
87-
8886
void request_layout(Container&, LayoutScheme);
8987

9088
/// Request a change to vertical window placement
@@ -113,8 +111,6 @@ class TilingWindowTree
113111

114112
geom::Rectangle get_area() const;
115113

116-
std::shared_ptr<LeafContainer> select_window_from_point(int x, int y);
117-
118114
bool advise_fullscreen_container(LeafContainer&);
119115
bool advise_restored_container(LeafContainer&);
120116
bool handle_container_ready(LeafContainer&);
@@ -159,7 +155,6 @@ class TilingWindowTree
159155
std::shared_ptr<ParentContainer> root_lane;
160156
std::unique_ptr<TilingWindowTreeInterface> tree_interface;
161157

162-
bool is_active_window_fullscreen = false;
163158
bool is_hidden = false;
164159
int config_handle = 0;
165160

@@ -187,8 +182,6 @@ class TilingWindowTree
187182
/// Selects the next node in the provided direction
188183
/// @returns The next selectable window or nullptr if none is found
189184
static std::shared_ptr<LeafContainer> handle_select(Container& from, Direction direction);
190-
191-
std::shared_ptr<LeafContainer> active_container() const;
192185
};
193186

194187
}

src/workspace.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ void Workspace::handle_ready_hack(LeafContainer& container)
177177
for (auto const& window : floating_windows)
178178
window_controller.raise(window->window().value());
179179

180-
if (tree->has_fullscreen_window())
180+
if (state.active() && state.active()->is_fullscreen())
181181
window_controller.raise(state.active()->window().value());
182182
}
183183

tests/test_animator.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class ImmediateServerActionQueue : public mir::ServerActionQueue
4545
action();
4646
}
4747

48-
void pause_processing_for(void const* owner) override {};
49-
void resume_processing_for(void const* owner) override {};
48+
void pause_processing_for(void const* owner) override { };
49+
void resume_processing_for(void const* owner) override { };
5050
};
5151

5252
class AnimatorTest : public testing::Test
@@ -154,6 +154,6 @@ TEST_F(AnimationTest, InterruptingSlideResultsInModifiedAnimationDuration)
154154
mir::geometry::Rectangle(
155155
mir::geometry::Point(200, 200),
156156
mir::geometry::Size(0, 0)),
157-
[](auto const& asr) {});
157+
[](auto const& asr) { });
158158
ASSERT_NEAR(animation.get_runtime_seconds(), 2, 0.05);
159159
}

0 commit comments

Comments
 (0)