From b9d785aa9c681f0a6c804eec9bc356aaca78f3ee Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Tue, 2 Jan 2024 22:07:15 -0600 Subject: initial commit --- .gitignore | 3 ++ acdwm | Bin 0 -> 70664 bytes acdwm.egg | 9 +++++ acdwm.scm | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ok | 19 +++++++++++ 5 files changed, 141 insertions(+) create mode 100644 .gitignore create mode 100755 acdwm create mode 100644 acdwm.egg create mode 100755 acdwm.scm create mode 100755 ok diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..75039f1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.fr +*.build.sh +*.install.sh \ No newline at end of file diff --git a/acdwm b/acdwm new file mode 100755 index 0000000..a847fa2 Binary files /dev/null and b/acdwm differ diff --git a/acdwm.egg b/acdwm.egg new file mode 100644 index 0000000..a0fb9ce --- /dev/null +++ b/acdwm.egg @@ -0,0 +1,9 @@ +;; -*- scheme -*- + +((synopsis "acdw indow manager") + (author "Case Duckworth") + (license "God Willing") + (version 0.0.0) + (dependencies matchable xlib srfi-1) + (components + (program acdwm))) diff --git a/acdwm.scm b/acdwm.scm new file mode 100755 index 0000000..fdd8395 --- /dev/null +++ b/acdwm.scm @@ -0,0 +1,110 @@ +#!/bin/sh +#| -*- scheme -*- +exec csi -ss "$0" "$@" ; acdwm +based on tinywm: https://github.com/mackstann/tinywm/ +|# + +(import (chicken bitwise) + (chicken process-context) + (srfi 1) + matchable + xlib) + +(define TRUE 1) +(define FALSE 0) + +(define dpy (make-parameter #f)) +(define screen (make-parameter #f)) +(define root (make-parameter #f)) + +(define (grab-keys) + (xgrabkey (dpy) + (char->integer (xkeysymtokeycode (dpy) (xstringtokeysym "F1"))) + MOD1MASK + (root) + TRUE + GRABMODEASYNC + GRABMODEASYNC) + (xgrabbutton (dpy) + 1 + MOD1MASK + (root) + TRUE + (bitwise-ior BUTTONPRESSMASK + BUTTONRELEASEMASK + POINTERMOTIONMASK) + GRABMODEASYNC + GRABMODEASYNC + NONE + NONE) + (xgrabbutton (dpy) + 3 + MOD1MASK + (root) + TRUE + (bitwise-ior BUTTONPRESSMASK + BUTTONRELEASEMASK + POINTERMOTIONMASK) + GRABMODEASYNC + GRABMODEASYNC + NONE + NONE)) + +(define (handle-events) + (let ((event (make-xevent)) + (start (make-xbuttonevent)) + (attrs (make-xwindowattributes))) + (set-xbuttonevent-subwindow! start NONE) + (let loop () + (xnextevent (dpy) event) + (cond + ((and (= KEYPRESS (xevent-type event)) + (not (= NONE (xevent-xkey-subwindow event)))) + (xraisewindow (dpy) (xevent-xkey-subwindow event))) + + ((and (= BUTTONPRESS (xevent-type event)) + (not (= NONE (xevent-xbutton-subwindow event)))) + (print "button!") + (xgetwindowattributes (dpy) (xevent-xbutton-subwindow event) attrs) + (set-xbuttonevent-x_root! start (xevent-xbutton-x_root event)) + (set-xbuttonevent-y_root! start (xevent-xbutton-y_root event)) + (set-xbuttonevent-button! start (xevent-xbutton-button event)) + (set-xbuttonevent-subwindow! start (xevent-xbutton-subwindow event))) + + ((and (= MOTIONNOTIFY (xevent-type event)) + (not (= NONE (xbuttonevent-subwindow start)))) + (let ((xdiff (- (xevent-xbutton-x_root event) + (xbuttonevent-x_root start))) + (ydiff (- (xevent-xbutton-y_root event) + (xbuttonevent-y_root start))) + (button (xbuttonevent-button start))) + (xmoveresizewindow (dpy) + (xbuttonevent-subwindow start) + (+ (xwindowattributes-x attrs) + (if (= button 1) xdiff 0)) + (+ (xwindowattributes-y attrs) + (if (= button 1) ydiff 0)) + (max 1 (+ (xwindowattributes-width attrs) + (if (= button 3) xdiff 0))) + (max 1 (+ (xwindowattributes-height attrs) + (if (= button 3) ydiff 0)))))) + + ((= BUTTONRELEASE (xevent-type event)) + (print "buttonrelease!") + (set-xbuttonevent-subwindow! start NONE))) + + ;; Annnd go around again + (loop)))) + +(define (main args) + (parameterize ((dpy (xopendisplay #f))) + (assert (dpy)) + (parameterize ((screen (xdefaultscreen (dpy)))) + (parameterize ((root (xrootwindow (dpy) (screen)))) + (grab-keys) + (handle-events))))) + +(cond-expand + ((or chicken-script compiling) + (main (command-line-arguments))) + (else)) diff --git a/ok b/ok new file mode 100755 index 0000000..c135a93 --- /dev/null +++ b/ok @@ -0,0 +1,19 @@ +#!/bin/sh + +fr<<. +acdwm chickenbuild acdwm.scm +. + +xephyr(){ + dep acdwm + quietly killall Xephyr + ok Xephyr -ac -screen 800x600 -br -reset -terminate 2>/dev/null :1 & + sleep 1 + xterm -display :1 & + xterm -display :1 -geometry +100+100 & + ok env DISPLAY=:1 ./acdwm +} + +chickenbuild(){ + ok chicken-install -n +} -- cgit 1.4.1-21-gabe81