]> git.mdlowis.com Git - archive/tide-ocaml.git/commitdiff
removed resize event in favor of Update event with width+height
authorMichael D. Lowis <mike.lowis@gentex.com>
Tue, 5 Sep 2017 20:09:25 +0000 (16:09 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Tue, 5 Sep 2017 20:09:25 +0000 (16:09 -0400)
edit.ml
lib/x11.ml
lib/x11_prims.c

diff --git a/edit.ml b/edit.ml
index 2c40b47218b7e089549e2cee83fa54cff6e08f9f..244938f488452c7fafb72fe51b3c9252682f3065 100644 (file)
--- a/edit.ml
+++ b/edit.ml
@@ -1,9 +1,8 @@
 open X11
 let () =
-  X11.make_window 640 480;
-  X11.show_window true;
-  X11.event_loop 50 (fun x ->
-  match x with
+  let win = X11.make_window 640 480 in
+  X11.show_window win true;
+  X11.event_loop 50 (function
   | Focus _          -> print_endline "focus"
   | KeyPress _       -> print_endline "keypress"
   | MouseClick _     -> print_endline "mouseclick"
index 78b9ed24a8d9f395bc0a3cd9a59531aa10ef6d08..7753f98152bbbf5d270524be24d0ff037b653201 100644 (file)
@@ -7,12 +7,12 @@ type xevent =
   | MouseRelease of { mods: int; btn: int; x: int; y: int }
   | MouseDrag of { mods: int; x: int; y: int }
   | Paste of { text: string }
-  | Resize of { height: int; width: int }
+  (*| Resize of { height: int; width: int }*)
   | Command of { commands: string array }
   | PipeClosed of { fd: int }
   | PipeWriteReady of { fd: int }
   | PipeReadReady of { fd: int }
-  | Update
+  | Update of { width: int; height: int }
   | Shutdown
 
 external connect : unit -> unit
@@ -21,13 +21,13 @@ external connect : unit -> unit
 external disconnect : unit -> unit
                     = "x11_disconnect"
 
-external make_window : int -> int -> unit
+external make_window : int -> int -> xwin
                      = "x11_make_window"
 
-external make_dialog : int -> int -> unit
+external make_dialog : int -> int -> xwin
                      = "x11_make_dialog"
 
-external show_window : bool -> unit
+external show_window : xwin -> bool -> unit
                   = "x11_show_window"
 
 external event_loop : int -> (xevent -> unit) -> unit
@@ -43,6 +43,10 @@ external prop_get : xwin -> xatom -> string
                   = "x11_prop_get"
 
 (* to be implemented
+
+void x11_draw_rect(int color, int x, int y, int width, int height)
+external draw_rect : int -> int -> int -> int -> int -> unit
+
 external sel_set : xatom -> string -> unit
                  = "x11_sel_set"
 external sel_fetch : xatom -> unit
index d5e67c910642316790152973cb06285cb6b92369..afab8e71cdea49eacefd51e922a51093a52e5892 100644 (file)
@@ -17,7 +17,6 @@ enum {
     TMouseRelease,
     TMouseDrag,
     TPaste,
-    TResize,
     TCommand,
     TPipeClosed,
     TPipeWriteReady,
@@ -152,12 +151,12 @@ CAMLprim value x11_make_dialog(value height, value width) {
     CAMLreturn(Val_int(X.self));
 }
 
-CAMLprim value x11_show_window(value state) {
-    CAMLparam1(state);
+CAMLprim value x11_show_window(value win, value state) {
+    CAMLparam2(win,state);
     if (Bool_val(state))
-        XMapWindow(X.display, X.self);
+        XMapWindow(X.display, (Window)Int_val(win));
     else
-        XUnmapWindow(X.display, X.self);
+        XUnmapWindow(X.display, (Window)Int_val(win));
     CAMLreturn(Val_unit);
 }
 
@@ -185,7 +184,7 @@ CAMLprim value x11_event_loop(value ms, value cbfn) {
             }
 
             if (X.running) {
-                caml_callback(cbfn, mkrecord(TUpdate, 0));
+                caml_callback(cbfn, mkrecord(TUpdate, 2, X.width, X.height));
                 XCopyArea(X.display, X.pixmap, X.self, X.gc, 0, 0, X.width, X.height, 0, 0);
             }
         }
@@ -372,7 +371,6 @@ static value ev_configure(XEvent* e) {
         X.height = e->xconfigure.height;
         X.pixmap = XCreatePixmap(X.display, X.self, X.width, X.height, X.depth);
         X.xft    = XftDrawCreate(X.display, X.pixmap, X.visual, X.colormap);
-        event    = mkrecord(TResize, 2, X.height, X.width);
     }
     return event;
 }