From 6290779a02500f174cb8123da53d4987b3275642 Mon Sep 17 00:00:00 2001 From: VincentWei Date: Sun, 21 Jan 2018 18:09:51 +0800 Subject: [PATCH] tune the implementation of tracing message --- include/window.h | 6 +++--- src/include/msgstr.h | 8 +++++--- src/include/timer.h | 2 +- src/kernel/desktop-comm.c | 6 +++--- src/kernel/desktop-ths.c | 18 ++++++++++-------- src/kernel/event.c | 30 +++++++++++++++--------------- src/kernel/message.c | 23 +++++++++++++---------- src/kernel/timer.c | 4 ++-- src/standalone/standalone.c | 4 ++-- 9 files changed, 54 insertions(+), 47 deletions(-) diff --git a/include/window.h b/include/window.h index 7d9a51a3..b2c90991 100644 --- a/include/window.h +++ b/include/window.h @@ -561,9 +561,9 @@ extern "C" { */ #define DEF_INTERVAL_TIME 200 -extern unsigned int __mg_key_longpress_time; -extern unsigned int __mg_key_alwayspress_time; -extern unsigned int __mg_interval_time; +extern DWORD __mg_key_longpress_time; +extern DWORD __mg_key_alwayspress_time; +extern DWORD __mg_interval_time; /** * \def SetKeyLongPressTime(time) diff --git a/src/include/msgstr.h b/src/include/msgstr.h index ff346255..ff5cbd09 100644 --- a/src/include/msgstr.h +++ b/src/include/msgstr.h @@ -3,7 +3,7 @@ ** ** msgstr.h: the text name of all messages. ** -** Copyright (C) 2003 ~ 2007 Feynman Software. +** Copyright (C) 2003 ~ 2018 FMSoft ** Copyright (C) 1999 ~ 2002 Wei Yongming. ** ** Create date: 1999/01/03 @@ -201,9 +201,9 @@ char * __mg_msgstr2 [] = "", // 0x00DB "", // 0x00DC "", // 0x00DD - "MSG_ERASEDESKTOP ", // 0x00DE "MSG_PAINTDESKTOP ", // 0x00DF + "MSG_DT_LBUTTONDOWN ", // 0x00E0 "MSG_DT_LBUTTONUP ", // 0x00E1 "MSG_DT_LBUTTONDBLCLK ", // 0x00E2 @@ -237,6 +237,7 @@ char * __mg_msgstr2 [] = "MSG_SCROLLMAINWIN ", // 0x00FD "MSG_CARET_CREATE ", // 0x00FE "MSG_CARET_DESTROY ", // 0x00FF + "MSG_ENABLEMAINWIN ", // 0x0100 "MSG_ISENABLED ", // 0x0101 "MSG_SETWINCURSOR", // 0x0102 @@ -284,7 +285,8 @@ char * __mg_msgstr3 [] = "", // 0x0136 "", // 0x0137 "", // 0x0138 - "", // 0x0139 "", // 0x013A + "", // 0x0139 + "", // 0x013A "", // 0x013B "", // 0x013C "", // 0x013D diff --git a/src/include/timer.h b/src/include/timer.h index 020df95c..417e33aa 100644 --- a/src/include/timer.h +++ b/src/include/timer.h @@ -33,7 +33,7 @@ typedef TIMER* PTIMER; BOOL mg_InitTimer (void); void mg_TerminateTimer (void); -void mg_dispatch_timer_message (unsigned int inter); +void mg_dispatch_timer_message (DWORD inter); void mg_remove_timers_by_msg_queue (const MSGQUEUE* msg_que); TIMER* __mg_get_timer (int slot); diff --git a/src/kernel/desktop-comm.c b/src/kernel/desktop-comm.c index 51d48d46..6c16fdfc 100644 --- a/src/kernel/desktop-comm.c +++ b/src/kernel/desktop-comm.c @@ -2198,10 +2198,10 @@ LRESULT DesktopWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case MSG_TIMER: // per 0.01s { - static UINT uCounter = 0; + static DWORD uCounter = 0; #ifndef _MGRM_THREADS - static UINT blink_counter = 0; - static UINT sg_old_counter = 0; + static DWORD blink_counter = 0; + static DWORD sg_old_counter = 0; if (sg_old_counter == 0) sg_old_counter = __mg_timer_counter; diff --git a/src/kernel/desktop-ths.c b/src/kernel/desktop-ths.c index f3dee9ef..2c4a07e2 100644 --- a/src/kernel/desktop-ths.c +++ b/src/kernel/desktop-ths.c @@ -125,12 +125,12 @@ void* DesktopMain (void* data) LRESULT lRet = 0; #ifdef _MGHAVE_TRACE_MSG - fprintf (stderr, "Message, %s: hWnd: %p, wP: %p, lP: %p. %s\n", - Message2Str (Msg.message), - Msg.hwnd, - (PVOID)Msg.wParam, - (PVOID)Msg.lParam, - Msg.pAdd?"Sync":"Normal"); + if (Msg.message != MSG_TIMEOUT && Msg.message != MSG_TIMER) { + fprintf (stderr, "Message %u (%s): hWnd: HWND_DESKTOP, wP: %p, lP: %p, tick: %u; %s\n", + Msg.message, Message2Str (Msg.message), + (PVOID)Msg.wParam, (PVOID)Msg.lParam, (UINT)Msg.time, + Msg.pAdd?"Sync":"Normal"); + } #endif lRet = DesktopWinProc (HWND_DESKTOP, @@ -144,8 +144,10 @@ void* DesktopMain (void* data) } #ifdef _MGHAVE_TRACE_MSG - fprintf (stderr, "Message, %s done, return value: %p\n", - Message2Str (Msg.message), (PVOID)lRet); + if (Msg.message != MSG_TIMEOUT && Msg.message != MSG_TIMER) { + fprintf (stderr, "Message %u (%s) done, return value: %p\n", + Msg.message, Message2Str (Msg.message), (PVOID)lRet); + } #endif } diff --git a/src/kernel/event.c b/src/kernel/event.c index 589eb552..c3f80ee2 100644 --- a/src/kernel/event.c +++ b/src/kernel/event.c @@ -54,9 +54,9 @@ static int repeatusec; static int dblclicktime; #ifndef _MGRM_THREADS -static unsigned int timeout_threshold; -static unsigned int repeat_threshold; -static unsigned int timeout_count; +static DWORD timeout_threshold; +static DWORD repeat_threshold; +static DWORD timeout_count; #endif static void GetDblclickTime(void) @@ -100,11 +100,11 @@ static void GetTimeout (void) /* Mouse event parameters. */ static int oldbutton = 0; -static unsigned int time1; -static unsigned int time2; +static DWORD time1; +static DWORD time2; /* Key event parameters. */ -static unsigned int ke_time; +static DWORD ke_time; #ifndef _MGRM_PROCESSES static unsigned char oldkeystate [MGUI_NR_KEYS + 1]; #endif @@ -180,15 +180,15 @@ static void ResetKeyEvent(void) * default long pressed and always pressed value * The default long press handling disabled at startup. */ -unsigned int __mg_key_longpress_time = 0; -unsigned int __mg_key_alwayspress_time = DEF_APRESS_TIME; -unsigned int __mg_interval_time = DEF_INTERVAL_TIME; +DWORD __mg_key_longpress_time = 0; +DWORD __mg_key_alwayspress_time = DEF_APRESS_TIME; +DWORD __mg_interval_time = DEF_INTERVAL_TIME; -static void treat_longpress (PKEYEVENT ke, unsigned int interval) +static void treat_longpress (PKEYEVENT ke, DWORD interval) { - static unsigned int starttime; + static DWORD starttime; static int flag1 = 0, flag2 = 1; /*flag1: longpress flags*/ - unsigned int maxctime; + DWORD maxctime; maxctime = (__mg_key_longpress_time < __mg_key_alwayspress_time) ? __mg_key_longpress_time : __mg_key_alwayspress_time; @@ -256,12 +256,12 @@ static void treat_longpress (PKEYEVENT ke, unsigned int interval) BOOL kernel_GetLWEvent (int event, PLWEVENT lwe) { static LWEVENT old_lwe = {0, 0}; - unsigned int interval; - int button; + DWORD interval; PMOUSEEVENT me = &(lwe->data.me); PKEYEVENT ke = &(lwe->data.ke); const char* keystate; int i; + int button; int make; /* 0 = release, 1 = presse */ if (event == 0) { @@ -516,7 +516,7 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe) static LWEVENT old_lwe = {0, 0}; int nr_keys = 0; - unsigned int interval; + DWORD interval; int button; PMOUSEEVENT me = &(lwe->data.me); PKEYEVENT ke = &(lwe->data.ke); diff --git a/src/kernel/message.c b/src/kernel/message.c index aea1d7cf..890d0186 100644 --- a/src/kernel/message.c +++ b/src/kernel/message.c @@ -1029,12 +1029,11 @@ LRESULT GUIAPI DispatchMessage (PMSG pMsg) LICENSE_MODIFY_MESSAGE(pMsg); #ifdef _MGHAVE_TRACE_MSG - fprintf (stderr, "Message, %s: hWnd: %p, wP: %p, lP: %p. %s\n", - Message2Str (pMsg->message), - pMsg->hwnd, - (PVOID)pMsg->wParam, - (PVOID)pMsg->lParam, - SYNMSGNAME); + if (pMsg->message != MSG_TIMEOUT && pMsg->message != MSG_CARETBLINK) { + fprintf (stderr, "Message %u (%s): hWnd: %p, wP: %p, lP: %p. %s\n", + pMsg->message, Message2Str (pMsg->message), + pMsg->hwnd, (PVOID)pMsg->wParam, (PVOID)pMsg->lParam, SYNMSGNAME); + } #endif if (pMsg->hwnd == HWND_INVALID) { @@ -1047,8 +1046,10 @@ LRESULT GUIAPI DispatchMessage (PMSG pMsg) #endif #ifdef _MGHAVE_TRACE_MSG - fprintf (stderr, "Message have been thrown away: %s\n", - Message2Str (pMsg->message)); + if (pMsg->message != MSG_TIMEOUT && pMsg->message != MSG_CARETBLINK) { + fprintf (stderr, "Message %u (%s) has been thrown away.\n", + pMsg->message, Message2Str (pMsg->message)); + } #endif return -1; } @@ -1071,8 +1072,10 @@ LRESULT GUIAPI DispatchMessage (PMSG pMsg) #endif #ifdef _MGHAVE_TRACE_MSG - fprintf (stderr, "Message, %s done, return value: %p\n", - Message2Str (pMsg->message), (PVOID)lRet); + if (pMsg->message != MSG_TIMEOUT && pMsg->message != MSG_CARETBLINK) { + fprintf (stderr, "Message %u (%s) done, return value: %p\n", + pMsg->message, Message2Str (pMsg->message), (PVOID)lRet); + } #endif return lRet; diff --git a/src/kernel/timer.c b/src/kernel/timer.c index 9a3d02b2..7c0fd136 100644 --- a/src/kernel/timer.c +++ b/src/kernel/timer.c @@ -54,7 +54,7 @@ static pthread_mutex_t timerLock; #ifdef _MGGAL_S3C6410 # define _MG_USE_BETTER_TIMER -#endif /* __NOUNIX__ */ +#endif /* _MGGAL_S3C6410 */ #ifdef _MG_USE_BETTER_TIMER #include @@ -255,7 +255,7 @@ void mg_TerminateTimer (void) } /************************* Functions run in desktop thread *******************/ -void mg_dispatch_timer_message (unsigned int inter) +void mg_dispatch_timer_message (DWORD inter) { int i; diff --git a/src/standalone/standalone.c b/src/standalone/standalone.c index 68a2ff58..7a7948c6 100644 --- a/src/standalone/standalone.c +++ b/src/standalone/standalone.c @@ -38,8 +38,8 @@ #include "menu.h" #include "ourhdr.h" -extern unsigned int __mg_timer_counter; -static unsigned int old_timer_counter = 0; +extern DWORD __mg_timer_counter; +static DWORD old_timer_counter = 0; static SRVEVTHOOK srv_evt_hook = NULL;