From 8bf8472697116ad5649be7b7889cd28d28d1c550 Mon Sep 17 00:00:00 2001 From: Philippe Brochard Date: Thu, 8 Aug 2013 00:06:49 +0200 Subject: [PATCH] Add a MOC - Console audio player - interface --- TODO | 11 +++-- contrib/moc.lisp | 111 +++++++++++++++++++++++++++++++++++++++++++++++ src/clfswm-internal.lisp | 69 +++++++++++++++++++++++++++++ src/package.lisp | 6 +-- src/xlib-util.lisp | 2 +- 5 files changed, 192 insertions(+), 7 deletions(-) create mode 100644 contrib/moc.lisp diff --git a/TODO b/TODO index 2d64202..e857e8c 100644 --- a/TODO +++ b/TODO @@ -9,6 +9,14 @@ Should handle these soon. - Make CLFSWM running with ECL +- Implement a save/restore root-frame system. And use it on error reset or for undo/redo. + +- Undo/redo + +- Dump frame -> tree saved in register / save/restore (frame-tree-register n) + +- Save/restore frame-tree-register to file (~/.clfswmrc) + FOR THE NEXT RELEASE ==================== @@ -20,8 +28,6 @@ FOR THE NEXT RELEASE MAYBE ===== -- Implement a save/restore root-frame system. And use it on error reset or for undo/redo. - - Add a tabbar layout : save some space on top/left... of the frame and display clickable children name. @@ -49,6 +55,5 @@ MAYBE http://en.wikipedia.org/wiki/Compositing_window_manager http://ktown.kde.org/~fredrik/composite_howto.html -- Undo/redo diff --git a/contrib/moc.lisp b/contrib/moc.lisp new file mode 100644 index 0000000..3a66bde --- /dev/null +++ b/contrib/moc.lisp @@ -0,0 +1,111 @@ +;;; -------------------------------------------------------------------------- +;;; CLFSWM - FullScreen Window Manager +;;; +;;; -------------------------------------------------------------------------- +;;; Documentation: MOC - Console audio player - interface +;;; -------------------------------------------------------------------------- +;;; +;;; (C) 2013 Philippe Brochard +;;; +;;; This program is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or +;;; (at your option) any later version. +;;; +;;; This program is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program; if not, write to the Free Software +;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +;;; +;;; Documentation: If you want to use this file, just add this line in +;;; your configuration file: +;;; +;;; (load-contrib "moc.lisp") +;;; +;;; -------------------------------------------------------------------------- + +(in-package :clfswm) + +(format t "Loading MOC code... ") + + +(defun moc-menu () + "Open the MOC menu" + (open-menu (find-menu 'moc-menu))) + + +(defun start-mocp () + "Start mocp" + (do-shell "exec xterm -e 'mocp 2> /dev/null'")) + + +(defun show-moc-info () + "Show MOC informations" + (info-on-shell "MOC informations:" "mocp --info") + (moc-menu)) + +(defun moc-previous (&optional (in-menu t)) + "Play the previous song in the current playlist" + (do-shell "mocp --previous" nil t) + (when in-menu + (moc-menu))) + +(defun moc-next (&optional (in-menu t)) + "Play the next song in the current playlist" + (do-shell "mocp --next" nil t) + (when in-menu + (moc-menu))) + +(defun moc-toggle () + "Toggles Play/Pause, plays if stopped" + (do-shell "mocp --toggle-pause")) + +(defun moc-play () + "Start playing" + (do-shell "mocp --play")) + +(defun moc-stop () + "Stop the currently playing playlists" + (do-shell "mocp --stop")) + + +(defun moc-seek-+5s (&optional (in-menu t)) + "Seeks to +5s" + (if in-menu + (progn + (do-shell "mocp --seek +5") + (moc-menu)) + (do-shell "mocp --seek +5" nil t))) + +(defun moc-seek--5s (&optional (in-menu t)) + "Seeks to -5s" + (if in-menu + (progn + (do-shell "mocp --seek -5") + (moc-menu)) + (do-shell "mocp --seek -5" nil t))) + +(unless (find-menu 'moc-menu) + (add-sub-menu 'help-menu "F3" 'moc-menu "MOC - Console audio player - menu") + + (add-menu-key 'moc-menu "i" 'show-moc-info) + (add-menu-key 'moc-menu "p" 'moc-previous) + (add-menu-key 'moc-menu "n" 'moc-next) + (add-menu-key 'moc-menu "t" 'moc-toggle) + (add-menu-key 'moc-menu "y" 'moc-play) + (add-menu-key 'moc-menu "k" 'moc-stop) + (add-menu-key 'moc-menu "x" 'moc-seek-+5s) + (add-menu-key 'moc-menu "w" 'moc-seek--5s) + (add-menu-key 'moc-menu "m" 'start-mocp)) + + +(defun moc-binding () + (define-main-key ("F3" :alt) 'moc-menu)) + +(add-hook *binding-hook* 'moc-binding) + +(format t "done~%") diff --git a/src/clfswm-internal.lisp b/src/clfswm-internal.lisp index 2659413..43ce372 100644 --- a/src/clfswm-internal.lisp +++ b/src/clfswm-internal.lisp @@ -1730,3 +1730,72 @@ managed." (+ (frame-rx child) 10) (+ (frame-ry child) 10)))))))))))) + + +;;; Dumping/restoring frame tree functions +(defun print-frame-tree (root &optional (disp-fun #'child-fullname)) + (labels ((rec (child space) + (print-space space) + (format t "~A~%" (funcall disp-fun child)) + (when (frame-p child) + (dolist (c (reverse (frame-child child))) + (rec c (+ space 2)))))) + (rec root 0))) + + +(defun window-list->xid-list (list) + (loop for win in list + collect (xlib:window-id win))) + + +(defun copy-frame (frame) + (with-slots (name number x y w h layout nw-hook managed-type + forced-managed-window forced-unmanaged-window + show-window-p hidden-children selected-pos + focus-policy data) + frame + (make-instance 'frame :name name :number number + :x x :y y :w w :h h + :layout layout :nw-hook nw-hook + :managed-type (if (consp managed-type) + (copy-list managed-type) + managed-type) + :forced-managed-window (window-list->xid-list forced-managed-window) + :forced-unmanaged-window (window-list->xid-list forced-unmanaged-window) + :show-window-p show-window-p + :hidden-children (window-list->xid-list hidden-children) + :selected-pos selected-pos + :focus-policy focus-policy + :data (copy-tree data)))) + +(defun dump-frame-tree () + "Return a tree list of frame dimensions and name" + (let ((root (make-instance 'frame :name "root"))) + (labels ((store (from root) + (when (frame-p from) + (dolist (c (frame-child from)) + (push (if (frame-p c) + (let ((new-root (copy-frame c))) + (store c new-root) + new-root) + (format nil "~A (#x~X)" (child-fullname c) (xlib:window-id c))) + (frame-child root)))))) + (store *root-frame* root) + (print-frame-tree root #'(lambda (x) + (if (frame-p x) + (format nil "~A - ~F ~F ~F ~F ~A ~A ~A ~X ~X ~A ~A ~A ~A ~A" + (child-fullname x) + (frame-x x) (frame-y x) (frame-w x) (frame-h x) + (frame-layout x) (frame-nw-hook x) + (frame-managed-type x) + (frame-forced-managed-window x) + (frame-forced-unmanaged-window x) + (frame-show-window-p x) + (frame-hidden-children x) + (frame-selected-pos x) + (frame-focus-policy x) + (frame-data x)) + x)))))) + + + diff --git a/src/package.lisp b/src/package.lisp index 5149953..87ac874 100644 --- a/src/package.lisp +++ b/src/package.lisp @@ -141,12 +141,12 @@ It is particulary useful with CLISP/MIT-CLX.") (defclass frame () ((name :initarg :name :accessor frame-name :initform nil) (number :initarg :number :accessor frame-number :initform 0) - ;;; Float size between 0 and 1 - Manipulate only this variable and not real size + ;;; Float size between 0 and 1 - Manipulate only those variables and not real size (x :initarg :x :accessor frame-x :initform 0.1) (y :initarg :y :accessor frame-y :initform 0.1) (w :initarg :w :accessor frame-w :initform 0.8) (h :initarg :h :accessor frame-h :initform 0.8) - ;;; Real size (integer) in screen size - Don't set directly this variables + ;;; Real size (integer) in screen size - Don't set directly those variables ;;; they may be recalculated by the layout manager. (rx :initarg :rx :accessor frame-rx :initform 0) (ry :initarg :ry :accessor frame-ry :initform 0) @@ -174,7 +174,7 @@ It is particulary useful with CLISP/MIT-CLX.") :documentation "A list of hidden children") (selected-pos :initarg :selected-pos :accessor frame-selected-pos :initform 0 :documentation "The position in the child list of the selected child") - (focus-policy :initarg :focus-ploicy :accessor frame-focus-policy + (focus-policy :initarg :focus-policy :accessor frame-focus-policy :initform *default-focus-policy*) (window :initarg :window :accessor frame-window :initform nil) (gc :initarg :gc :accessor frame-gc :initform nil) diff --git a/src/xlib-util.lisp b/src/xlib-util.lisp index b70f654..20bcf5f 100644 --- a/src/xlib-util.lisp +++ b/src/xlib-util.lisp @@ -103,6 +103,7 @@ Features: ~A" ;; `(progn ;; ,@body)) +(declaim (inline screen-width screen-height)) (defun screen-width () ;;(xlib:screen-width *screen*)) (x-drawable-width *root*)) @@ -112,7 +113,6 @@ Features: ~A" (x-drawable-height *root*)) - (defmacro with-x-pointer (&body body) "Bind (x y) to mouse pointer positions" `(multiple-value-bind (x y) -- 2.11.4.GIT