fix focus property in json payloads (#275)

This commit is contained in:
TibboddiT 2024-10-31 15:30:32 +01:00 committed by GitHub
parent 5b63bcdc83
commit 9b186b0352
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 11 additions and 8 deletions

View File

@ -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 },

View File

@ -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 },

View File

@ -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 },

View File

@ -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())
@ -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);

View File

@ -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" },

View File

@ -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);