Include/Gui: Add @gui_event_loop_handle_msg() to event loop
At the moment, this implementation may look a bit unnecessarily verbose, but eventually it will allow us to be more specific in our message handling.
This commit is contained in:
parent
d242f5c395
commit
e0d6102d60
1 changed files with 65 additions and 37 deletions
102
Include/Gui.HC
102
Include/Gui.HC
|
@ -1,3 +1,67 @@
|
|||
U0 @gui_event_loop_handle_msg(IpcMessage* msg)
|
||||
{
|
||||
Window* win = NULL;
|
||||
Widget* widget = NULL;
|
||||
Bool win_repaint = FALSE;
|
||||
// Bool widget_repaint = FALSE;
|
||||
switch (msg->type) {
|
||||
case CPZ_MSG_WIN_REPAINT:
|
||||
case CPZ_MSG_WIN_MOUSE_AT:
|
||||
case CPZ_MSG_WIN_MOUSE_WHEEL:
|
||||
case CPZ_MSG_WIN_LEFT_BTN_UP:
|
||||
case CPZ_MSG_WIN_LEFT_BTN_DOWN:
|
||||
case CPZ_MSG_WIN_RIGHT_BTN_UP:
|
||||
case CPZ_MSG_WIN_RIGHT_BTN_DOWN:
|
||||
case CPZ_MSG_WIN_KEY_PRESS:
|
||||
win = msg->payload;
|
||||
@umami_set_focused_and_hovered_widget(win, msg->type);
|
||||
break;
|
||||
case CPZ_MSG_WIN_WIDGET_DESTROY:
|
||||
widget = msg->payload;
|
||||
@gui_widget_destroy(widget);
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if (!win)
|
||||
return;
|
||||
switch (msg->type) {
|
||||
case CPZ_MSG_WIN_REPAINT:
|
||||
win_repaint = TRUE;
|
||||
break;
|
||||
case CPZ_MSG_WIN_MOUSE_AT:
|
||||
case CPZ_MSG_WIN_MOUSE_WHEEL:
|
||||
case CPZ_MSG_WIN_LEFT_BTN_UP:
|
||||
case CPZ_MSG_WIN_LEFT_BTN_DOWN:
|
||||
case CPZ_MSG_WIN_RIGHT_BTN_UP:
|
||||
case CPZ_MSG_WIN_RIGHT_BTN_DOWN:
|
||||
case CPZ_MSG_WIN_KEY_PRESS:
|
||||
if (!win->explicit_repaint)
|
||||
win_repaint = TRUE;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (msg->type) {
|
||||
case CPZ_MSG_WIN_MOUSE_AT:
|
||||
if (win->callback.mouseat)
|
||||
win->callback.mouseat(win);
|
||||
break;
|
||||
case CPZ_MSG_WIN_KEY_PRESS:
|
||||
if (win->callback.keypress)
|
||||
win->callback.keypress(win, msg->i64);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (win_repaint) {
|
||||
@gui_window_repaint(win, msg->type);
|
||||
Compositor.theme.window_repaint(win, msg->type);
|
||||
if (win->callback.repaint)
|
||||
win->callback.repaint(win);
|
||||
}
|
||||
}
|
||||
|
||||
U0 @gui_event_loop(CTask* task)
|
||||
{
|
||||
Fs->ipc = task->ipc;
|
||||
|
@ -5,43 +69,7 @@ U0 @gui_event_loop(CTask* task)
|
|||
while (1) {
|
||||
msg = Ipc.MsgRecv();
|
||||
if (msg) {
|
||||
switch (msg->type) {
|
||||
// TODO:
|
||||
case CPZ_MSG_WIN_WIDGET_DESTROY:
|
||||
@gui_widget_destroy(msg->payload);
|
||||
case CPZ_MSG_WIN_MOVE_TO:
|
||||
break;
|
||||
case CPZ_MSG_WIN_KEY_PRESS:
|
||||
if (msg->payload(Window*)->callback.keypress)
|
||||
msg->payload(Window*)->callback.keypress(msg->payload, msg->i64);
|
||||
@gui_window_repaint(msg->payload, msg->type);
|
||||
Compositor.theme.window_repaint(msg->payload, msg->type);
|
||||
if (msg->payload(Window*)->callback.repaint)
|
||||
msg->payload(Window*)->callback.repaint(msg->payload);
|
||||
break;
|
||||
case CPZ_MSG_WIN_MOUSE_AT:
|
||||
if (msg->payload(Window*)->callback.mouseat)
|
||||
msg->payload(Window*)->callback.mouseat(msg->payload);
|
||||
@gui_window_repaint(msg->payload, msg->type);
|
||||
Compositor.theme.window_repaint(msg->payload, msg->type);
|
||||
if (msg->payload(Window*)->callback.repaint)
|
||||
msg->payload(Window*)->callback.repaint(msg->payload);
|
||||
break;
|
||||
case CPZ_MSG_WIN_MOUSE_WHEEL:
|
||||
case CPZ_MSG_WIN_LEFT_BTN_UP:
|
||||
case CPZ_MSG_WIN_LEFT_BTN_DOWN:
|
||||
case CPZ_MSG_WIN_RIGHT_BTN_UP:
|
||||
case CPZ_MSG_WIN_RIGHT_BTN_DOWN:
|
||||
case CPZ_MSG_WIN_REPAINT:
|
||||
@gui_window_repaint(msg->payload, msg->type);
|
||||
Compositor.theme.window_repaint(msg->payload, msg->type);
|
||||
if (msg->payload(Window*)->callback.repaint)
|
||||
msg->payload(Window*)->callback.repaint(msg->payload);
|
||||
break;
|
||||
// FIXME: add CPZ_MSG_WIN_RESIZE
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@gui_event_loop_handle_msg(msg);
|
||||
Free(msg);
|
||||
}
|
||||
Sleep(1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue