From 00b8cd32394a3d4064136d88b72e8219ee6bef91 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se>
Date: Fri, 26 Dec 1997 22:09:02 +0100
Subject: [PATCH] *** empty log message ***

Rev: lib/modules/Protocols.pmod/X.pmod/Xlib.pmod:1.4
Rev: lib/modules/Protocols.pmod/X.pmod/_Xlib.pmod:1.3
Rev: lib/modules/Protocols.pmod/X.pmod/my_struct.pmod:1.2
---
 lib/modules/Protocols.pmod/X.pmod/Xlib.pmod   | 215 ++++++++++--------
 lib/modules/Protocols.pmod/X.pmod/_Xlib.pmod  |  57 +++--
 .../Protocols.pmod/X.pmod/my_struct.pmod      |   3 +-
 3 files changed, 165 insertions(+), 110 deletions(-)

diff --git a/lib/modules/Protocols.pmod/X.pmod/Xlib.pmod b/lib/modules/Protocols.pmod/X.pmod/Xlib.pmod
index 6698ae5bbb..5f65b7f258 100644
--- a/lib/modules/Protocols.pmod/X.pmod/Xlib.pmod
+++ b/lib/modules/Protocols.pmod/X.pmod/Xlib.pmod
@@ -2,7 +2,7 @@
  *
  */
 
-#define error(x) throw( ({ (x), backtrace() }) )
+#include "error.h"
 
 constant XPORT = 6000;
 
@@ -353,106 +353,135 @@ class Display
 	case STATE_WAIT_HEADER:
 	  {
 	    received->expect(32); /* Correct for most of the cases */
-	    string type = _Xlib.event_types[msg[0]];
-	    switch(type)
+	    string type = _Xlib.event_types[msg[0] & 0x3f];
+	    if (type == "Error")
 	      {
-	      case "Error":
-		{
-		  mapping m = ([]);
-		  sscanf(msg, "%*c%c%2c%4c%2c%c",
-			 m->errorCode, m->sequenceNumber, m->resourceID,
-			 m->minorCode, m->majorCode);
-		  return ({ ACTION_ERROR, m });
-		}
-	      case "Reply":
-		{
-		  reply = ([]);
-		  int length;
-	      
-		  sscanf(msg, "%*c%c%2c%4c%s",
-			 reply->data1, reply->sequenceNumber, length,
-			 reply->rest);
-		  if (!length)
-		    return ({ ACTION_REPLY, reply });
-
-		  state = STATE_WAIT_REPLY;
-		  received->expect(length*4);
+		mapping m = ([]);
+		sscanf(msg, "%*c%c%2c%4c%2c%c",
+		       m->errorCode, m->sequenceNumber, m->resourceID,
+		       m->minorCode, m->majorCode);
+		return ({ ACTION_ERROR, m });
+	      }
+	    else if (type == "Reply")
+	      {
+		reply = ([]);
+		int length;
 	      
-		  break;
-		}
+		sscanf(msg, "%*c%c%2c%4c%s",
+		       reply->data1, reply->sequenceNumber, length,
+		       reply->rest);
+		if (!length)
+		  return ({ ACTION_REPLY, reply });
+
+		state = STATE_WAIT_REPLY;
+		received->expect(length*4);
+	      }
+	    else
+	      {
+		mapping event = ([ "type" : type ]);
+		switch(type)
+		  {
+		  case "KeyPress":
+		  case "KeyRelease":
+		  case "ButtonPress":
+		  case "ButtonRelease":
+		  case "MotionNotify": {
+		    int root, child;
+		    sscanf(msg, "%*c%c%2c%4c" "%4c%4c%4c" "%2c%2c%2c%2c" "%2c%c",
+			   event->detail, event->sequenceNumber, event->time,
+			   root, event->wid, child,
+			   event->rootX, event->rootY, event->eventx, event->eventY,
+			   event->state, event->sameScreen);
+		    event->root = lookup_id(root);
+		    event->event = lookup_id(event->wid);
+		    event->child = child && lookup_id(child);
+		    break;
+		  }
 #if 0 
-	      case "KeyPress":
-	      case "KeyRelease":
-	      case "ButtonPress":
-	      case "ButtonRelease":
-	      case "MotionNotify":
-		...
-	      case "EnterNotify":
-	      case "LeaveNotify":
-		...
-	      case "FocusIn":
-	      case "FocusOut":
-		...
+		
+		  case "EnterNotify":
+		  case "LeaveNotify":
+		    ...;
+		  case "FocusIn":
+		  case "FocusOut":
+		    ...;
 #endif
-	      case "KeymapNotify":
-		return ({ ACTION_EVENT,
-			    ([ "type" : "KeymapNotify",
-			     "map" : msg[1..] ]) });
+		  case "KeymapNotify":
+		    event->map = msg[1..];
+		    break;
+		  case "Expose": {
+		    sscanf(msg, "%*4c%4c" "%2c%2c%2c%2c" "%2c",
+			   event->wid,
+			   event->x, event->y, event->width, event->height,
+			   event->count);
+		    event->window = lookup_id(event->wid);
+		    break;
+		  }
 #if 0		
-	      case "Expose":
-		...
-	      case "GraphicsExpose":
-		...
-	      case "NoExpose":
-		...
-	      case "VisibilityNotify":
-		...
-	      case "CreateNotify":
-		...
-	      case "DestroyNotify":
-		...
-	      case "UnmapNotify":
-		...
-	      case "MapNotify":
-		...
-	      case "MapRequest":
-		...
-	      case "ReparentNotify":
-		...
-	      case "ConfigureNotify":
-		...
-	      case "ConfigureRequest":
-		...
-	      case "GravityNotify":
-		...
-	      case "ResizeRequest":
-		...
-	      case "CirculateNotify":
-		...
-	      case "CirculateRequest":
-		...
-	      case "PropertyNotify":
-		...
-	      case "SelectionClear":
-		...
-	      case "SelectionRequest":
-		...
-	      case "SelectionNotify":
-		...
-	      case "ColormapNotify":
-		...
-	      case "ClientMessage":
-		...
-	      case "MappingNotify":
+		  case "GraphicsExpose":
+		    ...;
+		  case "NoExpose":
+		    ...;
+		  case "VisibilityNotify":
+		    ...;
+#endif
+		  case "CreateNotify": {
+		    int window;
+		    sscanf(msg, "%*4c%4c%4c" "%2c%2c" "%2c%2c%2c" "%c",
+			   event->wid, window,
+			   event->x, event->y,
+			   event->width, event->height, event->borderWidth,
+			   event->override);
+		    event->parent = lookup_id(event->wid);
+		    event->window = lookup_id(window) || window;
+		    break;
+		  }
+#if 0
+		  case "DestroyNotify":
+		    ...;
+		  case "UnmapNotify":
+		    ...;
+		  case "MapNotify":
+		    ...;
+		  case "MapRequest":
+		    ...;
+		  case "ReparentNotify":
+		    ...;
+		  case "ConfigureNotify":
+		    ...;
+		  case "ConfigureRequest":
+		    ...;
+		  case "GravityNotify":
+		    ...;
+		  case "ResizeRequest":
+		    ...;
+		  case "CirculateNotify":
+		    ...;
+		  case "CirculateRequest":
+		    ...;
+		  case "PropertyNotify":
+		    ...;
+		  case "SelectionClear":
+		    ...;
+		  case "SelectionRequest":
+		    ...;
+		  case "SelectionNotify":
+		    ...;
+		  case "ColormapNotify":
+		    ...;
+		  case "ClientMessage":
+		    ...;
+		  case "MappingNotify":
 #endif		
-	      default:  /* Any other event */
-		return ({ ACTION_EVENT,
-			    ([ "type" : "Unimplemented",
+		  default:  /* Any other event */
+		    event = ([ "type" : "Unimplemented",
 			     "name" : type,
-			     "raw" : msg ]) });
-	      
+			     "raw" : msg ]);
+		    break;
+		  }
+		return ({ ACTION_EVENT, event });
 	      }
-	    break;
+	    break; 
 	  }
 	case STATE_WAIT_REPLY:
 	  reply->rest += msg;
