]> git.mdlowis.com Git - archive/tide-ocaml.git/commitdiff
fixed segfault in handling of TShutdown
authorMichael D. Lowis <mike@mdlowis.com>
Thu, 7 Sep 2017 01:07:53 +0000 (21:07 -0400)
committerMichael D. Lowis <mike@mdlowis.com>
Thu, 7 Sep 2017 01:07:53 +0000 (21:07 -0400)
Makefile
edit.ml
lib/x11_prims.c

index 6f84b66c2761e71cd5f57a0c6506c21c8d0b3c8f..22c6baae68fc0f546983941a41e8e7b94f61c186 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ LIBS = -L/usr/X11R6/lib -lX11 -lXft
 
 ifeq ($(NATIVE), 1)
     OC         = ocamlopt
-    OCFLAGS    =
+    OCFLAGS    = -g
     MKLIB      = ocamlmklib
     MKLIBFLAGS = -custom
     OBJEXT     = cmx
diff --git a/edit.ml b/edit.ml
index 938adf7383933036af32759ff6caab41722e0cbd..369fbc6ec46f68b5b90161b69f00c2ddc4622f61 100644 (file)
--- a/edit.ml
+++ b/edit.ml
@@ -23,7 +23,7 @@ let onevent = function
   | KeyPress e       -> onkeypress e.mods e.rune
   | MouseClick e     -> onmousebtn e.mods e.btn e.x e.y true
   | MouseRelease e   -> onmousebtn e.mods e.btn e.x e.y false
-  | MouseMove e      -> onmousedrag e.mods e.x e.y
+  | MouseMove e      -> onmousemove e.mods e.x e.y
   | Paste e          -> print_endline "paste"
   | Command e        -> print_endline "command"
   | PipeClosed e     -> print_endline "pipeclosed"
index 1d454c2f5a17e8e20535a3ece7e56b992142dfa6..62f440bb91c991e2a2df55cd620bbe5c7b965210 100644 (file)
@@ -9,8 +9,12 @@
 #include <X11/Xatom.h>
 #include <X11/Xft/Xft.h>
 
-/* The order of this enum should match the type specified in x11.ml */
+/* The order of this enum should match the type specified in x11.ml. The
+   variants are divided into two groups, those with args and those without.
+   Each group's tags increment, starting at 0, in the order the appear in the
+   type definition */
 enum {
+    TShutdown = 0,
     TFocus = 0,
     TKeyPress,
     TMouseClick,
@@ -21,8 +25,7 @@ enum {
     TPipeClosed,
     TPipeWriteReady,
     TPipeReadReady,
-    TUpdate,
-    TShutdown
+    TUpdate
 };
 
 enum Keys {
@@ -182,18 +185,12 @@ CAMLprim value x11_event_loop(value ms, value cbfn) {
                 if (XFilterEvent(&e, None)) continue;
                 if (!EventHandlers[e.type]) continue;
                 event = EventHandlers[e.type](&e);
-                if (event != Val_unit) {
-                puts("B event");
-                printf("event: %#x\n", event);
+                if (event != Val_unit)
                     caml_callback(cbfn, event);
-                puts("A event");
-                }
             }
 
             if (X.running) {
-                puts("B event");
                 caml_callback(cbfn, mkrecord(TUpdate, 2, X.width, X.height));
-                puts("A event");
                 XCopyArea(X.display, X.pixmap, X.self, X.gc, 0, 0, X.width, X.height, 0, 0);
             }
         }
@@ -336,7 +333,7 @@ static value ev_mouse(XEvent* e) {
     int mods = e->xbutton.state, btn = e->xbutton.button,
         x = e->xbutton.x, y = e->xbutton.y;
     if (e->type == MotionNotify)
-        return mkrecord(TMouseDrag, 3, Val_int(mods), Val_int(x), Val_int(y));
+        return mkrecord(TMouseMove, 3, Val_int(mods), Val_int(x), Val_int(y));
     else if (e->type == ButtonPress)
         return mkrecord(TMouseClick, 4, Val_int(mods), Val_int(btn), Val_int(x), Val_int(y));
     else
@@ -368,7 +365,7 @@ static value ev_propnotify(XEvent* e) {
 static value ev_clientmsg(XEvent* e) {
     Atom wmDeleteMessage = XInternAtom(X.display, "WM_DELETE_WINDOW", False);
     if (e->xclient.data.l[0] == wmDeleteMessage)
-        return mkrecord(TShutdown, 1, 0);
+        return mkrecord(TShutdown, 0);
     return Val_unit;
 }