diff --git a/MenuApplets/Clock/main.cpp b/MenuApplets/Clock/main.cpp index 42c2fc19669..c8e51a0da67 100644 --- a/MenuApplets/Clock/main.cpp +++ b/MenuApplets/Clock/main.cpp @@ -46,7 +46,7 @@ private: tm->tm_hour, tm->tm_min, tm->tm_sec); - + GPainter painter(*this); painter.fill_rect(event.rect(), palette().window()); painter.draw_text(event.rect(), time_text, Font::default_font(), TextAlignment::Center, palette().window_text()); @@ -69,7 +69,7 @@ int main(int argc, char** argv) window->set_window_type(GWindowType::MenuApplet); auto widget = ClockWidget::construct(); - + window->resize(widget->get_width(), 16); window->set_main_widget(widget); window->show(); diff --git a/Servers/WindowServer/WSClientConnection.cpp b/Servers/WindowServer/WSClientConnection.cpp index 4328ce63af2..01860856661 100644 --- a/Servers/WindowServer/WSClientConnection.cpp +++ b/Servers/WindowServer/WSClientConnection.cpp @@ -85,7 +85,7 @@ OwnPtr WSClientConnection::handle(const Wi return nullptr; } auto& menubar = *(*it).value; - WSWindowManager::the().close_menubar(menubar); + WSWindowManager::the().menu_manager().close_menubar(menubar); m_menubars.remove(it); return make(); } diff --git a/Servers/WindowServer/WSMenu.cpp b/Servers/WindowServer/WSMenu.cpp index d6de3f68526..210a247b109 100644 --- a/Servers/WindowServer/WSMenu.cpp +++ b/Servers/WindowServer/WSMenu.cpp @@ -127,7 +127,7 @@ WSWindow& WSMenu::ensure_menu_window() void WSMenu::draw() { auto palette = WSWindowManager::the().palette(); - m_theme_index_at_last_paint = WSWindowManager::the().theme_index(); + m_theme_index_at_last_paint = WSWindowManager::the().menu_manager().theme_index(); ASSERT(menu_window()); ASSERT(menu_window()->backing_store()); @@ -279,7 +279,7 @@ void WSMenu::close() void WSMenu::redraw_if_theme_changed() { - if (m_theme_index_at_last_paint != WSWindowManager::the().theme_index()) + if (m_theme_index_at_last_paint != WSWindowManager::the().menu_manager().theme_index()) redraw(); } diff --git a/Servers/WindowServer/WSMenuItem.cpp b/Servers/WindowServer/WSMenuItem.cpp index fe56a74ee37..108d543c2f5 100644 --- a/Servers/WindowServer/WSMenuItem.cpp +++ b/Servers/WindowServer/WSMenuItem.cpp @@ -48,5 +48,5 @@ WSMenu* WSMenuItem::submenu() ASSERT(is_submenu()); if (m_menu.client()) return m_menu.client()->find_menu_by_id(m_submenu_id); - return WSWindowManager::the().find_internal_menu_by_id(m_submenu_id); + return WSWindowManager::the().menu_manager().find_internal_menu_by_id(m_submenu_id); } diff --git a/Servers/WindowServer/WSMenuManager.cpp b/Servers/WindowServer/WSMenuManager.cpp index f40b5715271..af321246674 100644 --- a/Servers/WindowServer/WSMenuManager.cpp +++ b/Servers/WindowServer/WSMenuManager.cpp @@ -1,14 +1,145 @@ +#include +#include +#include #include +#include #include #include #include #include #include +//#define DEBUG_MENUS + WSMenuManager::WSMenuManager() { m_username = getlogin(); m_needs_window_resize = true; + + HashTable seen_app_categories; + { + CDirIterator dt("/res/apps", CDirIterator::SkipDots); + while (dt.has_next()) { + auto af_name = dt.next_path(); + auto af_path = String::format("/res/apps/%s", af_name.characters()); + auto af = CConfigFile::open(af_path); + if (!af->has_key("App", "Name") || !af->has_key("App", "Executable")) + continue; + auto app_name = af->read_entry("App", "Name"); + auto app_executable = af->read_entry("App", "Executable"); + auto app_category = af->read_entry("App", "Category"); + auto app_icon_path = af->read_entry("Icons", "16x16"); + m_apps.append({ app_executable, app_name, app_icon_path, app_category }); + seen_app_categories.set(app_category); + } + } + + Vector sorted_app_categories; + for (auto& category : seen_app_categories) + sorted_app_categories.append(category); + quick_sort(sorted_app_categories.begin(), sorted_app_categories.end(), [](auto& a, auto& b) { return a < b; }); + + u8 system_menu_name[] = { 0xc3, 0xb8, 0 }; + m_system_menu = WSMenu::construct(nullptr, -1, String((const char*)system_menu_name)); + + // First we construct all the necessary app category submenus. + for (const auto& category : sorted_app_categories) { + + if (m_app_category_menus.contains(category)) + continue; + auto category_menu = WSMenu::construct(nullptr, 5000 + m_app_category_menus.size(), category); + category_menu->on_item_activation = [this](auto& item) { + if (item.identifier() >= 1 && item.identifier() <= 1u + m_apps.size() - 1) { + if (fork() == 0) { + const auto& bin = m_apps[item.identifier() - 1].executable; + execl(bin.characters(), bin.characters(), nullptr); + ASSERT_NOT_REACHED(); + } + } + }; + auto item = make(*m_system_menu, -1, category); + item->set_submenu_id(category_menu->menu_id()); + m_system_menu->add_item(move(item)); + m_app_category_menus.set(category, move(category_menu)); + } + + // Then we create and insert all the app menu items into the right place. + int app_identifier = 1; + for (const auto& app : m_apps) { + auto parent_menu = m_app_category_menus.get(app.category).value_or(*m_system_menu); + parent_menu->add_item(make(*m_system_menu, app_identifier++, app.name, String(), true, false, false, load_png(app.icon_path))); + } + + m_system_menu->add_item(make(*m_system_menu, WSMenuItem::Separator)); + + m_themes_menu = WSMenu::construct(nullptr, 9000, "Themes"); + + auto themes_menu_item = make(*m_system_menu, 100, "Themes"); + themes_menu_item->set_submenu_id(m_themes_menu->menu_id()); + m_system_menu->add_item(move(themes_menu_item)); + + { + CDirIterator dt("/res/themes", CDirIterator::SkipDots); + while (dt.has_next()) { + auto theme_name = dt.next_path(); + auto theme_path = String::format("/res/themes/%s", theme_name.characters()); + m_themes.append({ FileSystemPath(theme_name).title(), theme_path }); + } + quick_sort(m_themes.begin(), m_themes.end(), [](auto& a, auto& b) { return a.name < b.name; }); + } + + { + int theme_identifier = 9000; + for (auto& theme : m_themes) { + m_themes_menu->add_item(make(*m_themes_menu, theme_identifier++, theme.name)); + } + } + + m_themes_menu->on_item_activation = [this](WSMenuItem& item) { + auto& theme = m_themes[(int)item.identifier() - 9000]; + WSWindowManager::the().update_theme(theme.path, theme.name); + ++m_theme_index; + }; + + m_system_menu->add_item(make(*m_system_menu, WSMenuItem::Separator)); + m_system_menu->add_item(make(*m_system_menu, 100, "Reload WM Config File")); + + m_system_menu->add_item(make(*m_system_menu, WSMenuItem::Separator)); + m_system_menu->add_item(make(*m_system_menu, 200, "About...", String(), true, false, false, load_png("/res/icons/16x16/ladybug.png"))); + m_system_menu->add_item(make(*m_system_menu, WSMenuItem::Separator)); + m_system_menu->add_item(make(*m_system_menu, 300, "Shutdown...")); + m_system_menu->on_item_activation = [this](WSMenuItem& item) { + if (item.identifier() >= 1 && item.identifier() <= 1u + m_apps.size() - 1) { + if (fork() == 0) { + const auto& bin = m_apps[item.identifier() - 1].executable; + execl(bin.characters(), bin.characters(), nullptr); + ASSERT_NOT_REACHED(); + } + } + switch (item.identifier()) { + case 100: + WSWindowManager::the().reload_config(true); + break; + case 200: + if (fork() == 0) { + execl("/bin/About", "/bin/About", nullptr); + ASSERT_NOT_REACHED(); + } + return; + case 300: + if (fork() == 0) { + execl("/bin/SystemDialog", "/bin/SystemDialog", "--shutdown", nullptr); + ASSERT_NOT_REACHED(); + } + return; + } +#ifdef DEBUG_MENUS + dbg() << "WSMenu 1 item activated: " << item.text(); +#endif + }; + + // NOTE: This ensures that the system menu has the correct dimensions. + set_current_menubar(nullptr); } WSMenuManager::~WSMenuManager() @@ -68,7 +199,7 @@ void WSMenuManager::draw() painter.fill_rect(menubar_rect, palette.window()); painter.draw_line({ 0, menubar_rect.bottom() }, { menubar_rect.right(), menubar_rect.bottom() }, palette.threed_shadow1()); int index = 0; - wm.for_each_active_menubar_menu([&](WSMenu& menu) { + for_each_active_menubar_menu([&](WSMenu& menu) { Color text_color = palette.window_text(); if (is_open(menu)) { painter.fill_rect(menu.rect_in_menubar(), palette.menu_selection()); @@ -115,7 +246,7 @@ void WSMenuManager::event(CEvent& event) if (event.type() == WSEvent::MouseMove || event.type() == WSEvent::MouseUp || event.type() == WSEvent::MouseDown || event.type() == WSEvent::MouseWheel) { auto& mouse_event = static_cast(event); - WSWindowManager::the().for_each_active_menubar_menu([&](WSMenu& menu) { + for_each_active_menubar_menu([&](WSMenu& menu) { if (menu.rect_in_menubar().contains(mouse_event.position())) { handle_menu_mouse_event(menu, mouse_event); return IterationDecision::Break; @@ -137,10 +268,9 @@ void WSMenuManager::event(CEvent& event) void WSMenuManager::handle_menu_mouse_event(WSMenu& menu, const WSMouseEvent& event) { - auto& wm = WSWindowManager::the(); bool is_hover_with_any_menu_open = event.type() == WSMouseEvent::MouseMove && !m_open_menu_stack.is_empty() - && (m_open_menu_stack.first()->menubar() || m_open_menu_stack.first() == wm.system_menu()); + && (m_open_menu_stack.first()->menubar() || m_open_menu_stack.first() == system_menu()); bool is_mousedown_with_left_button = event.type() == WSMouseEvent::MouseDown && event.button() == MouseButton::Left; bool should_open_menu = &menu != m_current_menu && (is_hover_with_any_menu_open || is_mousedown_with_left_button); @@ -171,7 +301,7 @@ void WSMenuManager::set_needs_window_resize() m_needs_window_resize = true; } -void WSMenuManager::close_all_menus_from_client(Badge, WSClientConnection & client) +void WSMenuManager::close_all_menus_from_client(Badge, WSClientConnection& client) { if (m_open_menu_stack.is_empty()) return; @@ -300,3 +430,42 @@ Rect WSMenuManager::menubar_rect() const { return { 0, 0, WSScreen::the().rect().width(), 18 }; } + +WSMenu* WSMenuManager::find_internal_menu_by_id(int menu_id) +{ + if (m_themes_menu->menu_id() == menu_id) + return m_themes_menu.ptr(); + for (auto& it : m_app_category_menus) { + if (menu_id == it.value->menu_id()) + return it.value; + } + return nullptr; +} + +void WSMenuManager::set_current_menubar(WSMenuBar* menubar) +{ + if (menubar) + m_current_menubar = menubar->make_weak_ptr(); + else + m_current_menubar = nullptr; +#ifdef DEBUG_MENUS + dbg() << "[WM] Current menubar is now " << menubar; +#endif + Point next_menu_location { WSMenuManager::menubar_menu_margin() / 2, 0 }; + int index = 0; + for_each_active_menubar_menu([&](WSMenu& menu) { + int text_width = index == 1 ? Font::default_bold_font().width(menu.name()) : Font::default_font().width(menu.name()); + menu.set_rect_in_menubar({ next_menu_location.x() - WSMenuManager::menubar_menu_margin() / 2, 0, text_width + WSMenuManager::menubar_menu_margin(), menubar_rect().height() - 1 }); + menu.set_text_rect_in_menubar({ next_menu_location, { text_width, menubar_rect().height() } }); + next_menu_location.move_by(menu.rect_in_menubar().width(), 0); + ++index; + return IterationDecision::Continue; + }); + refresh(); +} + +void WSMenuManager::close_menubar(WSMenuBar& menubar) +{ + if (current_menubar() == &menubar) + set_current_menubar(nullptr); +} diff --git a/Servers/WindowServer/WSMenuManager.h b/Servers/WindowServer/WSMenuManager.h index 3fb68f133e0..26cd609800a 100644 --- a/Servers/WindowServer/WSMenuManager.h +++ b/Servers/WindowServer/WSMenuManager.h @@ -1,6 +1,8 @@ #pragma once #include "WSMenu.h" +#include "WSMenuBar.h" +#include #include #include @@ -29,6 +31,10 @@ public: WSMenu* current_menu() { return m_current_menu.ptr(); } void set_current_menu(WSMenu*, bool is_submenu = false); + WSMenuBar* current_menubar() { return m_current_menubar.ptr(); } + void set_current_menubar(WSMenuBar*); + void close_menubar(WSMenuBar&); + void close_bar(); void close_everyone(); void close_everyone_not_in_lineage(WSMenu&); @@ -40,6 +46,20 @@ public: void remove_applet(WSWindow&); void invalidate_applet(const WSWindow&, const Rect&); + Color menu_selection_color() const { return m_menu_selection_color; } + WSMenu* system_menu() { return m_system_menu; } + WSMenu* find_internal_menu_by_id(int); + int theme_index() const { return m_theme_index; } + + template + void for_each_active_menubar_menu(Callback callback) + { + if (callback(*system_menu()) == IterationDecision::Break) + return; + if (m_current_menubar) + m_current_menubar->for_each_menu(callback); + } + private: void close_menus(const Vector&); @@ -64,4 +84,28 @@ private: bool m_needs_window_resize { false }; bool m_bar_open { false }; + + struct AppMetadata { + String executable; + String name; + String icon_path; + String category; + }; + Vector m_apps; + + HashMap> m_app_category_menus; + + struct ThemeMetadata { + String name; + String path; + }; + + RefPtr m_system_menu; + Color m_menu_selection_color; + + int m_theme_index { 0 }; + Vector m_themes; + RefPtr m_themes_menu; + + WeakPtr m_current_menubar; }; diff --git a/Servers/WindowServer/WSWindowManager.cpp b/Servers/WindowServer/WSWindowManager.cpp index e0ec62a80b2..8b4d62a5393 100644 --- a/Servers/WindowServer/WSWindowManager.cpp +++ b/Servers/WindowServer/WSWindowManager.cpp @@ -6,16 +6,11 @@ #include "WSMenuItem.h" #include "WSScreen.h" #include "WSWindow.h" -#include #include -#include #include #include -#include -#include #include #include -#include #include #include #include @@ -29,7 +24,6 @@ #include //#define DEBUG_COUNTERS -//#define DEBUG_MENUS //#define RESIZE_DEBUG //#define MOVE_DEBUG //#define DOUBLECLICK_DEBUG @@ -49,148 +43,6 @@ WSWindowManager::WSWindowManager(const PaletteImpl& palette) reload_config(false); - HashTable seen_app_categories; - { - CDirIterator dt("/res/apps", CDirIterator::SkipDots); - while (dt.has_next()) { - auto af_name = dt.next_path(); - auto af_path = String::format("/res/apps/%s", af_name.characters()); - auto af = CConfigFile::open(af_path); - if (!af->has_key("App", "Name") || !af->has_key("App", "Executable")) - continue; - auto app_name = af->read_entry("App", "Name"); - auto app_executable = af->read_entry("App", "Executable"); - auto app_category = af->read_entry("App", "Category"); - auto app_icon_path = af->read_entry("Icons", "16x16"); - m_apps.append({ app_executable, app_name, app_icon_path, app_category }); - seen_app_categories.set(app_category); - } - } - - Vector sorted_app_categories; - for (auto& category : seen_app_categories) - sorted_app_categories.append(category); - quick_sort(sorted_app_categories.begin(), sorted_app_categories.end(), [](auto& a, auto& b) { return a < b; }); - - u8 system_menu_name[] = { 0xc3, 0xb8, 0 }; - m_system_menu = WSMenu::construct(nullptr, -1, String((const char*)system_menu_name)); - - // First we construct all the necessary app category submenus. - for (const auto& category : sorted_app_categories) { - - if (m_app_category_menus.contains(category)) - continue; - auto category_menu = WSMenu::construct(nullptr, 5000 + m_app_category_menus.size(), category); - category_menu->on_item_activation = [this](auto& item) { - if (item.identifier() >= 1 && item.identifier() <= 1u + m_apps.size() - 1) { - if (fork() == 0) { - const auto& bin = m_apps[item.identifier() - 1].executable; - execl(bin.characters(), bin.characters(), nullptr); - ASSERT_NOT_REACHED(); - } - } - }; - auto item = make(*m_system_menu, -1, category); - item->set_submenu_id(category_menu->menu_id()); - m_system_menu->add_item(move(item)); - m_app_category_menus.set(category, move(category_menu)); - } - - // Then we create and insert all the app menu items into the right place. - int app_identifier = 1; - for (const auto& app : m_apps) { - auto parent_menu = m_app_category_menus.get(app.category).value_or(*m_system_menu); - parent_menu->add_item(make(*m_system_menu, app_identifier++, app.name, String(), true, false, false, load_png(app.icon_path))); - } - - m_system_menu->add_item(make(*m_system_menu, WSMenuItem::Separator)); - - m_themes_menu = WSMenu::construct(nullptr, 9000, "Themes"); - - auto themes_menu_item = make(*m_system_menu, 100, "Themes"); - themes_menu_item->set_submenu_id(m_themes_menu->menu_id()); - m_system_menu->add_item(move(themes_menu_item)); - - { - CDirIterator dt("/res/themes", CDirIterator::SkipDots); - while (dt.has_next()) { - auto theme_name = dt.next_path(); - auto theme_path = String::format("/res/themes/%s", theme_name.characters()); - m_themes.append({ FileSystemPath(theme_name).title(), theme_path }); - } - quick_sort(m_themes.begin(), m_themes.end(), [](auto& a, auto& b) { return a.name < b.name; }); - } - - { - int theme_identifier = 9000; - for (auto& theme : m_themes) { - m_themes_menu->add_item(make(*m_themes_menu, theme_identifier++, theme.name)); - } - } - - m_themes_menu->on_item_activation = [this](WSMenuItem& item) { - auto& theme = m_themes[(int)item.identifier() - 9000]; - auto new_theme = load_system_theme(theme.path); - ASSERT(new_theme); - set_system_theme(*new_theme); - m_palette = PaletteImpl::create_with_shared_buffer(*new_theme); - HashTable notified_clients; - for_each_window([&](WSWindow& window) { - if (window.client()) { - if (!notified_clients.contains(window.client())) { - window.client()->post_message(WindowClient::UpdateSystemTheme(current_system_theme_buffer_id())); - notified_clients.set(window.client()); - } - } - return IterationDecision::Continue; - }); - ++m_theme_index; - auto wm_config = CConfigFile::get_for_app("WindowManager"); - wm_config->write_entry("Theme", "Name", theme.name); - wm_config->sync(); - invalidate(); - }; - - m_system_menu->add_item(make(*m_system_menu, WSMenuItem::Separator)); - m_system_menu->add_item(make(*m_system_menu, 100, "Reload WM Config File")); - - m_system_menu->add_item(make(*m_system_menu, WSMenuItem::Separator)); - m_system_menu->add_item(make(*m_system_menu, 200, "About...", String(), true, false, false, load_png("/res/icons/16x16/ladybug.png"))); - m_system_menu->add_item(make(*m_system_menu, WSMenuItem::Separator)); - m_system_menu->add_item(make(*m_system_menu, 300, "Shutdown...")); - m_system_menu->on_item_activation = [this](WSMenuItem& item) { - if (item.identifier() >= 1 && item.identifier() <= 1u + m_apps.size() - 1) { - if (fork() == 0) { - const auto& bin = m_apps[item.identifier() - 1].executable; - execl(bin.characters(), bin.characters(), nullptr); - ASSERT_NOT_REACHED(); - } - } - switch (item.identifier()) { - case 100: - reload_config(true); - break; - case 200: - if (fork() == 0) { - execl("/bin/About", "/bin/About", nullptr); - ASSERT_NOT_REACHED(); - } - return; - case 300: - if (fork() == 0) { - execl("/bin/SystemDialog", "/bin/SystemDialog", "--shutdown", nullptr); - ASSERT_NOT_REACHED(); - } - return; - } -#ifdef DEBUG_MENUS - dbg() << "WSMenu 1 item activated: " << item.text(); -#endif - }; - - // NOTE: This ensures that the system menu has the correct dimensions. - set_current_menubar(nullptr); - m_menu_manager.setup(); invalidate(); @@ -277,28 +129,6 @@ void WSWindowManager::set_resolution(int width, int height) } } -void WSWindowManager::set_current_menubar(WSMenuBar* menubar) -{ - if (menubar) - m_current_menubar = menubar->make_weak_ptr(); - else - m_current_menubar = nullptr; -#ifdef DEBUG_MENUS - dbg() << "[WM] Current menubar is now " << menubar; -#endif - Point next_menu_location { WSMenuManager::menubar_menu_margin() / 2, 0 }; - int index = 0; - for_each_active_menubar_menu([&](WSMenu& menu) { - int text_width = index == 1 ? Font::default_bold_font().width(menu.name()) : font().width(menu.name()); - menu.set_rect_in_menubar({ next_menu_location.x() - WSMenuManager::menubar_menu_margin() / 2, 0, text_width + WSMenuManager::menubar_menu_margin(), menubar_rect().height() - 1 }); - menu.set_text_rect_in_menubar({ next_menu_location, { text_width, menubar_rect().height() } }); - next_menu_location.move_by(menu.rect_in_menubar().width(), 0); - ++index; - return IterationDecision::Continue; - }); - m_menu_manager.refresh(); -} - void WSWindowManager::add_window(WSWindow& window) { m_windows_in_order.append(&window); @@ -1205,10 +1035,10 @@ void WSWindowManager::set_active_window(WSWindow* window) auto* client = window->client(); ASSERT(client); - set_current_menubar(client->app_menubar()); + menu_manager().set_current_menubar(client->app_menubar()); tell_wm_listeners_window_state_changed(*m_active_window); } else { - set_current_menubar(nullptr); + menu_manager().set_current_menubar(nullptr); } if (active_client != previously_active_client) { @@ -1267,12 +1097,6 @@ void WSWindowManager::invalidate(const WSWindow& window, const Rect& rect) invalidate(inner_rect); } -void WSWindowManager::close_menubar(WSMenuBar& menubar) -{ - if (current_menubar() == &menubar) - set_current_menubar(nullptr); -} - const WSClientConnection* WSWindowManager::active_client() const { if (m_active_window) @@ -1283,8 +1107,7 @@ const WSClientConnection* WSWindowManager::active_client() const void WSWindowManager::notify_client_changed_app_menubar(WSClientConnection& client) { if (active_client() == &client) - set_current_menubar(client.app_menubar()); - m_menu_manager.refresh(); + menu_manager().set_current_menubar(client.app_menubar()); } const WSCursor& WSWindowManager::active_cursor() const @@ -1359,17 +1182,6 @@ Rect WSWindowManager::maximized_window_rect(const WSWindow& window) const return rect; } -WSMenu* WSWindowManager::find_internal_menu_by_id(int menu_id) -{ - if (m_themes_menu->menu_id() == menu_id) - return m_themes_menu.ptr(); - for (auto& it : m_app_category_menus) { - if (menu_id == it.value->menu_id()) - return it.value; - } - return nullptr; -} - void WSWindowManager::start_dnd_drag(WSClientConnection& client, const String& text, GraphicsBitmap* bitmap, const String& data_type, const String& data) { ASSERT(!m_dnd_client); @@ -1400,3 +1212,25 @@ Rect WSWindowManager::dnd_rect() const auto location = WSCompositor::the().current_cursor_rect().center().translated(8, 8); return Rect(location, { width, height }).inflated(4, 4); } + +void WSWindowManager::update_theme(String theme_path, String theme_name) +{ + auto new_theme = load_system_theme(theme_path); + ASSERT(new_theme); + set_system_theme(*new_theme); + m_palette = PaletteImpl::create_with_shared_buffer(*new_theme); + HashTable notified_clients; + for_each_window([&](WSWindow& window) { + if (window.client()) { + if (!notified_clients.contains(window.client())) { + window.client()->post_message(WindowClient::UpdateSystemTheme(current_system_theme_buffer_id())); + notified_clients.set(window.client()); + } + } + return IterationDecision::Continue; + }); + auto wm_config = CConfigFile::get_for_app("WindowManager"); + wm_config->write_entry("Theme", "Name", theme_name); + wm_config->sync(); + invalidate(); +} diff --git a/Servers/WindowServer/WSWindowManager.h b/Servers/WindowServer/WSWindowManager.h index 855aad4ee36..f8e01f13617 100644 --- a/Servers/WindowServer/WSWindowManager.h +++ b/Servers/WindowServer/WSWindowManager.h @@ -20,7 +20,6 @@ #include class WSScreen; -class WSMenuBar; class WSMouseEvent; class WSClientWantsToPaintMessage; class WSWindow; @@ -99,9 +98,6 @@ public: const WSMenuManager& menu_manager() const { return m_menu_manager; } Rect menubar_rect() const; - WSMenuBar* current_menubar() { return m_current_menubar.ptr(); } - void set_current_menubar(WSMenuBar*); - WSMenu* system_menu() { return m_system_menu.ptr(); } const WSCursor& active_cursor() const; const WSCursor& arrow_cursor() const { return *m_arrow_cursor; } @@ -126,9 +122,6 @@ public: const Font& menu_font() const; const Font& app_menu_font() const; - void close_menu(WSMenu&); - void close_menubar(WSMenuBar&); - Color menu_selection_color() const { return m_menu_selection_color; } int menubar_menu_margin() const; void set_resolution(int width, int height); @@ -156,18 +149,7 @@ public: const WSWindow* active_fullscreen_window() const { return (m_active_window && m_active_window->is_fullscreen()) ? m_active_window : nullptr; } WSWindow* active_fullscreen_window() { return (m_active_window && m_active_window->is_fullscreen()) ? m_active_window : nullptr; } - template - void for_each_active_menubar_menu(Callback callback) - { - if (callback(*m_system_menu) == IterationDecision::Break) - return; - if (m_current_menubar) - m_current_menubar->for_each_menu(callback); - } - - WSMenu* find_internal_menu_by_id(int); - - int theme_index() const { return m_theme_index; } + void update_theme(String theme_path, String theme_name); private: NonnullRefPtr get_cursor(const String& name); @@ -276,11 +258,6 @@ private: u8 m_keyboard_modifiers { 0 }; - RefPtr m_system_menu; - Color m_menu_selection_color; - WeakPtr m_current_menubar; - - int m_theme_index { 0 }; WSWindowSwitcher m_switcher; WSMenuManager m_menu_manager; @@ -292,22 +269,6 @@ private: RefPtr m_wm_config; - struct AppMetadata { - String executable; - String name; - String icon_path; - String category; - }; - Vector m_apps; - HashMap> m_app_category_menus; - - struct ThemeMetadata { - String name; - String path; - }; - Vector m_themes; - RefPtr m_themes_menu; - WeakPtr m_dnd_client; String m_dnd_text; String m_dnd_data_type;