Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/Window-creation-X11/OCaml/window-creation-x11.ocaml
Normal file
24
Task/Window-creation-X11/OCaml/window-creation-x11.ocaml
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
open Xlib
|
||||
|
||||
let () =
|
||||
let d = xOpenDisplay "" in
|
||||
let s = xDefaultScreen d in
|
||||
let w = xCreateSimpleWindow d (xRootWindow d s) 10 10 100 100 1
|
||||
(xBlackPixel d s) (xWhitePixel d s) in
|
||||
xSelectInput d w [ExposureMask; KeyPressMask];
|
||||
xMapWindow d w;
|
||||
|
||||
let msg = "Hello, World!" in
|
||||
|
||||
let rec main_loop() =
|
||||
match xEventType(xNextEventFun d) with
|
||||
| Expose ->
|
||||
xFillRectangle d w (xDefaultGC d s) 20 20 10 10;
|
||||
xDrawString d w (xDefaultGC d s) 10 50 msg;
|
||||
main_loop()
|
||||
| KeyPress -> () (* exit main loop *)
|
||||
| _ -> main_loop()
|
||||
in
|
||||
main_loop();
|
||||
xCloseDisplay d;
|
||||
;;
|
||||
Loading…
Add table
Add a link
Reference in a new issue