summaryrefslogtreecommitdiff
path: root/wm.scm
diff options
context:
space:
mode:
authorSamuel Fadel <samuel@nihil.ws>2022-12-01 15:03:05 +0100
committerSamuel Fadel <samuel@nihil.ws>2022-12-01 15:03:05 +0100
commit7aa66702b2b9396add0cc20849ec89a48495c7ff (patch)
tree3d5bf019313264ff6527e5cfb464b060113b44aa /wm.scm
Initial commit.
Sketching Scheme/C interop.
Diffstat (limited to 'wm.scm')
-rw-r--r--wm.scm24
1 files changed, 24 insertions, 0 deletions
diff --git a/wm.scm b/wm.scm
new file mode 100644
index 0000000..8304dca
--- /dev/null
+++ b/wm.scm
@@ -0,0 +1,24 @@
+(define-module (wm)
+ #:use-module (system foreign)
+ #:export (wm-init wm-quit))
+
+(define libschewm (dynamic-link "libschewm"))
+
+(define (int-as-bool i)
+ (not (eq? 0 i)))
+
+(define (schewm-func return-type name args)
+ (pointer->procedure
+ return-type
+ (dynamic-func name libschewm)
+ args))
+
+(define (wm-init)
+ (let ((c/wm-init
+ (schewm-func int "wm_init" '())))
+ (int-as-bool (c/wm-init))))
+
+(define (wm-quit s)
+ (let ((c/wm-quit
+ (schewm-func void "wm_quit" (list '*))))
+ (c/wm-quit (string->pointer s))))