-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpanel.lisp
134 lines (116 loc) · 5.29 KB
/
panel.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
;;;; Doors a window manager based on McCLIM.
;;;; Copyright (C) 2021 Andrea De Michele
;;;;
;;;; This library is free software; you can redistribute it and/or
;;;; modify it under the terms of the GNU Lesser General Public
;;;; License as published by the Free Software Foundation; either
;;;; version 2.1 of the License, or (at your option) any later version.
;;;;
;;;; This library 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
;;;; Lesser General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU Lesser General Public
;;;; License along with this library; if not, write to the Free Software
;;;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
;;;; USA
(in-package :doors)
;;;; Doors panel
(define-application-frame doors-panel ()
((tray :initarg :tray
:reader panel-tray
:initform nil))
(:command-table (doors-panel :inherit-from (doors-wm)))
(:menu-bar nil)
(:panes
(info :application
:incremental-redisplay t
:display-function 'display-info :max-height 15 :scroll-bars nil)
(interactor :interactor :height 24)
(pointer-doc :pointer-documentation :scroll-bars nil)
(tray (make-pane 'doors-systray:tray-pane :background +white+)))
(:layouts
(with-interactor
(vertically ()
interactor pointer-doc (horizontally () (:fill info) tray)))
(without-interactor
(vertically ()
pointer-doc (horizontally () (:fill info) tray)))))
(defmethod find-pane-for-frame
((fm doors-wm) (frame doors-panel))
(let ((tls (make-pane-1 fm frame 'climi::standard-top-level-sheet-pane
:name (frame-name frame)
:pretty-name (frame-pretty-name frame)
:icon (clime:frame-icon frame)
;; sheet is enabled from enable-frame
:enabled-p nil)))
(sheet-adopt-child (find-frame-container fm frame) tls)
tls))
(defclass info-line-event (window-manager-event) ())
(defmethod handle-event ((frame doors-panel) (event info-line-event))
(with-application-frame (frame)
(redisplay-frame-pane frame 'info))
(clime:schedule-event (find-pane-named frame 'info)
(make-instance 'info-line-event :sheet frame)
1))
(defmethod run-frame-top-level :before ((frame doors-panel) &key &allow-other-keys)
(queue-event (find-pane-named frame 'info) (make-instance 'info-line-event :sheet frame))
(when (panel-tray frame)
(doors-systray:start-tray (find-pane-named frame 'tray))))
(defmethod default-frame-top-level :around ((frame doors-panel)
&key &allow-other-keys)
(setf (frame-properties frame :wm-desktop) :all-desktops)
(call-next-method))
(defmethod execute-frame-command ((frame doors-panel) command)
(if (command-present-in-command-table-p (car command) 'doors-wm)
(execute-frame-command *wm-application* command)
(call-next-method)))
;;;; Commands
(define-presentation-to-command-translator
com-frame-toggle-fullscreen
(application-frame com-frame-toggle-fullscreen doors-panel
:gesture nil
:documentation "Toggle Fullscreen")
(object)
(list object))
(define-doors-panel-command (com-run :name t)
((command 'program-name :prompt "Command")
(args '(or null (sequence string)) :prompt "Arguments" :default '()))
(format (frame-query-io *application-frame*) "~s" (cons command args))
(uiop:launch-program (cons command args)))
(define-doors-wm-command-with-grabbed-keystroke (com-goto-wm-interactor :keystroke (#\i :super))
()
(a:when-let ((panel (wm-panel *application-frame*)))
(setf (frame-current-layout panel) 'with-interactor)
(stream-set-input-focus (frame-standard-input panel))))
(define-doors-wm-command-with-grabbed-keystroke (com-toggle-interactor :keystroke (#\I :super))
()
(let ((panel (wm-panel *application-frame*)))
(execute-frame-command panel '(com-change-layout))))
(define-doors-panel-command(com-change-layout :name t)
()
(let* ((panel *application-frame*)
(tls (frame-top-level-sheet panel)))
(unwind-protect
(setf (frame-current-layout panel)
(case (frame-current-layout panel)
(with-interactor 'without-interactor)
(without-interactor 'with-interactor)))
(move-sheet tls 0 (- (graft-height (graft tls))
(bounding-rectangle-height (sheet-region tls)))))))
(defun start-panel (&key new-process tray)
(assert *wm-application*)
(let* ((graft (find-graft))
(height 150)
(panel (make-application-frame 'doors-panel :tray tray :top (- (graft-height graft) height) :height height :width (graft-width graft))))
(setf (wm-panel *wm-application*) panel)
(if new-process
(clim-sys:make-process #'(lambda () (run-frame-top-level panel)) :name "Doors panel")
(run-frame-top-level panel))))
(define-doors-panel-command(com-update-info-line :name t)
()
(redisplay-frame-pane *application-frame* 'info)
(clime:schedule-event (find-pane-named *application-frame* 'info)
(make-instance 'info-line-event :sheet *application-frame*)
1))