1 ;;; --------------------------------------------------------------------------
2 ;;; CLFSWM - FullScreen Window Manager
4 ;;; --------------------------------------------------------------------------
5 ;;; Documentation: Package definition
6 ;;; --------------------------------------------------------------------------
8 ;;; (C) 2012 Philippe Brochard <pbrochard@common-lisp.net>
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.
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.
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.
24 ;;; --------------------------------------------------------------------------
29 (:use
:common-lisp
:my-html
:tools
:version
)
37 ;;;;; Uncomment the line below if you want to see all ignored X errors
38 ;;(pushnew :xlib-debug *features*)
40 ;;;;; Uncomment the line below if you want to see all event debug messages
41 ;;(pushnew :event-debug *features*)
45 ;;; CONFIG - Compress motion notify ?
46 ;; This variable may be useful to speed up some slow version of CLX.
47 ;; It is particulary useful with CLISP/MIT-CLX (and others).
48 (defconfig *have-to-compress-notify
* t
49 nil
"Compress event notify?
50 This variable may be useful to speed up some slow version of CLX.
51 It is particulary useful with CLISP/MIT-CLX.")
53 (defconfig *transparent-background
* t
54 nil
"Enable transparent background: one of nil, :pseudo, t (xcompmgr must be started)")
56 (defconfig *default-transparency
* 0.8
57 nil
"Default transparency for all windows when in xcompmgr transparency mode")
59 (defconfig *show-root-frame-p
* nil
60 nil
"Show the root frame information or not")
63 (defconfig *border-size
* 1
64 nil
"Windows and frames border size")
68 (defparameter *modifier-alias
* '((:alt
:mod-1
) (:alt-l
:mod-1
)
71 (:alt-r
:mod-5
) (:alt-gr
:mod-5
)
73 "Syntax: (modifier-alias effective-modifier)")
76 (defparameter *display
* nil
)
77 (defparameter *screen
* nil
)
78 (defparameter *root
* nil
)
79 (defparameter *no-focus-window
* nil
)
81 (defparameter *background-image
* nil
)
82 (defparameter *background-gc
* nil
)
84 (defconfig *loop-timeout
* 1 nil
85 "Maximum time (in seconds) to wait before calling *loop-hook*")
87 (defparameter *pixmap-buffer
* nil
)
89 (defparameter *contrib-dir
* "contrib/")
91 (defparameter *default-font
* nil
)
92 ;;(defparameter *default-font-string* "9x15")
93 (defconfig *default-font-string
* "fixed" nil
94 "The default font used in clfswm")
96 (defconfig *color-move-window
* "DeepPink" 'Main-mode
97 "Color when moving or resizing a windows")
99 (defparameter *child-selection
* nil
)
101 ;;; CONFIG - Default frame datas
102 (defconfig *default-frame-data
*
103 (list '(:tile-size
0.8) '(:tile-space-size
0.1)
104 '(:fast-layout
(tile-left-layout tile-layout
))
105 '(:main-layout-windows nil
))
107 "Default slots set in frame date")
110 ;;; CONFIG - Default managed window type for a frame
111 ;;; type can be :all, :normal, :transient, :maxsize, :desktop, :dock, :toolbar, :menu, :utility, :splash, :dialog
112 (defconfig *default-managed-type
* '(:normal
) nil
113 "Default managed window types")
114 ;;(defparameter *default-managed-type* '(:normal :maxsize :transient))
115 ;;(defparameter *default-managed-type* '(:normal :transient :maxsize :desktop :dock :toolbar :menu :utility :splash :dialog))
116 ;;(defparameter *default-managed-type* '())
117 ;;(defparameter *default-managed-type* '(:all))
120 ;;; CONFIG - Default focus policy
121 (defconfig *default-focus-policy
* :click nil
122 "Default mouse focus policy. One of :click, :sloppy, :sloppy-strict, :sloppy-select or
123 :sloppy-select-window.")
126 (defconfig *show-hide-policy
* #'<=
127 nil
"'NIL': always display all children (better with transparency support).
128 '<': Hide only children less than children above.
129 '<=': Hide children less or equal to children above (better for performance on slow machine).")
131 (defconfig *show-hide-policy-type
* '(:normal
)
132 nil
"Windows types which are optimized by the show hide policy")
134 (defstruct child-rect child parent selected-p x y w h
)
136 (defstruct root child original current-child x y w h
)
139 ((name :initarg
:name
:accessor frame-name
:initform nil
)
140 (number :initarg
:number
:accessor frame-number
:initform
0)
141 ;;; Float size between 0 and 1 - Manipulate only this variable and not real size
142 (x :initarg
:x
:accessor frame-x
:initform
0.1)
143 (y :initarg
:y
:accessor frame-y
:initform
0.1)
144 (w :initarg
:w
:accessor frame-w
:initform
0.8)
145 (h :initarg
:h
:accessor frame-h
:initform
0.8)
146 ;;; Real size (integer) in screen size - Don't set directly this variables
147 ;;; they may be recalculated by the layout manager.
148 (rx :initarg
:rx
:accessor frame-rx
:initform
0)
149 (ry :initarg
:ry
:accessor frame-ry
:initform
0)
150 (rw :initarg
:rw
:accessor frame-rw
:initform
800)
151 (rh :initarg
:rh
:accessor frame-rh
:initform
600)
152 ;; (root :initarg :root :accessor frame-root :initform nil
153 ;; :documentation "A list a physical coordinates (x y w h) if frame is a root frame. Nil otherwise")
154 (layout :initarg
:layout
:accessor frame-layout
:initform nil
155 :documentation
"Layout to display windows on a frame")
156 (nw-hook :initarg
:nw-hook
:accessor frame-nw-hook
:initform nil
157 :documentation
"Hook done by the frame when a new window is mapped")
158 (managed-type :initarg
:managed-type
:accessor frame-managed-type
159 :initform
*default-managed-type
*
160 :documentation
"Managed window type")
161 (forced-managed-window :initarg
:forced-managed-window
162 :accessor frame-forced-managed-window
164 :documentation
"A list of forced managed windows (wm-name or window)")
165 (forced-unmanaged-window :initarg
:forced-unmanaged-window
166 :accessor frame-forced-unmanaged-window
168 :documentation
"A list of forced unmanaged windows (wm-name or window)")
169 (show-window-p :initarg
:show-window-p
:accessor frame-show-window-p
:initform t
)
170 (hidden-children :initarg
:hidden-children
:accessor frame-hidden-children
:initform nil
171 :documentation
"A list of hidden children")
172 (selected-pos :initarg
:selected-pos
:accessor frame-selected-pos
:initform
0
173 :documentation
"The position in the child list of the selected child")
174 (focus-policy :initarg
:focus-ploicy
:accessor frame-focus-policy
175 :initform
*default-focus-policy
*)
176 (window :initarg
:window
:accessor frame-window
:initform nil
)
177 (gc :initarg
:gc
:accessor frame-gc
:initform nil
)
178 (child :initarg
:child
:accessor frame-child
:initform nil
)
179 (data :initarg
:data
:accessor frame-data
180 :initform
*default-frame-data
*
181 :documentation
"An assoc list to store additional data")))
185 (defparameter *root-frame
* nil
186 "Root of the root - ie the root frame")
188 (defparameter *main-keys
* nil
)
189 (defparameter *main-mouse
* nil
)
190 (defparameter *second-keys
* nil
)
191 (defparameter *second-mouse
* nil
)
192 (defparameter *info-keys
* nil
)
193 (defparameter *info-mouse
* nil
)
194 (defparameter *query-keys
* nil
)
195 (defparameter *circulate-keys
* nil
)
196 (defparameter *circulate-keys-release
* nil
)
197 (defparameter *expose-keys
* nil
)
198 (defparameter *expose-mouse
* nil
)
201 (defparameter *other-window-manager
* nil
)
204 (defstruct menu name item doc
)
205 (defstruct menu-item key value
)
208 (defparameter *menu
* (make-menu :name
'main
:doc
"Main menu"))
213 (defconfig *binding-hook
* nil
'Hook
214 "Hook executed when keys/buttons are bounds")
216 (defconfig *loop-hook
* nil
'Hook
217 "Hook executed on each event loop")
219 (defconfig *main-entrance-hook
* nil
'Hook
220 "Hook executed on the main function entrance after
221 loading configuration file and before opening the display.")
223 (defconfig *root-size-change-hook
* nil
'Hook
224 "Hook executed when the root size has changed for example when adding/removing a monitor")
227 (defparameter *in-second-mode
* nil
)
230 ;;; Placement variables. A list of two absolute coordinates
231 ;;; or a function: 'Y-X-placement' for absolute placement or
232 ;;; 'Y-X-child-placement' for child relative placement or
233 ;;; 'Y-X-root-placement' for root relative placement.
234 ;;; Where Y-X are one of:
236 ;;; top-left top-middle top-right
237 ;;; middle-left middle-middle middle-right
238 ;;; bottom-left bottom-middle bottom-right
240 (defconfig *banish-pointer-placement
* 'bottom-right-root-placement
241 'Placement
"Pointer banishment placement")
242 (defconfig *second-mode-placement
* 'top-middle-root-placement
243 'Placement
"Second mode window placement")
244 (defconfig *info-mode-placement
* 'top-left-root-placement
245 'Placement
"Info mode window placement")
246 (defconfig *query-mode-placement
* 'top-left-root-placement
247 'Placement
"Query mode window placement")
248 (defconfig *circulate-mode-placement
* 'bottom-middle-root-placement
249 'Placement
"Circulate mode window placement")
250 (defconfig *expose-mode-placement
* 'top-left-child-placement
251 'Placement
"Expose mode window placement (Selection keys position)")
252 (defconfig *expose-query-placement
* 'bottom-left-root-placement
253 'Placement
"Expose mode query window placement")
254 (defconfig *fastswitch-mode-placement
* 'top-left-root-placement
255 'Placement
"Fastswitch mode window placement")
256 (defconfig *notify-window-placement
* 'bottom-right-root-placement
257 'Placement
"Notify window placement")
258 (defconfig *ask-close
/kill-placement
* 'top-right-root-placement
259 'Placement
"Ask close/kill window placement")
260 (defconfig *unmanaged-window-placement
* 'middle-middle-root-placement
261 'Placement
"Unmanager window placement")
264 (defparameter *in-process-existing-windows
* nil
)
266 ;; For debug - redefine defun
269 ;;(defmacro defun (name args &body body)
271 ;; (format t "defun: ~A ~A~%" ',name ',args)
273 ;; (cl:defun ,name ,args
278 ;; (format t "New defun: Error in ~A : ~A~%" ',name c)
279 ;; (format t "Root tree=~A~%All windows=~A~%"
280 ;; (xlib:query-tree *root*) (get-all-windows))
281 ;; (force-output))))))
286 (defmacro make-x-drawable
(argname type
)
287 "Drawable wrapper to prevent type error in some CLX versions.
288 Replace xlib:drawable-* functions with x-drawable-* equivalents"
289 (let ((fun-symbol (create-symbol 'x-drawable- argname
))
290 (set-symbol (create-symbol 'set-x-drawable- argname
))
291 (xlib-equiv-symbol (create-symbol-in-package :xlib
'drawable- argname
)))
293 (declaim (inline ,fun-symbol
))
294 (defun ,fun-symbol
(window)
295 (,xlib-equiv-symbol window
))
296 (defun ,set-symbol
(window ,argname
)
297 (if (typep ,argname
',type
)
298 (setf (,xlib-equiv-symbol window
) ,argname
)
299 (dbg ',(create-symbol 'drawable-type-error- argname
) window
,argname
(xlib:wm-name window
))))
300 (defsetf ,fun-symbol
,set-symbol
))))
304 (make-x-drawable x
(signed-byte 16))
305 (make-x-drawable y
(signed-byte 16))
306 (make-x-drawable width
(unsigned-byte 16))
307 (make-x-drawable height
(unsigned-byte 16))
308 (make-x-drawable border-width
(unsigned-byte 16))