fikovnik / ShiftIt

Managing windows size and position in OSX
5.54k stars 360 forks source link

Spatially aware window switching #47

Open bradphelan opened 13 years ago

bradphelan commented 13 years ago

Previously I was a wmii http://wmii.suckless.org/ user under linux. Shiftit is the next best thing under OSX and I'm really happy to have it. There are many features of wmii which Shiftit could be inspired by. However one thing I really like is the ability to switch windows according to adjacency.

If I have two windows side by side I would like to be able to do

<cmd-alt-shift-l> switch to the window to the right of the current window
<cmd-alt-shift-h> switch to the window to the left of the current window
<cmd-alt-shift-k> switch to the above window
<cmd-alt-shift-j> switch to the below window

When running a window manager in tiled mode it is always easier to jump around the window space spatially rather than hunt through the OSX switcher for an application and then switch through it's windows.

Given SwitchIt is not a pure tiled manager like wmii I guess there would be problems handling overlapping windows and non aligned windows to decide what window to switch to.

I'm not a good objective-c programmer. However if I could be sandboxed to a simple function call where I had the list of windows the current window and their geometries I could probably figure out a switching algorithm for you.

Regards

Brad

chriscrowe commented 13 years ago

If we were going to implement this feature then it would probably make the most sense to use the X and Y coordinates of the center points of each window to figure out which windows are to the left/right/up/down.

bradphelan commented 13 years ago

Thanks for the quick reply.

Not really sure what would be needed to make it properly usable. However if you were able to get me a function where I had all the geometry and the action required I could have a hack at it.

My feeling is that for

moving to the right you would check the alignment of the left side of all candidate windows. moviing to the left you would check the alignment of the right side of all candidate window. moving down you would check the alignment of the top of all candidate windows moving down check alignment of bottom.

though it may not be so simple especially for windows with greatly different widths and heights.

B

On Wed, May 11, 2011 at 8:59 AM, skandocious < reply@reply.github.com>wrote:

If we were going to implement this feature then it would probably make the most sense to use the X and Y coordinates of the center points of each window to figure out which windows are to the left/right/up/down.

Reply to this email directly or view it on GitHub: https://github.com/fikovnik/ShiftIt/issues/47#comment_1136039

fikovnik commented 13 years ago

Indeed this feature I'm missing the most.

I'm sorry for not being very responsive lately and not doing much - been swamped with the work. I already started on this - there is a need to rewrite a bit the logic of how the shifting work - a bunch of atomic operations - in order to have it done. The way @skandocious describes that is exactly the one I chose - getting a vector beading between centers and its length. I will see if I have a bit of a time during the weekend to at least make a commit.

jasonm commented 12 years ago

This would be amazing. @fikovnik any chance the code you wrote would still apply, or could be published in a branch off of the shiftit16 branch?

SizeUp feature req thread http://getsatisfaction.com/irradiatedsoftware/topics/switching_window_focus_via_sizeup - note that I'm currently a happy user of ShiftIt instead of SizeUp, FOSS love :)

fikovnik commented 12 years ago

Just yesterday I commit acode that does switch the screen and that is based on the idea of traversing adjacent rectangles (monitors). The idea of the centers does not seem to work very well, instead it looks better to compute the distance between the point on the appropriate side to a vector that is formed by the adjacent side of the other window (not sure I make myself clear). Right now it should not be tat difficult to do this because:

  1. there is an API that gives you all the visible windows ordered by z-index.
  2. there is a code that that can figure out their relative position. It's again more about how to present this to a user (which key binding?) and how to deal with overlapping windows? Any idea?

My current priority now is to release the shiftit16, but if you feel like to help please go ahead, branch off the shiftit16 and check the SIAdacentRectangles.m and FMTGeometry.m and SIWindowManager.m.