mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:27:35 +00:00
LibGfx+LibGUI+WindowServer+Apps+Demos: Replace ToolWindows
with the RenderAbove WindowMode. This mode will ensure child windows always draw above their parents, even when focus is lost. RenderAbove modals are automatically themed the same as the old ToolWindows. Fixes ToolWindows rendering above ALL normal windows, regardless of parent. We can't rely on WindowType to create these sort of effects because of WindowManager's strict display hierarchy.
This commit is contained in:
parent
589572cfa4
commit
0d4fd4e2a6
15 changed files with 106 additions and 144 deletions
|
@ -474,7 +474,7 @@ static Gfx::IntSize calculate_minimum_size_for_window(Window const& window)
|
|||
|
||||
// NOTE: Windows with a title bar have a minimum size enforced by the system,
|
||||
// because we want to always keep their title buttons accessible.
|
||||
if (window.type() == WindowType::Normal || window.type() == WindowType::ToolWindow) {
|
||||
if (window.type() == WindowType::Normal) {
|
||||
auto palette = WindowManager::the().palette();
|
||||
|
||||
int required_width = 0;
|
||||
|
|
|
@ -16,7 +16,7 @@ void Menubar::layout_menu(Menu& menu, Gfx::IntRect window_rect)
|
|||
static constexpr auto menubar_menu_margin = 14;
|
||||
|
||||
auto& wm = WindowManager::the();
|
||||
auto menubar_rect = Gfx::WindowTheme::current().menubar_rect(Gfx::WindowTheme::WindowType::Normal, window_rect, wm.palette(), 1);
|
||||
auto menubar_rect = Gfx::WindowTheme::current().menubar_rect(Gfx::WindowTheme::WindowType::Normal, Gfx::WindowTheme::WindowMode::Other, window_rect, wm.palette(), 1);
|
||||
|
||||
int text_width = wm.font().width(Gfx::parse_ampersand_string(menu.name()));
|
||||
menu.set_rect_in_window_menubar({ m_next_menu_location.x(), 0, text_width + menubar_menu_margin, menubar_rect.height() });
|
||||
|
|
|
@ -134,10 +134,7 @@ public:
|
|||
bool is_occluded() const { return m_occluded; }
|
||||
void set_occluded(bool);
|
||||
|
||||
bool is_movable() const
|
||||
{
|
||||
return m_type == WindowType::Normal || m_type == WindowType::ToolWindow;
|
||||
}
|
||||
bool is_movable() const { return m_type == WindowType::Normal; }
|
||||
|
||||
WindowFrame& frame() { return m_frame; }
|
||||
WindowFrame const& frame() const { return m_frame; }
|
||||
|
@ -183,6 +180,7 @@ public:
|
|||
|
||||
bool is_modal() const { return m_mode != WindowMode::Modeless; }
|
||||
bool is_passive() { return m_mode == WindowMode::Passive; }
|
||||
bool is_rendering_above() { return m_mode == WindowMode::RenderAbove; }
|
||||
|
||||
bool is_blocking() const { return m_mode == WindowMode::Blocking; }
|
||||
Window* blocking_modal_window();
|
||||
|
|
|
@ -26,8 +26,6 @@ static Gfx::WindowTheme::WindowType to_theme_window_type(WindowType type)
|
|||
switch (type) {
|
||||
case WindowType::Normal:
|
||||
return Gfx::WindowTheme::WindowType::Normal;
|
||||
case WindowType::ToolWindow:
|
||||
return Gfx::WindowTheme::WindowType::ToolWindow;
|
||||
case WindowType::Notification:
|
||||
return Gfx::WindowTheme::WindowType::Notification;
|
||||
default:
|
||||
|
@ -35,6 +33,16 @@ static Gfx::WindowTheme::WindowType to_theme_window_type(WindowType type)
|
|||
}
|
||||
}
|
||||
|
||||
static Gfx::WindowTheme::WindowMode to_theme_window_mode(WindowMode mode)
|
||||
{
|
||||
switch (mode) {
|
||||
case WindowMode::RenderAbove:
|
||||
return Gfx::WindowTheme::WindowMode::RenderAbove;
|
||||
default:
|
||||
return Gfx::WindowTheme::WindowMode::Other;
|
||||
}
|
||||
}
|
||||
|
||||
static Button::Icon s_minimize_icon;
|
||||
static Button::Icon s_maximize_icon;
|
||||
static Button::Icon s_restore_icon;
|
||||
|
@ -57,7 +65,7 @@ static Gfx::IntRect frame_rect_for_window(Window& window, Gfx::IntRect const& re
|
|||
if (window.is_frameless())
|
||||
return rect;
|
||||
int menu_row_count = (window.menubar().has_menus() && window.should_show_menubar()) ? 1 : 0;
|
||||
return Gfx::WindowTheme::current().frame_rect_for_window(to_theme_window_type(window.type()), rect, WindowManager::the().palette(), menu_row_count);
|
||||
return Gfx::WindowTheme::current().frame_rect_for_window(to_theme_window_type(window.type()), to_theme_window_mode(window.mode()), rect, WindowManager::the().palette(), menu_row_count);
|
||||
}
|
||||
|
||||
WindowFrame::WindowFrame(Window& window)
|
||||
|
@ -241,22 +249,22 @@ Gfx::IntRect WindowFrame::menubar_rect() const
|
|||
{
|
||||
if (!m_window.menubar().has_menus() || !m_window.should_show_menubar())
|
||||
return {};
|
||||
return Gfx::WindowTheme::current().menubar_rect(to_theme_window_type(m_window.type()), m_window.rect(), WindowManager::the().palette(), menu_row_count());
|
||||
return Gfx::WindowTheme::current().menubar_rect(to_theme_window_type(m_window.type()), to_theme_window_mode(m_window.mode()), m_window.rect(), WindowManager::the().palette(), menu_row_count());
|
||||
}
|
||||
|
||||
Gfx::IntRect WindowFrame::titlebar_rect() const
|
||||
{
|
||||
return Gfx::WindowTheme::current().titlebar_rect(to_theme_window_type(m_window.type()), m_window.rect(), WindowManager::the().palette());
|
||||
return Gfx::WindowTheme::current().titlebar_rect(to_theme_window_type(m_window.type()), to_theme_window_mode(m_window.mode()), m_window.rect(), WindowManager::the().palette());
|
||||
}
|
||||
|
||||
Gfx::IntRect WindowFrame::titlebar_icon_rect() const
|
||||
{
|
||||
return Gfx::WindowTheme::current().titlebar_icon_rect(to_theme_window_type(m_window.type()), m_window.rect(), WindowManager::the().palette());
|
||||
return Gfx::WindowTheme::current().titlebar_icon_rect(to_theme_window_type(m_window.type()), to_theme_window_mode(m_window.mode()), m_window.rect(), WindowManager::the().palette());
|
||||
}
|
||||
|
||||
Gfx::IntRect WindowFrame::titlebar_text_rect() const
|
||||
{
|
||||
return Gfx::WindowTheme::current().titlebar_text_rect(to_theme_window_type(m_window.type()), m_window.rect(), WindowManager::the().palette());
|
||||
return Gfx::WindowTheme::current().titlebar_text_rect(to_theme_window_type(m_window.type()), to_theme_window_mode(m_window.mode()), m_window.rect(), WindowManager::the().palette());
|
||||
}
|
||||
|
||||
Gfx::WindowTheme::WindowState WindowFrame::window_state_for_theme() const
|
||||
|
@ -278,13 +286,7 @@ Gfx::WindowTheme::WindowState WindowFrame::window_state_for_theme() const
|
|||
void WindowFrame::paint_notification_frame(Gfx::Painter& painter)
|
||||
{
|
||||
auto palette = WindowManager::the().palette();
|
||||
Gfx::WindowTheme::current().paint_notification_frame(painter, m_window.rect(), palette, m_buttons.last().relative_rect());
|
||||
}
|
||||
|
||||
void WindowFrame::paint_tool_window_frame(Gfx::Painter& painter)
|
||||
{
|
||||
auto palette = WindowManager::the().palette();
|
||||
Gfx::WindowTheme::current().paint_tool_window_frame(painter, window_state_for_theme(), m_window.rect(), m_window.computed_title(), palette, leftmost_titlebar_button_rect());
|
||||
Gfx::WindowTheme::current().paint_notification_frame(painter, to_theme_window_mode(m_window.mode()), m_window.rect(), palette, m_buttons.last().relative_rect());
|
||||
}
|
||||
|
||||
void WindowFrame::paint_menubar(Gfx::Painter& painter)
|
||||
|
@ -326,7 +328,7 @@ void WindowFrame::paint_menubar(Gfx::Painter& painter)
|
|||
void WindowFrame::paint_normal_frame(Gfx::Painter& painter)
|
||||
{
|
||||
auto palette = WindowManager::the().palette();
|
||||
Gfx::WindowTheme::current().paint_normal_frame(painter, window_state_for_theme(), m_window.rect(), m_window.computed_title(), m_window.icon(), palette, leftmost_titlebar_button_rect(), menu_row_count(), m_window.is_modified());
|
||||
Gfx::WindowTheme::current().paint_normal_frame(painter, window_state_for_theme(), to_theme_window_mode(m_window.mode()), m_window.rect(), m_window.computed_title(), m_window.icon(), palette, leftmost_titlebar_button_rect(), menu_row_count(), m_window.is_modified());
|
||||
|
||||
if (m_window.menubar().has_menus() && m_window.should_show_menubar())
|
||||
paint_menubar(painter);
|
||||
|
@ -387,8 +389,6 @@ void WindowFrame::render(Screen& screen, Gfx::Painter& painter)
|
|||
paint_notification_frame(painter);
|
||||
else if (m_window.type() == WindowType::Normal)
|
||||
paint_normal_frame(painter);
|
||||
else if (m_window.type() == WindowType::ToolWindow)
|
||||
paint_tool_window_frame(painter);
|
||||
else
|
||||
return;
|
||||
|
||||
|
@ -667,7 +667,7 @@ void WindowFrame::window_rect_changed(Gfx::IntRect const& old_rect, Gfx::IntRect
|
|||
|
||||
void WindowFrame::layout_buttons()
|
||||
{
|
||||
auto button_rects = Gfx::WindowTheme::current().layout_buttons(to_theme_window_type(m_window.type()), m_window.rect(), WindowManager::the().palette(), m_buttons.size());
|
||||
auto button_rects = Gfx::WindowTheme::current().layout_buttons(to_theme_window_type(m_window.type()), to_theme_window_mode(m_window.mode()), m_window.rect(), WindowManager::the().palette(), m_buttons.size());
|
||||
for (size_t i = 0; i < m_buttons.size(); i++)
|
||||
m_buttons[i].set_relative_rect(button_rects[i]);
|
||||
}
|
||||
|
@ -792,7 +792,7 @@ void WindowFrame::handle_titlebar_mouse_event(MouseEvent const& event)
|
|||
}
|
||||
|
||||
if (event.type() == Event::MouseDown) {
|
||||
if ((m_window.type() == WindowType::Normal || m_window.type() == WindowType::ToolWindow) && event.button() == MouseButton::Secondary) {
|
||||
if (m_window.type() == WindowType::Normal && event.button() == MouseButton::Secondary) {
|
||||
auto default_action = m_window.is_maximized() ? WindowMenuDefaultAction::Restore : WindowMenuDefaultAction::Maximize;
|
||||
m_window.popup_window_menu(event.position().translated(rect().location()), default_action);
|
||||
return;
|
||||
|
@ -806,11 +806,11 @@ void WindowFrame::handle_mouse_event(MouseEvent const& event)
|
|||
{
|
||||
VERIFY(!m_window.is_fullscreen());
|
||||
|
||||
if (m_window.type() != WindowType::Normal && m_window.type() != WindowType::ToolWindow && m_window.type() != WindowType::Notification)
|
||||
if (m_window.type() != WindowType::Normal && m_window.type() != WindowType::Notification)
|
||||
return;
|
||||
|
||||
auto& wm = WindowManager::the();
|
||||
if (m_window.type() == WindowType::Normal || m_window.type() == WindowType::ToolWindow) {
|
||||
if (m_window.type() == WindowType::Normal) {
|
||||
if (event.type() == Event::MouseDown)
|
||||
wm.move_to_front_and_make_active(m_window);
|
||||
}
|
||||
|
|
|
@ -122,7 +122,6 @@ public:
|
|||
private:
|
||||
void paint_notification_frame(Gfx::Painter&);
|
||||
void paint_normal_frame(Gfx::Painter&);
|
||||
void paint_tool_window_frame(Gfx::Painter&);
|
||||
void paint_menubar(Gfx::Painter&);
|
||||
MultiScaleBitmaps const* shadow_bitmap() const;
|
||||
Gfx::IntRect inflated_for_shadow(Gfx::IntRect const&) const;
|
||||
|
|
|
@ -577,7 +577,7 @@ void WindowManager::tell_wms_current_window_stack_changed()
|
|||
|
||||
static bool window_type_has_title(WindowType type)
|
||||
{
|
||||
return type == WindowType::Normal || type == WindowType::ToolWindow;
|
||||
return type == WindowType::Normal;
|
||||
}
|
||||
|
||||
void WindowManager::notify_modified_changed(Window& window)
|
||||
|
@ -649,7 +649,7 @@ bool WindowManager::pick_new_active_window(Window* previous_active)
|
|||
Window* first_candidate = nullptr;
|
||||
|
||||
for_each_visible_window_from_front_to_back([&](Window& candidate) {
|
||||
if (candidate.type() != WindowType::Normal && candidate.type() != WindowType::ToolWindow)
|
||||
if (candidate.type() != WindowType::Normal)
|
||||
return IterationDecision::Continue;
|
||||
if (candidate.is_destroyed())
|
||||
return IterationDecision::Continue;
|
||||
|
@ -1246,7 +1246,7 @@ void WindowManager::process_mouse_event_for_window(HitTestResult& result, MouseE
|
|||
}
|
||||
|
||||
if (event.type() == Event::MouseDown) {
|
||||
if (window.type() == WindowType::Normal || window.type() == WindowType::ToolWindow)
|
||||
if (window.type() == WindowType::Normal)
|
||||
move_to_front_and_make_active(window);
|
||||
else if (window.type() == WindowType::Desktop)
|
||||
set_active_window(&window);
|
||||
|
@ -1420,7 +1420,6 @@ Gfx::IntRect WindowManager::arena_rect_for_type(Screen& screen, WindowType type)
|
|||
case WindowType::Desktop:
|
||||
return Screen::bounding_rect();
|
||||
case WindowType::Normal:
|
||||
case WindowType::ToolWindow:
|
||||
return desktop_rect(screen);
|
||||
case WindowType::Menu:
|
||||
case WindowType::WindowSwitcher:
|
||||
|
@ -1797,7 +1796,7 @@ bool WindowManager::is_active_window_or_accessory(Window& window) const
|
|||
|
||||
static bool window_type_can_become_active(WindowType type)
|
||||
{
|
||||
return type == WindowType::Normal || type == WindowType::ToolWindow || type == WindowType::Desktop;
|
||||
return type == WindowType::Normal || type == WindowType::Desktop;
|
||||
}
|
||||
|
||||
void WindowManager::restore_active_input_window(Window* window)
|
||||
|
@ -2193,7 +2192,7 @@ void WindowManager::set_always_on_top(Window& window, bool always_on_top)
|
|||
Gfx::IntPoint WindowManager::get_recommended_window_position(Gfx::IntPoint const& desired)
|
||||
{
|
||||
// FIXME: Find a better source for the width and height to shift by.
|
||||
Gfx::IntPoint shift(8, Gfx::WindowTheme::current().titlebar_height(Gfx::WindowTheme::WindowType::Normal, palette()) + 10);
|
||||
Gfx::IntPoint shift(8, Gfx::WindowTheme::current().titlebar_height(Gfx::WindowTheme::WindowType::Normal, Gfx::WindowTheme::WindowMode::Other, palette()) + 10);
|
||||
|
||||
Window const* overlap_window = nullptr;
|
||||
current_window_stack().for_each_visible_window_of_type_from_front_to_back(WindowType::Normal, [&](Window& window) {
|
||||
|
@ -2209,7 +2208,7 @@ Gfx::IntPoint WindowManager::get_recommended_window_position(Gfx::IntPoint const
|
|||
point = overlap_window->position() + shift;
|
||||
point = { point.x() % screen.width(),
|
||||
(point.y() >= (screen.height() - (screen.is_main_screen() ? TaskbarWindow::taskbar_height() : 0)))
|
||||
? Gfx::WindowTheme::current().titlebar_height(Gfx::WindowTheme::WindowType::Normal, palette())
|
||||
? Gfx::WindowTheme::current().titlebar_height(Gfx::WindowTheme::WindowType::Normal, Gfx::WindowTheme::WindowMode::Other, palette())
|
||||
: point.y() };
|
||||
} else {
|
||||
point = desired;
|
||||
|
|
|
@ -312,7 +312,6 @@ public:
|
|||
{
|
||||
switch (window_type) {
|
||||
case WindowType::Normal:
|
||||
case WindowType::ToolWindow:
|
||||
case WindowType::Tooltip:
|
||||
return false;
|
||||
default:
|
||||
|
@ -516,8 +515,6 @@ inline IterationDecision WindowManager::for_each_visible_window_from_back_to_fro
|
|||
return IterationDecision::Break;
|
||||
if (for_each_window.template operator()<WindowType::Normal>() == IterationDecision::Break)
|
||||
return IterationDecision::Break;
|
||||
if (for_each_window.template operator()<WindowType::ToolWindow>() == IterationDecision::Break)
|
||||
return IterationDecision::Break;
|
||||
if (for_each_window.template operator()<WindowType::Taskbar>() == IterationDecision::Break)
|
||||
return IterationDecision::Break;
|
||||
if (for_each_window.template operator()<WindowType::AppletArea>() == IterationDecision::Break)
|
||||
|
@ -561,8 +558,6 @@ inline IterationDecision WindowManager::for_each_visible_window_from_front_to_ba
|
|||
return IterationDecision::Break;
|
||||
if (for_each_window.template operator()<WindowType::Taskbar>() == IterationDecision::Break)
|
||||
return IterationDecision::Break;
|
||||
if (for_each_window.template operator()<WindowType::ToolWindow>() == IterationDecision::Break)
|
||||
return IterationDecision::Break;
|
||||
if (for_each_window.template operator()<WindowType::Normal>() == IterationDecision::Break)
|
||||
return IterationDecision::Break;
|
||||
return for_each_window.template operator()<WindowType::Desktop>();
|
||||
|
|
|
@ -18,7 +18,6 @@ enum class WindowType {
|
|||
Applet,
|
||||
Notification,
|
||||
Desktop,
|
||||
ToolWindow,
|
||||
AppletArea,
|
||||
_Count
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue