[clfswm-devel] rearrange windows

Philippe Brochard pbrochard at common-lisp.net
Fri Nov 5 21:22:53 UTC 2010


Fernando Aguayo writes:

> Hi,
>
Hi,

> Normally, when I'm using the tiled layouts I like to rearrange the
> position of my windows.
>
I don't see exactly what you mean by this. Have you a window manager
example which act like this by default? Or maybe you can make a
drawing.

>  Since I couldn't find a way to do it I wrote
> this function, which just switches the position of the current window with
> the next one in the frame:
>
> -----------------------------------------------------------------
> (defun change-pos (side)
>   (when (xlib:window-p *current-child*)
>     (let* ((parent (find-parent-frame *current-child*))
>            (managed-children (frame-child parent))
>            (len (length managed-children))
>            (pos (child-position *current-child* managed-children))
>            (npos (mod (+ pos side) len)))
>       (rotatef (nth pos  (frame-child (find-parent-frame *current-child*)))
>                (nth npos (frame-child (find-parent-frame *current-child*))))
>     )))
> -----------------------------------------------------------------
> (sorry for my lisp ;)
>
No problem with your lisp (except maybe the remaining parenthesis on a
separate line).

> This almost works: every time I change the indexing I have to change
> the layout for it to take effect. I tried to change the layout inside
> the function but it just doesn't have the same effect.
>
> I also loose the focus of the moved window. How can I retain it?
>
Well, each time you change something in a frame, you have to manage all
children affected by the change. For this, you use the
'show-all-children' function.
By default it redisplay only the current-child and all its children.
If your change is for children outside the current-child you must
specify this with the optional parameter. For example if you change all
children in the current root, you must use show-all-children with the
*current-root* parameter.

Note: be careful, this is this functions which cause the flickering in
the current code :( (this is also one of the most complex).

> Is there a better way to do it?
>
There is already the frame-raise/lower-child functions bounds to
mod-1+control+page_up/down by default which change the position of the
selected child. Here is an example of its effect:

Mod-1+Control+Page_Up
+----------+    +----------+    +----------+    +----------+
|      | 2 |    |      | F1|    |      | 3 |    |      | 3 |
|      +---+    |      +---+    |      +---+    |      +---+
|  F1  | 3 | -> |   2  | 3 | -> |   2  | F1| -> |   2  | 4 |
|      +---+    |      +---+    |      +---+    |      +---+
|      | 4 |    |      | 4 |    |      | 4 |    |      | F1|
+----------+    +----------+    +----------+    +----------+
Here the 'F' is the focused child. It doesn't change and you can grab it
to place it where you want.

I have added recently a function frame-select-next/previous-child which
change the selected child. There is already a 'selected-pos' slot in
each frames to tell which child is focused.
I've bound them to mod-1+page_up/down. Here is an example of there
effect:

Mod-1+Page_Up
+----------+    +----------+    +----------+    +----------+
|      | 2 |    |      | F2|    |      | 2 |    |      | 2 |
|      +---+    |      +---+    |      +---+    |      +---+
|  F1  | 3 | -> |   1  | 3 | -> |   1  | F3| -> |   1  | 3 |
|      +---+    |      +---+    |      +---+    |      +---+
|      | 4 |    |      | 4 |    |      | 4 |    |      | F4|
+----------+    +----------+    +----------+    +----------+

Here the focused child is changed each time you call those functions.

Does one of those functions do what you need? If not, there is no
problem to do it.


> Thank you!
>
Regards,

Philippe






More information about the clfswm-devel mailing list