Xfce Forum

Sub domains
 

You are not logged in.

#1 2019-01-05 10:24:46

roelkluin
Member
Registered: 2019-01-05
Posts: 3

Request: improved layout for snapping windows

Currently snapping windows, if enabled, can place windows on four corners of your workspace. Nice for small screens, but if your display monitor is large, this placement is space inefficient. Optimal placement can be achieved by dragging windows, but it would be nice if snapping would become more useful as well.

I envision to configure the layout for window placement, to place windows in 3, 4 or more horizontal areas. For even larger monitors vertical areas may be interesting as well. To illustrate layout and inspire:

[1] https://i.stack.imgur.com/ARkMu.png
[2] https://snook.ca/technical/matrix-layouts/grid.png

Two extra sliders in 'Settings' -> 'Window manager tweaks' tab placement may suffice. Let's keep by default:

Horizontal number of areas for window snapping:
1 --|----------------- 10

Vertical number of areas for window snapping:
1 --|----------------- 10

A few potential questions:
* In a 3x3 environment, how could one snap to the central area?

One solution would be if left mouse button dragging a window + shift + alt/meta were to place a window to its nearest area (least Euclidean distance to centre of area).

* How could one achieve a layout such as in example [2] above?

Dragging a window corner + shift + alt/meta could expand the window to cover the adjacent areas you dragged towards.

Is there a development repository for the window manager tweaks and window placement?

Last edited by roelkluin (2019-01-05 10:30:46)

Offline

#2 2019-01-05 14:39:45

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 5,049

Re: Request: improved layout for snapping windows

Hello and welcome.

That's an interesting idea. To access the Xfce development repository, click on the "GIT" link in the top right corner of this page.

* How could one achieve a layout such as in example [2] above?

You could use an X automation tool like xdotool to resize and move windows to those locations. Here is a proof-of-concept script that you could build on:

#!/bin/bash

# window geometry enum (Xpos, Ypos, width, height)
X=0
Y=1
W=2
H=3

# area arrays
declare -a AreaA
declare -a AreaB
declare -a AreaC
declare -a AreaD
declare -a AreaE
declare -a AreaF

# area dimensions
AreaA=(351 23 666 487)
AreaB=(351 512 222 222)
AreaC=(573 512 222 222)
AreaD=(795 512 222 222)
AreaE=(0 23 350 725)
AreaF=(1017 23 349 725)

# get the active window
WINID=$(xdotool getwindowfocus)

case $1 in
	A)	xdotool windowsize $WINID ${AreaA[$W]} ${AreaA[$H]}
		xdotool windowmove $WINID ${AreaA[$X]} ${AreaA[$Y]}		
	;;
	B)	xdotool windowsize $WINID ${AreaB[$W]} ${AreaB[$H]}
		xdotool windowmove $WINID ${AreaB[$X]} ${AreaB[$Y]}
	;;
	C)	xdotool windowsize $WINID ${AreaC[$W]} ${AreaC[$H]}
		xdotool windowmove $WINID ${AreaC[$X]} ${AreaC[$Y]}
	;;
	D)	xdotool windowsize $WINID ${AreaD[$W]} ${AreaD[$H]}
		xdotool windowmove $WINID ${AreaD[$X]} ${AreaD[$Y]}
	;;
	E)	xdotool windowsize $WINID ${AreaE[$W]} ${AreaE[$H]}
		xdotool windowmove $WINID ${AreaE[$X]} ${AreaE[$Y]}
	;;
	F)	xdotool windowsize $WINID ${AreaF[$W]} ${AreaF[$H]}
		xdotool windowmove $WINID ${AreaF[$X]} ${AreaF[$Y]}		
	;;
	*) ;;
esac

You'll need to define each area's X, Y, Width, Height parameters (in the "area dimensions" section) specific to your screen layout. I saved the script as "snap".

Basically, create keyboard shortcuts to match each area. For example:
- Win+a = "snap A"
- Win+b = "snap B"
- Win+c = "snap C"
- Win+d = "snap D"
- Win+e = "snap E"
- Win+f = "snap F"
...and when you want to snap any given active window to one of those areas, press the shortcut key.

Offline

#3 2019-01-05 20:30:30

roelkluin
Member
Registered: 2019-01-05
Posts: 3

Re: Request: improved layout for snapping windows

Thanks ToZ, before your reply I tried to implement it in the Window manager tweaks, below link is to a patch based on current git. It compiles and shows the dialogue, but the actual window placement I haven't been able to test yet. Also shortcut keys are not yet implemented.

https://pastebin.com/EtvpCM4c

Last edited by roelkluin (2019-01-05 20:43:19)

Offline

#4 2019-01-06 20:37:58

mint4all
Member
From: America
Registered: 2018-08-21
Posts: 94

Re: Request: improved layout for snapping windows

roelkluin wrote:

Thanks ToZ, before your reply I tried to implement it in the Window manager tweaks, below link is to a patch based on current git. It compiles and shows the dialogue, but the actual window placement I haven't been able to test yet. Also shortcut keys are not yet implemented.

https://pastebin.com/EtvpCM4c

Greetings! What you're trying to do (get the most out of your large display) is both interesting and, as it appears from your posts, quite a challenge to figure it out and get it to work.

Perhaps there's an easier way? Fwiw: a while ago, i came across a tiling applet/add-on for xfce that might just do what you want, see @ https://www.giuspen.com/x-tile/ ... I admit that I am not using this myself lacking a large display such as your's, but for several years i have extensively used that developer's "cherrytree" note-taking app and can vouch for the quality of his code. Worth a try?

Cheers, m4a


Linux Mint 18.3-xfce & Linux Mint 19-xfce  -- Dell Precision T1500 Desktops -- Toshiba Satellite Laptop -- Family & Community Support re. Linux

Offline

#5 2019-01-07 22:24:20

roelkluin
Member
Registered: 2019-01-05
Posts: 3

Re: Request: improved layout for snapping windows

Thanks mint4all,

I had a workaround before, I can probably still find one, but what I was trying to do is implement it in xfwm4 so it's just an option for anyone to use without too much hassle. I still have some hope my approach may work, I was trying to figure out how to test this without installing it system wide and messing up my system. I compiled and installed it in prefix=$HOME/testxfwm4

My arch startxfce4 script, eventually starts xfce4-session, this uses /usr/bin/xfwm4* without easy means to override this. In my login I now placed the prefix bin dir earlier in PATH for testing: `PATH=$HOME/testxfwm4/bin:$PATH startxfce4'
This is insecure; if the directory would contain a rogue executable this is used instead of the system command. E.g. nasty if one places a link named 'ls' to /usr/bin/rm here.

The patch however did not yet work. I get my desired 'Window manager tweaks' mods and the exe link in the /proc/$PID directory for xfwm4 shows that I'm running $HOME/testxfwm4/bin/xfwm4, but the exit button does not work, maybe the resulting config is refused somehow. So.. I'll have to amend my patch.

Last edited by roelkluin (2019-01-07 22:49:29)

Offline

Board footer

Powered by FluxBB