1 ;; --------------------------------------------------------------------------
2 ;;; CLFSWM - FullScreen Window Manager
4 ;;; --------------------------------------------------------------------------
5 ;;; Documentation: Main functions
6 ;;; --------------------------------------------------------------------------
8 ;;; (C) 2011 Philippe Brochard <hocwp@free.fr>
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 ;;; --------------------------------------------------------------------------
30 ;;; Conversion functions
31 ;;; Float -> Pixel conversion
32 (defun x-fl->px
(x parent
)
33 "Convert float X coordinate to pixel"
34 (round (+ (* x
(frame-rw parent
)) (frame-rx parent
))))
36 (defun y-fl->px
(y parent
)
37 "Convert float Y coordinate to pixel"
38 (round (+ (* y
(frame-rh parent
)) (frame-ry parent
))))
40 (defun w-fl->px
(w parent
)
41 "Convert float Width coordinate to pixel"
42 (round (* w
(frame-rw parent
))))
44 (defun h-fl->px
(h parent
)
45 "Convert float Height coordinate to pixel"
46 (round (* h
(frame-rh parent
))))
48 ;;; Pixel -> Float conversion
49 (defun x-px->fl
(x parent
)
50 "Convert pixel X coordinate to float"
51 (/ (- x
(frame-rx parent
) *border-size
*) (frame-rw parent
)))
53 (defun y-px->fl
(y parent
)
54 "Convert pixel Y coordinate to float"
55 (/ (- y
(frame-ry parent
) *border-size
*) (frame-rh parent
)))
57 (defun w-px->fl
(w parent
)
58 "Convert pixel Width coordinate to float"
59 (/ w
(frame-rw parent
)))
61 (defun h-px->fl
(h parent
)
62 "Convert pixel Height coordinate to float"
63 (/ h
(frame-rh parent
)))
67 (defun rect-hidden-p (rect1 rect2
)
68 "Return T if child-rect1 hide child-rect2"
69 (and (<= (child-rect-x rect1
) (child-rect-x rect2
))
70 (<= (child-rect-y rect1
) (child-rect-y rect2
))
71 (>= (+ (child-rect-x rect1
) (child-rect-w rect1
)) (+ (child-rect-x rect2
) (child-rect-w rect2
)))
72 (>= (+ (child-rect-y rect1
) (child-rect-h rect1
)) (+ (child-rect-y rect2
) (child-rect-h rect2
)))))
76 (defgeneric frame-p
(frame))
77 (defmethod frame-p ((frame frame
))
78 (declare (ignore frame
))
80 (defmethod frame-p (frame)
81 (declare (ignore frame
))
86 ;;; in-*: Find if point (x,y) is in frame, window or child
87 (defun in-rect (x y xr yr wr hr
)
88 (and (<= xr x
(+ xr wr
))
91 (defun in-frame (frame x y
)
93 (in-rect x y
(frame-rx frame
) (frame-ry frame
) (frame-rw frame
) (frame-rh frame
))))
95 (defun in-window (window x y
)
96 (and (xlib:window-p window
)
98 (x-drawable-x window
) (x-drawable-y window
)
99 (x-drawable-width window
) (x-drawable-height window
))))
101 (defgeneric in-child
(child x y
))
103 (defmethod in-child ((child frame
) x y
)
104 (in-frame child x y
))
105 (defmethod in-child ((child xlib
:window
) x y
)
106 (in-window child x y
))
107 (defmethod in-child (child x y
)
108 (declare (ignore child x y
))
114 (defun frame-selected-child (frame)
115 (when (frame-p frame
)
116 (with-slots (child selected-pos
) frame
117 (let ((len (length child
)))
118 (cond ((minusp selected-pos
) (setf selected-pos
0))
119 ((>= selected-pos len
) (setf selected-pos
(max (1- len
) 0)))))
120 (nth selected-pos child
))))
126 (defgeneric child-equal-p
(child-1 child-2
))
128 (defmethod child-equal-p ((child-1 xlib
:window
) (child-2 xlib
:window
))
129 (xlib:window-equal child-1 child-2
))
131 (defmethod child-equal-p ((child-1 frame
) (child-2 frame
))
132 (equal child-1 child-2
))
134 (defmethod child-equal-p (child-1 child-2
)
135 (declare (ignore child-1 child-2
))
141 (declaim (inline child-member child-remove child-position
))
143 (defun child-member (child list
)
144 (member child list
:test
#'child-equal-p
))
146 (defun child-remove (child list
)
147 (remove child list
:test
#'child-equal-p
))
149 (defun child-position (child list
)
150 (position child list
:test
#'child-equal-p
))
154 ;;; Frame data manipulation functions
155 (defun frame-data-slot (frame slot
)
156 "Return the value associated to data slot"
157 (when (frame-p frame
)
158 (second (assoc slot
(frame-data frame
)))))
160 (defun set-frame-data-slot (frame slot value
)
161 "Set the value associated to data slot"
162 (when (frame-p frame
)
163 (with-slots (data) frame
164 (setf data
(remove (assoc slot data
) data
))
165 (push (list slot value
) data
))
168 (defsetf frame-data-slot set-frame-data-slot
)
171 (defun remove-frame-data-slot (frame slot
)
172 "Remove a slot in frame data slots"
173 (when (frame-p frame
)
174 (with-slots (data) frame
175 (setf data
(remove (assoc slot data
) data
)))))
179 (defun managed-window-p (window frame
)
180 "Return t only if window is managed by frame"
182 (with-slots ((managed forced-managed-window
)
183 (unmanaged forced-unmanaged-window
)) frame
184 (and (xlib:window-p window
)
185 (not (child-member window unmanaged
))
186 (not (member (xlib:wm-name window
) unmanaged
:test
#'string-equal-p
))
187 (or (member :all
(frame-managed-type frame
))
188 (member (window-type window
) (frame-managed-type frame
))
189 (child-member window managed
)
190 (member (xlib:wm-name window
) managed
:test
#'string-equal-p
))))
194 (defun never-managed-window-p (window)
195 (when (xlib:window-p window
)
196 (dolist (type *never-managed-window-list
*)
197 (when (funcall (first type
) window
)
198 (return (values t
(second type
)))))))
202 (defgeneric child-name
(child))
204 (defmethod child-name ((child xlib
:window
))
205 (xlib:wm-name child
))
207 (defmethod child-name ((child frame
))
210 (defmethod child-name (child)
211 (declare (ignore child
))
215 (defgeneric set-child-name
(child name
))
217 (defmethod set-child-name ((child xlib
:window
) name
)
218 (setf (xlib:wm-name child
) name
))
220 (defmethod set-child-name ((child frame
) name
)
221 (setf (frame-name child
) name
))
223 (defmethod set-child-name (child name
)
224 (declare (ignore child name
)))
226 (defsetf child-name set-child-name
)
231 (defgeneric child-fullname
(child))
233 (defmethod child-fullname ((child xlib
:window
))
234 (format nil
"~A (~A)" (or (xlib:wm-name child
) "?") (or (xlib:get-wm-class child
) "?")))
236 (defmethod child-fullname ((child frame
))
237 (aif (frame-name child
)
238 (format nil
"~A (Frame ~A)" it
(frame-number child
))
239 (format nil
"Frame ~A" (frame-number child
))))
241 (defmethod child-fullname (child)
242 (declare (ignore child
))
246 (defgeneric child-transparency
(child))
248 (defmethod child-transparency ((child xlib
:window
))
249 (window-transparency child
))
251 (defmethod child-transparency ((child frame
))
252 (window-transparency (frame-window child
)))
254 (defmethod child-transparency (child)
255 (declare (ignore child
))
258 (defgeneric set-child-transparency
(child value
))
260 (defmethod set-child-transparency ((child xlib
:window
) value
)
261 (setf (window-transparency child
) value
))
263 (defmethod set-child-transparency ((child frame
) value
)
264 (setf (window-transparency (frame-window child
)) value
))
266 (defmethod set-child-transparency (child value
)
267 (declare (ignore child value
)))
269 (defsetf child-transparency set-child-transparency
)
274 (defgeneric child-x
(child))
275 (defmethod child-x ((child xlib
:window
))
276 (x-drawable-x child
))
277 (defmethod child-x ((child frame
))
280 (defgeneric child-y
(child))
281 (defmethod child-y ((child xlib
:window
))
282 (x-drawable-y child
))
283 (defmethod child-y ((child frame
))
286 (defgeneric child-width
(child))
287 (defmethod child-width ((child xlib
:window
))
288 (x-drawable-width child
))
289 (defmethod child-width ((child frame
))
292 (defgeneric child-height
(child))
293 (defmethod child-height ((child xlib
:window
))
294 (x-drawable-height child
))
295 (defmethod child-height ((child frame
))
298 (defgeneric child-x2
(child))
299 (defmethod child-x2 ((child xlib
:window
))
300 (+ (x-drawable-x child
) (x-drawable-width child
)))
301 (defmethod child-x2 ((child frame
))
302 (+ (frame-rx child
) (frame-rw child
)))
304 (defgeneric child-y2
(child))
305 (defmethod child-y2 ((child xlib
:window
))
306 (+ (x-drawable-y child
) (x-drawable-height child
)))
307 (defmethod child-y2 ((child frame
))
308 (+ (frame-ry child
) (frame-rh child
)))
312 (defgeneric child-center
(child))
314 (defmethod child-center ((child xlib
:window
))
315 (values (+ (x-drawable-x child
) (/ (x-drawable-width child
) 2))
316 (+ (x-drawable-y child
) (/ (x-drawable-height child
) 2))))
318 (defmethod child-center ((child frame
))
319 (values (+ (frame-rx child
) (/ (frame-rw child
) 2))
320 (+ (frame-ry child
) (/ (frame-rh child
) 2))))
322 (defun child-distance (child1 child2
)
323 (multiple-value-bind (x1 y1
) (child-center child1
)
324 (multiple-value-bind (x2 y2
) (child-center child2
)
325 (values (+ (abs (- x2 x1
)) (abs (- y2 y1
)))
329 (defun middle-child-x (child)
330 (+ (child-x child
) (/ (child-width child
) 2)))
332 (defun middle-child-y (child)
333 (+ (child-y child
) (/ (child-height child
) 2)))
335 (declaim (inline adj-border-xy adj-border-wh
))
336 (defgeneric adj-border-xy
(value child
))
337 (defgeneric adj-border-wh
(value child
))
339 (defmethod adj-border-xy (v (child xlib
:window
))
340 (+ v
(x-drawable-border-width child
)))
342 (defmethod adj-border-xy (v (child frame
))
343 (+ v
(x-drawable-border-width (frame-window child
))))
345 (defmethod adj-border-wh (v (child xlib
:window
))
346 (- v
(* (x-drawable-border-width child
) 2)))
348 (defmethod adj-border-wh (v (child frame
))
349 (- v
(* (x-drawable-border-width (frame-window child
)) 2)))
352 (declaim (inline anti-adj-border-xy anti-adj-border-wh
))
353 (defgeneric anti-adj-border-xy
(value child
))
354 (defgeneric anti-adj-border-wh
(value child
))
356 (defmethod anti-adj-border-xy (v (child xlib
:window
))
357 (- v
(x-drawable-border-width child
)))
359 (defmethod anti-adj-border-xy (v (child frame
))
360 (- v
(x-drawable-border-width (frame-window child
))))
362 (defmethod anti-adj-border-wh (v (child xlib
:window
))
363 (+ v
(* (x-drawable-border-width child
) 2)))
365 (defmethod anti-adj-border-wh (v (child frame
))
366 (+ v
(* (x-drawable-border-width (frame-window child
)) 2)))
371 (defmacro with-focus-window
((window) &body body
)
372 `(let ((,window
(xlib:input-focus
*display
*)))
373 (when (and ,window
(not (xlib:window-equal
,window
*no-focus-window
*)))
378 ;; (with-all-children (*root-frame* child) (typecase child (xlib:window (print child)) (frame (print (frame-number child)))))
379 (defmacro with-all-children
((root child
) &body body
)
381 (sub-child (gensym)))
383 (labels ((,rec
(,child
)
385 (when (frame-p ,child
)
386 (dolist (,sub-child
(reverse (frame-child ,child
)))
387 (,rec
,sub-child
)))))
391 ;; (with-all-children (*root-frame* child) (typecase child (xlib:window (print child)) (frame (print (frame-number child)))))
392 (defmacro with-all-children-reversed
((root child
) &body body
)
394 (sub-child (gensym)))
396 (labels ((,rec
(,child
)
398 (when (frame-p ,child
)
399 (dolist (,sub-child
(frame-child ,child
))
400 (,rec
,sub-child
)))))
407 ;; (with-all-frames (*root-frame* frame) (print (frame-number frame)))
408 (defmacro with-all-frames
((root frame
) &body body
)
412 (labels ((,rec
(,frame
)
413 (when (frame-p ,frame
)
415 (dolist (,child
(reverse (frame-child ,frame
)))
420 ;; (with-all-windows (*root-frame* window) (print window))
421 (defmacro with-all-windows
((root window
) &body body
)
425 (labels ((,rec
(,window
)
426 (when (xlib:window-p
,window
)
428 (when (frame-p ,window
)
429 (dolist (,child
(reverse (frame-child ,window
)))
435 ;; (with-all-frames-windows (*root-frame* child) (print child) (print (frame-number child)))
436 (defmacro with-all-windows-frames
((root child
) body-window body-frame
)
438 (sub-child (gensym)))
440 (labels ((,rec
(,child
)
442 (xlib:window
,body-window
)
444 (dolist (,sub-child
(reverse (frame-child ,child
)))
445 (,rec
,sub-child
))))))
448 (defmacro with-all-windows-frames-and-parent
((root child parent
) body-window body-frame
)
450 (sub-child (gensym)))
452 (labels ((,rec
(,child
,parent
)
454 (xlib:window
,body-window
)
456 (dolist (,sub-child
(reverse (frame-child ,child
)))
457 (,rec
,sub-child
,child
))))))
462 (defun create-frame-window ()
463 (let ((win (xlib:create-window
:parent
*root
*
468 :background
(get-color *frame-background
*)
469 :colormap
(xlib:screen-default-colormap
*screen
*)
470 :border-width
*border-size
*
471 :border
(get-color *color-selected
*)
472 :event-mask
'(:exposure
:button-press
:button-release
:pointer-motion
:enter-window
))))
473 (setf (window-transparency win
) *frame-transparency
*)
476 (defun create-frame-gc (window)
477 (xlib:create-gcontext
:drawable window
478 :foreground
(get-color *frame-foreground
*)
479 :background
(get-color *frame-background
*)
484 (defun destroy-all-frames-window ()
485 (with-all-frames (*root-frame
* frame
)
486 (when (frame-gc frame
)
487 (xlib:free-gcontext
(frame-gc frame
))
488 (setf (frame-gc frame
) nil
))
489 (when (frame-window frame
)
490 (xlib:destroy-window
(frame-window frame
))
491 (setf (frame-window frame
) nil
))))
493 (defun create-all-frames-window ()
494 (with-all-frames (*root-frame
* frame
)
495 (unless (frame-window frame
)
496 (setf (frame-window frame
) (create-frame-window)))
497 (unless (frame-gc frame
)
498 (setf (frame-gc frame
) (create-frame-gc (frame-window frame
)))))
499 (with-all-frames (*root-frame
* frame
)
500 (dolist (child (frame-child frame
))
502 (dbg (child-fullname child
))
504 (setf (frame-child frame
) (remove child
(frame-child frame
) :test
#'child-equal-p
))
510 (defun frame-find-free-number ()
511 (let ((all-numbers nil
))
512 (with-all-frames (*root-frame
* frame
)
513 (pushnew (frame-number frame
) all-numbers
))
514 (find-free-number all-numbers
)))
517 (defun create-frame (&rest args
&key
(number (frame-find-free-number)) &allow-other-keys
)
518 (let* ((window (create-frame-window))
519 (gc (create-frame-gc window
)))
520 (apply #'make-instance
'frame
:number number
:window window
:gc gc args
)))
523 (defun add-frame (frame parent
)
524 (push frame
(frame-child parent
))
528 (defun place-frame (frame parent prx pry prw prh
)
529 "Place a frame from real (pixel) coordinates"
530 (when (and (frame-p frame
) (frame-p parent
))
531 (with-slots (window x y w h
) frame
532 (setf (x-drawable-x window
) prx
533 (x-drawable-y window
) pry
534 (x-drawable-width window
) prw
535 (x-drawable-height window
) prh
536 x
(x-px->fl prx parent
)
537 y
(y-px->fl pry parent
)
538 w
(w-px->fl prw parent
)
539 h
(h-px->fl prh parent
))
540 (xlib:display-finish-output
*display
*))))
544 (defun find-child (to-find root
)
545 "Find to-find in root or in its children"
546 (with-all-children (root child
)
547 (when (child-equal-p child to-find
)
548 (return-from find-child t
))))
552 (defmacro with-find-in-all-frames
(test &optional return-value
)
555 (with-all-frames (root frame
)
558 (return-from return-block
(or ,return-value frame
))
560 (or ,return-value ret
))))
562 (defun find-parent-frame (to-find &optional
(root *root-frame
*) first-foundp
)
563 "Return the parent frame of to-find"
564 (with-find-in-all-frames
565 (child-member to-find
(frame-child frame
))))
567 (defun find-frame-window (window &optional
(root *root-frame
*) first-foundp
)
568 "Return the frame with the window window"
569 (with-find-in-all-frames
570 (xlib:window-equal window
(frame-window frame
))))
572 (defun find-frame-by-name (name &optional
(root *root-frame
*) first-foundp
)
573 "Find a frame from its name"
575 (with-find-in-all-frames
576 (string-equal name
(frame-name frame
)))))
578 (defun find-frame-by-number (number &optional
(root *root-frame
*) first-foundp
)
579 "Find a frame from its number"
580 (when (numberp number
)
581 (with-find-in-all-frames
582 (= number
(frame-number frame
)))))
585 (defun find-child-in-parent (child base
)
586 "Return t if child is in base or in its parents"
588 (when (child-equal-p child base
)
589 (return-from find-child-in-parent t
))
590 (let ((parent (find-parent-frame base
)))
595 ;;; Multiple roots support (replace the old *current-root* variable)
596 ;; TODO: Add find-root-by-coordinates, change-root-geometry
597 (let ((root-list nil
)
599 (defun define-as-root (child x y width height
)
600 (push (make-root :child child
:original child
:current-child nil
:x x
:y y
:w width
:h height
) root-list
))
602 (defun unsure-at-least-one-root ()
604 (define-as-root *root-frame
* (- *border-size
*) (- *border-size
*)
605 (xlib:screen-width
*screen
*) (xlib:screen-height
*screen
*))))
607 (defun find-root-by-coordinates (x y
)
608 (dolist (root root-list
)
609 (when (in-rect x y
(root-x root
) (root-y root
) (root-w root
) (root-h root
))
612 (defun all-root-child ()
613 (loop for root in root-list
614 collect
(root-child root
)))
616 (labels ((generic-child-root-p (child function
)
617 (dolist (root root-list
)
618 (when (child-equal-p child
(funcall function root
))
620 (defun child-root-p (child)
621 (generic-child-root-p child
#'root-child
))
623 (defun child-original-root-p (child)
624 (generic-child-root-p child
#'root-original
)))
626 (defun change-root (old-root new-child
)
627 (when (and old-root new-child
)
628 (setf (root-child old-root
) new-child
)))
630 (defun find-root (child)
631 (aif (child-original-root-p child
)
633 (awhen (find-parent-frame child
)
636 (defun find-child-in-all-root (child)
637 (dolist (root root-list
)
638 (when (find-child child
(root-child root
))
639 (return-from find-child-in-all-root root
))))
641 (defun find-current-root ()
642 (root-child (find-root (current-child))))
644 (defun exchange-root-geometry (root-1 root-2
)
645 (rotatef (root-x root-1
) (root-x root-2
))
646 (rotatef (root-y root-1
) (root-y root-2
))
647 (rotatef (root-w root-1
) (root-w root-2
))
648 (rotatef (root-h root-1
) (root-h root-2
)))
650 (defun rotate-root-geometry ()
651 (let* ((first (first root-list
))
652 (len (length root-list
))
653 (orig-x (root-x first
))
654 (orig-y (root-y first
))
655 (orig-w (root-w first
))
656 (orig-h (root-h first
)))
657 (dotimes (i (1- len
))
658 (exchange-root-geometry (nth i root-list
) (nth (1+ i
) root-list
)))
659 (let ((root-1 (nth (1- len
) root-list
)))
660 (setf (root-x root-1
) orig-x
)
661 (setf (root-y root-1
) orig-y
)
662 (setf (root-w root-1
) orig-w
)
663 (setf (root-h root-1
) orig-h
))))
666 (defun anti-rotate-root-geometry ()
667 (setf root-list
(nreverse root-list
))
668 (rotate-root-geometry)
669 (setf root-list
(nreverse root-list
)))
671 ;;; Current child functions
672 (defun current-child ()
675 (defun current-child-setter (value)
676 (awhen (find-root value
)
677 (setf (root-current-child it
) value
))
678 (setf current-child value
))
680 (defmacro with-current-child
((new-child) &body body
)
681 "Temporarly change the current child"
682 (let ((old-child (gensym))
684 `(let ((,old-child
(current-child)))
685 (setf (current-child) ,new-child
)
686 (let ((,ret
(multiple-value-list (progn ,@body
))))
687 (setf (current-child) ,old-child
)
688 (values-list ,ret
))))))
690 (defsetf current-child current-child-setter
)
693 (defun is-in-current-child-p (child)
694 (and (frame-p (current-child))
695 (child-member child
(frame-child (current-child)))))
698 (defun fixe-real-size (frame parent
)
699 "Fixe real (pixel) coordinates in float coordinates"
700 (when (frame-p frame
)
701 (with-slots (x y w h rx ry rw rh
) frame
702 (setf x
(x-px->fl rx parent
)
703 y
(y-px->fl ry parent
)
704 w
(w-px->fl
(anti-adj-border-wh rw parent
) parent
)
705 h
(h-px->fl
(anti-adj-border-wh rh parent
) parent
)))))
707 (defun fixe-real-size-current-child ()
708 "Fixe real (pixel) coordinates in float coordinates for children in the current child"
709 (when (frame-p (current-child))
710 (dolist (child (frame-child (current-child)))
711 (fixe-real-size child
(current-child)))))
715 ;;; Multiple physical screen helper
716 (defun add-placed-frame-tmp (frame n
) ;; For test
717 (add-frame (create-frame :x
0.01 :y
0.01 :w
0.4 :h
0.4) frame
)
718 (add-frame (create-frame :x
0.55 :y
0.01 :w
0.4 :h
0.4) frame
)
719 (add-frame (create-frame :x
0.03 :y
0.5 :w
0.64 :h
0.44) frame
)
721 (add-placed-frame-tmp (first (frame-child frame
)) (1- n
))))
723 (defun parse-xinerama-info (line)
725 (mapcar (lambda (string)
726 (parse-integer string
:junk-allowed t
))
727 (split-string (substitute #\space
#\x
(substitute #\space
#\
, line
))))))
729 (defun get-connected-heads-size (&optional
(fake nil
))
730 (labels ((heads-info ()
732 (do-shell "xdpyinfo -ext XINERAMA")
734 (setf *show-root-frame-p
* t
)
735 (do-shell "echo ' available colormap entries: 256 per subfield
736 red, green, blue masks: 0xff0000, 0xff00, 0xff
737 significant bits in color specification: 8 bits
739 XINERAMA version 1.1 opcode: 150
740 head #0: 500x300 @ 10,10
741 head #1: 480x300 @ 520,20
742 head #2: 600x250 @ 310,330'")))))
743 (when (xlib:query-extension
*display
* "XINERAMA")
744 (let ((output (heads-info))
746 (loop for line
= (read-line output nil nil
)
748 do
(when (search " head " line
)
749 (destructuring-bind (w h x y
)
750 (parse-xinerama-info line
)
751 (push (list (- x
*border-size
*) (- y
*border-size
*) w h
) sizes
))))
753 (remove-duplicates sizes
:test
#'equal
)))))
756 (defun place-frames-from-xinerama-infos ()
757 "Place frames according to xdpyinfo/xinerama informations"
758 (let ((sizes (get-connected-heads-size))
759 (width (xlib:screen-width
*screen
*))
760 (height (xlib:screen-height
*screen
*)))
761 ;;(add-placed-frame-tmp (first (frame-child *root-frame*)) 2)
762 (if (<= (length sizes
) 1)
763 (define-as-root *root-frame
* (- *border-size
*) (- *border-size
*) width height
)
765 (loop while
(< (length (frame-child *root-frame
*)) (length sizes
))
766 do
(let ((frame (create-frame)))
767 ;;(add-placed-frame-tmp frame 2)))
768 (add-frame frame
*root-frame
*)))
769 (loop for size in sizes
770 for frame in
(frame-child *root-frame
*)
771 do
(destructuring-bind (x y w h
) size
772 (setf (frame-x frame
) (float (/ x width
))
773 (frame-y frame
) (float (/ y height
))
774 (frame-w frame
) (float (/ w width
))
775 (frame-h frame
) (float (/ h height
)))
776 (add-frame (create-frame) frame
)
777 (define-as-root frame x y w h
)))
778 (setf (current-child) (first (frame-child (first (frame-child *root-frame
*)))))))))
783 (defun get-all-windows (&optional
(root *root-frame
*))
784 "Return all windows in root and in its children"
786 (with-all-windows (root window
)
791 (defun get-hidden-windows ()
792 "Return all hiddens windows"
793 (let ((all-windows (get-all-windows))
794 (hidden-windows (remove-if-not #'window-hidden-p
795 (copy-list (xlib:query-tree
*root
*)))))
796 (set-difference hidden-windows all-windows
)))
800 ;;; Current window utilities
801 (defun get-current-window ()
802 (typecase (current-child)
803 (xlib:window
(current-child))
804 (frame (frame-selected-child (current-child)))))
806 (defmacro with-current-window
(&body body
)
807 "Bind 'window' to the current window"
808 `(let ((window (get-current-window)))
809 (when (xlib:window-p window
)
812 (defun get-first-window ()
813 (typecase (current-child)
814 (xlib:window
(current-child))
815 (frame (or (first (frame-child (current-child)))
822 (defun display-frame-info (frame)
823 (when (frame-p frame
)
824 (let ((dy (+ (xlib:max-char-ascent
*default-font
*) (xlib:max-char-descent
*default-font
*))))
825 (with-slots (name number gc window child hidden-children
) frame
826 (setf (xlib:gcontext-background gc
) (get-color *frame-background
*)
827 (xlib:window-background window
) (get-color *frame-background
*))
828 (clear-pixmap-buffer window gc
)
829 (setf (xlib:gcontext-foreground gc
) (get-color (if (and (child-root-p frame
)
830 (child-equal-p frame
(current-child)))
831 *frame-foreground-root
* *frame-foreground
*)))
832 (xlib:draw-glyphs
*pixmap-buffer
* gc
5 dy
833 (format nil
"Frame: ~A~A"
835 (if name
(format nil
" - ~A" name
) "")))
837 (when (child-root-p frame
)
838 (when *child-selection
*
839 (xlib:draw-glyphs
*pixmap-buffer
* gc
5 (incf pos dy
)
840 (with-output-to-string (str)
841 (format str
" Selection: ")
842 (dolist (child *child-selection
*)
844 (xlib:window
(format str
" ~A " (xlib:wm-name child
)))
845 (frame (format str
" frame:~A[~A] " (frame-number child
)
846 (aif (frame-name child
) it
"")))))))))
848 (xlib:draw-glyphs
*pixmap-buffer
* gc
5 (incf pos dy
)
849 (format nil
" ~A" (ensure-printable (child-fullname ch
))))))
850 (copy-pixmap-buffer window gc
)
854 (defun display-all-frame-info ()
855 (with-all-frames (*root-frame
* frame
)
856 (display-frame-info frame
)))
858 (defun display-all-root-frame-info ()
859 (dolist (root (all-root-child))
860 (display-frame-info root
)))
863 (defgeneric rename-child
(child name
))
865 (defmethod rename-child ((child frame
) name
)
866 (setf (frame-name child
) name
)
867 (display-frame-info child
))
869 (defmethod rename-child ((child xlib
:window
) name
)
870 (setf (xlib:wm-name child
) name
))
872 (defmethod rename-child (child name
)
873 (declare (ignore child name
)))
878 (defun get-parent-layout (child parent
)
879 (aif (child-root-p child
)
880 (values (root-x it
) (root-y it
) (root-w it
) (root-h it
))
881 (if (or (frame-p child
) (managed-window-p child parent
))
883 (aif (frame-layout parent
)
884 (funcall it child parent
)
885 (no-layout child parent
))
886 (values (- *border-size
*) (- *border-size
*)
887 (xlib:screen-width
*screen
*)
888 (xlib:screen-height
*screen
*)))
889 (values (x-drawable-x child
) (x-drawable-y child
)
890 (x-drawable-width child
) (x-drawable-height child
)))))
896 (defgeneric adapt-child-to-parent
(child parent
))
898 (defmethod adapt-child-to-parent ((window xlib
:window
) parent
)
899 (when (managed-window-p window parent
)
900 (multiple-value-bind (nx ny nw nh
)
901 (get-parent-layout window parent
)
902 (setf nw
(max nw
1) nh
(max nh
1))
903 (let ((change (or (/= (x-drawable-x window
) nx
)
904 (/= (x-drawable-y window
) ny
)
905 (/= (x-drawable-width window
) nw
)
906 (/= (x-drawable-height window
) nh
))))
908 (setf (x-drawable-x window
) nx
909 (x-drawable-y window
) ny
910 (x-drawable-width window
) nw
911 (x-drawable-height window
) nh
))
915 (defmethod adapt-child-to-parent ((frame frame
) parent
)
916 (declare (ignore parent
))
917 (with-slots (rx ry rw rh window
) frame
918 (let ((change (or (/= (x-drawable-x window
) rx
)
919 (/= (x-drawable-y window
) ry
)
920 (/= (x-drawable-width window
) rw
)
921 (/= (x-drawable-height window
) rh
))))
923 (setf (x-drawable-x window
) rx
924 (x-drawable-y window
) ry
925 (x-drawable-width window
) rw
926 (x-drawable-height window
) rh
))
929 (defmethod adapt-child-to-parent (child parent
)
930 (declare (ignore child parent
))
934 (defgeneric set-child-stack-order
(window child
)
935 (:documentation
"Raise window if child is NIL else put window just below child"))
937 (defmethod set-child-stack-order (window (child xlib
:window
))
938 (lower-window window child
))
940 (defmethod set-child-stack-order (window (child frame
))
941 (lower-window window
(frame-window child
)))
943 (defmethod set-child-stack-order (window child
)
944 (declare (ignore child
))
945 (raise-window window
))
949 (defgeneric show-child
(child parent previous
))
951 (defmethod show-child ((frame frame
) parent previous
)
952 (declare (ignore parent
))
953 (with-slots (window show-window-p
) frame
954 (if (and show-window-p
955 (or *show-root-frame-p
* (not (child-root-p frame
))))
958 (set-child-stack-order window previous
)
959 (display-frame-info frame
))
960 (hide-window window
))))
964 (defun hide-unmanaged-window-p (parent)
965 (let ((action (frame-data-slot parent
:unmanaged-window-action
)))
969 (t *hide-unmanaged-window
*))))
972 (defmethod show-child ((window xlib
:window
) parent previous
)
973 (if (or (managed-window-p window parent
)
974 (child-equal-p window
(current-child))
975 (not (hide-unmanaged-window-p parent
))
976 (child-equal-p parent
(current-child)))
979 (set-child-stack-order window previous
))
980 (hide-window window
)))
982 (defmethod show-child (child parent raise-p
)
983 (declare (ignore child parent raise-p
))
987 (defgeneric hide-child
(child))
989 (defmethod hide-child ((frame frame
))
990 (with-slots (window) frame
991 (xlib:unmap-window window
)))
993 (defmethod hide-child ((window xlib
:window
))
994 (hide-window window
))
996 (defmethod hide-child (child)
997 (declare (ignore child
))
1001 (defgeneric select-child
(child selected
))
1003 (labels ((get-selected-color (child selected-p
)
1004 (get-color (cond ((child-equal-p child
(current-child)) *color-selected
*)
1005 (selected-p *color-maybe-selected
*)
1006 (t *color-unselected
*)))))
1007 (defmethod select-child ((frame frame
) selected-p
)
1008 (when (and (frame-p frame
) (frame-window frame
))
1009 (setf (xlib:window-border
(frame-window frame
))
1010 (get-selected-color frame selected-p
))))
1012 (defmethod select-child ((window xlib
:window
) selected-p
)
1013 (setf (xlib:window-border window
)
1014 (get-selected-color window selected-p
)))
1016 (defmethod select-child (child selected
)
1017 (declare (ignore child selected
))
1020 (defun select-current-frame (selected)
1021 (select-child (current-child) selected
))
1023 (defun unselect-all-frames ()
1024 (with-all-children (*root-frame
* child
)
1025 (select-child child nil
)))
1029 (defun set-focus-to-current-child ()
1030 (labels ((rec (child)
1032 (xlib:window
(focus-window child
))
1033 (frame (rec (frame-selected-child child
))))))
1035 (rec (current-child))))
1040 (defun adapt-frame-to-parent (frame parent
)
1041 (multiple-value-bind (nx ny nw nh
)
1042 (get-parent-layout frame parent
)
1043 (with-slots (rx ry rw rh window
) frame
1049 (defun adapt-child-to-rect (rect)
1050 (let ((window (typecase (child-rect-child rect
)
1051 (xlib:window
(when (managed-window-p (child-rect-child rect
) (child-rect-parent rect
))
1052 (child-rect-child rect
)))
1053 (frame (frame-window (child-rect-child rect
))))))
1055 (let ((change (or (/= (x-drawable-x window
) (child-rect-x rect
))
1056 (/= (x-drawable-y window
) (child-rect-y rect
))
1057 (/= (x-drawable-width window
) (child-rect-w rect
))
1058 (/= (x-drawable-height window
) (child-rect-h rect
)))))
1060 (setf (x-drawable-x window
) (child-rect-x rect
)
1061 (x-drawable-y window
) (child-rect-y rect
)
1062 (x-drawable-width window
) (child-rect-w rect
)
1063 (x-drawable-height window
) (child-rect-h rect
)))
1069 (defun show-all-children (&optional
(from-root-frame nil
))
1070 "Show all children and hide those not in a root frame"
1071 (let ((geometry-change nil
)
1072 (displayed-child nil
)
1074 (labels ((in-displayed-list (child)
1075 (member child displayed-child
:test
(lambda (c rect
)
1076 (child-equal-p c
(child-rect-child rect
)))))
1078 (add-in-hidden-list (child)
1079 (pushnew child hidden-child
:test
#'child-equal-p
))
1081 (set-geometry (child parent in-current-root child-current-root-p
)
1082 (if (or in-current-root child-current-root-p
)
1083 (when (frame-p child
)
1084 (adapt-frame-to-parent child
(if child-current-root-p nil parent
)))
1085 (add-in-hidden-list child
)))
1087 (recurse-on-frame-child (child in-current-root child-current-root-p selected-p
)
1088 (let ((selected-child (frame-selected-child child
)))
1089 (dolist (sub-child (frame-child child
))
1090 (rec sub-child child
1091 (and selected-p
(child-equal-p sub-child selected-child
))
1092 (or in-current-root child-current-root-p
)))))
1094 (hidden-child-p (rect)
1095 (dolist (r displayed-child
)
1096 (when (rect-hidden-p r rect
)
1099 (select-and-display (child parent selected-p
)
1100 (multiple-value-bind (nx ny nw nh
)
1101 (get-parent-layout child parent
)
1102 (let ((rect (make-child-rect :child child
:parent parent
1103 :selected-p selected-p
1104 :x nx
:y ny
:w nw
:h nh
)))
1105 (if (hidden-child-p rect
)
1106 (add-in-hidden-list child
)
1107 (push rect displayed-child
)))))
1109 (display-displayed-child ()
1110 (let ((previous nil
))
1111 (dolist (rect (nreverse displayed-child
))
1112 (when (adapt-child-to-rect rect
)
1113 (setf geometry-change t
))
1114 (select-child (child-rect-child rect
) (child-rect-selected-p rect
))
1115 (show-child (child-rect-child rect
)
1116 (child-rect-parent rect
)
1118 (setf previous
(child-rect-child rect
)))))
1120 (rec (child parent selected-p in-current-root
)
1121 (let ((child-current-root-p (child-root-p child
)))
1122 (unless (in-displayed-list child
)
1123 (set-geometry child parent in-current-root child-current-root-p
))
1124 (when (frame-p child
)
1125 (recurse-on-frame-child child in-current-root child-current-root-p selected-p
))
1126 (when (and (or in-current-root child-current-root-p
)
1127 (not (in-displayed-list child
)))
1128 (select-and-display child parent selected-p
)))))
1130 (rec *root-frame
* nil t
(child-root-p *root-frame
*))
1131 (display-displayed-child)
1132 (dolist (child hidden-child
)
1134 (set-focus-to-current-child)
1135 (xlib:display-finish-output
*display
*)
1141 (defun hide-all-children (root &optional except
)
1142 "Hide all root children"
1143 (when (and (frame-p root
) (not (child-equal-p root except
)))
1144 (dolist (child (frame-child root
))
1145 (hide-all child except
))))
1147 (defun hide-all (root &optional except
)
1148 "Hide root and all its children"
1149 (unless (child-equal-p root except
)
1151 (hide-all-children root except
))
1157 (defun focus-child (child parent
)
1158 "Focus child - Return true if something has change"
1159 (when (and (frame-p parent
)
1160 (child-member child
(frame-child parent
)))
1161 (when (not (child-equal-p child
(frame-selected-child parent
)))
1162 (with-slots ((parent-child child
) selected-pos
) parent
1163 (setf parent-child
(nth-insert selected-pos child
(child-remove child parent-child
))))
1166 (defun focus-child-rec (child parent
)
1167 "Focus child and its parents - Return true if something has change"
1169 (labels ((rec (child parent
)
1170 (when (focus-child child parent
)
1173 (rec parent
(find-parent-frame parent
)))))
1178 (defun set-current-child-generic (child)
1179 (unless (child-equal-p (current-child) child
)
1180 (setf (current-child) child
)
1183 (defgeneric set-current-child
(child parent window-parent
))
1185 (defmethod set-current-child ((child xlib
:window
) parent window-parent
)
1186 (set-current-child-generic (if window-parent parent child
)))
1188 (defmethod set-current-child ((child frame
) parent window-parent
)
1189 (declare (ignore parent window-parent
))
1190 (set-current-child-generic child
))
1192 (defmethod set-current-child (child parent window-parent
)
1193 (declare (ignore child parent window-parent
))
1197 (defun set-current-root (child parent window-parent
)
1198 "Set current root if parent is not in current root"
1199 (let ((root (find-root child
)))
1200 (when (and window-parent
1201 (not (child-root-p child
))
1202 (not (find-child parent
(root-child root
))))
1203 (change-root root parent
)
1207 (defun focus-all-children (child parent
&optional
(window-parent t
))
1208 "Focus child and its parents -
1209 For window: set current child to window or its parent according to window-parent"
1210 (let ((new-focus (focus-child-rec child parent
))
1211 (new-current-child (set-current-child child parent window-parent
))
1212 (new-root (set-current-root child parent window-parent
)))
1213 (or new-focus new-current-child new-root
)))
1218 (defun select-next-level ()
1219 "Select the next level in frame"
1220 (select-current-frame :maybe
)
1221 (when (frame-p (current-child))
1222 (awhen (frame-selected-child (current-child))
1223 (setf (current-child) it
)))
1224 (show-all-children))
1226 (defun select-previous-level ()
1227 "Select the previous level in frame"
1228 (unless (child-root-p (current-child))
1229 (select-current-frame :maybe
)
1230 (awhen (find-parent-frame (current-child))
1231 (setf (current-child) it
))
1232 (show-all-children)))
1235 (defun enter-frame ()
1236 "Enter in the selected frame - ie make it the root frame"
1237 (let ((root (find-root (current-child))))
1238 (unless (child-equal-p (root-child root
) (current-child))
1239 (change-root root
(current-child)))
1240 (show-all-children t
)))
1242 (defun leave-frame ()
1243 "Leave the selected frame - ie make its parent the root frame"
1244 (let ((root (find-root (current-child))))
1245 (unless (or (child-equal-p (root-child root
) *root-frame
*)
1246 (child-original-root-p (root-child root
)))
1247 (awhen (and root
(find-parent-frame (root-child root
)))
1249 (change-root root it
)))
1250 (show-all-children))))
1253 ;;; Other actions (select-next-child, select-next-brother...) are in
1254 ;;; clfswm-circulate-mode.lisp
1258 (defun frame-lower-child ()
1259 "Lower the child in the current frame"
1260 (when (frame-p (current-child))
1261 (with-slots (child selected-pos
) (current-child)
1262 (unless (>= selected-pos
(length child
))
1263 (when (nth (1+ selected-pos
) child
)
1264 (rotatef (nth selected-pos child
)
1265 (nth (1+ selected-pos
) child
)))
1266 (incf selected-pos
)))
1267 (show-all-children)))
1270 (defun frame-raise-child ()
1271 "Raise the child in the current frame"
1272 (when (frame-p (current-child))
1273 (with-slots (child selected-pos
) (current-child)
1274 (unless (< selected-pos
1)
1275 (when (nth (1- selected-pos
) child
)
1276 (rotatef (nth selected-pos child
)
1277 (nth (1- selected-pos
) child
)))
1278 (decf selected-pos
)))
1279 (show-all-children)))
1282 (defun frame-select-next-child ()
1283 "Select the next child in the current frame"
1284 (when (frame-p (current-child))
1285 (with-slots (child selected-pos
) (current-child)
1286 (unless (>= selected-pos
(length child
))
1287 (incf selected-pos
)))
1288 (show-all-children)))
1291 (defun frame-select-previous-child ()
1292 "Select the previous child in the current frame"
1293 (when (frame-p (current-child))
1294 (with-slots (child selected-pos
) (current-child)
1295 (unless (< selected-pos
1)
1296 (decf selected-pos
)))
1297 (show-all-children)))
1301 (defun switch-to-root-frame (&key
(show-later nil
))
1302 "Switch to the root frame"
1303 (let ((root (find-root (current-child))))
1304 (change-root root
(root-original root
)))
1306 (show-all-children t
)))
1308 (defun switch-and-select-root-frame (&key
(show-later nil
))
1309 "Switch and select the root frame"
1310 (let ((root (find-root (current-child))))
1311 (change-root root
(root-original root
))
1312 (setf (current-child) (root-original root
)))
1314 (show-all-children t
)))
1317 (defun toggle-show-root-frame ()
1318 "Show/Hide the root frame"
1319 (setf *show-root-frame-p
* (not *show-root-frame-p
*))
1320 (show-all-children))
1324 (defun prevent-current-*-equal-child
(child)
1325 " Prevent current-root and current-child equal to child"
1326 (if (child-original-root-p child
)
1329 (awhen (child-root-p child
)
1330 (change-root it
(find-parent-frame child
)))
1331 (when (child-equal-p child
(current-child))
1332 (setf (current-child) (root-child (find-root child
))))
1337 (defun remove-child-in-frame (child frame
)
1338 "Remove the child in frame"
1339 (when (frame-p frame
)
1340 (setf (frame-child frame
) (child-remove child
(frame-child frame
)))))
1342 (defun remove-child-in-frames (child root
)
1343 "Remove child in the frame root and in all its children"
1344 (with-all-frames (root frame
)
1345 (remove-child-in-frame child frame
)))
1348 (defun remove-child-in-all-frames (child)
1349 "Remove child in all frames from *root-frame*"
1350 (when (prevent-current-*-equal-child child
)
1351 (remove-child-in-frames child
*root-frame
*)))
1354 (defun delete-child-in-frames (child root
)
1355 "Delete child in the frame root and in all its children
1356 Warning:frame window and gc are freeed."
1357 (with-all-frames (root frame
)
1358 (remove-child-in-frame child frame
)
1359 (unless (find-frame-window (frame-window frame
))
1360 (awhen (frame-gc frame
) (xlib:free-gcontext it
) (setf it nil
))
1361 (awhen (frame-window frame
) (xlib:destroy-window it
) (setf it nil
))))
1362 (when (xlib:window-p child
)
1363 (netwm-remove-in-client-list child
)))
1366 (defun delete-child-in-all-frames (child)
1367 "Delete child in all frames from *root-frame*"
1368 (when (prevent-current-*-equal-child child
)
1369 (delete-child-in-frames child
*root-frame
*)))
1371 (defun delete-child-and-children-in-frames (child root
)
1372 "Delete child and its children in the frame root and in all its children
1373 Warning:frame window and gc are freeed."
1374 (when (and (frame-p child
) (frame-child child
))
1375 (dolist (ch (frame-child child
))
1376 (delete-child-and-children-in-frames ch root
)))
1377 (delete-child-in-frames child root
))
1379 (defun delete-child-and-children-in-all-frames (child &optional
(close-methode 'delete-window
))
1380 "Delete child and its children in all frames from *root-frame*"
1381 (when (prevent-current-*-equal-child child
)
1382 (delete-child-and-children-in-frames child
*root-frame
*)
1383 (when (xlib:window-p child
)
1384 (funcall close-methode child
))
1385 (show-all-children)))
1388 (defun clean-windows-in-all-frames ()
1389 "Remove all xlib:windows present in *root-frame* and not in the xlib tree"
1390 (let ((x-tree (xlib:query-tree
*root
*)))
1391 (with-all-frames (*root-frame
* frame
)
1392 (dolist (child (frame-child frame
))
1393 (when (xlib:window-p child
)
1394 (unless (member child x-tree
:test
#'xlib
:window-equal
)
1395 (when (prevent-current-*-equal-child child
)
1396 (setf (frame-child frame
)
1397 (child-remove child
(frame-child frame
))))))))))
1401 (defun do-all-frames-nw-hook (window)
1402 "Call nw-hook of each frame."
1403 (catch 'nw-hook-loop
1405 (with-all-frames (*root-frame
* frame
)
1406 (awhen (frame-nw-hook frame
)
1407 (setf found
(call-hook it
(list frame window
)))))
1412 (defun process-new-window (window)
1413 "When a new window is created (or when we are scanning initial
1414 windows), this function dresses the window up and gets it ready to be
1416 (setf (xlib:window-event-mask window
) *window-events
*)
1417 (set-window-state window
+normal-state
+)
1418 (setf (x-drawable-border-width window
) (case (window-type window
)
1419 (:normal
*border-size
*)
1420 (:maxsize
*border-size
*)
1421 (:transient
*border-size
*)
1423 (grab-all-buttons window
)
1424 (unless (never-managed-window-p window
)
1425 (unless (do-all-frames-nw-hook window
)
1426 (call-hook *default-nw-hook
* (list *root-frame
* window
))))
1427 (netwm-add-in-client-list window
))
1432 (defun with-all-mapped-windows (screen fun
)
1433 (let ((all-windows (get-all-windows)))
1434 (dolist (win (xlib:query-tree
(xlib:screen-root screen
)))
1435 (unless (child-member win all-windows
)
1436 (let ((map-state (xlib:window-map-state win
))
1437 (wm-state (window-state win
)))
1438 (unless (or (eql (xlib:window-override-redirect win
) :on
)
1439 (eql win
*no-focus-window
*)
1440 (is-notify-window-p win
))
1441 (when (or (eql map-state
:viewable
)
1442 (eql wm-state
+iconic-state
+))
1443 (funcall fun win
))))))))
1445 (defun store-root-background ()
1446 (with-all-mapped-windows *screen
* #'hide-window
)
1447 (setf *background-image
* (xlib:create-pixmap
:width
(xlib:screen-width
*screen
*)
1448 :height
(xlib:screen-height
*screen
*)
1449 :depth
(xlib:screen-root-depth
*screen
*)
1451 *background-gc
* (xlib:create-gcontext
:drawable
*background-image
*
1452 :foreground
(get-color *frame-foreground
*)
1453 :background
(get-color *frame-background
*)
1454 :font
*default-font
*
1455 :line-style
:solid
))
1456 (xlib:copy-area
*root
* *background-gc
*
1457 0 0 (xlib:screen-width
*screen
*) (xlib:screen-height
*screen
*)
1458 *background-image
* 0 0)
1459 (with-all-mapped-windows *screen
* #'unhide-window
))
1464 (defun hide-existing-windows (screen)
1465 "Hide all existing windows in screen"
1466 (dolist (win (xlib:query-tree
(xlib:screen-root screen
)))
1471 (defun process-existing-windows (screen)
1472 "Windows present when clfswm starts up must be absorbed by clfswm."
1473 (setf *in-process-existing-windows
* t
)
1475 (all-windows (get-all-windows)))
1476 (dolist (win (xlib:query-tree
(xlib:screen-root screen
)))
1477 (unless (child-member win all-windows
)
1478 (let ((map-state (xlib:window-map-state win
))
1479 (wm-state (window-state win
)))
1480 (unless (or (eql (xlib:window-override-redirect win
) :on
)
1481 (eql win
*no-focus-window
*)
1482 (is-notify-window-p win
))
1483 (when (or (eql map-state
:viewable
)
1484 (eql wm-state
+iconic-state
+))
1485 (format t
"Processing ~S: type=~A ~S~%" (xlib:wm-name win
) (window-type win
) win
)
1487 (process-new-window win
)
1490 (pushnew (xlib:window-id win
) id-list
))))))
1491 (netwm-set-client-list id-list
))
1492 (setf *in-process-existing-windows
* nil
))
1495 ;;; Child order manipulation functions
1496 (defun put-child-on-top (child parent
)
1497 "Put the child on top of its parent children"
1498 (when (frame-p parent
)
1499 (setf (frame-child parent
) (cons child
(child-remove child
(frame-child parent
)))
1500 (frame-selected-pos parent
) 0)))
1502 (defun put-child-on-bottom (child parent
)
1503 "Put the child at the bottom of its parent children"
1504 (when (frame-p parent
)
1505 (setf (frame-child parent
) (append (child-remove child
(frame-child parent
)) (list child
))
1506 (frame-selected-pos parent
) 0)))