Skip to content

Commit

Permalink
fix focus property in json payloads (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
TibboddiT authored Oct 31, 2024
1 parent 5b63bcd commit 9b186b0
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/floating_window_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ nlohmann::json FloatingWindowContainer::to_json() const
{ "width", logical_area.size.width.as_int() },
{ "height", logical_area.size.height.as_int() },
} },
{ "focused", is_focused() },
{ "focused", visible && is_focused() },
{ "focus", std::vector<int>() },
{ "border", "normal" },
{ "current_border_width", config->get_border_config().size },
Expand Down
2 changes: 1 addition & 1 deletion src/leaf_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ nlohmann::json LeafContainer::to_json() const
{ "width", logical_area.size.width.as_int() },
{ "height", logical_area.size.height.as_int() },
} },
{ "focused", is_focused() },
{ "focused", visible && is_focused() },
{ "focus", std::vector<int>() },
{ "border", "normal" },
{ "current_border_width", config->get_border_config().size },
Expand Down
2 changes: 1 addition & 1 deletion src/parent_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ nlohmann::json ParentContainer::to_json() const
{ "width", logical_area.size.width.as_int() },
{ "height", logical_area.size.height.as_int() },
} },
{ "focused", is_focused() },
{ "focused", visible && is_focused() },
{ "focus", std::vector<int>() },
{ "border", "none" },
{ "current_border_width", 0 },
Expand Down
5 changes: 4 additions & 1 deletion src/policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,10 @@ void Policy::advise_output_create(miral::Output const& output)
floating_window_manager, state, config, window_controller, animator);
workspace_manager.request_first_available_workspace(output_content);
output_list.push_back(output_content);
if (state.active_output == nullptr)
if (state.active_output == nullptr) {
state.active_output = output_content;
state.active_output->set_is_active(true);
}

// Let's rehome some orphan windows if we need to
if (!orphaned_window_list.empty())
Expand Down Expand Up @@ -525,6 +527,7 @@ void Policy::advise_output_delete(miral::Output const& output)
else
{
state.active_output = output_list.front();
state.active_output->set_is_active(true);
for (auto& window : other_output->collect_all_windows())
{
state.active_output->add_immediately(window);
Expand Down
2 changes: 1 addition & 1 deletion src/workspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ nlohmann::json Workspace::to_json() const
{ "type", "workspace" },
{ "name", std::to_string(workspace) },
{ "visible", output->is_active() && is_focused },
{ "focused", output->is_active() && is_focused && root->is_focused() },
{ "focused", output->is_active() && is_focused },
{ "urgent", false },
{ "output", output->get_output().name() },
{ "border", "none" },
Expand Down
6 changes: 3 additions & 3 deletions src/workspace_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,17 @@ std::shared_ptr<Output> WorkspaceManager::request_focus(int key)
return nullptr;

auto active_screen = get_active_screen();
int previous_workspace = -1;
if (active_screen)
{
int previous_workspace = active_screen->get_active_workspace_num();
previous_workspace = active_screen->get_active_workspace_num();
last_selected = { previous_workspace, output_to_workspace_mapping[previous_workspace] };
}
output_to_workspace_mapping[key]->advise_workspace_active(key);

if (active_screen != nullptr)
{
auto active_workspace = active_screen->get_active_workspace_num();
registry.advise_focused(active_screen, active_workspace, output_to_workspace_mapping[key].get(), key);
registry.advise_focused(output_to_workspace_mapping[previous_workspace].get(), previous_workspace, output_to_workspace_mapping[key].get(), key);
}
else
registry.advise_focused(nullptr, -1, output_to_workspace_mapping[key].get(), key);
Expand Down

0 comments on commit 9b186b0

Please sign in to comment.