1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 10:57:36 +00:00

Taskbar+WindowServer: Adding to Quick Launch via windows :^)

You can now add applications to Quick Launch via the context
menu option of their windows. Clicking it creates an event with the
stored PID of the process that created the window. The Taskbar receives
the event and tells the QuickLaunchWidget to add the PID, which then
gets the executable using /sys/kernel/processes. It also looks for an
AppFile using the name from the process object and if there is one, it
uses that, since it should contain a better formatted name.
This commit is contained in:
david072 2023-11-04 19:58:14 +01:00 committed by Andreas Kling
parent 4386182be1
commit 70f7c10ab9
11 changed files with 105 additions and 0 deletions

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2023, David Ganz <david.g.ganz@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -743,6 +744,13 @@ void Window::ensure_window_menu()
m_window_menu->add_item(make<MenuItem>(*m_window_menu, MenuItem::Type::Separator));
}
auto add_to_quick_launch_item = make<MenuItem>(*m_window_menu, (unsigned)WindowMenuAction::AddToQuickLaunch, "&Add to Quick Launch");
m_window_menu_add_to_quick_launch_item = add_to_quick_launch_item.ptr();
m_window_menu_add_to_quick_launch_item->set_icon(&pin_icon());
m_window_menu->add_item(move(add_to_quick_launch_item));
m_window_menu->add_item(make<MenuItem>(*m_window_menu, MenuItem::Type::Separator));
auto close_item = make<MenuItem>(*m_window_menu, (unsigned)WindowMenuAction::Close, "&Close");
m_window_menu_close_item = close_item.ptr();
m_window_menu_close_item->set_icon(&close_icon());
@ -792,6 +800,11 @@ void Window::handle_window_menu_action(WindowMenuAction action)
WindowManager::the().set_always_on_top(*this, new_is_checked);
break;
}
case WindowMenuAction::AddToQuickLaunch: {
if (m_process_id.has_value())
WindowManager::the().on_add_to_quick_launch(m_process_id.value());
break;
}
}
}

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2018-2023, Andreas Kling <kling@serenityos.org>
* Copyright (c) 2023, David Ganz <david.g.ganz@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -63,6 +64,7 @@ enum class WindowMenuAction {
Close,
Move,
ToggleAlwaysOnTop,
AddToQuickLaunch,
};
enum class WindowMenuDefaultAction {
@ -455,6 +457,7 @@ private:
MenuItem* m_window_menu_close_item { nullptr };
MenuItem* m_window_menu_always_on_top_item { nullptr };
MenuItem* m_window_menu_menubar_visibility_item { nullptr };
MenuItem* m_window_menu_add_to_quick_launch_item { nullptr };
Optional<int> m_progress;
bool m_should_show_menubar { true };
WindowStack* m_window_stack { nullptr };

View file

@ -765,6 +765,14 @@ void WindowManager::stop_tile_window_animation()
m_tile_window_overlay_animation = nullptr;
}
void WindowManager::on_add_to_quick_launch(pid_t pid)
{
for_each_window_manager([&](WMConnectionFromClient& conn) {
conn.async_add_to_quick_launch(conn.window_id(), pid);
return IterationDecision::Continue;
});
}
void WindowManager::show_tile_window_overlay(Window& window, Screen const& cursor_screen, WindowTileType tile_type)
{
m_move_window_suggested_tile = tile_type;

View file

@ -344,6 +344,8 @@ public:
void start_tile_window_animation(Gfx::IntRect const&);
void stop_tile_window_animation();
void on_add_to_quick_launch(pid_t);
private:
explicit WindowManager(Gfx::PaletteImpl&);

View file

@ -13,4 +13,5 @@ endpoint WindowManagerClient
super_digit_key_pressed(i32 wm_id, u8 digit) =|
workspace_changed(i32 wm_id, u32 row, u32 column) =|
keymap_changed(i32 wm_id, [UTF8] DeprecatedString keymap) =|
add_to_quick_launch(i32 wm_id, i32 process_id) =|
}