mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 22:07:36 +00:00
WindowServer: Add support for default MenuItem
This allows marking a MenuItem as a default action, e.g. in a context menu for an action that reflects what e.g. a double click would perform. Also enhance the window menu to mark the close action as the default, and when double clicked perform that action. Fixes #1289
This commit is contained in:
parent
684b04e02a
commit
fc4e01a3c9
10 changed files with 194 additions and 32 deletions
|
@ -62,6 +62,16 @@ enum class PopupMenuItem {
|
|||
Maximize,
|
||||
};
|
||||
|
||||
enum class WindowMenuDefaultAction {
|
||||
None = 0,
|
||||
BasedOnWindowState,
|
||||
Close,
|
||||
Minimize,
|
||||
Unminimize,
|
||||
Maximize,
|
||||
Restore
|
||||
};
|
||||
|
||||
class Window final : public Core::Object
|
||||
, public InlineLinkedListNode<Window> {
|
||||
C_OBJECT(Window)
|
||||
|
@ -70,7 +80,8 @@ public:
|
|||
Window(Core::Object&, WindowType);
|
||||
virtual ~Window() override;
|
||||
|
||||
void popup_window_menu(const Gfx::IntPoint&);
|
||||
void popup_window_menu(const Gfx::IntPoint&, WindowMenuDefaultAction);
|
||||
void window_menu_activate_default();
|
||||
void request_close();
|
||||
|
||||
unsigned wm_event_mask() const { return m_wm_event_mask; }
|
||||
|
@ -240,6 +251,7 @@ private:
|
|||
void update_menu_item_text(PopupMenuItem item);
|
||||
void update_menu_item_enabled(PopupMenuItem item);
|
||||
void add_child_window(Window&);
|
||||
void ensure_window_menu();
|
||||
|
||||
ClientConnection* m_client { nullptr };
|
||||
|
||||
|
@ -283,6 +295,7 @@ private:
|
|||
RefPtr<Menu> m_window_menu;
|
||||
MenuItem* m_window_menu_minimize_item { nullptr };
|
||||
MenuItem* m_window_menu_maximize_item { nullptr };
|
||||
MenuItem* m_window_menu_close_item { nullptr };
|
||||
int m_minimize_animation_step { -1 };
|
||||
int m_progress { -1 };
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue