]> git.mdlowis.com Git - archive/tide-ocaml.git/commitdiff
fixed update event to ensure correct behavior
authorMichael D. Lowis <mike.lowis@gentex.com>
Fri, 8 Sep 2017 20:27:10 +0000 (16:27 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Fri, 8 Sep 2017 20:27:10 +0000 (16:27 -0400)
edit.ml
lib/x11_prims.c

diff --git a/edit.ml b/edit.ml
index 09d84b17379736a592773e91b177ecc655811da9..e01cb8d6abf63ad5d3688f3b393ead98ac9ef6a4 100644 (file)
--- a/edit.ml
+++ b/edit.ml
@@ -13,8 +13,8 @@ let onmousemove mods x y =
   print_endline "onmousemove"
 
 let onupdate width height =
-  print_endline "onupdate";
-  draw_rect { x = 0; y = 0; w = width; h = height; c = 0x55555555 };
+  Printf.printf "onupdate: %d %d\n" width height;
+  draw_rect { x = 0; y = 0; w = width; h = height; c = Cfg.Color.palette.(0) };
   flip ()
 
 let onshutdown () =
index c370849e4d1899bb2f24faf29e0c2aa62a702d57..1ab4a05ddae4efa5809808cf6a2a3db452ddbb19 100644 (file)
@@ -177,11 +177,15 @@ CAMLprim value x11_flip(void) {
 
 CAMLprim value x11_draw_rect(value rect) {
     CAMLparam1(rect);
-
+    #define intfield(r,i) Int_val(Field(r,i))
     XftColor clr;
-    xftcolor(&clr, Field(rect, 4));
-    XftDrawRect(X.xft, &clr, Field(rect, 0), Field(rect, 1),  /* x,y */
-                             Field(rect, 2), Field(rect, 3)); /* w,h */
+    printf("x: %d y: %d w: %d h: %d: c: %#x\n",
+         intfield(rect, 0),  intfield(rect, 1),  intfield(rect, 2),
+         intfield(rect, 3),  intfield(rect, 4)
+    );
+    xftcolor(&clr, intfield(rect, 4));
+    XftDrawRect(X.xft, &clr, intfield(rect, 0), intfield(rect, 1),  /* x,y */
+                             intfield(rect, 2), intfield(rect, 3)); /* w,h */
     XftColorFree(X.display, X.visual, X.colormap, &clr);
 
     CAMLreturn(Val_unit);
@@ -220,8 +224,10 @@ CAMLprim value x11_event_loop(value ms, value cbfn) {
         }
 
         /* generate an update event and flush any outgoing events */
-        if (X.running)
-            caml_callback(cbfn, mkrecord(TUpdate, 2, X.width, X.height));
+        if (X.running) {
+        printf("update W: %d H: %d\n", X.width, X.height);
+            caml_callback(cbfn, mkrecord(TUpdate, 2, Val_int(X.width), Val_int(X.height)));
+        }
         XFlush(X.display);
     }
     CAMLreturn(Val_unit);
@@ -282,8 +288,7 @@ static void create_window(int height, int width) {
         (wa.height - X.height) / 2,
         X.width,
         X.height,
-        0, X.depth,
-        0xffffffff // config_get_int(Color00)
+        0, X.depth, 0
     );
 
     /* register interest in the delete window message */
@@ -409,6 +414,7 @@ static value ev_clientmsg(XEvent* e) {
 static value ev_configure(XEvent* e) {
     value event = Val_int(TNone);
     if (e->xconfigure.width != X.width || e->xconfigure.height != X.height) {
+        printf("W: %d H: %d\n", X.width, X.height);
         X.width  = e->xconfigure.width;
         X.height = e->xconfigure.height;
         X.pixmap = XCreatePixmap(X.display, X.self, X.width, X.height, X.depth);