WindowServer: Flash modal window when clicking on window blocked by it

This makes window modality a bit more discoverable by indicating to the
user that the modal window must be closed before mouse interaction is
possible in the clicked window.
This commit is contained in:
Andreas Kling 2021-01-01 01:10:53 +01:00
parent 2e8db6560f
commit af7800d947
Notes: sideshowbarker 2024-07-19 00:17:34 +09:00
3 changed files with 31 additions and 0 deletions

View file

@ -160,6 +160,10 @@ Gfx::IntRect WindowFrame::title_bar_text_rect() const
Gfx::WindowTheme::WindowState WindowFrame::window_state_for_theme() const
{
auto& wm = WindowManager::the();
if (m_flash_timer && m_flash_timer->is_active())
return m_flash_counter & 1 ? Gfx::WindowTheme::WindowState::Active : Gfx::WindowTheme::WindowState::Inactive;
if (&m_window == wm.m_highlight_window)
return Gfx::WindowTheme::WindowState::Highlighted;
if (&m_window == wm.m_move_window)
@ -360,4 +364,19 @@ void WindowFrame::on_mouse_event(const MouseEvent& event)
if (m_window.is_resizable() && event.type() == Event::MouseDown && event.button() == MouseButton::Left)
wm.start_window_resize(m_window, event.translated(rect().location()));
}
void WindowFrame::start_flash_animation()
{
if (!m_flash_timer) {
m_flash_timer = Core::Timer::construct(100, [this] {
ASSERT(m_flash_counter);
invalidate_title_bar();
if (!--m_flash_counter)
m_flash_timer->stop();
});
}
m_flash_counter = 8;
m_flash_timer->start();
}
}