diff options
author | Spencer Dixon <spencercdixon@gmail.com> | 2021-06-24 09:24:26 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-28 16:29:02 +0200 |
commit | cef2f55a8b9b59175ff5debc95596a867f265c42 (patch) | |
tree | f2c18129b9bc20fe8296255307f8601adc32b007 | |
parent | b9d1ef99ded6a0003b761210f4b08c99527966af (diff) | |
download | serenity-cef2f55a8b9b59175ff5debc95596a867f265c42.zip |
Taskbar: Move 'Assistant' Desktop::AppFile to member for quicker access
We care about showing 'Assistant' app as fast as possible when the
hotkey is pressed. In order to do that, we can parse the `.af` file
ahead of time and have it ready to use.
-rw-r--r-- | Userland/Services/Taskbar/TaskbarWindow.cpp | 9 | ||||
-rw-r--r-- | Userland/Services/Taskbar/TaskbarWindow.h | 3 |
2 files changed, 8 insertions, 4 deletions
diff --git a/Userland/Services/Taskbar/TaskbarWindow.cpp b/Userland/Services/Taskbar/TaskbarWindow.cpp index 50a2ae7be6..aaa095b921 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.cpp +++ b/Userland/Services/Taskbar/TaskbarWindow.cpp @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2021, Spencer Dixon <spencercdixon@gmail.com> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -10,7 +11,6 @@ #include <AK/Debug.h> #include <LibCore/ConfigFile.h> #include <LibCore/StandardPaths.h> -#include <LibDesktop/AppFile.h> #include <LibGUI/BoxLayout.h> #include <LibGUI/Button.h> #include <LibGUI/Desktop.h> @@ -87,6 +87,9 @@ TaskbarWindow::TaskbarWindow(NonnullRefPtr<GUI::Menu> start_menu) m_applet_area_container->set_frame_shadow(Gfx::FrameShadow::Sunken); main_widget.add<Taskbar::ClockWidget>(); + + auto af_path = String::formatted("{}/{}", Desktop::AppFile::APP_FILES_DIRECTORY, "Assistant.af"); + m_assistant_app_file = Desktop::AppFile::open(af_path); } TaskbarWindow::~TaskbarWindow() @@ -329,9 +332,7 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event) break; } case GUI::Event::WM_SuperSpaceKeyPressed: { - auto af_path = String::formatted("{}/{}", Desktop::AppFile::APP_FILES_DIRECTORY, "Assistant.af"); - auto af = Desktop::AppFile::open(af_path); - if (!af->spawn()) + if (!m_assistant_app_file->spawn()) warnln("failed to spawn 'Assistant' when requested via Super+Space"); break; } diff --git a/Userland/Services/Taskbar/TaskbarWindow.h b/Userland/Services/Taskbar/TaskbarWindow.h index d6c170718c..3ba5a36795 100644 --- a/Userland/Services/Taskbar/TaskbarWindow.h +++ b/Userland/Services/Taskbar/TaskbarWindow.h @@ -7,6 +7,7 @@ #pragma once #include "WindowList.h" +#include <LibDesktop/AppFile.h> #include <LibGUI/Widget.h> #include <LibGUI/Window.h> @@ -40,4 +41,6 @@ private: Gfx::IntSize m_applet_area_size; RefPtr<GUI::Frame> m_applet_area_container; RefPtr<GUI::Button> m_start_button; + + RefPtr<Desktop::AppFile> m_assistant_app_file; }; |