contrib/toolbar.lisp: End of toolbar framework.
[clfswm.git] / src / package.lisp
blobaa78f194dc707744d0cd7cf2774f4073dbe4a0dd
1 ;;; --------------------------------------------------------------------------
2 ;;; CLFSWM - FullScreen Window Manager
3 ;;;
4 ;;; --------------------------------------------------------------------------
5 ;;; Documentation: Package definition
6 ;;; --------------------------------------------------------------------------
7 ;;;
8 ;;; (C) 2012 Philippe Brochard <pbrochard@common-lisp.net>
9 ;;;
10 ;;; This program is free software; you can redistribute it and/or modify
11 ;;; it under the terms of the GNU General Public License as published by
12 ;;; the Free Software Foundation; either version 3 of the License, or
13 ;;; (at your option) any later version.
14 ;;;
15 ;;; This program is distributed in the hope that it will be useful,
16 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;;; GNU General Public License for more details.
19 ;;;
20 ;;; You should have received a copy of the GNU General Public License
21 ;;; along with this program; if not, write to the Free Software
22 ;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 ;;;
24 ;;; --------------------------------------------------------------------------
26 (in-package :cl-user)
28 (defpackage clfswm
29 (:use :common-lisp :my-html :tools :version)
30 ;; (:shadow :defun)
31 (:export :main
32 :reload-clfswm
33 :reset-clfswm
34 :exit-clfswm))
38 (in-package :clfswm)
40 ;;; CONFIG - Compress motion notify ?
41 ;; This variable may be useful to speed up some slow version of CLX.
42 ;; It is particulary useful with CLISP/MIT-CLX (and others).
43 (defconfig *have-to-compress-notify* t nil
44 "Compress event notify?
45 This variable may be useful to speed up some slow version of CLX.
46 It is particulary useful with CLISP/MIT-CLX.")
48 (defconfig *transparent-background* t nil
49 "Enable transparent background: one of nil, :pseudo, t (xcompmgr must be started)")
51 (defconfig *default-transparency* 0.9 nil
52 "Default transparency for all windows when in xcompmgr transparency mode")
54 (defconfig *show-root-frame-p* nil nil
55 "Show the root frame information or not")
58 (defconfig *border-size* 1 nil
59 "Windows and frames border size")
63 (defparameter *modifier-alias* '((:alt :mod-1) (:alt-l :mod-1)
64 (:numlock :mod-2)
65 (:super_l :mod-4)
66 (:alt-r :mod-5) (:alt-gr :mod-5)
67 (:capslock :lock))
68 "Syntax: (modifier-alias effective-modifier)")
71 (defparameter *display* nil)
72 (defparameter *screen* nil)
73 (defparameter *root* nil)
74 (defparameter *no-focus-window* nil)
76 (defparameter *background-image* nil)
77 (defparameter *background-gc* nil)
79 (defconfig *loop-timeout* 1 nil
80 "Maximum time (in seconds) to wait before calling *loop-hook*")
82 (defparameter *pixmap-buffer* nil)
84 (defparameter *contrib-dir* "")
86 (defparameter *default-font* nil)
87 ;;(defparameter *default-font-string* "9x15")
88 (defconfig *default-font-string* "fixed" nil
89 "The default font used in clfswm")
91 (defconfig *color-move-window* "DeepPink" 'Main-mode
92 "Color when moving or resizing a windows")
94 (defparameter *child-selection* nil)
96 ;;; CONFIG - Default frame datas
97 (defconfig *default-frame-data*
98 (list '(:tile-size 0.8) '(:tile-space-size 0.1)
99 '(:fast-layout (tile-left-layout tile-layout))
100 '(:main-layout-windows nil))
102 "Default slots set in frame date")
105 ;;; CONFIG - Default managed window type for a frame
106 ;;; type can be :all, :normal, :transient, :maxsize, :desktop, :dock, :toolbar, :menu, :utility, :splash, :dialog
107 (defconfig *default-managed-type* '(:normal) nil
108 "Default managed window types")
109 ;;(defparameter *default-managed-type* '(:normal :maxsize :transient))
110 ;;(defparameter *default-managed-type* '(:normal :transient :maxsize :desktop :dock :toolbar :menu :utility :splash :dialog))
111 ;;(defparameter *default-managed-type* '())
112 ;;(defparameter *default-managed-type* '(:all))
115 ;;; CONFIG - Default focus policy
116 (defconfig *default-focus-policy* :click nil
117 "Default mouse focus policy. One of :click, :sloppy, :sloppy-strict or :sloppy-select.")
119 (defstruct child-rect child parent selected-p x y w h)
121 (defstruct root child original current-child x y w h)
123 (defclass frame ()
124 ((name :initarg :name :accessor frame-name :initform nil)
125 (number :initarg :number :accessor frame-number :initform 0)
126 ;;; Float size between 0 and 1 - Manipulate only this variable and not real size
127 (x :initarg :x :accessor frame-x :initform 0.1)
128 (y :initarg :y :accessor frame-y :initform 0.1)
129 (w :initarg :w :accessor frame-w :initform 0.8)
130 (h :initarg :h :accessor frame-h :initform 0.8)
131 ;;; Real size (integer) in screen size - Don't set directly this variables
132 ;;; they may be recalculated by the layout manager.
133 (rx :initarg :rx :accessor frame-rx :initform 0)
134 (ry :initarg :ry :accessor frame-ry :initform 0)
135 (rw :initarg :rw :accessor frame-rw :initform 800)
136 (rh :initarg :rh :accessor frame-rh :initform 600)
137 ;; (root :initarg :root :accessor frame-root :initform nil
138 ;; :documentation "A list a physical coordinates (x y w h) if frame is a root frame. Nil otherwise")
139 (layout :initarg :layout :accessor frame-layout :initform nil
140 :documentation "Layout to display windows on a frame")
141 (nw-hook :initarg :nw-hook :accessor frame-nw-hook :initform nil
142 :documentation "Hook done by the frame when a new window is mapped")
143 (managed-type :initarg :managed-type :accessor frame-managed-type
144 :initform *default-managed-type*
145 :documentation "Managed window type")
146 (forced-managed-window :initarg :forced-managed-window
147 :accessor frame-forced-managed-window
148 :initform nil
149 :documentation "A list of forced managed windows (wm-name or window)")
150 (forced-unmanaged-window :initarg :forced-unmanaged-window
151 :accessor frame-forced-unmanaged-window
152 :initform nil
153 :documentation "A list of forced unmanaged windows (wm-name or window)")
154 (show-window-p :initarg :show-window-p :accessor frame-show-window-p :initform t)
155 (hidden-children :initarg :hidden-children :accessor frame-hidden-children :initform nil
156 :documentation "A list of hidden children")
157 (selected-pos :initarg :selected-pos :accessor frame-selected-pos :initform 0
158 :documentation "The position in the child list of the selected child")
159 (focus-policy :initarg :focus-ploicy :accessor frame-focus-policy
160 :initform *default-focus-policy*)
161 (window :initarg :window :accessor frame-window :initform nil)
162 (gc :initarg :gc :accessor frame-gc :initform nil)
163 (child :initarg :child :accessor frame-child :initform nil)
164 (data :initarg :data :accessor frame-data
165 :initform *default-frame-data*
166 :documentation "An assoc list to store additional data")))
170 (defparameter *root-frame* nil
171 "Root of the root - ie the root frame")
173 (defparameter *main-keys* nil)
174 (defparameter *main-mouse* nil)
175 (defparameter *second-keys* nil)
176 (defparameter *second-mouse* nil)
177 (defparameter *info-keys* nil)
178 (defparameter *info-mouse* nil)
179 (defparameter *query-keys* nil)
180 (defparameter *circulate-keys* nil)
181 (defparameter *circulate-keys-release* nil)
182 (defparameter *expose-keys* nil)
183 (defparameter *expose-mouse* nil)
186 (defparameter *other-window-manager* nil)
189 (defstruct menu name item doc)
190 (defstruct menu-item key value)
193 (defparameter *menu* (make-menu :name 'main :doc "Main menu"))
198 (defconfig *binding-hook* nil 'Hook
199 "Hook executed when keys/buttons are bounds")
201 (defconfig *loop-hook* nil 'Hook
202 "Hook executed on each event loop")
204 (defconfig *main-entrance-hook* nil 'Hook
205 "Hook executed on the main function entrance after
206 loading configuration file and before opening the display.")
209 (defparameter *in-second-mode* nil)
212 ;;; Placement variables. A list of two absolute coordinates
213 ;;; or a function: 'Y-X-placement' for absolute placement or
214 ;;; 'Y-X-child-placement' for child relative placement or
215 ;;; 'Y-X-root-placement' for root relative placement.
216 ;;; Where Y-X are one of:
218 ;;; top-left top-middle top-right
219 ;;; middle-left middle-middle middle-right
220 ;;; bottom-left bottom-middle bottom-right
222 (defconfig *banish-pointer-placement* 'bottom-right-root-placement
223 'Placement "Pointer banishment placement")
224 (defconfig *second-mode-placement* 'top-middle-root-placement
225 'Placement "Second mode window placement")
226 (defconfig *info-mode-placement* 'top-left-root-placement
227 'Placement "Info mode window placement")
228 (defconfig *query-mode-placement* 'top-left-root-placement
229 'Placement "Query mode window placement")
230 (defconfig *circulate-mode-placement* 'bottom-middle-root-placement
231 'Placement "Circulate mode window placement")
232 (defconfig *expose-mode-placement* 'top-left-child-placement
233 'Placement "Expose mode window placement (Selection keys position)")
234 (defconfig *expose-query-placement* 'bottom-left-root-placement
235 'Placement "Expose mode query window placement")
236 (defconfig *notify-window-placement* 'bottom-right-root-placement
237 'Placement "Notify window placement")
238 (defconfig *ask-close/kill-placement* 'top-right-root-placement
239 'Placement "Ask close/kill window placement")
240 (defconfig *unmanaged-window-placement* 'middle-middle-root-placement
241 'Placement "Unmanager window placement")
244 (defparameter *in-process-existing-windows* nil)
246 ;; For debug - redefine defun
247 ;;(shadow :defun)
249 ;;(defmacro defun (name args &body body)
250 ;; `(progn
251 ;; (format t "defun: ~A ~A~%" ',name ',args)
252 ;; (force-output)
253 ;; (cl:defun ,name ,args
254 ;; (handler-case
255 ;; (progn
256 ;; ,@body)
257 ;; (error (c)
258 ;; (format t "New defun: Error in ~A : ~A~%" ',name c)
259 ;; (format t "Root tree=~A~%All windows=~A~%"
260 ;; (xlib:query-tree *root*) (get-all-windows))
261 ;; (force-output))))))
266 (defmacro make-x-drawable (argname type)
267 "Drawable wrapper to prevent type error in some CLX versions.
268 Replace xlib:drawable-* functions with x-drawable-* equivalents"
269 (let ((fun-symbol (create-symbol 'x-drawable- argname))
270 (set-symbol (create-symbol 'set-x-drawable- argname))
271 (xlib-equiv-symbol (create-symbol-in-package :xlib 'drawable- argname)))
272 `(progn
273 (declaim (inline ,fun-symbol))
274 (defun ,fun-symbol (window)
275 (,xlib-equiv-symbol window))
276 (defun ,set-symbol (window ,argname)
277 (if (typep ,argname ',type)
278 (setf (,xlib-equiv-symbol window) ,argname)
279 (dbg ',(create-symbol 'drawable-type-error- argname) window ,argname (xlib:wm-name window))))
280 (defsetf ,fun-symbol ,set-symbol))))
284 (make-x-drawable x (signed-byte 16))
285 (make-x-drawable y (signed-byte 16))
286 (make-x-drawable width (unsigned-byte 16))
287 (make-x-drawable height (unsigned-byte 16))
288 (make-x-drawable border-width (unsigned-byte 16))