diff --git a/lib/modules/Protocols.pmod/X.pmod/_Xlib.pmod b/lib/modules/Protocols.pmod/X.pmod/_Xlib.pmod
index 6d6471fac8..45fd957b3e 100644
--- a/lib/modules/Protocols.pmod/X.pmod/_Xlib.pmod
+++ b/lib/modules/Protocols.pmod/X.pmod/_Xlib.pmod
@@ -6,21 +6,48 @@
 object display_re = Regexp("([^:]*):([0-9]+).([0-9]+)");
 
 array(string) window_attributes =
-({ "background_pixmap",
-   "background_pixel",
-   "border_pixmap",
-   "border_pixel",
-   "bit_gravity",
-   "win_gravity",
-   "backing_store",
-   "backing_bit_planes",
-   "backing_pixel",
-   "override_redirect",
-   "save_under",
-   "event_mask",
-   "do_not_propagate_mask",
-   "colormap",
-   "cursor" });
+({ "BackPixmap",
+   "BackPixel",
+   "BorderPixmap",
+   "BorderPixel",
+   "BitGravity",
+   "WinGravity",
+   "BackingStore",
+   "BackingPlanes",
+   "BackingPixel",
+   "OverrideRedirect",
+   "SaveUnder",
+   "EventMask",
+   "DontPropagate",
+   "Colormap",
+   "Cursor" });
+
+array(string) gc_attributes =
+({
+  "Function",
+  "PlaneMask",
+  "Foreground",
+  "Background",
+  "LineWidth",
+  "LineStyle",
+  "CapStyle",
+  "JoinStyle",
+  "FillStyle",
+  "FillRule",
+  "Tile",
+  "Stipple",
+  "TileStipXOrigin",
+  "TileStipYOrigin",
+  "Font",
+  "SubwindowMode",
+  "GraphicsExposures",
+  "ClipXOrigin",
+  "ClipYOrigin",
+  "ClipMask",
+  "DashOffset",
+  "DashList",
+  "ArcMode"
+});
 
 mapping(string:int) event_masks =
 ([
diff --git a/lib/modules/Protocols.pmod/X.pmod/my_struct.pmod b/lib/modules/Protocols.pmod/X.pmod/my_struct.pmod
index c05e452a27..1fd6859562 100644
--- a/lib/modules/Protocols.pmod/X.pmod/my_struct.pmod
+++ b/lib/modules/Protocols.pmod/X.pmod/my_struct.pmod
@@ -3,8 +3,7 @@
  * This should replace ADT.struct at some time.
  */
 
-#define error(x) throw( ({ (x), backtrace() }) )
-// #include "error.h"
+#include "error.h"
 
 class struct {     
   string buffer;
-- 
GitLab