From 4ebd23bf56c997421f8a7569df7a9ca419eab126 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Mon, 3 May 2021 21:26:42 +0800 Subject: [PATCH] use MSG_TIMEOUT instead of MSG_TIMER for desktop --- src/client/client.c | 24 ++++++++++------------- src/kernel/desktop-comm.c | 11 ++++------- src/kernel/desktop-procs.c | 39 +++++++------------------------------ src/kernel/init.c | 2 +- src/kernel/message.c | 2 +- src/kernel/timer.c | 4 ++-- src/newgdi/bitmap.c | 2 +- src/server/server.c | 2 +- src/standalone/standalone.c | 2 +- 9 files changed, 28 insertions(+), 60 deletions(-) diff --git a/src/client/client.c b/src/client/client.c index 3eaff73e..54acb7b2 100644 --- a/src/client/client.c +++ b/src/client/client.c @@ -368,23 +368,19 @@ sock_error: static void check_live (void) { + static DWORD last_ticks; REQUEST req; -#if 0 /* deprecated code */ - /* Since 5.0.0, call __mg_update_tick_count instead */ - if (__mg_tick_counter != SHAREDRES_TIMER_COUNTER) { - AlertDesktopTimerEvent (); - __mg_tick_counter = SHAREDRES_TIMER_COUNTER; - } -#endif /* deprecated code */ - __mg_update_tick_count (NULL); - /* 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); + // Since 5.0.6, only send IAMLIVE if the current ticks > (last_ticks + 100) + if (__mg_tick_counter > last_ticks + 100) { + /* 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) @@ -440,7 +436,7 @@ BOOL client_IdleHandler4Client (PMSGQUEUE msg_queue, BOOL wait) Msg.wParam = (WPARAM)__mg_tick_counter; Msg.lParam = 0; Msg.time = __mg_tick_counter; - // Since 5.0.0, we do not genenrate MSG_TIMEOUT message any more. + // Since 5.0.0, we do not genenrate MSG_TIMEOUT message here. // kernel_QueueMessage (msg_queue, &Msg); old_timer = __mg_tick_counter; diff --git a/src/kernel/desktop-comm.c b/src/kernel/desktop-comm.c index 7fcdd4ed..d0c7e424 100644 --- a/src/kernel/desktop-comm.c +++ b/src/kernel/desktop-comm.c @@ -1868,7 +1868,7 @@ void GUIAPI DesktopUpdateAllWindow(void) SendMessage(HWND_DESKTOP, MSG_PAINT, 0, 0); } -static void dskOnTimer (void) +static void dskOnTimeout (void) { static DWORD uCounter = 0; static DWORD blink_counter = 0; @@ -2150,7 +2150,10 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message, break; #endif + /* Since 5.0.6, the desktop handles caret blinking in MSG_TIMEOUT + message, and the interval for this message changes to about 0.05s. */ case MSG_TIMEOUT: + dskOnTimeout (); // Since 5.0.0: MSG_IDLE messages will be generated by PeekMessage. // BroadcastMessageInThisThread (MSG_IDLE, wParam, 0); break; @@ -2184,12 +2187,6 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message, dsk_ops->mouse_handler(dt_context, message, wParam, lParam); break; - /* Since 5.0.0, the desktop only handles caret blinking in MSG_TIMER - message, and the interval for this MSG_TIMER changes to about 0.05s. */ - case MSG_TIMER: - dskOnTimer (); - break; - default: break; } diff --git a/src/kernel/desktop-procs.c b/src/kernel/desktop-procs.c index 406a470f..aa34c26d 100644 --- a/src/kernel/desktop-procs.c +++ b/src/kernel/desktop-procs.c @@ -4207,7 +4207,7 @@ static int srvSesseionMessageHandler (int message, WPARAM wParam, LPARAM lParam) } /* Since 5.0.0, we handle caret blink and auto repeat message here */ -static void dskOnTimer (void) +static void dskOnTimeout (void) { static UINT uCounter = 0; static UINT blink_counter = 0; @@ -4372,11 +4372,6 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message, break; } - case MSG_TIMEOUT: - // Since 5.0.0: MSG_IDLE messages will be generated by PeekMessage. - // BroadcastMessageInThisThread (MSG_IDLE, wParam, 0); - break; - case MSG_SRVNOTIFY: { MSG msg = {0, MSG_SRVNOTIFY, wParam, lParam}; dskBroadcastMessage (&msg); @@ -4488,32 +4483,12 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message, case MSG_BROADCASTMSG: return dskBroadcastMessage ((PMSG)lParam); - case MSG_TIMER: -#if 0 /* deprecated code */ - /* Since 5.0.0, the desktop only handles caret blinking in MSG_TIMER - message, and the interval for this MSG_TIMER changes to about 0.05s. */ - if (__mg_quiting_stage < 0) { - if (__mg_quiting_stage > _MG_QUITING_STAGE_FORCE && - __mg_quiting_stage <= _MG_QUITING_STAGE_START) { - __mg_quiting_stage--; - /* printf("try to quit %d\n", __mg_quiting_stage); */ - } - else if (__mg_quiting_stage <= _MG_QUITING_STAGE_FORCE) { - /* printf("force to quit !!!\n"); */ - } - - if (__mg_quiting_stage > _MG_QUITING_STAGE_DESKTOP - && (mgIsServer ? SERVER_HAS_NO_MAINWINDOW() : - CLIENT_HAS_NO_MAINWINDOW())) { - __mg_quiting_stage = _MG_QUITING_STAGE_DESKTOP; - } - else if (__mg_quiting_stage <= _MG_QUITING_STAGE_DESKTOP) { - PostMessage (HWND_DESKTOP, MSG_ENDSESSION, 0, 0); - } - } -#endif /* deprecated code */ - - dskOnTimer (); + case MSG_TIMEOUT: + /* Since 5.0.6, the desktop only handles caret blinking in MSG_TIMEOUT + message, and the interval for this message changes to about 0.05s. */ + // Since 5.0.0: MSG_IDLE messages will be generated by PeekMessage. + // BroadcastMessageInThisThread (MSG_IDLE, wParam, 0); + dskOnTimeout (); break; } diff --git a/src/kernel/init.c b/src/kernel/init.c index a95a9cdd..df113f47 100644 --- a/src/kernel/init.c +++ b/src/kernel/init.c @@ -112,7 +112,7 @@ static void ParseEvent (PLWEVENT lwe) Msg.message = MSG_TIMEOUT; Msg.wParam = (WPARAM)lwe->count; Msg.lParam = 0; - // Since 5.0.0, we do not genenrate MSG_TIMEOUT message any more. + // Since 5.0.0, we do not genenrate MSG_TIMEOUT message here. // QueueDeskMessage (&Msg); } else if (lwe->type == LWETYPE_KEY) { diff --git a/src/kernel/message.c b/src/kernel/message.c index 7999b5c9..dd2135e9 100644 --- a/src/kernel/message.c +++ b/src/kernel/message.c @@ -860,7 +860,7 @@ checkagain: /* handle desktop timer here */ if (pMsgQueue == __mg_dsk_msg_queue && pMsgQueue->dwState & QS_DESKTIMER) { pMsg->hwnd = HWND_DESKTOP; - pMsg->message = MSG_TIMER; + pMsg->message = MSG_TIMEOUT; pMsg->wParam = 0; pMsg->lParam = 0; diff --git a/src/kernel/timer.c b/src/kernel/timer.c index fbf276ce..5edf6979 100644 --- a/src/kernel/timer.c +++ b/src/kernel/timer.c @@ -94,7 +94,7 @@ void __mg_update_tick_count (void *data) __mg_tick_counter = __mg_os_get_time_ticks (); #endif /* not defined _MGRM_PROCESSES */ - /* Since 5.0.0, the desktop only handles caret blinking in MSG_TIMER + /* Since 5.0.0, the desktop only handles caret blinking in MSG_TIMEOUT message, and the interval for the timer of desktop changes to 0.05s. */ if (__mg_tick_counter > __mg_dsk_msg_queue->last_ticks_desktop + DESKTOP_TIMER_INERTVAL) { @@ -129,7 +129,7 @@ void __mg_update_tick_count (void *data) __mg_tick_counter += elapsed_ticks; #endif /* not defined _MGRM_PROCESSES */ - /* Since 5.0.0, the desktop only handles caret blinking in MSG_TIMER + /* Since 5.0.0, the desktop only handles caret blinking in MSG_TIMEOUT message, and the interval for the timer of desktop changes to 0.05s. */ if (__mg_tick_counter > __mg_dsk_msg_queue->last_ticks_desktop + DESKTOP_TIMER_INERTVAL) { diff --git a/src/newgdi/bitmap.c b/src/newgdi/bitmap.c index 1702aa72..8f494898 100644 --- a/src/newgdi/bitmap.c +++ b/src/newgdi/bitmap.c @@ -1266,7 +1266,7 @@ void GUIAPI BitBlt (HDC hsdc, int sx, int sy, int sw, int sh, src.x = sx; src.y = sy; src.w = sw; src.h = sh; dst.x = dx; dst.y = dy; dst.w = sw; dst.h = sh; - GAL_BlitSurface (psdc->surface, &src, pddc->surface, &dst); + GAL_UpperBlit (psdc->surface, &src, pddc->surface, &dst, dwRop); } cliprect = cliprect->next; } diff --git a/src/server/server.c b/src/server/server.c index 927449bf..58c88e03 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -125,7 +125,7 @@ static void ParseEvent (PMSGQUEUE msg_que, int event) Msg.wParam = (WPARAM)lwe.count; Msg.lParam = 0; - // Since 5.0.0, we do not genenrate MSG_TIMEOUT message any more. + // Since 5.0.0, we do not genenrate MSG_TIMEOUT message here. // kernel_QueueMessage (msg_que, &Msg); } else if (lwe.type == LWETYPE_KEY) { diff --git a/src/standalone/standalone.c b/src/standalone/standalone.c index 0d898c47..dab0a63f 100644 --- a/src/standalone/standalone.c +++ b/src/standalone/standalone.c @@ -107,7 +107,7 @@ static void ParseEvent (PMSGQUEUE msg_que, int event) Msg.wParam = (WPARAM)lwe.count; Msg.lParam = 0; - // Since 5.0.0, we do not genenrate MSG_TIMEOUT message any more. + // Since 5.0.0, we do not genenrate MSG_TIMEOUT message here. // kernel_QueueMessage (msg_que, &Msg); } else if (lwe.type == LWETYPE_KEY) {