> If I start a program using PD-Curses from DOS-Box with the start
> command, any output will be frozen if I click to the new created
> curses window. Only with a keypress the output is restarted again. ...
> How can get around this problem?

The attached file contains a patch for PDCurese 2.4 that I wrote some time ago
to overcome the problem mentioned above (It also contains patches to handle
Ctrl-- and Ctrl-Enter, you may ignore them):

Microsoft says in the "man" page of MouseEventRecord:
"Mouse events are placed in a console's input buffer only when
the console group has the keyboard focus and the cursor is within
the borders of the console's window."
Unfortunately, when getting focus by "click", the corresponding
"release" event is _not_ put into the input buffer. This causes
the output freeze.
The patch for "win32/pdckbd.c" tries to solve this,
but it only works partially: It does not work when acquiring focus coming
from the desktop and clicking twice into the target window (NO double click!)
without moving the mouse between the two clicks.
Precondition: Trap ALL mouse events, e.g. mousemask(ALL_MOUSE_EVENTS, NULL)
Anything else may cause strange results.

Hope this helps
   Vassili Courzakis
--- pdckbd.c.orig       Fri Dec 24 00:19:28 1999
+++ pdckbd.c    Wed Apr 18 02:02:51 2001
@@ -266,7 +266,7 @@
  {0x3B,       0x3A,       0x3B,        ALT_SEMICOLON,0,        }, /* 186 */
  {0x3D,       0x2B,       0x3D,        ALT_EQUAL,  0           }, /* 187 */
  {0x2C,       0x3C,       0x2C,        ALT_COMMA,  0           }, /* 188 */
- {0x2D,       0x5F,       0x2D,        0x2D,       0           }, /* 189 */
+ {0x2D,       0x5F,       0x1E,        0x2D,       0           }, /* 189 */
  {0x2E,       0x3E,       0x2E,        ALT_STOP,   0           }, /* 190 */
  {0x2F,       0x3F,       0x2F,        ALT_FSLASH, 13          }, /* 191 */
  {0x60,       0x7E,       0x60,        ALT_BQUOTE, 0           }, /* 192 */
@@ -565,6 +565,12 @@
                      return(kptab[idx].alt);
                   return(kptab[idx].normal);
                  }
+/*
+ * if-Path added by vco, Ctrl-Enter handling, 09-Aug-1998
+ */
+               else if ((save_ip.Event.KeyEvent.wVirtualScanCode == 0x1C)
+                    &&  (save_ip.Event.KeyEvent.uChar.AsciiChar == 0x0A))
+                       return(kptab[save_ip.Event.KeyEvent.wVirtualKeyCode].control);
                else
                   return((int)(unsigned char)save_ip.Event.KeyEvent.uChar.AsciiChar);
               }
@@ -982,8 +988,13 @@
 static int win32_kbhit(int timeout)
 {
  INPUT_RECORD ip;
- DWORD read;
+ DWORD read = 0;
  static int save_press;
+ static int got_focus = 0;
+
+#ifdef PDCDEBUG
+       if (trace_on) PDC_debug("win32_kbhit() - called\n");
+#endif
 
  if (keyCount > 0)
     return TRUE;
@@ -1036,6 +1047,13 @@
          keyCount = ip.Event.KeyEvent.wRepeatCount;
          break;
     case MOUSE_EVENT:
+         if (got_focus)
+         {
+            got_focus = 0;
+            keyCount = 0;
+            return(FALSE);
+         }
+
          if (ip.Event.MouseEvent.dwEventFlags == MS_MOUSE_MOVED
          &&  ip.Event.MouseEvent.dwButtonState == 0)
             return(FALSE);               /* throw away plain MOUSE_MOVE events */
@@ -1048,6 +1066,11 @@
          SP->resized = TRUE;
          keyCount = 1;
          break;
+    case FOCUS_EVENT:
+         if (ip.Event.FocusEvent.bSetFocus != 0)
+            got_focus = 1;
+         keyCount = 0;
+         return(FALSE);
     default:
          keyCount = 0;
          return(FALSE);

Reply via email to