[PATCH] Win32 idle loop


Subject: [PATCH] Win32 idle loop
From: David Mandelin (mandelin@cs.wisc.edu)
Date: Tue Sep 18 2001 - 17:30:05 CDT


Implementation of UT_Win32Idle. Most of it is in ut_Win32Idle.*, but I
had to write a new event loop in ap_Win32App.cpp.

Also, the patch fixes a typo in the XP file ut_worker.cpp.

? af/util/win/ut_Win32Idle.cpp
? af/util/win/ut_Win32Idle.h
Index: af/util/Makefile
===================================================================
RCS file: /cvsroot/abi/src/af/util/Makefile,v
retrieving revision 1.62
diff -u -r1.62 Makefile
--- af/util/Makefile 2001/09/18 21:23:44 1.62
+++ af/util/Makefile 2001/09/18 22:26:24
@@ -50,6 +50,7 @@
                 $(OBJDIR)/ut_$(ABI_FE)OS.$(OBJ_SUFFIX) \
                 $(OBJDIR)/ut_$(ABI_FE)String.$(OBJ_SUFFIX) \
                 $(OBJDIR)/ut_$(ABI_FE)Timer.$(OBJ_SUFFIX) \
+ $(OBJDIR)/ut_$(ABI_FE)Idle.$(OBJ_SUFFIX) \
                 $(OBJDIR)/ut_$(ABI_FE)Locale.$(OBJ_SUFFIX) \
                 $(OBJDIR)/ut_sleep.$(OBJ_SUFFIX) \
                 $(OBJDIR)/ut_Xpm2Bmp.$(OBJ_SUFFIX)
Index: af/util/win/Makefile
===================================================================
RCS file: /cvsroot/abi/src/af/util/win/Makefile,v
retrieving revision 1.18
diff -u -r1.18 Makefile
--- af/util/win/Makefile 2001/08/24 17:49:11 1.18
+++ af/util/win/Makefile 2001/09/18 22:26:25
@@ -25,6 +25,7 @@
 CPPSRCS= ut_debugmsg.cpp \
                         ut_Win32OS.cpp \
                         ut_Win32String.cpp \
+ ut_Win32Idle.cpp \
                         ut_Win32Timer.cpp \
                         ut_Win32Locale.cpp \
                         ut_Xpm2Bmp.cpp \
Index: af/util/xp/ut_worker.cpp
===================================================================
RCS file: /cvsroot/abi/src/af/util/xp/ut_worker.cpp,v
retrieving revision 1.3
diff -u -r1.3 ut_worker.cpp
--- af/util/xp/ut_worker.cpp 2001/09/18 19:52:59 1.3
+++ af/util/xp/ut_worker.cpp 2001/09/18 22:26:25
@@ -129,7 +129,7 @@
 #ifdef SUPPORTS_UT_IDLE
   if ( mode & IDLE )
     {
- tmp = UT_Idle::static_constructor ( cb, mode );
+ tmp = UT_Idle::static_constructor ( cb, data );
       outMode = IDLE;
     }
   else
Index: config/platforms/win32.mk
===================================================================
RCS file: /cvsroot/abi/src/config/platforms/win32.mk,v
retrieving revision 1.25
diff -u -r1.25 win32.mk
--- config/platforms/win32.mk 2001/02/16 00:51:39 1.25
+++ config/platforms/win32.mk 2001/09/18 22:26:29
@@ -81,7 +81,7 @@
 OPTIMIZER = $(OPTIMIZER_DEBUG)
 endif
 
-DEFINES = -DDEBUG -D_DEBUG -UNDEBUG -D_CRTDBG_MAP_ALLOC
+DEFINES = -DDEBUG -D_DEBUG -UNDEBUG -D_CRTDBG_MAP_ALLOC -DSUPPORTS_UT_IDLE
 OBJ_DIR_SFX = DBG
 OS_CFLAGS = -W3 -nologo -GF -Gy -MDd -DWIN32 -Zm200
 DLLFLAGS = -DEBUG -DEBUGTYPE:CV -OUT:"$@"
@@ -90,7 +90,7 @@
 
 else
 
