# Toolchain Configuration
#-------------------------------------------------------------------------------
-INCS = -I . -I lib -I /usr/X11R6/include -I /usr/include/freetype2
+INCS = -I . -I lib -I /usr/X11R6/include -I /usr/include/freetype2 -I /usr/X11R6/include/freetype2
LIBS = -L/usr/X11R6/lib -lX11 -lXft
ifeq ($(NATIVE), 1)
-type atom
-type winid
+type xatom
+type xwin
+type xevent =
+ Focus of { focused: bool }
+ | KeyPress of { mods: int; rune: int }
+ | MouseBtn of {
+ mods: int;
+ btn: int;
+ x: int;
+ y: int;
+ pressed: bool;
+ dragged: bool
+ }
+ | Paste of { text: string }
+ | Command of { commands: string array }
+ | Resize of { height: int; width: int }
+ | Shutdown
+ | QueueEmpty
external connect : unit -> unit
= "x11_connect"
external disconnect : unit -> unit
= "x11_disconnect"
+external connfd : unit -> int
+ = "x11_connfd"
+
external make_window : int -> int -> unit
= "x11_make_window"
external show_window : bool -> unit
= "x11_show_window"
+external has_event : unit -> bool
+ = "x11_has_event"
+
+external next_event : unit -> xevent
+ = "x11_next_event"
+
external errno : unit -> int
= "x11_errno"
-external intern : string -> atom
+external intern : string -> xatom
= "x11_intern"
-external prop_set : winid -> atom -> string -> unit
+external prop_set : xwin -> xatom -> string -> unit
= "x11_prop_set"
-external prop_get : winid -> atom -> string
+external prop_get : xwin -> xatom -> string
= "x11_prop_get"
(* to be implemented
unsigned depth;
int screen;
Window root;
- int errno;
+ int errnum;
/* assume one window per process for now */
Window self;
XftDraw* xft;
CAMLreturn(Val_unit);
}
+CAMLprim value x11_connfd(void) {
+ CAMLparam0();
+ CAMLreturn(Val_int( ConnectionNumber(X.display) ));
+}
+
CAMLprim value x11_make_window(value height, value width) {
CAMLparam2(height, width);
create_window(Int_val(height), Int_val(width));
- CAMLreturn(Val_unit);
+ CAMLreturn(Val_int(X.self));
}
CAMLprim value x11_make_dialog(value height, value width) {
Atom WindowType = XInternAtom(X.display, "_NET_WM_WINDOW_TYPE", False);
Atom DialogType = XInternAtom(X.display, "_NET_WM_WINDOW_TYPE_DIALOG", False);
XChangeProperty(X.display, X.self, WindowType, XA_ATOM, 32, PropModeReplace, (unsigned char*)&DialogType, 1);
- CAMLreturn(Val_unit);
+ CAMLreturn(Val_int(X.self));
}
CAMLprim value x11_show_window(value state) {
CAMLprim value x11_errno(void) {
CAMLparam0();
- CAMLreturn(Val_int(X.errno));
+ CAMLreturn(Val_int(X.errnum));
}
CAMLprim value x11_intern(value name) {
}
static int error_handler(Display* disp, XErrorEvent* ev) {
- X.errno = ev->error_code;
+ X.errnum = ev->error_code;
return 0;
}