1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:47:45 +00:00

Taskbar: Show start menu when super key is pressed

This commit re-adds the functionality of the start menu appearing when
the super key is pressed
This commit is contained in:
Conor Byrne 2021-04-17 23:21:56 +01:00 committed by Andreas Kling
parent 88ecfa164a
commit 68d1469aea
2 changed files with 16 additions and 6 deletions

View file

@ -84,14 +84,15 @@ TaskbarWindow::TaskbarWindow(NonnullRefPtr<GUI::Menu> start_menu)
main_widget.set_layout<GUI::HorizontalBoxLayout>();
main_widget.layout()->set_margins({ 3, 3, 3, 1 });
auto& start_button = main_widget.add<GUI::Button>("Serenity");
start_button.set_font(Gfx::FontDatabase::default_bold_font());
start_button.set_icon_spacing(0);
start_button.set_fixed_size(80, 22);
m_start_button = GUI::Button::construct("Serenity");
m_start_button->set_font(Gfx::FontDatabase::default_bold_font());
m_start_button->set_icon_spacing(0);
m_start_button->set_fixed_size(80, 22);
auto app_icon = GUI::Icon::default_icon("ladybug");
start_button.set_icon(app_icon.bitmap_for_size(16));
start_button.set_menu(m_start_menu);
m_start_button->set_icon(app_icon.bitmap_for_size(16));
m_start_button->set_menu(m_start_menu);
main_widget.add_child(*m_start_button);
create_quick_launch_bar();
m_task_button_container = main_widget.add<GUI::Widget>();
@ -338,6 +339,14 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
update_applet_area();
break;
}
case GUI::Event::WM_SuperKeyPressed: {
if (m_start_menu->is_visible()) {
m_start_menu->dismiss();
} else {
m_start_menu->popup(m_start_button->screen_relative_rect().top_left());
}
break;
}
default:
break;
}

View file

@ -59,4 +59,5 @@ private:
Gfx::IntSize m_applet_area_size;
RefPtr<GUI::Frame> m_applet_area_container;
RefPtr<GUI::Button> m_start_button;
};