Generic_Window_Manager/data/vtwm-zoom.gwm

137 lines
5.8 KiB
Plaintext

;; vtwm-zoom.gwm --- Window zooming functions for the VTWM profile
;;
;; Author: Anders Holst (aho@sans.kth.se)
;; Copyright (C) 1995 Anders Holst
;; Version: vtwm-1.0
;; Last change: 17/6 1995
;;
;; This file is copyrighted under the same terms as the rest of GWM
;; (see the X Inc license for details). There is no warranty that it
;; works.
;;
;; ---------------------------------------------------------------------
;;
;; The original zoom code came from Jay Berkenbilt. This is just an
;; adaption of it to the VTWM profile, with several different ways of
;; zooming added.
;;
;;
;; USER CUSTOMIZABLE VARIABLES
;; ---------------------------
;; Adjust these in your own profile
;;
(defaults-to
zoom-offset 3 ; Minimum distance to screen edge.
zoom-window-method-list () ; List of (wind-type zoom-func) specs.
; This is to make zoom-window use different zoom methods for different
; types of windows.
)
;; You can use this to define several further zooming functions, as below.
(defun zoom-window-aux (name method)
(pop-to-window)
(with (zoomed (# 'zoom window)
old-pos (# 'zpos window) ;; virtual screen is tricky
old-x (if old-pos (if (virtual-nailed) (# 0 old-pos)
(- (virtual-x (- (# 0 old-pos))))))
old-y (if old-pos (if (virtual-nailed) (# 1 old-pos)
(- (virtual-y (- (# 1 old-pos))))))
db (* (with (wob window) wob-borderwidth) 2))
(if (= zoomed name)
(progn ;; unzoom window
(## 'zoom window ())
(move-window old-x old-y)
(resize-window (+ (# 2 old-pos) db) (+ (# 3 old-pos) db)))
(not zoomed)
(progn ;; zoom window
(## 'zoom window name)
(## 'zpos window (list (if (virtual-nailed) window-x
(virtual-x window-x))
(if (virtual-nailed) window-y
(virtual-y window-y))
window-width window-height))
(method window-x window-y (+ window-width db) (+ window-height db)))
(progn ;; rezoom window
(## 'zoom window name)
(method old-x old-y (+ (# 2 old-pos) db) (+ (# 3 old-pos) db))))))
(defun zoom-window-full ()
(zoom-window-aux 'zoom-window-full
(lambda (x y w h)
(move-window zoom-offset zoom-offset)
(resize-window (- screen-width (* zoom-offset 2))
(- screen-height (* zoom-offset 2))))))
(defun zoom-window-vert ()
(zoom-window-aux 'zoom-window-vert
(lambda (x y w h)
(move-window x zoom-offset)
(resize-window w
(- screen-height (* zoom-offset 2))))))
(defun zoom-window-horiz ()
(zoom-window-aux 'zoom-window-horiz
(lambda (x y w h)
(move-window zoom-offset y)
(resize-window (- screen-width (* zoom-offset 2))
h))))
(defun zoom-window-left ()
(zoom-window-aux 'zoom-window-left
(lambda (x y w h)
(with (zoffh (/ (+ zoom-offset 1) 2))
(move-window zoom-offset zoom-offset)
(resize-window (- (/ screen-width 2) zoom-offset zoffh)
(- screen-height (* zoom-offset 2)))))))
(defun zoom-window-right ()
(zoom-window-aux 'zoom-window-right
(lambda (x y w h)
(with (zoffh (/ (+ zoom-offset 1) 2))
(move-window (+ (/ screen-width 2) zoffh) zoom-offset)
(resize-window (- (/ screen-width 2) zoom-offset zoffh)
(- screen-height (* zoom-offset 2)))))))
(defun zoom-window-top ()
(zoom-window-aux 'zoom-window-top
(lambda (x y w h)
(with (zoffh (/ (+ zoom-offset 1) 2))
(move-window zoom-offset zoom-offset)
(resize-window (- screen-width (* zoom-offset 2))
(- (/ screen-height 2) zoom-offset zoffh))))))
(defun zoom-window-bottom ()
(zoom-window-aux 'zoom-window-bottom
(lambda (x y w h)
(with (zoffh (/ (+ zoom-offset 1) 2))
(move-window zoom-offset (+ (/ screen-height 2) zoffh))
(resize-window (- screen-width (* zoom-offset 2))
(- (/ screen-height 2) zoom-offset zoffh))))))
(defun zoom-window-prop ()
(zoom-window-aux 'zoom-window-prop
(lambda (x y w h)
(with (bw (with (wob window) wob-borderwidth)
wbs (+ (- window-width window-client-width) (* 2 bw))
hbs (+ (- window-height window-client-height) (* 2 bw))
prop (min (/ (* (- screen-width wbs (* zoom-offset 2))
1000) (- w wbs))
(/ (* (- screen-height hbs (* zoom-offset 2))
1000) (- h hbs)))
neww (+ (/ (* (- w wbs) prop) 1000) wbs)
newh (+ (/ (* (- h hbs) prop) 1000) hbs)
newx (/ (- screen-width neww) 2)
newy (/ (- screen-height newh) 2))
(move-window newx newy)
(resize-window neww newh)))))
(defun zoom-window ()
(with (method (matches-cond zoom-window-method-list))
(if method
(eval method)
(zoom-window-full))))