Changeset 10104


Ignore:
Timestamp:
May 16, 2003, 12:59:28 PM (22 years ago)
Author:
sandervl
Message:

Handle WM_(SYS)TIMER timer calls in DispatchMessageA/W

Location:
trunk/src/user32
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/user32/oslibmsg.cpp

    r10012 r10104  
    1 /* $Id: oslibmsg.cpp,v 1.68 2003-04-11 14:22:05 sandervl Exp $ */
     1/* $Id: oslibmsg.cpp,v 1.69 2003-05-16 10:59:26 sandervl Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    324324    {
    325325        filtermin = TranslateWinMsg(uMsgFilterMin, TRUE);
    326             filtermax = TranslateWinMsg(uMsgFilterMax, FALSE);
    327             if(filtermin > filtermax) {
    328                 ULONG tmp = filtermin;
    329                     filtermin = filtermax;
    330                     filtermax = filtermin;
    331             }
    332         do {
    333                 eaten = FALSE;
    334                 rc = WinGetMsg(teb->o.odin.hab, &os2msg, 0, filtermin, filtermax);
    335                 if (os2msg.msg == WM_TIMER)
    336                     eaten = TIMER_HandleTimer(&os2msg);
    337                 if (os2msg.msg == WM_QUIT && ((ULONG)os2msg.mp2 != 0) ) {
    338                     // Don't return FALSE when the window list sends us
    339                     // a WM_QUIT message, improper killing can lead to
    340                     // application crashes.
    341                     // In the WM_QUIT handler in pmwindow we send a WM_CLOSE
    342                     // in this case. When the app calls PostQuitMessage (mp2 == 0),
    343                     // then we handle it the normal way
    344                     rc = 1;
    345                 }
    346             }
    347         while (eaten);
     326        filtermax = TranslateWinMsg(uMsgFilterMax, FALSE);
     327        if(filtermin > filtermax) {
     328            ULONG tmp = filtermin;
     329            filtermin = filtermax;
     330            filtermax = filtermin;
     331        }
     332        rc = WinGetMsg(teb->o.odin.hab, &os2msg, 0, filtermin, filtermax);
     333        if (os2msg.msg == WM_QUIT && ((ULONG)os2msg.mp2 != 0) ) {
     334            // Don't return FALSE when the window list sends us
     335            // a WM_QUIT message, improper killing can lead to
     336            // application crashes.
     337            // In the WM_QUIT handler in pmwindow we send a WM_CLOSE
     338            // in this case. When the app calls PostQuitMessage (mp2 == 0),
     339            // then we handle it the normal way
     340            rc = 1;
     341        }
    348342    }
    349343    if(OS2ToWinMsgTranslate((PVOID)teb, &os2msg, pMsg, isUnicode, MSG_REMOVE) == FALSE) {
     
    483477            if(ulPMFilter) {
    484478                do {
    485                     eaten = FALSE;
    486 
    487479                    rc = WinPeekMsg(teb->o.odin.hab, &os2msg, hwndOS2, ulPMFilter, ulPMFilter,
    488480                                    (fRemove & PM_REMOVE_W) ? PM_REMOVE : PM_NOREMOVE);
     
    492484                       rc = 0;
    493485                    }
    494                     if (rc && (fRemove & PM_REMOVE_W) && os2msg.msg == WM_TIMER) {
    495                         eaten = TIMER_HandleTimer(&os2msg);
    496                     }
    497486                }
    498                 while (eaten && rc);
     487                while (rc);
    499488            }
    500489            if(rc) {
     
    504493    }
    505494    else {
    506         do {
    507             eaten = FALSE;
    508 
    509             rc = WinPeekMsg(teb->o.odin.hab, &os2msg, hwndOS2, 0, 0, (fRemove & PM_REMOVE_W) ? PM_REMOVE : PM_NOREMOVE);
    510 
    511             if (rc && (fRemove & PM_REMOVE_W) && os2msg.msg == WM_TIMER) {
    512                 eaten = TIMER_HandleTimer(&os2msg);
    513             }
    514         }
    515         while (eaten && rc);
     495        rc = WinPeekMsg(teb->o.odin.hab, &os2msg, hwndOS2, 0, 0, (fRemove & PM_REMOVE_W) ? PM_REMOVE : PM_NOREMOVE);
    516496    }
    517497    if(rc == FALSE) {
  • TabularUnified trunk/src/user32/oslibmsgtranslate.cpp

    r10017 r10104  
    1 /* $Id: oslibmsgtranslate.cpp,v 1.109 2003-04-11 17:26:11 sandervl Exp $ */
     1/* $Id: oslibmsgtranslate.cpp,v 1.110 2003-05-16 10:59:27 sandervl Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    929929//        {
    930930          BOOL sys;
    931           ULONG id;
    932 
    933           if (TIMER_GetTimerInfo(os2Msg->hwnd,(ULONG)os2Msg->mp1,&sys,&id))
     931          ULONG id, proc;
     932
     933          if (TIMER_GetTimerInfo(os2Msg->hwnd,(ULONG)os2Msg->mp1,&sys,&id, &proc))
    934934          {
    935935                winMsg->wParam = (WPARAM)id;
     936                winMsg->lParam = (LPARAM)proc;
    936937                winMsg->message= (sys) ? WINWM_SYSTIMER : WINWM_TIMER;
    937938                break;
  • TabularUnified trunk/src/user32/timer.cpp

    r10102 r10104  
    1 /* $Id: timer.cpp,v 1.15 2003-05-16 09:21:00 sandervl Exp $ */
     1/* $Id: timer.cpp,v 1.16 2003-05-16 10:59:27 sandervl Exp $ */
    22
    33/*
     
    3232#endif
    3333
    34 #define WM_TIMER_W    0x0113
    35 #define WM_SYSTIMER_W 0x0118
    36 typedef VOID (CALLBACK *TIMERPROC)(HWND hwnd, UINT msg, UINT id, DWORD dwTime);
    37 
    3834typedef struct tagTIMER
    3935{
     
    6864}
    6965
    70 BOOL TIMER_GetTimerInfo(HWND PMhwnd,ULONG PMid,PBOOL sys,PULONG id)
     66BOOL TIMER_GetTimerInfo(HWND PMhwnd,ULONG PMid,PBOOL sys,PULONG id, PULONG proc)
    7167{
    7268  int i;
    7369  TIMER *pTimer;
    7470
     71  EnterCriticalSection ();
    7572  for (i = 0, pTimer = TimersArray; i < NB_TIMERS; i++, pTimer++)
    7673      if (pTimer->inUse && (pTimer->PMhwnd == PMhwnd) && (pTimer->PMid == PMid))
    7774          break;
     75  LeaveCriticalSection();
    7876
    7977  if (i == NB_TIMERS)  /* no matching timer found */
     
    8280  *sys = pTimer->inUse == TIMER::SystemTimer;
    8381  *id  = pTimer->id;
     82  *proc = (ULONG)pTimer->proc;
    8483
    8584  return TRUE;
    8685}
     86
     87/***********************************************************************
     88 *           TIMER_IsTimerValid
     89 */
     90BOOL TIMER_IsTimerValid( HWND hwnd, UINT id, ULONG proc )
     91{
     92    int i;
     93    TIMER *pTimer;
     94    BOOL ret = FALSE;
     95
     96    EnterCriticalSection ();
     97
     98    for (i = 0, pTimer = TimersArray; i < NB_TIMERS; i++, pTimer++)
     99        if ((pTimer->hwnd == hwnd) && (pTimer->id == id) && (pTimer->proc == (TIMERPROC)proc))
     100        {
     101            ret = TRUE;
     102            break;
     103        }
     104
     105    LeaveCriticalSection();
     106    return ret;
     107}
     108
    87109
    88110BOOL TIMER_HandleTimer (PQMSG pMsg)
     
    93115    ULONG PMid   = (ULONG)(pMsg->mp1);
    94116
     117    EnterCriticalSection ();
    95118    for (i = 0, pTimer = TimersArray; i < NB_TIMERS; i++, pTimer++)
    96119        if (pTimer->inUse && (pTimer->PMhwnd == PMhwnd) && (pTimer->PMid == PMid))
    97120            break;
     121    LeaveCriticalSection();
    98122
    99123    if (i == NB_TIMERS)  /* no matching timer found */
  • TabularUnified trunk/src/user32/timer.h

    r2469 r10104  
    1 /* $Id: timer.h,v 1.5 2000-01-18 20:08:14 sandervl Exp $ */
     1/* $Id: timer.h,v 1.6 2003-05-16 10:59:28 sandervl Exp $ */
    22/*
    33 * public timer functions
     
    1414
    1515#ifndef INCL_TIMERWIN32
    16 extern BOOL TIMER_GetTimerInfo(HWND PMhwnd,ULONG PMid,PBOOL sys,PULONG id);
     16extern BOOL TIMER_GetTimerInfo(HWND PMhwnd,ULONG PMid,PBOOL sys,PULONG id, PULONG proc);
    1717extern BOOL TIMER_HandleTimer (PQMSG pMsg);
    1818#endif
     19extern BOOL TIMER_IsTimerValid( HWND hwnd, UINT id, ULONG proc );
    1920extern VOID TIMER_KillTimerFromWindow(HWND hwnd);
    2021
  • TabularUnified trunk/src/user32/windowmsg.cpp

    r9928 r10104  
    1 /* $Id: windowmsg.cpp,v 1.41 2003-03-20 09:15:31 sandervl Exp $ */
     1/* $Id: windowmsg.cpp,v 1.42 2003-05-16 10:59:28 sandervl Exp $ */
    22/*
    33 * Win32 window message APIs for OS/2
     
    3232#include "oslibmsg.h"
    3333#include "hook.h"
     34#define INCL_TIMERWIN32
     35#include "timer.h"
    3436
    3537#define DBG_LOCALLOG    DBG_windowmsg
     
    4446{
    4547    dprintf2(("DispatchMessageA %x %x %x %x %x", msg->hwnd, msg->message, msg->wParam, msg->lParam, msg->time));
     48
     49    /* Process timer messages */
     50    if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
     51    {
     52        if (msg->lParam)
     53        {
     54/*            HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
     55
     56            /* before calling window proc, verify whether timer is still valid;
     57               there's a slim chance that the application kills the timer
     58               between GetMessage and DispatchMessage API calls */
     59            if (!TIMER_IsTimerValid(msg->hwnd, (UINT) msg->wParam, msg->lParam))
     60                return 0; /* invalid winproc */
     61
     62            return CallWindowProcA( (WNDPROC)msg->lParam, msg->hwnd,
     63                                   msg->message, msg->wParam, GetTickCount() );
     64        }
     65    }
     66
    4667    return OSLibWinDispatchMsg((MSG *)msg);
    4768}
     
    5172{
    5273    dprintf2(("DispatchMessageW %x %x %x %x %x", msg->hwnd, msg->message, msg->wParam, msg->lParam, msg->time));
     74
     75    /* Process timer messages */
     76    if ((msg->message == WM_TIMER) || (msg->message == WM_SYSTIMER))
     77    {
     78        if (msg->lParam)
     79        {
     80/*            HOOK_CallHooks32A( WH_CALLWNDPROC, HC_ACTION, 0, FIXME ); */
     81
     82            /* before calling window proc, verify whether timer is still valid;
     83               there's a slim chance that the application kills the timer
     84               between GetMessage and DispatchMessage API calls */
     85            if (!TIMER_IsTimerValid(msg->hwnd, (UINT) msg->wParam, msg->lParam))
     86                return 0; /* invalid winproc */
     87
     88            return CallWindowProcA( (WNDPROC)msg->lParam, msg->hwnd,
     89                                   msg->message, msg->wParam, GetTickCount() );
     90        }
     91    }
    5392    return OSLibWinDispatchMsg((MSG *)msg, TRUE);
    5493}
Note: See TracChangeset for help on using the changeset viewer.