[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [STUMP] Placement rules, automatic group create/restore
From: |
Morgan Veyret |
Subject: |
Re: [STUMP] Placement rules, automatic group create/restore |
Date: |
Sun, 15 Jun 2008 03:35:11 +0200 |
User-agent: |
Mutt/1.4.2.3i |
Forgot to change make-rule-for-window, this patch fixes it.
On 03:11 Sun 15 Jun , Morgan Veyret wrote:
> Hello,
>
> The following serie of patches add automatic group create/restore
> functionnalities to window placement routines.
>
> It add one parameter:
> *group-dump-dir* which should point to a directory containing dumped
> frames to restore if needed.
>
> And three parameters to rule definition:
> :dump-name: key parameter defining the dump file to restore instead of a
> one with the group name.
> create: when set, a new group is created as needed and if a dump file
> named as the group exists it is used to restore the group layout.
> restore: force layout to be restored even if the group exists (this may
> be used along with :dump-name option)
>
> See sample rc file for an example.
> --
>
> Morgan Veyret (address@hidden)
> http://appart.kicks-ass.net/patzy
> From bc99736c1fe63c2facaf741c5638d645576c1d88 Mon Sep 17 00:00:00 2001
> From: Morgan Veyret <address@hidden>
> Date: Sun, 15 Jun 2008 00:55:06 +0200
> Subject: [PATCH] Added restore-or-create options to define-frame-preference.
>
> When set to T a new group will be created if there's no match, if NIL old
> behavior is assumed (this
> is the window is placed into the current group and an error message appears).
>
> If a dump file matching group-name is present inside *group-dump-dir* it'll
> be used to restore the group layout
> upon creation.
> ---
> primitives.lisp | 8 ++++++--
> window.lisp | 31 ++++++++++++++++++++++++-------
> 2 files changed, 30 insertions(+), 9 deletions(-)
>
> diff --git a/primitives.lisp b/primitives.lisp
> index 2326897..0debc3d 100644
> --- a/primitives.lisp
> +++ b/primitives.lisp
> @@ -909,13 +909,17 @@ will have no effect.")
> "List of rules governing window placement. Use define-frame-preference to
> add rules")
>
> +(defvar *group-dump-dir* ".stumpwm.d/")
>
> (defmacro define-frame-preference (group &rest frames)
> (let ((x (gensym "X")))
> `(dolist (,x ',frames)
> ;; verify the correct structure
> - (destructuring-bind (frame-number raise lock &rest keys &key class
> instance type role title) ,x
> - (push (list* ,group frame-number raise lock keys)
> *window-placement-rules*)))))
> + (destructuring-bind (frame-number raise lock restore-or-create
> + &rest keys
> + &key class instance type role
> title) ,x
> + (push (list* ,group frame-number raise lock restore-or-create keys)
> + *window-placement-rules*)))))
>
> (defun clear-window-placement-rules ()
> (setf *window-placement-rules* nil))
> diff --git a/window.lisp b/window.lisp
> index 8abbf15..74709e2 100644
> --- a/window.lisp
> +++ b/window.lisp
> @@ -735,8 +735,9 @@ than the root window's width and height."
>
> (defun window-matches-rule-p (w rule)
> "Returns T if window matches rule"
> - (destructuring-bind (group-name frame raise lock &rest props) rule
> - (declare (ignore frame raise))
> + (destructuring-bind (group-name frame raise lock restore-or-create
> + &rest props) rule
> + (declare (ignore frame raise restore-or-create))
> (if (or lock
> (equal group-name (group-name (or (window-group w)
> (current-group)))))
> (apply 'window-matches-properties-p w props))))
> @@ -752,14 +753,30 @@ than the root window's width and height."
> the window should be raised."
> (let ((match (rule-matching-window window)))
> (if match
> - (destructuring-bind (group-name frame raise lock &rest props) match
> + (destructuring-bind (group-name frame raise lock
> + restore-or-create dump-name
> + &rest props) match
> (declare (ignore lock props))
> (let ((group (find-group screen group-name)))
> (if group
> (values group (frame-by-number group frame) raise)
> - (progn
> - (message "^B^1*Error placing window, group \"^b~a^B\" does
> not exist." group-name)
> - (values)))))
> + (if restore-or-create
> + (let ((new-group (add-group (current-screen) group-name))
> + (group-dump-file (concat *group-dump-dir*
> + group-name)))
> + (if (and new-group
> + (probe-file group-dump-file))
> + (progn (restore-group new-group
> + (read-dump-from-file
> group-dump-file))
> + (values new-group
> + (frame-by-number new-group frame)
> + raise))
> + (progn (message "^B^1*Error restoring group
> \"^b~a^B\" from \"^b~a^B\"." new-group group-dump-file)
> + (values new-group
> + (frame-by-number new-group frame)
> + raise))))
> + (progn (message "^B^1*Error placing window, group
> \"^b~a^B\" does not exist." group-name)
> + (values))))))
> (values))))
>
> (defun sync-window-placement ()
> @@ -919,7 +936,7 @@ needed."
> (declare (type window window))
> ;; put it in a valid group
> (let ((screen (window-screen window)))
> - ;; Use window plaecment rules
> + ;; Use window placement rules
> (multiple-value-bind (group frame raise) (get-window-placement screen
> window)
> (declare (ignore raise))
> (unless (find (window-group window)
> --
> 1.5.5.1
>
> From f5b64fa1dd09af5b3f64c94ea94032562acb4fae Mon Sep 17 00:00:00 2001
> From: Morgan Veyret <address@hidden>
> Date: Sun, 15 Jun 2008 01:43:52 +0200
> Subject: [PATCH] Added :dump-name options to define-frame-preference to
> specify a group dump filename to try.
> Defaults to group-name.
>
> ---
> primitives.lisp | 11 +++++++++--
> window.lisp | 11 +++++------
> 2 files changed, 14 insertions(+), 8 deletions(-)
>
> diff --git a/primitives.lisp b/primitives.lisp
> index 0debc3d..edc991a 100644
> --- a/primitives.lisp
> +++ b/primitives.lisp
> @@ -917,8 +917,15 @@ add rules")
> ;; verify the correct structure
> (destructuring-bind (frame-number raise lock restore-or-create
> &rest keys
> - &key class instance type role
> title) ,x
> - (push (list* ,group frame-number raise lock restore-or-create keys)
> + &key (dump-name ,group)
> + class instance type role title) ,x
> + (push (list* ,group frame-number raise lock restore-or-create
> + (concat *group-dump-dir* dump-name)
> + ;; FIXME: there's probably something better
> + (remove-if (lambda (item)
> + (or (eq item :dump-name)
> + (eq item dump-name)))
> + keys))
> *window-placement-rules*)))))
>
> (defun clear-window-placement-rules ()
> diff --git a/window.lisp b/window.lisp
> index 74709e2..3c0356f 100644
> --- a/window.lisp
> +++ b/window.lisp
> @@ -736,8 +736,9 @@ than the root window's width and height."
> (defun window-matches-rule-p (w rule)
> "Returns T if window matches rule"
> (destructuring-bind (group-name frame raise lock restore-or-create
> + dump-name
> &rest props) rule
> - (declare (ignore frame raise restore-or-create))
> + (declare (ignore frame raise restore-or-create dump-name))
> (if (or lock
> (equal group-name (group-name (or (window-group w)
> (current-group)))))
> (apply 'window-matches-properties-p w props))))
> @@ -761,13 +762,11 @@ than the root window's width and height."
> (if group
> (values group (frame-by-number group frame) raise)
> (if restore-or-create
> - (let ((new-group (add-group (current-screen) group-name))
> - (group-dump-file (concat *group-dump-dir*
> - group-name)))
> + (let ((new-group (add-group (current-screen)
> group-name)))
> (if (and new-group
> - (probe-file group-dump-file))
> + (probe-file dump-name))
> (progn (restore-group new-group
> - (read-dump-from-file
> group-dump-file))
> + (read-dump-from-file dump-name))
> (values new-group
> (frame-by-number new-group frame)
> raise))
> --
> 1.5.5.1
>
> From cbd00fa84a1e0d2c4b64f7fe18ed184937b45017 Mon Sep 17 00:00:00 2001
> From: Morgan Veyret <address@hidden>
> Date: Sun, 15 Jun 2008 02:55:33 +0200
> Subject: [PATCH] Splitted define-frame-preference CREATE-OR-RESTORE options
> into two.
>
> If create is T: creation if no matching group and restoration if dump file
> found.
> If restore is T: restore from file even if the group already exists.
> ---
> primitives.lisp | 4 ++--
> window.lisp | 16 ++++++++++------
> 2 files changed, 12 insertions(+), 8 deletions(-)
>
> diff --git a/primitives.lisp b/primitives.lisp
> index edc991a..ffc120b 100644
> --- a/primitives.lisp
> +++ b/primitives.lisp
> @@ -915,11 +915,11 @@ add rules")
> (let ((x (gensym "X")))
> `(dolist (,x ',frames)
> ;; verify the correct structure
> - (destructuring-bind (frame-number raise lock restore-or-create
> + (destructuring-bind (frame-number raise lock create restore
> &rest keys
> &key (dump-name ,group)
> class instance type role title) ,x
> - (push (list* ,group frame-number raise lock restore-or-create
> + (push (list* ,group frame-number raise lock create restore
> (concat *group-dump-dir* dump-name)
> ;; FIXME: there's probably something better
> (remove-if (lambda (item)
> diff --git a/window.lisp b/window.lisp
> index 3c0356f..13238be 100644
> --- a/window.lisp
> +++ b/window.lisp
> @@ -735,10 +735,10 @@ than the root window's width and height."
>
> (defun window-matches-rule-p (w rule)
> "Returns T if window matches rule"
> - (destructuring-bind (group-name frame raise lock restore-or-create
> + (destructuring-bind (group-name frame raise lock create restore
> dump-name
> &rest props) rule
> - (declare (ignore frame raise restore-or-create dump-name))
> + (declare (ignore frame raise create restore dump-name))
> (if (or lock
> (equal group-name (group-name (or (window-group w)
> (current-group)))))
> (apply 'window-matches-properties-p w props))))
> @@ -755,13 +755,17 @@ than the root window's width and height."
> (let ((match (rule-matching-window window)))
> (if match
> (destructuring-bind (group-name frame raise lock
> - restore-or-create dump-name
> + create restore dump-name
> &rest props) match
> (declare (ignore lock props))
> (let ((group (find-group screen group-name)))
> (if group
> - (values group (frame-by-number group frame) raise)
> - (if restore-or-create
> + (progn (when restore
> + (message "Restoring group \"^b~a^B\" from
> \"^b~a^B\"." group-name dump-name)
> + (restore-group group
> + (read-dump-from-file dump-name)))
> + (values group (frame-by-number group frame) raise))
> + (if create
> (let ((new-group (add-group (current-screen)
> group-name)))
> (if (and new-group
> (probe-file dump-name))
> @@ -770,7 +774,7 @@ than the root window's width and height."
> (values new-group
> (frame-by-number new-group frame)
> raise))
> - (progn (message "^B^1*Error restoring group
> \"^b~a^B\" from \"^b~a^B\"." new-group group-dump-file)
> + (progn (message "^B^1*Error restoring group
> \"^b~a^B\" from \"^b~a^B\"." new-group dump-name)
> (values new-group
> (frame-by-number new-group frame)
> raise))))
> --
> 1.5.5.1
>
> From 1d7c3c1153aa355c2a0679900d5afd4e12a27ca0 Mon Sep 17 00:00:00 2001
> From: Morgan Veyret <address@hidden>
> Date: Sun, 15 Jun 2008 03:02:45 +0200
> Subject: [PATCH] Documented *group-dump-dir* and updated sample rc file.
>
> ---
> primitives.lisp | 3 ++-
> sample-stumpwmrc.lisp | 37 ++++++++++++++++++++-----------------
> 2 files changed, 22 insertions(+), 18 deletions(-)
>
> diff --git a/primitives.lisp b/primitives.lisp
> index ffc120b..8bb69f6 100644
> --- a/primitives.lisp
> +++ b/primitives.lisp
> @@ -909,7 +909,8 @@ will have no effect.")
> "List of rules governing window placement. Use define-frame-preference to
> add rules")
>
> -(defvar *group-dump-dir* ".stumpwm.d/")
> +(defvar *group-dump-dir* ".stumpwm.d/"
> + "Directory to search for group dump files when applying placement rules.")
>
> (defmacro define-frame-preference (group &rest frames)
> (let ((x (gensym "X")))
> diff --git a/sample-stumpwmrc.lisp b/sample-stumpwmrc.lisp
> index 8ef329e..084ea3f 100644
> --- a/sample-stumpwmrc.lisp
> +++ b/sample-stumpwmrc.lisp
> @@ -47,26 +47,29 @@
> ;; Last rule to match takes precedence!
> ;; TIP: if the argument to :title or :role begins with an ellipsis, a
> substring
> ;; match is performed.
> -;; TIP: rules won't do anything if the target groups/frames don't exist! Save
> -;; your layout with "asfdump" and "asfrestore" will re-create everything for
> -;; you.
> -
> +;; TIP: if the create flag is set then a missing group will be created and
> +;; restored from *group-dump-dir*/dump-name file (defaults to group name).
> +;; TIP: if the restore flag is set then group dumpis restored even for an
> +;; existing group.
> (define-frame-preference "Default"
> - ;; frame raise lock (lock AND raise == jumpto)
> - (0 t nil :class "Konqueror" :role "...konqueror-mainwindow")
> - (1 t nil :class "XTerm"))
> + ;; frame raise lock create restore (lock AND raise == jumpto)
> + (0 t nil nil :class "Konqueror" :role "...konqueror-mainwindow")
> + (1 t nil nil :class "XTerm"))
>
> (define-frame-preference "Ardour"
> - (0 t t :instance "ardour_editor" :type :normal)
> - (0 t t :title "Ardour - Session Control")
> - (0 nil nil :class "XTerm")
> - (1 t nil :type :normal)
> - (1 t t :instance "ardour_mixer")
> - (2 t t :instance "jvmetro")
> - (1 t t :instance "qjackctl")
> - (3 t t :instance "qjackctl" :role "qjackctlMainForm"))
> + (0 t t nil nil :instance "ardour_editor" :type :normal)
> + (0 t t nil nil :title "Ardour - Session Control")
> + (0 nil nil nil nil :class "XTerm")
> + (1 t nil nil nil :type :normal)
> + (1 t t nil nil :instance "ardour_mixer")
> + (2 t t nil nil :instance "jvmetro")
> + (1 t t nil nil :instance "qjackctl")
> + (3 t t nil nil :instance "qjackctl" :role "qjackctlMainForm"))
>
> (define-frame-preference "Shareland"
> - (0 t nil :class "XTerm")
> - (1 nil t :class "aMule"))
> + (0 t nil nil nil :class "XTerm")
> + (1 nil t nil nil :class "aMule"))
>
> +(define-frame-preference "Emacs"
> + (1 t t t t :dump-name "emacs-editing" :title "...xdvi")
> + (0 t t t nil :class "Emacs"))
> \ No newline at end of file
> --
> 1.5.5.1
>
> _______________________________________________
> Stumpwm-devel mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/stumpwm-devel
--
Morgan Veyret (address@hidden)
http://appart.kicks-ass.net/patzy
0021-Fixed-make-rule-for-window-to-reflect-the-previous-c.patch
Description: Text document