1 ;;; --------------------------------------------------------------------------
2 ;;; CLFSWM - FullScreen Window Manager
4 ;;; --------------------------------------------------------------------------
5 ;;; Documentation: Corner 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 (symbol-macrolet ((sw (xlib:screen-width
*screen
*))
31 (sh (xlib:screen-height
*screen
*))
33 (defun in-corner (corner x y
)
34 "Return t if (x, y) is in corner.
35 Corner is one of :bottom-right :bottom-left :top-right :top-left"
36 (multiple-value-bind (xmin ymin xmax ymax
)
38 (:bottom-right
(values (- sw cs
) (- sh cs
) sw sh
))
39 (:bottom-left
(values 0 (- sh cs
) cs sh
))
40 (:top-left
(values 0 0 cs cs
))
41 (:top-right
(values (- sw cs
) 0 sw cs
))
42 (t (values 10 10 0 0)))
47 (symbol-macrolet ((sw (xlib:screen-width
*screen
*))
48 (sh (xlib:screen-height
*screen
*))
50 (defun find-corner (x y
)
51 (cond ((and (< cs x
(- sw cs
)) (< cs y
(- sh cs
))) nil
)
52 ((and (<= 0 x cs
) (<= 0 y cs
)) :top-left
)
53 ((and (<= (- sw cs
) x sw
) (<= 0 y cs
)) :top-right
)
54 ((and (<= 0 x cs
) (<= (- sh cs
) y sh
)) :bottom-left
)
55 ((and (<= (- sw cs
) x sw
) (<= (- sh cs
) y sh
)) :bottom-right
)
61 (defun do-corner-action (x y corner-list
)
62 (when (frame-p *current-root
*)
63 (let ((corner (find-corner x y
)))
65 (let ((fun (second (assoc corner corner-list
))))
73 ;;;***************************************;;;
74 ;;; CONFIG - Corner actions definitions: ;;;
75 ;;;***************************************;;;
76 (defun find-window-in-query-tree (target-win)
77 (dolist (win (xlib:query-tree
*root
*))
78 (when (child-equal-p win target-win
)
81 (defun wait-window-in-query-tree (wait-test)
83 (dolist (win (xlib:query-tree
*root
*))
84 (when (funcall wait-test win
)
85 (return-from wait-window-in-query-tree win
)))))
88 (defun generic-present-body (cmd wait-test win
&optional focus-p
)
90 (unless (find-window-in-query-tree win
)
92 (setf win
(wait-window-in-query-tree wait-test
))
93 (grab-all-buttons win
)
95 (cond ((window-hidden-p win
)
101 (show-all-children)))
107 (defun close-virtual-keyboard ()
109 (xlib:destroy-window win
)
110 (xlib:display-finish-output
*display
*)
112 (defun present-virtual-keyboard ()
113 "Present a virtual keyboard"
114 (setf win
(generic-present-body *virtual-keyboard-cmd
*
116 (string-equal (xlib:get-wm-class win
) "xvkbd"))
122 (defun equal-clfswm-terminal (window)
124 (xlib:window-equal window win
)))
125 (defun close-clfswm-terminal ()
127 (xlib:destroy-window win
)
128 (xlib:display-finish-output
*display
*)
130 (defun present-clfswm-terminal ()
131 "Hide/Unhide a terminal"
132 (setf win
(generic-present-body *clfswm-terminal-cmd
*
134 (string-equal (xlib:wm-name win
) *clfswm-terminal-name
*))