mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
Let WindowManager send out events for WindowBecame{Active,Inactive}
This commit is contained in:
parent
4775fd88e3
commit
39e236d346
3 changed files with 14 additions and 20 deletions
|
@ -35,9 +35,12 @@ public:
|
|||
KeyUp,
|
||||
Timer,
|
||||
DeferredDestroy,
|
||||
WindowBecameInactive,
|
||||
WindowBecameActive,
|
||||
};
|
||||
|
||||
Event() { }
|
||||
explicit Event(Type type) : m_type(type) { }
|
||||
~Event() { }
|
||||
|
||||
Type type() const { return m_type; }
|
||||
|
@ -48,9 +51,6 @@ public:
|
|||
bool isKeyEvent() const { return m_type == KeyUp || m_type == KeyDown; }
|
||||
bool isPaintEvent() const { return m_type == Paint; }
|
||||
|
||||
protected:
|
||||
explicit Event(Type type) : m_type(type) { }
|
||||
|
||||
private:
|
||||
Type m_type { Invalid };
|
||||
};
|
||||
|
|
|
@ -66,10 +66,9 @@ dword* FrameBufferSDL::scanline(int y)
|
|||
void FrameBufferSDL::blit(const Point& position, GraphicsBitmap& bitmap)
|
||||
{
|
||||
Rect dst_rect(position, bitmap.size());
|
||||
|
||||
printf("blit at %d,%d %dx%d\n", dst_rect.x(), dst_rect.y(), dst_rect.width(), dst_rect.height());
|
||||
//printf("blit at %d,%d %dx%d\n", dst_rect.x(), dst_rect.y(), dst_rect.width(), dst_rect.height());
|
||||
dst_rect.intersect(rect());
|
||||
printf(" -> intersection %d,%d %dx%d\n", dst_rect.x(), dst_rect.y(), dst_rect.width(), dst_rect.height());
|
||||
//printf(" -> intersection %d,%d %dx%d\n", dst_rect.x(), dst_rect.y(), dst_rect.width(), dst_rect.height());
|
||||
|
||||
for (int y = 0; y < dst_rect.height(); ++y) {
|
||||
auto* framebuffer_scanline = scanline(position.y() + y);
|
||||
|
|
|
@ -282,10 +282,11 @@ void WindowManager::recompose()
|
|||
auto& framebuffer = FrameBufferSDL::the();
|
||||
m_rootWidget->repaint(m_rootWidget->rect());
|
||||
for (auto* window = m_windows_in_order.head(); window; window = window->next()) {
|
||||
if (!window->backing())
|
||||
continue;
|
||||
paintWindowFrame(*window);
|
||||
if (m_dragWindow.ptr() == window)
|
||||
continue;
|
||||
ASSERT(window->backing());
|
||||
framebuffer.blit(window->position(), *window->backing());
|
||||
}
|
||||
framebuffer.flush();
|
||||
|
@ -324,19 +325,13 @@ void WindowManager::setActiveWindow(Window* window)
|
|||
if (window == m_activeWindow.ptr())
|
||||
return;
|
||||
|
||||
auto* previouslyActiveWindow = m_activeWindow.ptr();
|
||||
|
||||
if (auto* previously_active_window = m_activeWindow.ptr())
|
||||
EventLoop::main().postEvent(previously_active_window, make<Event>(Event::WindowBecameInactive));
|
||||
m_activeWindow = window->makeWeakPtr();
|
||||
if (m_activeWindow)
|
||||
EventLoop::main().postEvent(m_activeWindow.ptr(), make<Event>(Event::WindowBecameActive));
|
||||
|
||||
if (previouslyActiveWindow) {
|
||||
paintWindowFrame(*previouslyActiveWindow);
|
||||
previouslyActiveWindow->repaint();
|
||||
}
|
||||
|
||||
if (m_activeWindow) {
|
||||
paintWindowFrame(*m_activeWindow);
|
||||
m_activeWindow->repaint();
|
||||
}
|
||||
recompose();
|
||||
}
|
||||
|
||||
bool WindowManager::isVisible(Window& window) const
|
||||
|
|
Loading…
Add table
Reference in a new issue