-DEFINES = -UDEBUG -U_DEBUG -DNDEBUG
+DEFINES = -UDEBUG -U_DEBUG -DNDEBUG -DSUPPORTS_UT_IDLE
 OBJ_DIR_SFX = OBJ
 OS_CFLAGS = -W3 -nologo -GF -Gy -MD -DWIN32 -Zm200
 DLLFLAGS = -OUT:"$@"
Index: wp/ap/win/ap_Win32App.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/win/ap_Win32App.cpp,v
retrieving revision 1.68
diff -u -r1.68 ap_Win32App.cpp
--- wp/ap/win/ap_Win32App.cpp 2001/09/05 03:25:11 1.68
+++ wp/ap/win/ap_Win32App.cpp 2001/09/18 22:26:36
@@ -59,6 +59,7 @@
 
 #include "fp_Run.h"
 #include "ut_Win32OS.h"
+#include "ut_Win32Idle.h"
 
 #include "ie_impexp_Register.h"
 
@@ -793,15 +794,24 @@
 
         if (bShowApp)
         {
- while (GetMessage(&msg, NULL, 0, 0))
+ // Special event loop to support idle functions.
+ while (1)
                 {
- // Note: we do not call TranslateMessage() because
- // Note: the keybinding mechanism is responsible
- // Note: for deciding if/when to do this.
-
- if( pMyWin32App->handleModelessDialogMessage( &msg ) )
- continue;
-
+ if (!PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
+ {
+ while (1)
+ {
+ if (UT_Win32Idle::_isEmpty()) break;
+ UT_Win32Idle::_fireall();
+ if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) break;
+ }
+ GetMessage(&msg, NULL, 0, 0);
+ }
+
+ if (msg.message == WM_QUIT) break;
+ if (pMyWin32App->handleModelessDialogMessage(&msg)) continue;
+ // TranslateMessage is not called because AbiWord
+ // has its own way of decoding keyboard accelerators.
                         DispatchMessage(&msg);
                 }
         }
Index: wp/ap/win/ap_Win32Dialog_Lists.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/win/ap_Win32Dialog_Lists.cpp,v
retrieving revision 1.24
diff -u -r1.24 ap_Win32Dialog_Lists.cpp
--- wp/ap/win/ap_Win32Dialog_Lists.cpp 2001/09/18 21:23:46 1.24
+++ wp/ap/win/ap_Win32Dialog_Lists.cpp 2001/09/18 22:26:36
@@ -205,7 +205,7 @@
 
         activate();
 
- m_pAutoUpdateLists = UT_Timer::static_constructor(autoupdateLists, this);
+ m_pAutoUpdateLists = UT_Timer::static_constructor(reinterpret_cast<UT_WorkerCallback>(autoupdateLists), this);
         m_pAutoUpdateLists->set(500); // auto-updater at 1/2 Hz
 
         return 1; // 1 == we did not call SetFocus()
Index: wp/ap/win/ap_Win32Dialog_WordCount.cpp
===================================================================
RCS file: /cvsroot/abi/src/wp/ap/win/ap_Win32Dialog_WordCount.cpp,v
retrieving revision 1.9
diff -u -r1.9 ap_Win32Dialog_WordCount.cpp
--- wp/ap/win/ap_Win32Dialog_WordCount.cpp 2001/09/18 21:23:46 1.9
+++ wp/ap/win/ap_Win32Dialog_WordCount.cpp 2001/09/18 22:26:36
@@ -262,7 +262,7 @@
                 CheckDlgButton(hWnd, AP_RID_DIALOG_WORDCOUNT_CHK_AUTOUPDATE, BST_CHECKED);
 
         GR_Graphics * pG = NULL;
- m_pAutoUpdateWC = UT_Timer::static_constructor(autoupdateWC,this,pG);
+ m_pAutoUpdateWC = UT_Timer::static_constructor(reinterpret_cast<UT_WorkerCallback>(autoupdateWC),this,pG);
         setUpdateCounter( 1 );
 
         // localize controls





This archive was generated by hypermail 2b25 : Tue Sep 18 2001 - 17:30:13 CDT