pkkid / x11pygrid

Quickly move windows around the an X11 desktop
GNU General Public License v2.0
324 stars 41 forks source link

How to move window to divs #23

Open rsuzano opened 4 years ago

rsuzano commented 4 years ago

Hi, I have an doubt, if in my pygrid.json I configure xdivs:4 ... So I think when I press Ctrl Alt 1 de window is size to 25% and its moved do bottom left of my screen (and seems to be what it does). When I focus another window, and press Ctrl Alt 1 the another window is resized to 25% of my screen,but goes to bottom left to, overlaying the first window.

If I configured xdivs=4, so, how can I put the second window just after the first?

like the picture attached, when I focus on Sublime Text editor and press Ctrl Alt 1 the window is resized and goes to bottom left corner, when I focus on Gnome Terminal and press Ctrl Alt 1 I want do send the window at the "next" screen division, next to sublime text window.

Screenshot from 2020-05-26 22-56-32

pkkid commented 4 years ago

I never programmed that in. When using the corners, I always have that corner of the window touching the corner of the screen. It's been so long that I don't actually remember this code much anymore. However, if you're feeling adventurous, take a look at the function _generate_sequence_percents(); It returns a list of window positions to iterate through.

rsuzano commented 4 years ago

Ok, so, can you please give me more details about what's the idea of the config "xdivs" and "ydivs"??

pkkid commented 4 years ago

You have the idea of xdivs and ydivs correct in your statements above. They are used to help determine how to cycle windows when repeatedly pressing the corner hotkeys. The function _generate_sequence_percents() mentioned above builds a list of the window areas to cycle through. This function needs to be updated to cycle through additional areas if you want to include the area mentioned your question.

For example: If I add print(seqp) just above line 188 and have xdivs=4 and ydivs=2 in the config. I get the below output when moving the window to the bottom left corner (ctrl+alt+1).

Seq(x1=0.0, x2=0.25, y1=0.5, y2=1.0, w=0.25, h=0.5)
Seq(x1=0.0, x2=0.5, y1=0.5, y2=1.0, w=0.5, h=0.5)

This is showing the two positions that would be cycled through when repeatedly pressing this key combination (values represented as percentages of the screen width and height). If this function is updated to return more positions in the list, it will cycle those positions as well. You would want it to include an entry for Seq(x1=0.25, x2=0.5, y1=0.5, y2=1.0, w=0.25, h=0.5).

Hope that helps, ask as many questions as you need.