From: Michael D. Lowis Date: Fri, 8 Sep 2017 20:27:10 +0000 (-0400) Subject: fixed update event to ensure correct behavior X-Git-Url: https://git.mdlowis.com/?a=commitdiff_plain;h=94b01723691fc8055556615bd3d83aa157f9deab;p=archive%2Ftide-ocaml.git fixed update event to ensure correct behavior --- diff --git a/edit.ml b/edit.ml index 09d84b1..e01cb8d 100644 --- 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 () = diff --git a/lib/x11_prims.c b/lib/x11_prims.c index c370849..1ab4a05 100644 --- a/lib/x11_prims.c +++ b/lib/x11_prims.c @@ -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);