Use integer tags, provide macros for pleasant handlers
This commit is contained in:
@@ -26,6 +26,12 @@
|
||||
R:input
|
||||
R:map
|
||||
R:keyboard-group
|
||||
handle-exit
|
||||
handle-idle
|
||||
handle-layout-demand
|
||||
handle-user-command
|
||||
handle-new-output
|
||||
; Provided by C, injected into this module
|
||||
riverctl
|
||||
install-handler
|
||||
seat
|
||||
@@ -39,6 +45,7 @@
|
||||
seat-focused-view-title
|
||||
seat-mode
|
||||
))
|
||||
(use-modules (srfi srfi-1))
|
||||
|
||||
(define (stringify x)
|
||||
(cond ((string? x) x)
|
||||
@@ -79,3 +86,36 @@
|
||||
(riverctl "keyboard-group-add" N d))
|
||||
D)))))
|
||||
|
||||
(define-syntax handle-exit
|
||||
(syntax-rules ()
|
||||
((_ body body* ...)
|
||||
(install-handler 'exit (lambda () body body* ...)))))
|
||||
|
||||
(define-syntax handle-idle
|
||||
(syntax-rules ()
|
||||
((_ tag (event) body body* ...)
|
||||
(install-handler tag (lambda (event) body body* ...)))))
|
||||
|
||||
(define-syntax handle-layout-demand
|
||||
(syntax-rules ()
|
||||
((_ (views width height tags output) body body* ...)
|
||||
(install-handler 'layout-demand (lambda (views width height tags out)
|
||||
(let ((output (find (lambda (x) (eq? (output-name x) out)) (outputs))))
|
||||
body body* ...
|
||||
))))))
|
||||
|
||||
(define-syntax handle-user-command
|
||||
(syntax-rules ()
|
||||
((_ (command tags output) body body* ...)
|
||||
(install-handler 'user-command (lambda (command tags out)
|
||||
(let ((output (find (lambda (x) (eq? (output-name x) out)) (outputs))))
|
||||
body body* ...
|
||||
))))))
|
||||
|
||||
(define-syntax handle-new-output
|
||||
(syntax-rules ()
|
||||
((_ (output) body body* ...)
|
||||
(install-handler 'new-output (lambda (out)
|
||||
(let ((output (find (lambda (x) (eq? (output-name x) out)) (outputs))))
|
||||
body body* ...
|
||||
))))))
|
||||
|
||||
Reference in New Issue
Block a user