Add new primitive OS2PS-GET-BITMAP and OS2PM-SYNCHRONIZE. Fix some
authorChris Hanson <org/chris-hanson/cph>
Tue, 21 Feb 1995 22:54:30 +0000 (22:54 +0000)
committerChris Hanson <org/chris-hanson/cph>
Tue, 21 Feb 1995 22:54:30 +0000 (22:54 +0000)
minor bugs in OS2PS-GET-BITMAP-PARAMETERS.

v7/src/microcode/os2msg.h
v7/src/microcode/os2pm.c
v7/src/microcode/os2pm.h
v7/src/microcode/pros2pm.c

index 8734c75e36906cd26e4c6ca411a216c8a3cb5a6d..b653a74dc1f4246c8edaa0377d87a39b23e5002d 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: os2msg.h,v 1.6 1995/02/14 00:25:43 cph Exp $
+$Id: os2msg.h,v 1.7 1995/02/21 22:54:30 cph Exp $
 
 Copyright (c) 1994-95 Massachusetts Institute of Technology
 
@@ -76,6 +76,11 @@ typedef enum
      return no meaningful data other than that they have completed.  */
   mt_generic_reply,
 
+  /* This message, when sent to the PM thread, causes it to return a
+     generic reply message.  This is used to synchronize with the PM
+     thread.  */
+  mt_pm_synchronize_request,
+
   /* These are messages that command the PM thread to perform specific
      actions.  A command that does not have a specific reply type will
      receive a generic reply when the PM code is configured to do
@@ -131,8 +136,7 @@ typedef enum
   mt_ps_set_mix,               /* set fg mix */
   mt_ps_query_caps,            /* query display capabilities */
   mt_ps_set_clip_rectangle,    /* set/clear clipping rectangle */
-  mt_get_bitmap_parameters_request, /* get bitmap dimensions, depth, etc. */
-  mt_get_bitmap_parameters_reply,
+  mt_get_bitmap_parameters,    /* get bitmap dimensions, depth, etc. */
   mt_ps_get_bitmap_bits_request, /* get bitmap contents */
   mt_ps_get_bitmap_bits_reply,
   mt_ps_set_bitmap_bits_request, /* set bitmap contents */
index 679e75db3dbf54e56cff6de4aea98225727c48ea..edcf3403f2feff4933ca29af1a553fbb0e4aea52 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: os2pm.c,v 1.6 1995/02/14 00:25:24 cph Exp $
+$Id: os2pm.c,v 1.7 1995/02/21 22:54:15 cph Exp $
 
 Copyright (c) 1994-95 Massachusetts Institute of Technology
 
@@ -119,6 +119,8 @@ typedef struct
 #define ID_TABLE_LENGTH(table) ((table) -> length)
 #define ID_TABLE_POINTERS(table) ((table) -> pointers)
 \f
