4
4
;; Copyright (C) 1999 John Harper <john@dcs.warwick.ac.uk>
6
;; This file is part of sawmill.
6
;; This file is part of sawfish.
8
;; sawmill is free software; you can redistribute it and/or modify it
8
;; sawfish is free software; you can redistribute it and/or modify it
9
9
;; under the terms of the GNU General Public License as published by
10
10
;; the Free Software Foundation; either version 2, or (at your option)
11
11
;; any later version.
13
;; sawmill is distributed in the hope that it will be useful, but
13
;; sawfish is distributed in the hope that it will be useful, but
14
14
;; WITHOUT ANY WARRANTY; without even the implied warranty of
15
15
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
16
;; GNU General Public License for more details.
18
18
;; You should have received a copy of the GNU General Public License
19
;; along with sawmill; see the file COPYING. If not, write to
19
;; along with sawfish; see the file COPYING. If not, write to
20
20
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
22
22
(define-structure sawfish.wm.viewport
49
49
;; Virtual workspaces are implemented by moving windows in and out of
50
50
;; the screen dimensions. E.g. moving to the left moves all windows one
51
;; screen-width to the right.
53
(defvar viewport-dimensions '(1 . 1)
54
"Size of each virtual workspace.")
56
(defvar uniconify-to-current-viewport t
57
"Windows uniconify to the current viewport.")
51
;; screen-width to the right.
53
(defgroup viewport "Viewport" :group workspace)
55
(defcustom viewport-dimensions '(1 . 1)
56
"Number of columns and rows in each virtual workspace: \\w"
57
:group (workspace viewport)
58
:type (pair (number 1) (number 1))
59
:after-set (lambda () (viewport-size-changed)))
61
(defcustom uniconify-to-current-viewport t
62
"Windows uniconify to the current viewport."
64
:group (workspace viewport))
59
66
(defcustom scroll-viewport-steps 1
60
"Number of steps in which to scroll between viewports (less steps = faster scrolling)."
67
"Number of steps for viewport scrolling."
68
:group (workspace viewport)
65
72
(defcustom viewport-boundary-mode 'stop
66
"Wether to stop or wrap-around on first/last viewport"
73
"Whether to stop or wrap-around on first/last viewport"
74
:group (workspace viewport)
68
75
:type (choice wrap-around stop))
70
77
;;; raw viewport handling
139
146
(define (select-workspace-and-viewport space col row)
140
147
(select-workspace space nil (lambda ()
141
148
(set-screen-viewport col row))))
143
150
;; returns t if it actually moved the viewport
144
151
(define (move-viewport right down)
145
152
(let ((port (screen-viewport)))
236
243
#:spec "NX:\nNY:"
237
244
#:type `(and (labelled ,(_ "Column:") (number 1))
238
245
(labelled ,(_ "Row:") (number 1)))
241
248
(define (activate-viewport-column x)
242
249
"Select the specified viewport column."
245
252
(define-command 'activate-viewport-column activate-viewport-column
247
254
#:type `(and (labelled ,(_ "Column:") (number 1)))
250
257
(define (activate-viewport-row y)
251
258
"Select the specified viewport row."
254
261
(define-command 'activate-viewport-row activate-viewport-row
256
263
#:type `(and (labelled ,(_ "Row:") (number 1)))
259
266
(define (move-window-to-viewport x y)
260
267
"Move the current window to the specified viewport."
263
270
(define-command 'move-window-to-viewport move-window-to-viewport
264
271
#:spec "NX:\nNY:"
265
272
#:type '(and (labelled "X:" (number 1)) (labelled "Y:" (number 1)))
268
275
(define (move-viewport-right)
269
276
"Move the viewport one screen to the right."
310
317
"Move the window to the viewport above, and switch to that viewport."
311
318
(move-window-to-viewport-and-move-viewport w 0 -1))
313
(define-command 'move-viewport-right move-viewport-right #:class 'viewport)
314
(define-command 'move-viewport-left move-viewport-left #:class 'viewport)
315
(define-command 'move-viewport-up move-viewport-up #:class 'viewport)
316
(define-command 'move-viewport-down move-viewport-down #:class 'viewport)
317
(define-command 'move-window-right move-window-right #:spec "%W" #:class 'viewport)
318
(define-command 'move-window-left move-window-left #:spec "%W" #:class 'viewport)
319
(define-command 'move-window-up move-window-up #:spec "%W" #:class 'viewport)
320
(define-command 'move-window-down move-window-down #:spec "%W" #:class 'viewport)
320
(define-command 'move-viewport-right move-viewport-right #:class 'default)
321
(define-command 'move-viewport-left move-viewport-left #:class 'default)
322
(define-command 'move-viewport-up move-viewport-up #:class 'default)
323
(define-command 'move-viewport-down move-viewport-down #:class 'default)
324
(define-command 'move-window-right move-window-right #:spec "%W" #:class 'default)
325
(define-command 'move-window-left move-window-left #:spec "%W" #:class 'default)
326
(define-command 'move-window-up move-window-up #:spec "%W" #:class 'default)
327
(define-command 'move-window-down move-window-down #:spec "%W" #:class 'default)
322
329
;;; session management, config
344
351
(when (window-outside-workspace-p w)
345
352
(move-window-to-current-viewport w)))
346
353
(window-put w 'placed t))))
348
355
(sm-add-saved-properties 'sticky-viewport)
349
356
(add-hook 'sm-window-save-functions viewport-saved-state)
350
357
(add-hook 'sm-restore-window-hook viewport-load-state)