From 4de7e09c22747becd349836a825c43d2ca35d057 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Wed, 5 May 2021 16:43:52 +0800 Subject: [PATCH] Add MSG_WAKEUP_CLIENT to wake up a specific client --- include/window.h | 3 +++ src/client/client.c | 49 +++++++++++++++++++++++--------------------- src/kernel/desktop.c | 4 ++++ 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/include/window.h b/include/window.h index c52fda63..914be13d 100644 --- a/include/window.h +++ b/include/window.h @@ -2997,6 +2997,9 @@ typedef struct _WINMASKINFO { /* Since 5.0.0: for calculating the default position */ #define MSG_CALC_POSITION 0x014B +/* Since 5.0.6: for waking up the client */ +#define MSG_WAKEUP_CLIENT 0x014C + /** * \def MSG_DOESNEEDIME * \brief Send to a window to query whether the window needs to open diff --git a/src/client/client.c b/src/client/client.c index 0ddf2a1d..a68acaf6 100644 --- a/src/client/client.c +++ b/src/client/client.c @@ -154,9 +154,31 @@ int GUIAPI GetSockFD2Server (void) #include "debug.h" +static void check_live (BOOL woken) +{ + static DWORD last_ticks; + REQUEST req; + + __mg_update_tick_count (NULL); + + // Since 5.0.6, only send IAMLIVE if the current ticks > (last_ticks + 100) + if (woken || __mg_tick_counter > last_ticks + 100) { + last_ticks = __mg_tick_counter; + + /* Tell server that I am live */ + req.id = REQID_IAMLIVE; + req.data = &__mg_tick_counter; + req.len_data = sizeof (unsigned int); + ClientRequest (&req, NULL, 0); + } +} + static void process_socket_message (MSG *msg) { - if (msg->message == MSG_UPDATECLIWIN && + if (msg->message == MSG_WAKEUP_CLIENT) { + check_live (TRUE); + } + else if (msg->message == MSG_UPDATECLIWIN && __mg_client_check_hwnd (msg->hwnd, __mg_client_id)) { __mg_update_window (msg->hwnd, LOSWORD(msg->wParam), HISWORD(msg->wParam), @@ -366,25 +388,6 @@ sock_error: return -1; } -static void check_live (void) -{ - static DWORD last_ticks; - REQUEST req; - - __mg_update_tick_count (NULL); - - // Since 5.0.6, only send IAMLIVE if the current ticks > (last_ticks + 100) - if (__mg_tick_counter > last_ticks + 100) { - last_ticks = __mg_tick_counter; - - /* Tell server that I am live */ - req.id = REQID_IAMLIVE; - req.data = &__mg_tick_counter; - req.len_data = sizeof (unsigned int); - ClientRequest (&req, NULL, 0); - } -} - BOOL client_IdleHandler4Client (PMSGQUEUE msg_queue, BOOL wait) { static DWORD old_timer; @@ -396,7 +399,7 @@ BOOL client_IdleHandler4Client (PMSGQUEUE msg_queue, BOOL wait) struct timeval sel_timeout; MSG Msg; - check_live (); + check_live (FALSE); /* rset gets modified each time around */ rset = msg_queue->rfdset; @@ -431,7 +434,7 @@ BOOL client_IdleHandler4Client (PMSGQUEUE msg_queue, BOOL wait) static unsigned int old_mouse_move_serial = 0xdeadbeef; int flag = 0, mouse_x = -1, mouse_y = -1, buttons = -1; - check_live (); + check_live (FALSE); if (wait && (__mg_tick_counter - old_timer) >= repeat_timeout) { Msg.hwnd = HWND_DESKTOP; Msg.message = MSG_TIMEOUT; @@ -505,7 +508,7 @@ BOOL client_IdleHandler4Client (PMSGQUEUE msg_queue, BOOL wait) /* go through registered listen fds */ n += __mg_kernel_check_listen_fds (msg_queue, &rset, wsetptr, esetptr); - check_live (); + check_live (FALSE); if (n > 0) { old_timer = __mg_tick_counter; diff --git a/src/kernel/desktop.c b/src/kernel/desktop.c index 4b0a1231..9bddab2b 100644 --- a/src/kernel/desktop.c +++ b/src/kernel/desktop.c @@ -473,6 +473,8 @@ static int update_client_window (ZORDERNODE* znode, const RECT* rc) if (znode->cli != 0) { if (rc) { + MSG msg = {0, MSG_WAKEUP_CLIENT, 0, 0, __mg_tick_counter}; + _DBG_PRINTF ("Update window (%s): %d, %d, %d x %d\n", znode->caption, rc->left, rc->top, RECTWP(rc), RECTHP(rc)); @@ -484,7 +486,9 @@ static int update_client_window (ZORDERNODE* znode, const RECT* rc) else { GetBoundRect (&znode->dirty_rc, &znode->dirty_rc, rc); } + mgClients [znode->cli].has_dirty = TRUE; + __mg_send2client (&msg, mgClients + znode->cli); } } else