+typedef msg_t sm_pm_synchronize_request_t;
+
 typedef struct
 {
   DECLARE_MSG_HEADER_FIELDS;
@@ -625,17 +627,12 @@ typedef struct
 {
   DECLARE_MSG_HEADER_FIELDS;
   bitmap_t * bitmap;
-} sm_get_bitmap_parameters_request_t;
-#define SM_GET_BITMAP_PARAMETERS_REQUEST_BITMAP(m)                     \
-  (((sm_get_bitmap_parameters_request_t *) (m)) -> bitmap)
-
-typedef struct
-{
-  DECLARE_MSG_HEADER_FIELDS;
-  BITMAPINFOHEADER2 params;
-} sm_get_bitmap_parameters_reply_t;
-#define SM_GET_BITMAP_PARAMETERS_REPLY_PARAMS(m)                       \
-  (((sm_get_bitmap_parameters_reply_t *) (m)) -> params)
+  PBITMAPINFOHEADER params;
+} sm_get_bitmap_parameters_t;
+#define SM_GET_BITMAP_PARAMETERS_BITMAP(m)                             \
+  (((sm_get_bitmap_parameters_t *) (m)) -> bitmap)
+#define SM_GET_BITMAP_PARAMETERS_PARAMS(m)                             \
+  (((sm_get_bitmap_parameters_t *) (m)) -> params)
 
 typedef struct
 {
@@ -761,7 +758,7 @@ static void ps_set_line_type (ps_t *, LONG);
 static void ps_set_mix (ps_t *, LONG);
 static void ps_query_caps (ps_t *, LONG, LONG, PLONG);
 static void ps_set_clip_rectangle (ps_t *, PRECTL);
-static void get_bitmap_parameters (bitmap_t *, PBITMAPINFOHEADER2);
+static void get_bitmap_parameters (bitmap_t *, PBITMAPINFOHEADER);
 static unsigned long ps_get_bitmap_bits
   (ps_t *, unsigned long, unsigned long, PBYTE, PBITMAPINFO2);
 static unsigned long ps_set_bitmap_bits
@@ -820,7 +817,7 @@ window_error_1 (const char * name, int fatalp)
 {
   char buffer [1024];
   ERRORID code = (WinGetLastError (pm_hab));
-  sprintf (buffer, "%s error %d occurred in the %s procedure.  \
+  sprintf (buffer, "%s error 0x%08x occurred in the %s procedure.  \
 This indicates a bug in the Scheme implementation.  \
 Please report this information to a Scheme wizard.",
           (fatalp ? "Fatal" : "Non-fatal"), code, name);
@@ -838,6 +835,7 @@ Please report this information to a Scheme wizard.",
 void
 OS2_initialize_pm_thread (void)
 {
+  SET_MSG_TYPE_LENGTH (mt_pm_synchronize_request, sm_pm_synchronize_request_t);
   SET_MSG_TYPE_LENGTH (mt_window_open_request, sm_open_request_t);
   SET_MSG_TYPE_LENGTH (mt_window_open_reply, sm_open_reply_t);
   SET_MSG_TYPE_LENGTH (mt_window_close, sm_close_t);
@@ -890,10 +888,7 @@ OS2_initialize_pm_thread (void)
   SET_MSG_TYPE_LENGTH (mt_ps_set_mix, sm_ps_set_mix_t);
   SET_MSG_TYPE_LENGTH (mt_ps_query_caps, sm_ps_query_caps_t);
   SET_MSG_TYPE_LENGTH (mt_ps_set_clip_rectangle, sm_ps_set_clip_rectangle_t);
-  SET_MSG_TYPE_LENGTH (mt_get_bitmap_parameters_request,
-                      sm_get_bitmap_parameters_request_t);
-  SET_MSG_TYPE_LENGTH (mt_get_bitmap_parameters_reply,
-                      sm_get_bitmap_parameters_reply_t);
+  SET_MSG_TYPE_LENGTH (mt_get_bitmap_parameters, sm_get_bitmap_parameters_t);
   SET_MSG_TYPE_LENGTH (mt_ps_get_bitmap_bits_request,
                       sm_ps_get_bitmap_bits_request_t);
   SET_MSG_TYPE_LENGTH (mt_ps_get_bitmap_bits_reply,
@@ -1158,6 +1153,7 @@ close_all_windows (void)
    encapsulated messages sent from the Scheme thread.  This defines
    the protocol used to communicate with the Scheme thread.  */
 
+static void handle_pm_synchronize_request (msg_t *);
 static void handle_window_open_request (msg_t *);
 static void handle_window_close_request (msg_t *);
 static void handle_window_show_request (msg_t *);
@@ -1209,6 +1205,9 @@ object_window_procedure (HWND window, ULONG msg, MPARAM mp1, MPARAM mp2)
       msg_t * message = (PVOIDFROMMP (mp1));
       switch (MSG_TYPE (message))
        {
+       case mt_pm_synchronize_request:
+         handle_pm_synchronize_request (message);
+         break;
        case mt_window_open_request:
          handle_window_open_request (message);
          break;
@@ -1324,7 +1323,7 @@ object_window_procedure (HWND window, ULONG msg, MPARAM mp1, MPARAM mp2)
        case mt_ps_set_clip_rectangle:
          handle_ps_set_clip_rectangle_request (message);
          break;
-       case mt_get_bitmap_parameters_request:
+       case mt_get_bitmap_parameters:
          handle_get_bitmap_parameters_request (message);
          break;
        case mt_ps_get_bitmap_bits_request:
@@ -1353,6 +1352,20 @@ OS2_create_pm_qid (tqueue_t * tqueue)
   return (client_side);
 }
 
+void
+OS2_pm_synchronize (qid_t qid)
+{
+  sync_transaction (qid, (OS2_create_message (mt_pm_synchronize_request)));
+}
+
+static void
+handle_pm_synchronize_request (msg_t * message)
+{
+  qid_t sender = (MSG_SENDER (message));
+  OS2_destroy_message (message);
+  sync_reply (sender);
+}
+
 wid_t
 OS2_window_open (qid_t qid, qid_t event_qid, unsigned long style,
                 const char * title)
@@ -1890,6 +1903,13 @@ handle_destroy_bitmap_request (msg_t * request)
   simple_reply (sender);
 }
 
+bid_t
+OS2_ps_get_bitmap (psid_t psid)
+{
+  bitmap_t * bitmap = (PS_VISUAL (psid_to_ps (psid)));
+  return ((bitmap == 0) ? BID_NONE : (BITMAP_ID (bitmap)));
+}
+
 bid_t
 OS2_ps_set_bitmap (psid_t psid, bid_t bid)
 {
@@ -2284,26 +2304,20 @@ void
 OS2_get_bitmap_parameters (bid_t bid, void * params)
 {
   bitmap_t * bitmap = (bid_to_bitmap (bid));
-  msg_t * message = (OS2_create_message (mt_get_bitmap_parameters_request));
-  (SM_GET_BITMAP_PARAMETERS_REQUEST_BITMAP (message)) = bitmap;
-  message
-    = (OS2_message_transaction ((BITMAP_QID (bitmap)),
-                               message,
-                               mt_get_bitmap_parameters_reply));
-  (* ((PBITMAPINFOHEADER2) params))
-    = (SM_GET_BITMAP_PARAMETERS_REPLY_PARAMS (message));
-  OS2_destroy_message (message);
+  msg_t * message = (OS2_create_message (mt_get_bitmap_parameters));
+  (SM_GET_BITMAP_PARAMETERS_BITMAP (message)) = bitmap;
+  (SM_GET_BITMAP_PARAMETERS_PARAMS (message)) = params;
+  sync_transaction ((BITMAP_QID (bitmap)), message);
 }
 
 static void
-handle_get_bitmap_parameters_request (msg_t * request)
+handle_get_bitmap_parameters_request (msg_t * message)
 {
-  qid_t sender = (MSG_SENDER (request));
-  msg_t * reply = (OS2_create_message (mt_get_bitmap_parameters_reply));
-  get_bitmap_parameters ((SM_GET_BITMAP_PARAMETERS_REQUEST_BITMAP (request)),
-                        (& (SM_GET_BITMAP_PARAMETERS_REPLY_PARAMS (reply))));
-  OS2_destroy_message (request);
-  OS2_send_message (sender, reply);
+  qid_t sender = (MSG_SENDER (message));
+  get_bitmap_parameters ((SM_GET_BITMAP_PARAMETERS_BITMAP (message)),
+                        (SM_GET_BITMAP_PARAMETERS_PARAMS (message)));
+  OS2_destroy_message (message);
+  sync_reply (sender);
 }
 
 unsigned long
@@ -2984,10 +2998,9 @@ ps_set_clip_rectangle (ps_t * ps, PRECTL rectl)
 }
 
 static void
-get_bitmap_parameters (bitmap_t * bitmap, PBITMAPINFOHEADER2 params)
+get_bitmap_parameters (bitmap_t * bitmap, PBITMAPINFOHEADER params)
 {
-  if (!GpiQueryBitmapParameters ((BITMAP_HANDLE (bitmap)),
-                                ((PBITMAPINFOHEADER) params)))
+  if (!GpiQueryBitmapParameters ((BITMAP_HANDLE (bitmap)), params))
     window_error (GpiQueryBitmapParameters);
 }
 
index 2b04eba43c100637484f435f1e77c4723b100b28..b679f007f47b5d079f1c083d45ae6638b6f79980 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: os2pm.h,v 1.5 1995/02/14 00:25:15 cph Exp $
+$Id: os2pm.h,v 1.6 1995/02/21 22:54:23 cph Exp $
 
 Copyright (c) 1994-95 Massachusetts Institute of Technology
 
@@ -165,6 +165,7 @@ extern int OS2_bid_validp (bid_t);
 
 extern psid_t OS2_window_client_ps (wid_t);
 extern qid_t OS2_create_pm_qid (tqueue_t *);
+extern void OS2_pm_synchronize (qid_t);
 extern wid_t OS2_window_open (qid_t, qid_t, unsigned long, const char *);
 extern void OS2_window_permanent (wid_t);
 extern void OS2_window_close (wid_t);
@@ -192,6 +193,7 @@ extern void OS2_destroy_memory_ps (psid_t);
 extern int OS2_memory_ps_p (psid_t);
 extern bid_t OS2_create_bitmap (psid_t, USHORT, USHORT);
 extern void OS2_destroy_bitmap (bid_t);
+extern bid_t OS2_ps_get_bitmap (psid_t);
 extern bid_t OS2_ps_set_bitmap (psid_t, bid_t);
 extern void OS2_ps_bitblt (psid_t, psid_t, LONG, PPOINTL, LONG, ULONG);
 extern void OS2_ps_draw_text
index 1e3c0f657ba1694ebc16d1f64bf27cd1a01a535e..76491d2e31fb05445364ea52438d76dea80c96a2 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-C-*-
 
-$Id: pros2pm.c,v 1.4 1995/02/14 00:25:34 cph Exp $
+$Id: pros2pm.c,v 1.5 1995/02/21 22:54:07 cph Exp $
 
 Copyright (c) 1994-95 Massachusetts Institute of Technology
 
@@ -125,6 +125,13 @@ DEFINE_PRIMITIVE ("OS2WIN-BEEP", Prim_OS2_window_beep, 2, 2, 0)
   PRIMITIVE_RETURN (UNSPECIFIC);
 }
 
+DEFINE_PRIMITIVE ("OS2PM-SYNCHRONIZE", Prim_OS2_pm_synchronize, 0, 0, 0)
+{
+  PRIMITIVE_HEADER (0);
+  OS2_pm_synchronize (pm_qid);
+  PRIMITIVE_RETURN (UNSPECIFIC);
+}
+
 DEFINE_PRIMITIVE ("OS2WIN-OPEN", Prim_OS2_window_open, 2, 2, 0)
 {
   PRIMITIVE_HEADER (2);
@@ -328,6 +335,15 @@ DEFINE_PRIMITIVE ("OS2PS-DESTROY-BITMAP", Prim_OS2_destroy_bitmap, 1, 1, 0)
   PRIMITIVE_RETURN (UNSPECIFIC);
 }
 
+DEFINE_PRIMITIVE ("OS2PS-GET-BITMAP", Prim_OS2_ps_get_bitmap, 1, 1, 0)
+{
+  PRIMITIVE_HEADER (1);
+  {
+    bid_t bid = (OS2_ps_get_bitmap ((memory_psid_argument (1))));
+    PRIMITIVE_RETURN ((bid == BID_NONE) ? SHARP_F : (long_to_integer (bid)));
+  }
+}
+
 DEFINE_PRIMITIVE ("OS2PS-SET-BITMAP", Prim_OS2_ps_set_bitmap, 2, 2, 0)
 {
   PRIMITIVE_HEADER (2);
@@ -608,9 +624,9 @@ DEFINE_PRIMITIVE ("OS2PS-GET-BITMAP-PARAMETERS", Prim_OS2_ps_get_bitmap_paramete
 {
   PRIMITIVE_HEADER (1);
   {
-    SCHEME_OBJECT s = (allocate_string (sizeof (BITMAPINFOHEADER2)));
-    PBITMAPINFOHEADER2 params = ((PBITMAPINFOHEADER2) (STRING_LOC (s, 0)));
-    (params -> cbFix) = (sizeof (BITMAPINFOHEADER2));
+    SCHEME_OBJECT s = (allocate_string (sizeof (BITMAPINFOHEADER)));
+    PBITMAPINFOHEADER params = ((PBITMAPINFOHEADER) (STRING_LOC (s, 0)));
+    (params -> cbFix) = (sizeof (BITMAPINFOHEADER));
     OS2_get_bitmap_parameters ((bid_argument (1)), params);
     PRIMITIVE_RETURN (s);
   }