mirror of
https://github.com/RGBCube/serenity
synced 2025-07-19 20:17:40 +00:00
WindowServer: Rename the two painting phases.
Work now happens in terms of two messages: - WM_ClientWantsToPaint - WM_ClientFinishedPaint This feels fairly obvious compared to the old Paint/Invalidate.
This commit is contained in:
parent
244d5bcce1
commit
9fa8d4e22f
6 changed files with 39 additions and 39 deletions
|
@ -145,7 +145,7 @@ int Process::gui$invalidate_window(int window_id, const GUI_Rect* a_rect)
|
||||||
Rect rect;
|
Rect rect;
|
||||||
if (a_rect)
|
if (a_rect)
|
||||||
rect = *a_rect;
|
rect = *a_rect;
|
||||||
WSMessageLoop::the().post_message(&window, make<WSPaintEvent>(rect));
|
WSMessageLoop::the().post_message(&window, make<WSClientWantsToPaintMessage>(rect));
|
||||||
WSMessageLoop::the().server_process().request_wakeup();
|
WSMessageLoop::the().server_process().request_wakeup();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -169,7 +169,7 @@ int Process::gui$notify_paint_finished(int window_id, const GUI_Rect* a_rect)
|
||||||
Rect rect;
|
Rect rect;
|
||||||
if (a_rect)
|
if (a_rect)
|
||||||
rect = *a_rect;
|
rect = *a_rect;
|
||||||
WSMessageLoop::the().post_message(&window, make<WSWindowInvalidationEvent>(rect));
|
WSMessageLoop::the().post_message(&window, make<WSClientFinishedPaintMessage>(rect));
|
||||||
WSMessageLoop::the().server_process().request_wakeup();
|
WSMessageLoop::the().server_process().request_wakeup();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ int Process::gui$set_window_title(int window_id, const char* title, size_t size)
|
||||||
return -EBADWINDOW;
|
return -EBADWINDOW;
|
||||||
auto& window = *(*it).value;
|
auto& window = *(*it).value;
|
||||||
String new_title(title, size);
|
String new_title(title, size);
|
||||||
WSMessageLoop::the().post_message(&window, make<WSSetWindowTitle>(move(new_title)));
|
WSMessageLoop::the().post_message(&window, make<WSSetWindowTitleMessage>(move(new_title)));
|
||||||
WSMessageLoop::the().server_process().request_wakeup();
|
WSMessageLoop::the().server_process().request_wakeup();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -240,7 +240,7 @@ int Process::gui$set_window_rect(int window_id, const GUI_Rect* rect)
|
||||||
return -EBADWINDOW;
|
return -EBADWINDOW;
|
||||||
auto& window = *(*it).value;
|
auto& window = *(*it).value;
|
||||||
Rect new_rect = *rect;
|
Rect new_rect = *rect;
|
||||||
WSMessageLoop::the().post_message(&window, make<WSSetWindowRect>(new_rect));
|
WSMessageLoop::the().post_message(&window, make<WSSetWindowRectMessage>(new_rect));
|
||||||
WSMessageLoop::the().server_process().request_wakeup();
|
WSMessageLoop::the().server_process().request_wakeup();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,18 +9,18 @@ class WSMessage {
|
||||||
public:
|
public:
|
||||||
enum Type {
|
enum Type {
|
||||||
Invalid = 0,
|
Invalid = 0,
|
||||||
Paint,
|
WM_ClientWantsToPaint,
|
||||||
|
WM_ClientFinishedPaint,
|
||||||
|
WM_SetWindowTitle,
|
||||||
|
WM_SetWindowRect,
|
||||||
|
WM_DeferredCompose,
|
||||||
MouseMove,
|
MouseMove,
|
||||||
MouseDown,
|
MouseDown,
|
||||||
MouseUp,
|
MouseUp,
|
||||||
KeyDown,
|
KeyDown,
|
||||||
KeyUp,
|
KeyUp,
|
||||||
WM_Compose,
|
|
||||||
WM_Invalidate,
|
|
||||||
WindowActivated,
|
WindowActivated,
|
||||||
WindowDeactivated,
|
WindowDeactivated,
|
||||||
WM_SetWindowTitle,
|
|
||||||
WM_SetWindowRect,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
WSMessage() { }
|
WSMessage() { }
|
||||||
|
@ -31,16 +31,16 @@ public:
|
||||||
|
|
||||||
bool is_mouse_event() const { return m_type == MouseMove || m_type == MouseDown || m_type == MouseUp; }
|
bool is_mouse_event() const { return m_type == MouseMove || m_type == MouseDown || m_type == MouseUp; }
|
||||||
bool is_key_event() const { return m_type == KeyUp || m_type == KeyDown; }
|
bool is_key_event() const { return m_type == KeyUp || m_type == KeyDown; }
|
||||||
bool is_paint_event() const { return m_type == Paint; }
|
bool is_paint_event() const { return m_type == WM_ClientWantsToPaint; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type m_type { Invalid };
|
Type m_type { Invalid };
|
||||||
};
|
};
|
||||||
|
|
||||||
class WSWindowInvalidationEvent final : public WSMessage {
|
class WSClientFinishedPaintMessage final : public WSMessage {
|
||||||
public:
|
public:
|
||||||
explicit WSWindowInvalidationEvent(const Rect& rect = Rect())
|
explicit WSClientFinishedPaintMessage(const Rect& rect = Rect())
|
||||||
: WSMessage(WSMessage::WM_Invalidate)
|
: WSMessage(WSMessage::WM_ClientFinishedPaint)
|
||||||
, m_rect(rect)
|
, m_rect(rect)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,9 @@ private:
|
||||||
Rect m_rect;
|
Rect m_rect;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WSSetWindowTitle final : public WSMessage {
|
class WSSetWindowTitleMessage final : public WSMessage {
|
||||||
public:
|
public:
|
||||||
explicit WSSetWindowTitle(String&& title)
|
explicit WSSetWindowTitleMessage(String&& title)
|
||||||
: WSMessage(WSMessage::WM_SetWindowTitle)
|
: WSMessage(WSMessage::WM_SetWindowTitle)
|
||||||
, m_title(move(title))
|
, m_title(move(title))
|
||||||
{
|
{
|
||||||
|
@ -64,9 +64,9 @@ private:
|
||||||
String m_title;
|
String m_title;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WSSetWindowRect final : public WSMessage {
|
class WSSetWindowRectMessage final : public WSMessage {
|
||||||
public:
|
public:
|
||||||
explicit WSSetWindowRect(const Rect& rect)
|
explicit WSSetWindowRectMessage(const Rect& rect)
|
||||||
: WSMessage(WSMessage::WM_SetWindowRect)
|
: WSMessage(WSMessage::WM_SetWindowRect)
|
||||||
, m_rect(rect)
|
, m_rect(rect)
|
||||||
{
|
{
|
||||||
|
@ -78,10 +78,10 @@ private:
|
||||||
Rect m_rect;
|
Rect m_rect;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WSPaintEvent final : public WSMessage {
|
class WSClientWantsToPaintMessage final : public WSMessage {
|
||||||
public:
|
public:
|
||||||
explicit WSPaintEvent(const Rect& rect = Rect())
|
explicit WSClientWantsToPaintMessage(const Rect& rect = Rect())
|
||||||
: WSMessage(WSMessage::Paint)
|
: WSMessage(WSMessage::WM_ClientWantsToPaint)
|
||||||
, m_rect(rect)
|
, m_rect(rect)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,14 +79,14 @@ void WSMessageLoop::post_message(WSMessageReceiver* receiver, OwnPtr<WSMessage>&
|
||||||
dbgprintf("WSMessageLoop::post_message: {%u} << receiver=%p, message=%p\n", m_queued_messages.size(), receiver, message.ptr());
|
dbgprintf("WSMessageLoop::post_message: {%u} << receiver=%p, message=%p\n", m_queued_messages.size(), receiver, message.ptr());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (message->type() == WSMessage::WM_Invalidate) {
|
if (message->type() == WSMessage::WM_ClientFinishedPaint) {
|
||||||
auto& invalidation_message = static_cast<WSWindowInvalidationEvent&>(*message);
|
auto& invalidation_message = static_cast<WSClientFinishedPaintMessage&>(*message);
|
||||||
for (auto& queued_message : m_queued_messages) {
|
for (auto& queued_message : m_queued_messages) {
|
||||||
if (receiver == queued_message.receiver && queued_message.message->type() == WSMessage::WM_Invalidate) {
|
if (receiver == queued_message.receiver && queued_message.message->type() == WSMessage::WM_ClientFinishedPaint) {
|
||||||
auto& queued_invalidation_message = static_cast<WSWindowInvalidationEvent&>(*queued_message.message);
|
auto& queued_invalidation_message = static_cast<WSClientFinishedPaintMessage&>(*queued_message.message);
|
||||||
if (queued_invalidation_message.rect().is_empty() || queued_invalidation_message.rect().contains(invalidation_message.rect())) {
|
if (queued_invalidation_message.rect().is_empty() || queued_invalidation_message.rect().contains(invalidation_message.rect())) {
|
||||||
#ifdef WSEVENTLOOP_DEBUG
|
#ifdef WSEVENTLOOP_DEBUG
|
||||||
dbgprintf("Swallow WM_Invalidate\n");
|
dbgprintf("Swallow WM_ClientFinishedPaint\n");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -94,14 +94,14 @@ void WSMessageLoop::post_message(WSMessageReceiver* receiver, OwnPtr<WSMessage>&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message->type() == WSMessage::Paint) {
|
if (message->type() == WSMessage::WM_ClientWantsToPaint) {
|
||||||
auto& invalidation_message = static_cast<WSPaintEvent&>(*message);
|
auto& invalidation_message = static_cast<WSClientWantsToPaintMessage&>(*message);
|
||||||
for (auto& queued_message : m_queued_messages) {
|
for (auto& queued_message : m_queued_messages) {
|
||||||
if (receiver == queued_message.receiver && queued_message.message->type() == WSMessage::Paint) {
|
if (receiver == queued_message.receiver && queued_message.message->type() == WSMessage::WM_ClientWantsToPaint) {
|
||||||
auto& queued_invalidation_message = static_cast<WSPaintEvent&>(*queued_message.message);
|
auto& queued_invalidation_message = static_cast<WSClientWantsToPaintMessage&>(*queued_message.message);
|
||||||
if (queued_invalidation_message.rect().is_empty() || queued_invalidation_message.rect().contains(invalidation_message.rect())) {
|
if (queued_invalidation_message.rect().is_empty() || queued_invalidation_message.rect().contains(invalidation_message.rect())) {
|
||||||
#ifdef WSEVENTLOOP_DEBUG
|
#ifdef WSEVENTLOOP_DEBUG
|
||||||
dbgprintf("Swallow WM_Paint\n");
|
dbgprintf("Swallow WM_ClientWantsToPaint\n");
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,9 +60,9 @@ void WSWindow::on_message(WSMessage& message)
|
||||||
gui_event.window_id = window_id();
|
gui_event.window_id = window_id();
|
||||||
|
|
||||||
switch (message.type()) {
|
switch (message.type()) {
|
||||||
case WSMessage::Paint:
|
case WSMessage::WM_ClientWantsToPaint:
|
||||||
gui_event.type = GUI_Event::Type::Paint;
|
gui_event.type = GUI_Event::Type::Paint;
|
||||||
gui_event.paint.rect = static_cast<WSPaintEvent&>(message).rect();
|
gui_event.paint.rect = static_cast<WSClientWantsToPaintMessage&>(message).rect();
|
||||||
break;
|
break;
|
||||||
case WSMessage::MouseMove:
|
case WSMessage::MouseMove:
|
||||||
gui_event.type = GUI_Event::Type::MouseMove;
|
gui_event.type = GUI_Event::Type::MouseMove;
|
||||||
|
@ -90,14 +90,14 @@ void WSWindow::on_message(WSMessage& message)
|
||||||
gui_event.key.ctrl = static_cast<WSKeyEvent&>(message).ctrl();
|
gui_event.key.ctrl = static_cast<WSKeyEvent&>(message).ctrl();
|
||||||
gui_event.key.shift = static_cast<WSKeyEvent&>(message).shift();
|
gui_event.key.shift = static_cast<WSKeyEvent&>(message).shift();
|
||||||
break;
|
break;
|
||||||
case WSMessage::WM_Invalidate:
|
case WSMessage::WM_ClientFinishedPaint:
|
||||||
WSWindowManager::the().invalidate(*this, static_cast<WSWindowInvalidationEvent&>(message).rect());
|
WSWindowManager::the().invalidate(*this, static_cast<WSClientFinishedPaintMessage&>(message).rect());
|
||||||
return;
|
return;
|
||||||
case WSMessage::WM_SetWindowRect:
|
case WSMessage::WM_SetWindowRect:
|
||||||
set_rect(static_cast<WSSetWindowRect&>(message).rect());
|
set_rect(static_cast<WSSetWindowRectMessage&>(message).rect());
|
||||||
return;
|
return;
|
||||||
case WSMessage::WM_SetWindowTitle:
|
case WSMessage::WM_SetWindowTitle:
|
||||||
set_title(static_cast<WSSetWindowTitle&>(message).title());
|
set_title(static_cast<WSSetWindowTitleMessage&>(message).title());
|
||||||
return;
|
return;
|
||||||
case WSMessage::WindowActivated:
|
case WSMessage::WindowActivated:
|
||||||
gui_event.type = GUI_Event::Type::WindowActivated;
|
gui_event.type = GUI_Event::Type::WindowActivated;
|
||||||
|
|
|
@ -401,7 +401,7 @@ void WSWindowManager::on_message(WSMessage& message)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.type() == WSMessage::WM_Compose) {
|
if (message.type() == WSMessage::WM_DeferredCompose) {
|
||||||
m_pending_compose_event = false;
|
m_pending_compose_event = false;
|
||||||
compose();
|
compose();
|
||||||
return;
|
return;
|
||||||
|
@ -454,7 +454,7 @@ void WSWindowManager::invalidate(const Rect& a_rect)
|
||||||
|
|
||||||
if (!m_pending_compose_event) {
|
if (!m_pending_compose_event) {
|
||||||
ASSERT_INTERRUPTS_ENABLED();
|
ASSERT_INTERRUPTS_ENABLED();
|
||||||
WSMessageLoop::the().post_message(this, make<WSMessage>(WSMessage::WM_Compose));
|
WSMessageLoop::the().post_message(this, make<WSMessage>(WSMessage::WM_DeferredCompose));
|
||||||
m_pending_compose_event = true;
|
m_pending_compose_event = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
|
|
||||||
class WSScreen;
|
class WSScreen;
|
||||||
class WSMouseEvent;
|
class WSMouseEvent;
|
||||||
class WSPaintEvent;
|
class WSClientWantsToPaintMessage;
|
||||||
class WSWindow;
|
class WSWindow;
|
||||||
class CharacterBitmap;
|
class CharacterBitmap;
|
||||||
class GraphicsBitmap;
|
class GraphicsBitmap;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue