Skip to content

Commit

Permalink
(miracle-wm-org#48) Fullscreened windows are now guaranteed to be on …
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkae committed Mar 7, 2024
1 parent fd146aa commit 342f32a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/output_content.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ void OutputContent::advise_focus_gained(const std::shared_ptr<miracle::WindowMet
case WindowType::tiled:
{
metadata->get_tiling_node()->get_tree()->advise_focus_gained(metadata->get_window());
tools.send_tree_to_back(metadata->get_window());
break;
}
case WindowType::floating:
Expand Down Expand Up @@ -326,6 +325,9 @@ OutputContent::confirm_placement_on_display(
void OutputContent::select_window_from_point(int x, int y)
{
auto workspace = get_active_workspace();
if (workspace->get_tree()->has_fullscreen_window())
return;

auto const& floating = workspace->get_floating_windows();
int floating_index = -1;
for (int i = 0; i < floating.size(); i++)
Expand Down Expand Up @@ -526,6 +528,12 @@ void OutputContent::request_toggle_active_float()
case WindowType::tiled:
{
auto tree = metadata->get_tiling_node()->get_tree();
if (tree->has_fullscreen_window())
{
mir::log_warning("request_toggle_active_float: cannot float fullscreen window");
return;
}

tree->advise_delete_window(active_window);

auto& prev_info = tools.info_for(active_window);
Expand Down Expand Up @@ -570,4 +578,4 @@ void OutputContent::add_immediately(miral::Window &window)
advise_new_window(tools.info_for(window), type);
auto metadata = window_helpers::get_metadata(window, tools);
handle_window_ready(tools.info_for(window), metadata);
}
}
14 changes: 13 additions & 1 deletion src/tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ std::shared_ptr<Node> Tree::advise_new_window(miral::WindowInfo const& window_in
tools.select_active_window(window_info.window());
advise_fullscreen_window(window_info.window());
}
else
{
tools.send_tree_to_back(window_info.window());
}

return node;
}
Expand Down Expand Up @@ -344,13 +348,17 @@ void Tree::advise_focus_gained(miral::Window& window)
}

active_window = found_node;
if (active_window && is_active_window_fullscreen)
tools.raise_tree(window);
else
tools.send_tree_to_back(window);
}

void Tree::advise_focus_lost(miral::Window& window)
{
is_resizing = false;

if (active_window != nullptr && active_window->get_window() == window)
if (active_window != nullptr && active_window->get_window() == window && !is_active_window_fullscreen)
active_window = nullptr;
}

Expand Down Expand Up @@ -628,6 +636,7 @@ bool Tree::advise_fullscreen_window(miral::Window& window)
return false;

tools.select_active_window(node->get_window());
tools.raise_tree(node->get_window());
is_active_window_fullscreen = true;
is_resizing = false;
return true;
Expand All @@ -640,7 +649,10 @@ bool Tree::advise_restored_window(miral::Window& window)
return false;

if (node == active_window && is_active_window_fullscreen)
{
is_active_window_fullscreen = false;
constrain(active_window->get_window());
}

return true;
}
Expand Down
2 changes: 2 additions & 0 deletions src/tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class Tree
/// Toggle the active window between fullscreen and not fullscreen
bool try_toggle_active_fullscreen();

bool has_fullscreen_window() { return is_active_window_fullscreen; }

// Request a change to vertical window placement
void request_vertical();

Expand Down

0 comments on commit 342f32a

Please sign in to comment.