File: slide-window.jl

package info (click to toggle)
sawfish 1%3A1.3.5.2-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 11,636 kB
  • ctags: 1,327
  • sloc: lisp: 22,765; ansic: 15,810; sh: 10,203; makefile: 675; perl: 19
file content (98 lines) | stat: -rw-r--r-- 3,491 bytes parent folder | download
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
;; slide-window.jl -- simple code to move a window via the keyboard
;; $Id: slide-window.jl,v 1.8 2002/04/21 03:39:33 jsh Exp $

;; Copyright (C) 1999 John Harper <john@dcs.warwick.ac.uk>

;; This file is part of sawmill.

;; sawmill is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.

;; sawmill 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 General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with sawmill; see the file COPYING.  If not, write to
;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.

(define-structure sawfish.wm.commands.slide-window

    (export slide-window
	    slide-window-left
	    slide-window-right
	    slide-window-up
	    slide-window-down
	    slide-group-left
	    slide-group-right
	    slide-group-up
	    slide-group-down)

    (open rep
	  sawfish.wm.windows
	  sawfish.wm.custom
	  sawfish.wm.commands
	  sawfish.wm.util.groups)

  (defvar slide-window-increment 16
    "Number of pixels to move window in `slide-' commands.")

  (defvar before-slide-hook '()
    "Window hook called before a window is moved with the keyboard.")

  (define (slide-window w right down)
    (call-window-hook 'before-slide-hook w)
    (unless (window-get w 'fixed-position)
      (let ((coords (window-position w)))
	(move-window-to w (+ (car coords) right) (+ (cdr coords) down)))))

;;; window commands

  (define (slide-window-left w)
    "Move the window `slide-window-increment' pixels to the left."
    (slide-window w (- slide-window-increment) 0))

  (define (slide-window-right w)
    "Move the window `slide-window-increment' pixels to the right."
    (slide-window w slide-window-increment 0))

  (define (slide-window-up w)
    "Move the window `slide-window-increment' pixels upwards."
    (slide-window w 0 (- slide-window-increment)))

  (define (slide-window-down w)
    "Move the window `slide-window-increment' pixels downwards."
    (slide-window w 0 slide-window-increment))

  ;;###autoload
  (define-command 'slide-window-left slide-window-left #:spec "%W")
  (define-command 'slide-window-right slide-window-right #:spec "%W")
  (define-command 'slide-window-up slide-window-up #:spec "%W")
  (define-command 'slide-window-down slide-window-down #:spec "%W")

;; group commands

  (define (slide-group-left w)
    "Move the window group `slide-window-increment' pixels to the left."
    (map-window-group slide-window-left w))

  (define (slide-group-right w)
    "Move the window group `slide-window-increment' pixels to the right."
    (map-window-group slide-window-right w))

  (define (slide-group-up w)
    "Move the window group `slide-window-increment' pixels upwards."
    (map-window-group slide-window-up w))

  (define (slide-group-down w)
    "Move the window group `slide-window-increment' pixels downwards."
    (map-window-group slide-window-down w))

  ;;###autoload
  (define-command 'slide-group-left slide-group-left #:spec "%W")
  (define-command 'slide-group-right slide-group-right #:spec "%W")
  (define-command 'slide-group-up slide-group-up #:spec "%W")
  (define-command 'slide-group-down slide-group-down #:spec "%W"))