Hello,
I’m looking for a low-level X library with lwt support. but I did not found anything on opam, even the OCaml-Xlib is not referenced.
Is there any code I can use ?
Hello,
I’m looking for a low-level X library with lwt support. but I did not found anything on opam, even the OCaml-Xlib is not referenced.
Is there any code I can use ?
After some exploration in the xcb and ctypes documentation, I’ve managed a working proof of concept and to to recreate the xcb hello world :
xcb publish the underlying file descriptor, which allow to use Lwt for waiting events.
An example is given below :
open Xcb
let () = begin
match Xcb.connect () with
| None -> ()
| Some connexion ->
Xcb.get_setup connexion
|> Xcb.setup_roots_iterator
|> fun iter -> (
let screen = Xcb.getf iter Xcb.data in
let width = ((screen |.-> Xcb.width_in_pixel) / 2)
and height = ((screen |.-> Xcb.height_in_pixel) / 2)
and depth = ((screen |.-> Xcb.root_depth)) in
Printf.printf "Creating window (%d, %d) %d\n%!" width height depth;
match Xcb.create_window
connexion
~depth:(screen |.-> Xcb.root_depth)
~parent:(screen |.-> Xcb.root)
~x:10
~y:10
~width
~height
~border:0
1
~visual:(screen |.-> Xcb.root_visual)
[
Back_pixel (screen |.-> Xcb.white_pixel);
Event_mask ([Exposure; Key_press]);
]
with
| None -> print_endline "Error"
| Some id ->
let _ = Xcb.map_window connexion id in
let _ = Xcb.flush connexion in
print_endline "w created";
let rec p () = begin
match%lwt Xcb.poll_event connexion with
| Key_press -> print_endline "Key_press"; Lwt.return_unit
| _ -> print_endline "got event"; p()
end in
Lwt_main.run (p ())
)
end
I need to review the code and provide something more high level, but this is a first step 
I think there’s only some old unmaintained bindings to the C libraries which definitely don’t use Lwt.
Anyway, I’m writing a bindings generator that will output bindings with Lwt support… once it’s done. Haven’t done much progress lately. Though I’d be happy to return to it were somebody willing to help.