1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:17:34 +00:00

LibGUI+WindowServer: Add option to hide a widow's close button

This allows windows to be closed only programatically, and not from e.g.
the user clicking the X button on the window frame.
This commit is contained in:
Timothy Flynn 2021-10-21 09:09:58 -04:00 committed by Linus Groh
parent 8a57885494
commit 176155c695
8 changed files with 29 additions and 7 deletions

View file

@ -87,12 +87,13 @@ Window::Window(Core::Object& parent, WindowType type)
WindowManager::the().add_window(*this);
}
Window::Window(ClientConnection& client, WindowType window_type, int window_id, bool modal, bool minimizable, bool frameless, bool resizable, bool fullscreen, bool accessory, Window* parent_window)
Window::Window(ClientConnection& client, WindowType window_type, int window_id, bool modal, bool minimizable, bool closeable, bool frameless, bool resizable, bool fullscreen, bool accessory, Window* parent_window)
: Core::Object(&client)
, m_client(&client)
, m_type(window_type)
, m_modal(modal)
, m_minimizable(minimizable)
, m_closeable(closeable)
, m_frameless(frameless)
, m_resizable(resizable)
, m_fullscreen(fullscreen)
@ -282,6 +283,8 @@ void Window::update_window_menu_items()
m_window_menu_maximize_item->set_text(m_maximized ? "&Restore" : "Ma&ximize");
m_window_menu_maximize_item->set_enabled(m_resizable);
m_window_menu_close_item->set_enabled(m_closeable);
m_window_menu_move_item->set_enabled(m_minimized_state == WindowMinimizedState::None && !m_maximized && !m_fullscreen);
if (m_window_menu_pin_item)
@ -335,6 +338,14 @@ void Window::set_minimizable(bool minimizable)
// TODO: Hide/show (or alternatively change enabled state of) window minimize button dynamically depending on value of m_minimizable
}
void Window::set_closeable(bool closeable)
{
if (m_closeable == closeable)
return;
m_closeable = closeable;
update_window_menu_items();
}
void Window::set_taskbar_rect(const Gfx::IntRect& rect)
{
m_taskbar_rect = rect;