aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorMarvin Borner2021-05-22 12:36:08 +0200
committerMarvin Borner2021-05-22 12:36:08 +0200
commit0bf64a113f3d3baa110b362fd6a215ef29182671 (patch)
tree5af1c862945741aa2a56b0e72cc25c845eaac12a /libs
parent93174e167a6aa313fca43f4cb0e9b975e1618468 (diff)
Enabled window ping-pong checks
Diffstat (limited to 'libs')
-rw-r--r--libs/libgui/gui.c23
-rw-r--r--libs/libgui/msg.c8
-rw-r--r--libs/libgui/msg.h5
3 files changed, 17 insertions, 19 deletions
diff --git a/libs/libgui/gui.c b/libs/libgui/gui.c
index dab00a6..b53c366 100644
--- a/libs/libgui/gui.c
+++ b/libs/libgui/gui.c
@@ -572,11 +572,9 @@ INLINE void gui_new_window(u32 *id)
void gui_redraw_window_only(u32 id)
{
- struct message_redraw_window msg = { .id = id, .header.state = MSG_NEED_ANSWER };
+ struct message_redraw_window msg = { .id = id };
gui_connect_wm();
- if (msg_send(GUI_REDRAW_WINDOW, &msg, sizeof(msg)) > 0 &&
- msg_receive(&msg, sizeof(msg)) > 0 &&
- msg.header.type == (GUI_REDRAW_WINDOW | MSG_SUCCESS))
+ if (msg_send(GUI_REDRAW_WINDOW, &msg, sizeof(msg)) > 0)
return;
gui_error(EINVAL);
@@ -620,26 +618,25 @@ static void gui_destroy_windows(void)
* Message handling
*/
-static void gui_handle_ping(struct message_ping *msg)
+static void gui_handle_ping_window(struct message_ping_window *msg)
{
if (msg->ping != MSG_PING_SEND)
gui_error(EINVAL);
- msg->header.type |= MSG_SUCCESS;
msg->ping = MSG_PING_RECV;
if (msg_connect_conn(msg->header.bus.conn) == EOK &&
- msg_send(GUI_PING, msg, sizeof(msg)) == EOK)
+ msg_send(msg->header.type | MSG_SUCCESS, msg, sizeof(*msg)) > 0)
return;
- gui_error(errno);
+ gui_error(EINVAL);
}
static void gui_handle_mouse(struct message_mouse *msg)
{
if (msg->header.state == MSG_NEED_ANSWER) {
if (msg_connect_conn(msg->header.bus.conn) == EOK &&
- msg_send(msg->header.type | MSG_SUCCESS, msg, sizeof(msg)) == EOK)
+ msg_send(msg->header.type | MSG_SUCCESS, msg, sizeof(*msg)) > 0)
return;
- gui_error(errno);
+ gui_error(EINVAL);
}
struct gui_widget widget = { 0 };
@@ -698,12 +695,12 @@ void gui_loop(void)
while (gui_connect_wm(), msg_receive(msg, 4096) > 0) {
struct message_header *head = (void *)msg;
switch (head->type) {
- case GUI_PING:
- gui_handle_ping((void *)msg);
- break;
case GUI_MOUSE:
gui_handle_mouse((void *)msg);
break;
+ case GUI_PING_WINDOW:
+ gui_handle_ping_window((void *)msg);
+ break;
case GUI_DESTROY_WINDOW:
gui_handle_destroy_window((void *)msg);
break;
diff --git a/libs/libgui/msg.c b/libs/libgui/msg.c
index 70a77a1..eda4c34 100644
--- a/libs/libgui/msg.c
+++ b/libs/libgui/msg.c
@@ -11,14 +11,14 @@
res msg_connect_bus(const char *bus, u32 *conn)
{
res ret = io_control(IO_BUS, IOCTL_BUS_CONNECT_BUS, bus, conn);
- assert(ret == EOK && *conn);
- return EOK;
+ /* assert(ret == EOK && *conn); */
+ return ret;
}
res msg_connect_conn(u32 conn)
{
res ret = io_control(IO_BUS, IOCTL_BUS_CONNECT_CONN, conn);
- assert(ret == EOK);
+ /* assert(ret == EOK); */
return ret;
}
@@ -29,7 +29,7 @@ res msg_send(enum message_type type, void *data, u32 size)
header->magic = MSG_MAGIC;
header->type = type;
res ret = io_write(IO_BUS, (u8 *)data + sizeof(struct bus_header), 0, size);
- assert(ret >= EOK);
+ /* assert(ret >= EOK); */
return ret;
}
diff --git a/libs/libgui/msg.h b/libs/libgui/msg.h
index 4bffb74..71491c4 100644
--- a/libs/libgui/msg.h
+++ b/libs/libgui/msg.h
@@ -26,8 +26,9 @@ struct message_header {
enum message_state state;
};
-struct message_ping {
+struct message_ping_window {
struct message_header header;
+ u32 id;
u32 ping;
};
@@ -64,7 +65,7 @@ struct message_mouse {
};
enum message_type {
- GUI_PING,
+ GUI_PING_WINDOW,
GUI_NEW_WINDOW,
GUI_REDRAW_WINDOW,
GUI_DESTROY_WINDOW,