mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-26 20:45:36 +08:00
timer_count -> tick_count; use __mg_update_tick_count; cleanup MSG_TIMER handling of desktop
This commit is contained in:
+5
-1
@@ -11,7 +11,7 @@ tab2space() {
|
||||
# tab2space
|
||||
|
||||
# templates
|
||||
# sed -i 's/\<AAA\>/__AAA/g' `grep AAA -rl include/ src/`
|
||||
# sed -i 's/\<aaa\>/__aaa/g' `grep aaa -rl include/ src/`
|
||||
# sed -i 's/\<AAA\>/__mgAAA/g' `grep AAA -rl include/ src/`
|
||||
# sed -i 's/\<AAA\>/__gdiAAA/g' `grep AAA -rl include/ src/`
|
||||
# sed -i 's/\<AAA\>/__mg_AAA/g' `grep AAA -rl include/ src/`
|
||||
@@ -137,4 +137,8 @@ tab2space() {
|
||||
|
||||
# sed -i 's/\<SetDesktopTimerFlag\>/AlertDesktopTimerEvent/g' `grep SetDesktopTimerFlag -rl include/ src/`
|
||||
|
||||
# sed -i 's/\<__mg_update_timer_count\>/__mg_update_tick_count/g' `grep __mg_update_timer_count -rl include/ src/`
|
||||
|
||||
sed -i 's/\<__mg_timer_counter\>/__mg_tick_counter/g' `grep __mg_timer_counter -rl include/ src/`
|
||||
|
||||
exit 0
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ typedef struct _MSGQUEUE MSGQUEUE;
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
void __mg_update_timer_count (void* data);
|
||||
void __mg_update_tick_count (void* data);
|
||||
int __mg_check_expired_timers (MSGQUEUE* msg_queue, DWORD inter);
|
||||
void __mg_remove_timers_by_msg_queue (MSGQUEUE* msg_queue);
|
||||
void __mg_remove_timer (MSGQUEUE* msg_queue, int slot);
|
||||
|
||||
+24
-21
@@ -2509,11 +2509,28 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message,
|
||||
dsk_ops->mouse_handler(dt_context, message, wParam, lParam);
|
||||
break;
|
||||
|
||||
// per 0.01s
|
||||
/* 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: {
|
||||
static DWORD uCounter = 0;
|
||||
static DWORD blink_counter = 0;
|
||||
|
||||
_WRN_PRINTF ("got MSG_TIMER message for desktop (%lu)\n",
|
||||
__mg_tick_counter);
|
||||
if (__mg_tick_counter < (blink_counter + 10))
|
||||
break;
|
||||
|
||||
uCounter += (__mg_tick_counter - blink_counter) * 10;
|
||||
blink_counter = __mg_tick_counter;
|
||||
if (sg_hCaretWnd != 0
|
||||
&& gui_GetMainWindowPtrOfControl (sg_hCaretWnd) ==
|
||||
dskGetActiveWindow()
|
||||
&& uCounter >= sg_uCaretBTime) {
|
||||
PostMessage (sg_hCaretWnd, MSG_CARETBLINK, 0, 0);
|
||||
uCounter = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
#ifdef _MGRM_THREADS
|
||||
if (__mg_quiting_stage < 0) {
|
||||
|
||||
@@ -2544,10 +2561,10 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message,
|
||||
static DWORD sg_old_counter = 0;
|
||||
|
||||
if (sg_old_counter == 0)
|
||||
sg_old_counter = __mg_timer_counter;
|
||||
sg_old_counter = __mg_tick_counter;
|
||||
|
||||
__mg_check_expired_timers (NULL, __mg_timer_counter - sg_old_counter);
|
||||
sg_old_counter = __mg_timer_counter;
|
||||
__mg_check_expired_timers (NULL, __mg_tick_counter - sg_old_counter);
|
||||
sg_old_counter = __mg_tick_counter;
|
||||
|
||||
#else /* not defined _MGRM_THREADS */
|
||||
if (__mg_quiting_stage < 0) {
|
||||
@@ -2593,26 +2610,12 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message,
|
||||
static DWORD sg_old_counter = 0;
|
||||
|
||||
if (MG_UNLIKELY(sg_old_counter == 0))
|
||||
sg_old_counter = __mg_timer_counter;
|
||||
__mg_check_expired_timers (NULL, __mg_timer_counter - sg_old_counter);
|
||||
sg_old_counter = __mg_timer_counter;
|
||||
sg_old_counter = __mg_tick_counter;
|
||||
__mg_check_expired_timers (NULL, __mg_tick_counter - sg_old_counter);
|
||||
sg_old_counter = __mg_tick_counter;
|
||||
|
||||
#endif /* defined _MGRM_THREADS */
|
||||
#endif /* deprecated code */
|
||||
|
||||
if (__mg_timer_counter < (blink_counter + 10))
|
||||
break;
|
||||
|
||||
uCounter += (__mg_timer_counter - blink_counter) * 10;
|
||||
blink_counter = __mg_timer_counter;
|
||||
if (sg_hCaretWnd != 0
|
||||
&& gui_GetMainWindowPtrOfControl (sg_hCaretWnd) ==
|
||||
dskGetActiveWindow()
|
||||
&& uCounter >= sg_uCaretBTime) {
|
||||
PostMessage (sg_hCaretWnd, MSG_CARETBLINK, 0, 0);
|
||||
uCounter = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
|
||||
+21
-17
@@ -310,7 +310,7 @@ static int update_client_window_rgn (int cli, HWND hwnd)
|
||||
}
|
||||
}
|
||||
else {
|
||||
MSG msg = {hwnd, MSG_UPDATECLIWIN, 0, 0, __mg_timer_counter};
|
||||
MSG msg = {hwnd, MSG_UPDATECLIWIN, 0, 0, __mg_tick_counter};
|
||||
|
||||
while (crc) {
|
||||
msg.wParam = MAKELONG (crc->rc.left, crc->rc.top);
|
||||
@@ -883,7 +883,7 @@ static BOOL _cb_update_cli_znode (void* context,
|
||||
int cli = (int)(intptr_t)context;
|
||||
|
||||
if (znode->cli == cli && znode->flags & ZOF_VISIBLE && znode->hwnd) {
|
||||
MSG msg = {znode->hwnd, MSG_UPDATECLIWIN, 0, 0, __mg_timer_counter};
|
||||
MSG msg = {znode->hwnd, MSG_UPDATECLIWIN, 0, 0, __mg_tick_counter};
|
||||
|
||||
if (!IsRectEmpty(&(znode->dirty_rc))) {
|
||||
|
||||
@@ -1162,7 +1162,7 @@ static int do_drag_drop_window (int msg, int x, int y)
|
||||
FocusRect (HDC_SCREEN_SYS, _dd_info.rc.left, _dd_info.rc.top,
|
||||
_dd_info.rc.right, _dd_info.rc.bottom);
|
||||
#else
|
||||
MSG msg = {_dd_info.hwnd, MSG_WINDOWDROPPED, 0, 0, __mg_timer_counter};
|
||||
MSG msg = {_dd_info.hwnd, MSG_WINDOWDROPPED, 0, 0, __mg_tick_counter};
|
||||
#endif
|
||||
|
||||
switch (_dd_info.location) {
|
||||
@@ -1226,7 +1226,7 @@ static int do_drag_drop_window (int msg, int x, int y)
|
||||
msg.wParam, msg.lParam);
|
||||
}
|
||||
else {
|
||||
mgClients [_dd_info.cli].last_live_time = __mg_timer_counter;
|
||||
mgClients [_dd_info.cli].last_live_time = __mg_tick_counter;
|
||||
__mg_send2client (&msg, mgClients + _dd_info.cli);
|
||||
}
|
||||
#endif /* defined _MGSCHEMA_COMPOSITING */
|
||||
@@ -1234,7 +1234,7 @@ static int do_drag_drop_window (int msg, int x, int y)
|
||||
_dd_info.last_y = y;
|
||||
}
|
||||
else {
|
||||
MSG msg = {_dd_info.hwnd, MSG_WINDOWDROPPED, 0, 0, __mg_timer_counter};
|
||||
MSG msg = {_dd_info.hwnd, MSG_WINDOWDROPPED, 0, 0, __mg_tick_counter};
|
||||
|
||||
msg.wParam = MAKELONG (_dd_info.rc.left, _dd_info.rc.top);
|
||||
msg.lParam = MAKELONG (_dd_info.rc.right, _dd_info.rc.bottom);
|
||||
@@ -1251,7 +1251,7 @@ static int do_drag_drop_window (int msg, int x, int y)
|
||||
msg.wParam, msg.lParam);
|
||||
}
|
||||
else {
|
||||
mgClients [_dd_info.cli].last_live_time = __mg_timer_counter;
|
||||
mgClients [_dd_info.cli].last_live_time = __mg_tick_counter;
|
||||
__mg_send2client (&msg, mgClients + _dd_info.cli);
|
||||
}
|
||||
|
||||
@@ -1888,7 +1888,7 @@ int __mg_do_change_topmost_layer (void)
|
||||
MG_Layer* dst_layer = mgTopmostLayer;
|
||||
MSG msg = { HWND_DESKTOP,
|
||||
MSG_LAYERCHANGED, (WPARAM)dst_layer,
|
||||
(LPARAM)dst_layer->zorder_shmid, __mg_timer_counter };
|
||||
(LPARAM)dst_layer->zorder_shmid, __mg_tick_counter };
|
||||
|
||||
slot = old_zorder_info->first_tooltip;
|
||||
if (old_nodes[slot].cli > 0) {
|
||||
@@ -4168,24 +4168,26 @@ static void dskRefreshAllWindow (const RECT* invrc)
|
||||
/***********************************************************
|
||||
* Handler for MSG_TIMER for the server and all clients.
|
||||
**********************************************************/
|
||||
|
||||
static void dskOnTimer (void)
|
||||
{
|
||||
static UINT uCounter = 0;
|
||||
static UINT blink_counter = 0;
|
||||
|
||||
#if 0 /* deprecated code */
|
||||
/* Since 5.0.0, __mg_check_expired_timers is called in idle handler */
|
||||
static UINT sg_old_counter = 0;
|
||||
|
||||
if (sg_old_counter == 0)
|
||||
sg_old_counter = SHAREDRES_TIMER_COUNTER;
|
||||
sg_old_counter = __mg_tick_counter;
|
||||
|
||||
__mg_check_expired_timers (NULL, SHAREDRES_TIMER_COUNTER - sg_old_counter);
|
||||
sg_old_counter = SHAREDRES_TIMER_COUNTER;
|
||||
__mg_check_expired_timers (NULL, __mg_tick_counter - sg_old_counter);
|
||||
sg_old_counter = __mg_tick_counter;
|
||||
#endif /* deprecated code */
|
||||
|
||||
if (SHAREDRES_TIMER_COUNTER < (blink_counter + 10))
|
||||
if (__mg_tick_counter < (blink_counter + 10))
|
||||
return;
|
||||
|
||||
uCounter += (SHAREDRES_TIMER_COUNTER - blink_counter) * 10;
|
||||
blink_counter = SHAREDRES_TIMER_COUNTER;
|
||||
uCounter += (__mg_tick_counter - blink_counter) * 10;
|
||||
blink_counter = __mg_tick_counter;
|
||||
|
||||
if (sg_hCaretWnd != 0
|
||||
&& (HWND)gui_GetMainWindowPtrOfControl (sg_hCaretWnd)
|
||||
@@ -4493,7 +4495,7 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message,
|
||||
#endif
|
||||
|
||||
if (__mg_zorder_info->cli_trackmenu > 0) {
|
||||
MSG msg = {0, message, wParam, lParam, __mg_timer_counter};
|
||||
MSG msg = {0, message, wParam, lParam, __mg_tick_counter};
|
||||
__mg_send2client (&msg, mgClients +
|
||||
__mg_zorder_info->cli_trackmenu);
|
||||
}
|
||||
@@ -4525,7 +4527,7 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message,
|
||||
|
||||
if (__mg_zorder_info->cli_trackmenu > 0 ) {
|
||||
|
||||
MSG msg = {0, message, wParam, lParam, __mg_timer_counter};
|
||||
MSG msg = {0, message, wParam, lParam, __mg_tick_counter};
|
||||
|
||||
__mg_send2client (&msg, mgClients +
|
||||
__mg_zorder_info->cli_trackmenu);
|
||||
@@ -4683,6 +4685,8 @@ static LRESULT DesktopWinProc (HWND hWnd, UINT message,
|
||||
case MSG_BROADCASTMSG:
|
||||
return dskBroadcastMessage ((PMSG)lParam);
|
||||
|
||||
/* 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:
|
||||
if (__mg_quiting_stage < 0) {
|
||||
if (__mg_quiting_stage > _MG_QUITING_STAGE_FORCE &&
|
||||
|
||||
@@ -133,7 +133,7 @@ BOOL mg_InitDesktop (void)
|
||||
|
||||
// Init Window Management information.
|
||||
if (!InitWndManagementInfo()) {
|
||||
_WRN_PRINTF ("KERNEL>Desktop: Can not initialize window management information!\n");
|
||||
_ERR_PRINTF ("KERNEL>Desktop: failed to init window manager!\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -142,16 +142,6 @@ BOOL mg_InitDesktop (void)
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
static BOOL desktop_idle_handler (MSGQUEUE* msg_queue, BOOL wait)
|
||||
{
|
||||
if (wait) {
|
||||
__mg_os_time_delay (10);
|
||||
__mg_update_timer_count (NULL);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void* __kernel_desktop_main (void* data)
|
||||
{
|
||||
MSG Msg;
|
||||
@@ -159,11 +149,12 @@ void* __kernel_desktop_main (void* data)
|
||||
/* init message queue of desktop thread */
|
||||
if (!(__mg_dsk_msg_queue = mg_AllocMsgQueueForThisThread ()) ) {
|
||||
_ERR_PRINTF ("failed to allocate message queue\n");
|
||||
sem_post ((sem_t*)data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* for threads mode, the idle handler for desktop thread is NULL */
|
||||
__mg_dsk_msg_queue->OnIdle = desktop_idle_handler;
|
||||
__mg_dsk_msg_queue->OnIdle = NULL;
|
||||
|
||||
/* init desktop window */
|
||||
init_desktop_win ();
|
||||
@@ -206,7 +197,6 @@ void* __kernel_desktop_main (void* data)
|
||||
__mg_dsk_msg_queue = NULL;
|
||||
|
||||
__mg_quiting_stage = _MG_QUITING_STAGE_EVENT;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -1569,7 +1569,7 @@ static int srvForceCloseMenu (int cli)
|
||||
/* notify the client to close the menu */
|
||||
{
|
||||
#if defined(_MGRM_PROCESSES)
|
||||
MSG msg = {0, MSG_CLOSEMENU, 0, 0, __mg_timer_counter};
|
||||
MSG msg = {0, MSG_CLOSEMENU, 0, 0, __mg_tick_counter};
|
||||
|
||||
if (cli_trackmenu)
|
||||
ret = __mg_send2client (&msg, mgClients + cli_trackmenu);
|
||||
@@ -1773,7 +1773,7 @@ int __mg_post_msg_by_znode (const ZORDERINFO* zi, int znode,
|
||||
#if defined (_MGRM_PROCESSES)
|
||||
else {
|
||||
MSG msg = {nodes [znode].main_win,
|
||||
message, wParam, lParam, __mg_timer_counter};
|
||||
message, wParam, lParam, __mg_tick_counter};
|
||||
|
||||
ret = __mg_send2client (&msg, mgClients + nodes [znode].cli);
|
||||
}
|
||||
@@ -1797,7 +1797,7 @@ post_msg_by_znode_p (const ZORDERINFO* zi, const ZORDERNODE* znode,
|
||||
#if defined (_MGRM_PROCESSES)
|
||||
else {
|
||||
MSG msg = {znode->main_win,
|
||||
message, wParam, lParam, __mg_timer_counter};
|
||||
message, wParam, lParam, __mg_tick_counter};
|
||||
|
||||
ret = __mg_send2client (&msg, mgClients + znode->cli);
|
||||
}
|
||||
|
||||
+29
-29
@@ -259,14 +259,14 @@ static void treat_longpress (PKEYEVENT ke, DWORD interval)
|
||||
else if (interval >= __mg_key_alwayspress_time) {
|
||||
if (flag2) {
|
||||
flag2 = 0;
|
||||
starttime = __mg_timer_counter;
|
||||
starttime = __mg_tick_counter;
|
||||
ke->event = KE_KEYALWAYSPRESS;
|
||||
}
|
||||
else if (__mg_timer_counter - starttime < __mg_interval_time) {
|
||||
else if (__mg_tick_counter - starttime < __mg_interval_time) {
|
||||
ke->event = KE_KEYDOWN;
|
||||
}
|
||||
else {
|
||||
starttime = __mg_timer_counter;
|
||||
starttime = __mg_tick_counter;
|
||||
ke->event = KE_KEYALWAYSPRESS;
|
||||
}
|
||||
}
|
||||
@@ -276,14 +276,14 @@ static void treat_longpress (PKEYEVENT ke, DWORD interval)
|
||||
&& interval <= __mg_key_longpress_time) {
|
||||
if (flag2) {
|
||||
flag2 = 0;
|
||||
starttime = __mg_timer_counter;
|
||||
starttime = __mg_tick_counter;
|
||||
ke->event = KE_KEYALWAYSPRESS;
|
||||
}
|
||||
else if (__mg_timer_counter - starttime < __mg_interval_time) {
|
||||
else if (__mg_tick_counter - starttime < __mg_interval_time) {
|
||||
ke->event = KE_KEYDOWN;
|
||||
}
|
||||
else {
|
||||
starttime = __mg_timer_counter;
|
||||
starttime = __mg_tick_counter;
|
||||
ke->event = KE_KEYALWAYSPRESS;
|
||||
}
|
||||
}
|
||||
@@ -311,16 +311,16 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
|
||||
int make; /* 0 = release, 1 = presse */
|
||||
|
||||
if (event == 0) {
|
||||
if (__mg_timer_counter >= timeout_count) {
|
||||
if (__mg_tick_counter >= timeout_count) {
|
||||
|
||||
timeout_count = __mg_timer_counter + repeat_threshold;
|
||||
timeout_count = __mg_tick_counter + repeat_threshold;
|
||||
|
||||
// repeat last event
|
||||
if (old_lwe.type == LWETYPE_KEY
|
||||
&& old_lwe.data.ke.event == KE_KEYDOWN) {
|
||||
|
||||
memcpy (lwe, &old_lwe, sizeof (LWEVENT));
|
||||
interval = __mg_timer_counter - ke_time;
|
||||
interval = __mg_tick_counter - ke_time;
|
||||
treat_longpress (ke, interval);
|
||||
if (ke->event == KE_KEYDOWN) {
|
||||
lwe->data.ke.status |= KS_REPEATED;
|
||||
@@ -333,12 +333,12 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
|
||||
old_lwe.data.me.event == ME_RIGHTDOWN ||
|
||||
old_lwe.data.me.event == ME_MIDDLEDOWN))) {
|
||||
// reset delay time
|
||||
timeout_count = __mg_timer_counter + timeout_threshold;
|
||||
timeout_count = __mg_tick_counter + timeout_threshold;
|
||||
}
|
||||
|
||||
// reset delay time
|
||||
lwe->type = LWETYPE_TIMEOUT;
|
||||
lwe->count = __mg_timer_counter;
|
||||
lwe->count = __mg_tick_counter;
|
||||
|
||||
__mg_license_on_timeout();
|
||||
|
||||
@@ -347,7 +347,7 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
|
||||
return 0;
|
||||
}
|
||||
|
||||
timeout_count = __mg_timer_counter + timeout_threshold;
|
||||
timeout_count = __mg_tick_counter + timeout_threshold;
|
||||
// There was a event occurred.
|
||||
if (event & IAL_MOUSEEVENT) {
|
||||
if (!IAL_UpdateMouse ())
|
||||
@@ -369,12 +369,12 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
|
||||
{
|
||||
__mg_license_on_input();
|
||||
|
||||
interval = __mg_timer_counter - time1;
|
||||
interval = __mg_tick_counter - time1;
|
||||
if (interval <= dblclicktime)
|
||||
me->event = ME_LEFTDBLCLICK;
|
||||
else
|
||||
me->event = ME_LEFTDOWN;
|
||||
time1 = __mg_timer_counter;
|
||||
time1 = __mg_tick_counter;
|
||||
|
||||
goto mouseret;
|
||||
}
|
||||
@@ -391,12 +391,12 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
|
||||
if ( !(oldbutton & IAL_MOUSE_RIGHTBUTTON) &&
|
||||
(button & IAL_MOUSE_RIGHTBUTTON) )
|
||||
{
|
||||
interval = __mg_timer_counter - time2;
|
||||
interval = __mg_tick_counter - time2;
|
||||
if (interval <= dblclicktime)
|
||||
me->event = ME_RIGHTDBLCLICK;
|
||||
else
|
||||
me->event = ME_RIGHTDOWN;
|
||||
time2 = __mg_timer_counter;
|
||||
time2 = __mg_tick_counter;
|
||||
|
||||
goto mouseret;
|
||||
}
|
||||
@@ -411,12 +411,12 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
|
||||
if ( !(oldbutton & IAL_MOUSE_MIDDLEBUTTON) &&
|
||||
(button & IAL_MOUSE_MIDDLEBUTTON) )
|
||||
{
|
||||
interval = __mg_timer_counter - time3;
|
||||
interval = __mg_tick_counter - time3;
|
||||
if (interval <= dblclicktime)
|
||||
me->event = ME_MIDDLEDBLCLICK;
|
||||
else
|
||||
me->event = ME_MIDDLEDOWN;
|
||||
time3 = __mg_timer_counter;
|
||||
time3 = __mg_tick_counter;
|
||||
|
||||
goto mouseret;
|
||||
}
|
||||
@@ -446,7 +446,7 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
|
||||
if (!oldkeystate[i] && keystate[i]) {
|
||||
#endif
|
||||
ke->event = KE_KEYDOWN;
|
||||
ke_time =__mg_timer_counter;
|
||||
ke_time =__mg_tick_counter;
|
||||
ke->scancode = i;
|
||||
olddownkey = i;
|
||||
break;
|
||||
@@ -465,7 +465,7 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
|
||||
if (olddownkey == 0)
|
||||
return 0;
|
||||
ke->scancode = olddownkey;
|
||||
interval = __mg_timer_counter - ke_time;
|
||||
interval = __mg_tick_counter - ke_time;
|
||||
treat_longpress (ke, interval);
|
||||
if (ke->event == 0) {
|
||||
return 0;
|
||||
@@ -634,7 +634,7 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
|
||||
&& old_lwe.data.ke.event == KE_KEYDOWN) {
|
||||
|
||||
memcpy (lwe, &old_lwe, sizeof (LWEVENT));
|
||||
interval = __mg_timer_counter - ke_time;
|
||||
interval = __mg_tick_counter - ke_time;
|
||||
treat_longpress (ke, interval);
|
||||
if (ke->event == KE_KEYDOWN) {
|
||||
lwe->data.ke.status |= KS_REPEATED;
|
||||
@@ -685,12 +685,12 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
|
||||
{
|
||||
__mg_license_on_input();
|
||||
|
||||
interval = __mg_timer_counter - time1;
|
||||
interval = __mg_tick_counter - time1;
|
||||
if (interval <= dblclicktime)
|
||||
me->event = ME_LEFTDBLCLICK;
|
||||
else
|
||||
me->event = ME_LEFTDOWN;
|
||||
time1 = __mg_timer_counter;
|
||||
time1 = __mg_tick_counter;
|
||||
|
||||
goto mouseret;
|
||||
}
|
||||
@@ -707,12 +707,12 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
|
||||
if ( !(oldbutton & IAL_MOUSE_RIGHTBUTTON) &&
|
||||
(button & IAL_MOUSE_RIGHTBUTTON) )
|
||||
{
|
||||
interval = __mg_timer_counter - time2;
|
||||
interval = __mg_tick_counter - time2;
|
||||
if (interval <= dblclicktime)
|
||||
me->event = ME_RIGHTDBLCLICK;
|
||||
else
|
||||
me->event = ME_RIGHTDOWN;
|
||||
time2 = __mg_timer_counter;
|
||||
time2 = __mg_tick_counter;
|
||||
|
||||
goto mouseret;
|
||||
}
|
||||
@@ -727,12 +727,12 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
|
||||
if ( !(oldbutton & IAL_MOUSE_MIDDLEBUTTON) &&
|
||||
(button & IAL_MOUSE_MIDDLEBUTTON) )
|
||||
{
|
||||
interval = __mg_timer_counter - time3;
|
||||
interval = __mg_tick_counter - time3;
|
||||
if (interval <= dblclicktime)
|
||||
me->event = ME_MIDDLEDBLCLICK;
|
||||
else
|
||||
me->event = ME_MIDDLEDOWN;
|
||||
time3 = __mg_timer_counter;
|
||||
time3 = __mg_tick_counter;
|
||||
|
||||
goto mouseret;
|
||||
}
|
||||
@@ -754,7 +754,7 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
|
||||
for (i = 1; i < nr_keys; i++) {
|
||||
if(!oldkeystate[i] && keystate[i]) {
|
||||
ke->event = KE_KEYDOWN;
|
||||
ke_time =__mg_timer_counter;
|
||||
ke_time =__mg_tick_counter;
|
||||
ke->scancode = i;
|
||||
olddownkey = i;
|
||||
break;
|
||||
@@ -769,7 +769,7 @@ BOOL kernel_GetLWEvent (int event, PLWEVENT lwe)
|
||||
if (olddownkey == 0)
|
||||
return 0;
|
||||
ke->scancode = olddownkey;
|
||||
interval = __mg_timer_counter - ke_time;
|
||||
interval = __mg_tick_counter - ke_time;
|
||||
treat_longpress (ke, interval);
|
||||
if (ke->event == 0) {
|
||||
return 0;
|
||||
|
||||
@@ -61,7 +61,7 @@ static void timer_handler (int sig, siginfo_t *extra, void *cruft)
|
||||
}
|
||||
#endif
|
||||
|
||||
__mg_timer_counter++;
|
||||
__mg_tick_counter++;
|
||||
|
||||
// alert desktop
|
||||
AlertDesktopTimerEvent ();
|
||||
@@ -117,7 +117,7 @@ BOOL mg_InitTimer (void)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
__mg_timer_counter = 0;
|
||||
__mg_tick_counter = 0;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
+5
-5
@@ -72,7 +72,7 @@
|
||||
|
||||
#define NALLOC 4 /* #Client structs to alloc/realloc for */
|
||||
|
||||
extern DWORD __mg_timer_counter;
|
||||
extern DWORD __mg_tick_counter;
|
||||
|
||||
MG_Client* mgClients = NULL;
|
||||
int mgClientSize = 0;
|
||||
@@ -159,7 +159,7 @@ again:
|
||||
mgClients[i].pid = pid;
|
||||
mgClients[i].uid = uid;
|
||||
mgClients[i].has_dirty = FALSE;
|
||||
mgClients[i].last_live_time = __mg_timer_counter;
|
||||
mgClients[i].last_live_time = __mg_tick_counter;
|
||||
mgClients[i].layer = NULL;
|
||||
return (i); /* return index in client[] array */
|
||||
}
|
||||
@@ -240,7 +240,7 @@ int __mg_send2client (const MSG* Msg, MG_Client* client)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (__mg_timer_counter < (client->last_live_time + THRES_LIVE)) {
|
||||
if (__mg_tick_counter < (client->last_live_time + THRES_LIVE)) {
|
||||
|
||||
#if 1
|
||||
ret = sock_write_t (client->fd, Msg, sizeof (MSG), TO_SOCKIO);
|
||||
@@ -294,7 +294,7 @@ void __mg_set_active_client (MG_Client* client)
|
||||
return;
|
||||
|
||||
if (layer->cli_active) {
|
||||
MSG msg = {0, MSG_SETFOCUS, 0, 0, __mg_timer_counter};
|
||||
MSG msg = {0, MSG_SETFOCUS, 0, 0, __mg_tick_counter};
|
||||
|
||||
__mg_send2client (&msg, layer->cli_active);
|
||||
}
|
||||
@@ -362,7 +362,7 @@ int GUIAPI Send2Client (const MSG* msg, int cli)
|
||||
|
||||
BOOL GUIAPI Send2TopMostClients (UINT nMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
MSG msg = {0, nMsg, wParam, lParam, __mg_timer_counter};
|
||||
MSG msg = {0, nMsg, wParam, lParam, __mg_tick_counter};
|
||||
|
||||
if (!mgIsServer)
|
||||
return FALSE;
|
||||
|
||||
+3
-3
@@ -642,7 +642,7 @@ BOOL GUIAPI ServerSetTopmostLayer (MG_Layer* layer)
|
||||
|
||||
client = layer->cli_head;
|
||||
while (client) {
|
||||
MSG msg = {0, MSG_PAINT, 0, 0, __mg_timer_counter};
|
||||
MSG msg = {0, MSG_PAINT, 0, 0, __mg_tick_counter};
|
||||
|
||||
__mg_send2client (&msg, client);
|
||||
|
||||
@@ -720,7 +720,7 @@ void GUIAPI DisableClientsOutput (void)
|
||||
|
||||
void GUIAPI UpdateTopmostLayer (const RECT* dirty_rc)
|
||||
{
|
||||
MSG msg = {0, MSG_PAINT, 0, 0, __mg_timer_counter};
|
||||
MSG msg = {0, MSG_PAINT, 0, 0, __mg_tick_counter};
|
||||
|
||||
if (!mgIsServer)
|
||||
return;
|
||||
@@ -1108,7 +1108,7 @@ BOOL GUIAPI ServerMoveClientToLayer (int cli, MG_Layer* dst_layer)
|
||||
if (__mg_move_client_to_layer (client, dst_layer)) {
|
||||
MSG msg = { HWND_DESKTOP,
|
||||
MSG_LAYERCHANGED, (WPARAM)dst_layer,
|
||||
(LPARAM)dst_layer->zorder_shmid, __mg_timer_counter };
|
||||
(LPARAM)dst_layer->zorder_shmid, __mg_tick_counter };
|
||||
|
||||
__mg_send2client (&msg, client);
|
||||
|
||||
|
||||
+8
-5
@@ -80,7 +80,7 @@
|
||||
#include "timer.h"
|
||||
#include "license.h"
|
||||
|
||||
extern DWORD __mg_timer_counter;
|
||||
extern DWORD __mg_tick_counter;
|
||||
|
||||
ON_NEW_DEL_CLIENT OnNewDelClient = NULL;
|
||||
|
||||
@@ -119,7 +119,7 @@ static void ParseEvent (PMSGQUEUE msg_que, int event)
|
||||
if (!kernel_GetLWEvent (event, &lwe))
|
||||
return;
|
||||
|
||||
Msg.time = __mg_timer_counter;
|
||||
Msg.time = __mg_tick_counter;
|
||||
if (lwe.type == LWETYPE_TIMEOUT) {
|
||||
Msg.message = MSG_TIMEOUT;
|
||||
Msg.wParam = (WPARAM)lwe.count;
|
||||
@@ -354,10 +354,13 @@ BOOL server_IdleHandler4Server (PMSGQUEUE msg_queue, BOOL wait)
|
||||
EXTRA_INPUT_EVENT extra; // Since 4.0.0; for extra input events
|
||||
int nevts = 0; // Since 5.0.0; for timer and fd events
|
||||
|
||||
if (__mg_timer_counter != SHAREDRES_TIMER_COUNTER) {
|
||||
__mg_timer_counter = SHAREDRES_TIMER_COUNTER;
|
||||
#if 0 /* deprecated code */
|
||||
/* since 5.0.0, use __mg_update_tick_count instead */
|
||||
if (__mg_tick_counter != SHAREDRES_TIMER_COUNTER) {
|
||||
__mg_tick_counter = SHAREDRES_TIMER_COUNTER;
|
||||
AlertDesktopTimerEvent ();
|
||||
}
|
||||
#endif /* deprecated code */
|
||||
|
||||
/* rset gets modified each time around */
|
||||
rset = __mg_dsk_msg_queue->rfdset;
|
||||
@@ -455,7 +458,7 @@ BOOL server_IdleHandler4Server (PMSGQUEUE msg_queue, BOOL wait)
|
||||
msg.message = extra.event;
|
||||
msg.wParam = extra.wparam;
|
||||
msg.lParam = extra.lparam;
|
||||
msg.time = __mg_timer_counter;
|
||||
msg.time = __mg_tick_counter;
|
||||
if (extra.params_mask) {
|
||||
// packed multiple sub events
|
||||
int i, n = 0;
|
||||
|
||||
+22
-15
@@ -77,8 +77,10 @@
|
||||
#include "timer.h"
|
||||
#include "ourhdr.h"
|
||||
|
||||
extern DWORD __mg_timer_counter;
|
||||
extern DWORD __mg_tick_counter;
|
||||
#if 0 /* deprecated code */
|
||||
static DWORD old_timer_counter = 0;
|
||||
#endif /* deprecated code */
|
||||
|
||||
static void ParseEvent (PMSGQUEUE msg_que, int event)
|
||||
{
|
||||
@@ -99,7 +101,7 @@ static void ParseEvent (PMSGQUEUE msg_que, int event)
|
||||
if (!kernel_GetLWEvent (event, &lwe))
|
||||
return;
|
||||
|
||||
Msg.time = __mg_timer_counter;
|
||||
Msg.time = __mg_tick_counter;
|
||||
if (lwe.type == LWETYPE_TIMEOUT) {
|
||||
Msg.message = MSG_TIMEOUT;
|
||||
Msg.wParam = (WPARAM)lwe.count;
|
||||
@@ -208,10 +210,15 @@ BOOL salone_IdleHandler4StandAlone (PMSGQUEUE msg_queue, BOOL wait)
|
||||
EXTRA_INPUT_EVENT extra; // Since 4.0.0; for extra input events
|
||||
int nevts = 0; // Since 5.0.0; for timer and fd events
|
||||
|
||||
if (old_timer_counter != __mg_timer_counter) {
|
||||
old_timer_counter = __mg_timer_counter;
|
||||
#if 0 /* deprecated code */
|
||||
/* Since 5.0.0, call __mg_update_tick_count instead */
|
||||
if (old_timer_counter != __mg_tick_counter) {
|
||||
old_timer_counter = __mg_tick_counter;
|
||||
AlertDesktopTimerEvent ();
|
||||
}
|
||||
#endif /* deprecated code */
|
||||
|
||||
__mg_update_tick_count (NULL);
|
||||
|
||||
/* rset gets modified each time around */
|
||||
if (msg_queue->nr_rfds) {
|
||||
@@ -232,27 +239,27 @@ BOOL salone_IdleHandler4StandAlone (PMSGQUEUE msg_queue, BOOL wait)
|
||||
levt = IAL_WaitEvent (msg_queue->maxfd, rsetptr, wsetptr, esetptr,
|
||||
wait?&sel_timeout:&sel_timeout_nd, &extra);
|
||||
|
||||
/* update __mg_timer_counter */
|
||||
/* update __mg_tick_counter */
|
||||
if (wait) {
|
||||
//__mg_timer_counter += 10;
|
||||
//__mg_tick_counter += 10;
|
||||
/**
|
||||
10 is too fast, the "repeat_threshold" is 5, use ++, repeate 5 times
|
||||
**/
|
||||
__mg_timer_counter++;
|
||||
__mg_tick_counter++;
|
||||
}
|
||||
#elif defined (_MGGAL_BF533)
|
||||
levt = IAL_WaitEvent (msg_queue->maxfd, rsetptr, wsetptr, esetptr,
|
||||
wait?&sel_timeout:&sel_timeout_nd, &extra);
|
||||
|
||||
/* update __mg_timer_counter */
|
||||
/* update __mg_tick_counter */
|
||||
if (wait) {
|
||||
__mg_timer_counter += 1;
|
||||
__mg_tick_counter += 1;
|
||||
}
|
||||
#else
|
||||
levt = IAL_WaitEvent (msg_queue->maxfd, rsetptr, wsetptr, esetptr,
|
||||
wait?&sel_timeout:&sel_timeout_nd, &extra);
|
||||
/* update __mg_timer_counter */
|
||||
__mg_timer_counter = __mg_os_get_time_ms()/10;
|
||||
/* update __mg_tick_counter */
|
||||
__mg_tick_counter = __mg_os_get_time_ms()/10;
|
||||
#endif
|
||||
|
||||
if (levt < 0) {
|
||||
@@ -272,7 +279,7 @@ BOOL salone_IdleHandler4StandAlone (PMSGQUEUE msg_queue, BOOL wait)
|
||||
msg.message = extra.event;
|
||||
msg.wParam = extra.wparam;
|
||||
msg.lParam = extra.lparam;
|
||||
msg.time = __mg_timer_counter;
|
||||
msg.time = __mg_tick_counter;
|
||||
if (extra.params_mask) {
|
||||
// packed multiple sub events
|
||||
int i, n = 0;
|
||||
@@ -304,10 +311,10 @@ BOOL salone_IdleHandler4StandAlone (PMSGQUEUE msg_queue, BOOL wait)
|
||||
ParseEvent (msg_queue, 0);
|
||||
|
||||
if (MG_UNLIKELY (msg_queue->old_tick_count == 0))
|
||||
msg_queue->old_tick_count = __mg_timer_counter;
|
||||
msg_queue->old_tick_count = __mg_tick_counter;
|
||||
nevts += __mg_check_expired_timers (msg_queue,
|
||||
__mg_timer_counter - msg_queue->old_tick_count);
|
||||
msg_queue->old_tick_count = __mg_timer_counter;
|
||||
__mg_tick_counter - msg_queue->old_tick_count);
|
||||
msg_queue->old_tick_count = __mg_tick_counter;
|
||||
}
|
||||
|
||||
/* go through registered listen fds */
|
||||
|
||||
Reference in New Issue
Block a user