|
From: Jasmin R. <jas...@gm...> - 2013-01-16 20:08:27
|
Here is my patch. I hope I send it to right address.
Changes from upstream-master to origin-master
Modified scheme/tile.scm
diff --git a/scheme/tile.scm b/scheme/tile.scm
index 29b6be8..1a9b2c1 100644
--- a/scheme/tile.scm
+++ b/scheme/tile.scm
@@ -1,23 +1,25 @@
-;;;; $Id$
-;;;; Copyright (C) 1998-1999 Maciej Stachowiak
-;;;;
-;;;; This program 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.
-;;;;
-;;;; This program 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 this software; see the file COPYING. If not, write to
-;;;; the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
-;;;; Boston, MA 02111-1307 USA
-;;;;
-
-
+;;; tile.scm ---
+;;
+;; Description: tiling for scwm
+;; Author:
+;; URL:
+;; Keywords:
+;; Commentary:
+;;
+;; This program 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 3, or
+;; (at your option) any later version.
+;;
+;; This program 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 this program; see the file COPYING. If not, write to
+;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+;; Floor, Boston, MA 02110-1301, USA.
(define-module (app scwm tile)
:use-module (app scwm optargs)
@@ -37,7 +39,8 @@
(define*-public (tile-windows
windows #:key (start-pos '(0 0))
- (end-pos (display-size)) (resize 'always)
+ (end-pos (display-size))
+ (resize 'always)
(raise 'restack-only)
(max-windows #f)
(order 'horizontal))
@@ -49,8 +52,9 @@ default, to END-POS, the size of the display by default.
If MAX-WINDOWS is specified and not #f, at most MAX-WINDOWS elements
of WINDOWS will be operated on.
-If ORDER is 'horizontal, the windows will be tiled in row-major order;
-if it is 'vertical they will be tiled in column-major oder.
+If ORDER is 'horizontal, the windows will be tiled in row order;
+if it is 'vertical they will be tiled in column oder, if ORDER
+is 'mixed it will be tiled as matrix. The default is 'mixed.
RESIZE may be #f, 'shrink-only or 'always, indicating that the windows
should never be resized, that they should be resized to the max-size
@@ -63,78 +67,82 @@ on top of other windows and placed in the tile order with the upper
left window lowest in the stacking order; or that they should be
restacked as for #t but not raised above other windows,
respectively. The default is 'restack-only."
- (let* ((num-windows (if max-windows
- (min (length windows) max-windows)
- (length windows)))
- (windows (list-head windows num-windows)))
- (cond
- ((not (null? windows))
- (cond
- (raise (if (not (eq? raise 'restack-only))
- (raise-window (car (reverse windows))))
- (restack-windows (reverse windows))))
- (let* ((num-major (inexact->exact (ceiling (sqrt num-windows))))
- (num-minor (inexact->exact (ceiling (/ num-windows num-major))))
- (num-per-row (case order
- ((horizontal) num-major)
- ((vertical) num-minor)))
- (num-per-column (case order
- ((horizontal) num-minor)
- ((vertical) num-major)))
- (start-x (car start-pos))
- (start-y (cadr start-pos))
- (range-x (- (car end-pos) start-x))
- (range-y (- (cadr end-pos) start-y)))
- (let loop ((windows (list-head windows num-windows))
- (row 0)
- (column 0)
- (cur-x start-x)
- (cur-y start-y)
- (next-x (integer-step start-x range-x num-per-row 1))
- (next-y (integer-step start-y range-y num-per-column 1)))
- (cond
- ((not (null? windows))
- (let* ((win (car windows))
- (fs (window-frame-size win))
- (new-size (case resize
- ((always) (list (- next-x cur-x) (- next-y cur-y)))
- ((shrink-only)
- (list (min (car fs) (- next-x cur-x))
- (min (cadr fs) (- next-y cur-y))))
+ (let* ((num-windows (if max-windows
+ (min (length windows) max-windows)
+ (length windows)))
+ (windows (list-head windows num-windows)))
+ (cond
+ ((not (null? windows))
+ (cond
+ (raise (if (not (eq? raise 'restack-only))
+ (raise-window (car (reverse windows))))
+ (restack-windows (reverse windows))))
+ (let* ((num-major (inexact->exact (ceiling (sqrt num-windows))))
+ (num-minor (inexact->exact (ceiling (/ num-windows num-major))))
+ (num-per-row (case order
+ ((horizontal) (if max-windows max-windows num-windows))
+ ((vertical) 1)
+ ((mixed) num-major)))
+ (num-per-column (case order
+ ((horizontal) 1)
+ ((vertical) (if max-windows max-windows num-windows))
+ ((mixed) num-minor)))
+ (start-x (car start-pos))
+ (start-y (cadr start-pos))
+ (range-x (- (car end-pos) start-x))
+ (range-y (- (cadr end-pos) start-y)))
+ (let loop ((windows (list-head windows num-windows))
+ (row 0)
+ (column 0)
+ (cur-x start-x)
+ (cur-y start-y)
+ (next-x (integer-step start-x range-x num-per-column 1))
+ (next-y (integer-step start-y range-y num-per-row 1)))
+ (cond
+ ((not (null? windows))
+ (let* ((win (car windows))
+ (fs (window-frame-size win))
+ (new-size (case resize
+ ((always) (list (- next-x cur-x) (- next-y cur-y)))
+ ((shrink-only)
+ (list (min (car fs) (- next-x cur-x))
+ (min (cadr fs) (- next-y cur-y))))
;;; MS:FIXME:: check for bad values
- (else fs))))
- (if (not (equal? new-size fs))
- (resize-frame (car new-size) (cadr new-size) win))
- (move-window cur-x cur-y win))
- (cond
- ((and (eq? order 'horizontal) (= column (- num-per-row 1)))
- (loop (cdr windows) (+ row 1) 0 start-x next-y
- (integer-step start-x range-x num-per-row 1)
- (integer-step start-y range-y num-per-column (+ row 2))))
- ((eq? order 'horizontal)
- (loop (cdr windows) row (+ column 1) next-x cur-y
- (integer-step start-x range-x num-per-row (+ column 2))
- next-y))
- ((and (eq? order 'vertical) (= row (- num-per-column 1)))
- (loop (cdr windows) 0 (+ column 1) next-x start-y
- (integer-step start-x range-x num-per-row (+ column 2))
- (integer-step start-y range-y num-per-column 1)))
- ((eq? order 'vertical)
- (loop (cdr windows) (+ row 1) column cur-x next-y
- next-x
- (integer-step start-y range-y num-per-column
- (+ row 2)))))))))))))
-
+ (else fs))))
+ (if (not (equal? new-size fs))
+ (resize-frame (car new-size) (cadr new-size) win))
+ (move-window cur-x cur-y win))
+ (cond
+ ((and (eq? order 'mixed) (= column (- num-per-row 1)))
+ (loop (cdr windows) (+ row 1) 0 start-x next-y
+ (integer-step start-x range-x num-per-row 1)
+ (integer-step start-y range-y num-per-column (+ row 2))))
+
+ ((eq? order 'mixed)
+ (loop (cdr windows) row (+ column 1) next-x cur-y
+ (integer-step start-x range-x num-per-row (+ column 2))
+ next-y))
+
+ ((eq? order 'vertical)
+ (loop (cdr windows) row (+ column 1) next-x cur-y
+ (integer-step start-x range-x num-per-column (+ column 2))
+ next-y))
+
+ ((eq? order 'horizontal)
+ (loop (cdr windows) (+ row 1) column cur-x next-y
+ next-x
+ (integer-step start-y range-y num-per-row (+ row 2)))))))))))))
+
(define*-public (tile #:key (only '()) (except '())
- (by-stacking #f) (by-focus #f)
- (reverse #f)
- (all-viewports #f) (desk (current-desk))
- (ignore-default-exceptions #f)
- (start-pos '(0 0))
- (end-pos (display-size)) (resize 'always)
- (raise 'restack-only)
- (max-windows #f)
- (order 'horizontal))
+ (by-stacking #f) (by-focus #f)
+ (reverse #f)
+ (all-viewports #f) (desk (current-desk))
+ (ignore-default-exceptions #f)
+ (start-pos '(0 0))
+ (end-pos (display-size)) (resize 'always)
+ (raise 'restack-only)
+ (max-windows #f)
+ (order 'mixed))
"Tile the windows on the specified desk.
The DESK option, defaulting to the current desk, specifies which desk;
ALL-VIEWPORTS, when true indicates that the windows in all viewports
@@ -165,26 +173,3 @@ control the tiling options as for `tile-windows'."
#:by-stacking by-stacking #:by-focus by-focus #:reverse reverse)
#:start-pos start-pos #:end-pos end-pos #:raise raise
#:resize resize #:max-windows max-windows #:order order))
-
-
-(define*-public (tile-windows-interactively #:optional (order 'horizontal))
- "Tile a set of selected windows either vertically or horizontally.
-ORDER can be either 'horizontal or 'vertical.
-The windows used are selected either by `selected-windows-list' or
-`select-window-group'.
-If `selected-windows-list' is empty, then `select-window-group' is used.
-See also the undo module and `push-undo-global' to save the window
-configuration before executing this in case the effect is not what you
-expected."
- (interactive)
- (let* ((winlist (reverse (selected-windows-list)))
- (wins (if (pair? winlist) winlist (select-window-group)))
- (r (enclosing-rectangle wins)))
- (if (pair? winlist)
- (unselect-all-windows)
- (for-each unflash-window wins))
- (push-undo-global)
- (tile-windows wins
- #:start-pos (rect-nw r)
- #:end-pos (rect-se r)
- #:order order)))
Modified scheme/wininfo.scm
diff --git a/scheme/wininfo.scm b/scheme/wininfo.scm
index 6594c3f..301fe41 100644
--- a/scheme/wininfo.scm
+++ b/scheme/wininfo.scm
@@ -27,6 +27,7 @@
:use-module (app scwm minimal)
:use-module (ice-9 regex)
:export (on-desk?
+ on-desk-n?
on-current-desk?
in-viewport-any-desk?
visible?
@@ -47,7 +48,7 @@
"Return #t if WIN is on desk N, else #f."
(if win (= n (window-desk win))))
-(define*-public ((on-desk-n? n) #:optional (win (get-window)))
+(define* ((on-desk-n? n) #:optional (win (get-window)))
"Returns a function which takes WIN and returns #t if WIN is on desk N, else #f."
(on-desk? n win))
|