Bug 5946 - Add <center> option to the LeastOverlap placement algorithm
Status: RESOLVED FIXED
Alias: None
Product: Openbox
Classification: Unclassified
Component: general
Version: 3.5.2
Hardware: PC Linux
: P3 normal
Assignee: Dana Jansens
QA Contact:
URL:
: 6013
Depends on:
Blocks:
 
Reported: 2013-05-31 11:54 EDT by Gavcheg
Modified: 2013-11-01 03:42:11 EDT
8 users (show)

See Also:



Description Gavcheg 2013-05-31 11:54:44 EDT
Now "smart" window placement usually draws a new window in the upper left-hand corner. The old behavior of openbox with <center> been better.
Sorry for bad english.
Comment 1 Dirk Sohler 2013-08-12 14:40:27 EDT
+1 for that. center=yes seams to be ignored in placement settings. Previous behavior was much more intuitive. Though not sure if bug or removed feature.
Comment 2 Dana Jansens 2013-08-12 14:58:35 EDT
The old placement algorithm was replaced with one that finds an area of least overlap.

Center would need to be reimplemented in the new code. The configuration option was removed since this algorithm does not support it currently.
Comment 3 Dirk Sohler 2013-08-12 18:46:09 EDT
(In reply to comment #2)
> The old placement algorithm was replaced with one that finds an area of
> least overlap.

It should prefer centered position of windows if there is enough space to center a window in that space instead of placing it in the top left corner of that space.
Comment 4 Dana Jansens 2013-08-13 10:31:23 EDT
This has come up on IRC as well. 

It'd be nice to have the option of centering the window in the available space. This is especially noticeable when opening a window on an empty desktop.
Comment 5 Dana Jansens 2013-08-13 17:48:19 EDT
*** Bug 6013 has been marked as a duplicate of this bug. ***
Comment 6 Dana Jansens 2013-08-13 17:48:54 EDT
Ian, any interest in working on this?
Comment 7 itz 2013-08-14 01:10:58 EDT
Hi.  I have some interest, but also some reservations.

First, it is not even clear what centering means when the available area
is not convex, although I guess I could look up what the old code did in
that case.

Second, to me such a policy in combination with leastoverlap is clearly
suboptimal and I would never use it myself.  leastoverlap is meant for
situations with some real estate shortage, that is when some overlap is
expected after adding 2 or 3 windows.  Placing the first one centrally
only fragments the available space and means you'll get overlap sooner.

So, to summarise, maybe :)
Comment 8 Dana Jansens 2013-08-14 10:46:02 EDT
(In reply to comment #7)
> Hi.  I have some interest, but also some reservations.
> 
> First, it is not even clear what centering means when the available area
> is not convex, although I guess I could look up what the old code did in
> that case.

There's a few ways you can do it. If none of the rectangles making up the available area are larger than the window, then you're kinda helpless.

But if the rect you choose to put the window in is larger than the window, you can just center inside that rect?

> Second, to me such a policy in combination with leastoverlap is clearly
> suboptimal and I would never use it myself.  leastoverlap is meant for
> situations with some real estate shortage, that is when some overlap is
> expected after adding 2 or 3 windows.  Placing the first one centrally
> only fragments the available space and means you'll get overlap sooner.

You're right! But maybe it's also just creating a situation where it can shine.. :)
Comment 9 itz 2013-08-15 02:19:44 EDT
Okay then, I'll look at it.  At some point in the not too distant future.
Comment 10 Dana Jansens 2013-08-15 11:04:32 EDT
Thanks!
Comment 11 itz 2013-08-24 00:32:41 EDT
So, what must I do to stop bugzilla from spamming me about this daily?  From my POV, it is fixed, but it is not merged so I don't wan't to change the status.
Comment 12 itz 2013-08-24 00:36:26 EDT
I know what - I'll reassign it :-P
Comment 13 Dana Jansens 2013-08-24 01:23:10 EDT
I've been waiting on you putting up a new patch with the changes from code review. Is there a new patch somewhere?
Comment 14 itz 2013-08-25 00:34:39 EDT
Yes, it's in the same branch.  You didn't get any notifications about commits on that branch?
Comment 15 Mikachu 2013-08-25 17:38:27 EDT
This bug doesn't even mention a repo, what "same branch" are you talking about?
Comment 16 Dana Jansens 2013-08-25 18:47:53 EDT
Hit "watch" on my github repo to see pull requests there mikachu. 

I didn't receive any notifications! So thanks for pinging me here.
Comment 17 Dana Jansens 2013-09-01 11:53:00 EDT
Implementation is merged to my work branch as staging for master.
Comment 18 Dana Jansens 2013-09-01 16:49:51 EDT
Commit pushed to master at https://github.com/danakj/openbox

https://github.com/danakj/openbox/commit/f866c034bf6e954791442ff029d5ae51ab0bd616
Add the old <center> option for the placement policy. (Bug 5946)

Original commit messages:
. Reformat to move closer to house style
. Add center on top of leat overlap place algo
. Add sentinel value to edge arrays
. Use a Size instead of a Rect for a centering field
. Fix off by one bug
. Need to declare dx and dy
. Pass length of edge array instead of recomputing
. Fix missing open-brace in config.c
. Address the more trivial subset of danakj comments
. Revert "Remove now-unused config_place_center option."
  This reverts commit 5e282dae08be3b900e0337efa0fae8f3ffa92cd7.
. Remove reliance on sentinel value when scanning edge arrays
. Avoid need to initialize Size structure by removing it :)
. Clean up field expansion code somewhat
. Compress code further by using a structure for common args
. Fix search for next grid point
. Squeeze it even more by not using Size at all
Comment 19 Das 2013-11-01 03:23:28 EDT
I don't see this as working, I have this in the rc.xml;

 <placement>
    <policy>Smart</policy>
    <!-- 'Smart' or 'UnderMouse' -->
    <center>yes</center>
    <!-- whether to place windows in the center of the free area found or
       the top left corner -->
    <monitor>Primary</monitor>
    <!-- with Smart placement on a multi-monitor system, try to place new windows
       on: 'Any' - any monitor, 'Mouse' - where the mouse is, 'Active' - where
       the active window is, 'Primary' - only on the primary monitor -->
    <primaryMonitor>1</primaryMonitor>
    <!-- The monitor where Openbox should place popup dialogs such as the
       focus cycling popup, or the desktop switch popup.  It can be an index
       from 1, specifying a particular monitor.  Or it can be one of the
       following: 'Mouse' - where the mouse is, or
                  'Active' - where the active window is -->
  </placement>

Isn't that <center>yes</center> on the 4th line suppose to make windows open center? I thought this was the old placement policy? If so this is not working...
Comment 20 Das 2013-11-01 03:42:11 EDT
Sorry my bad, wasn't paying attention that I needed to grab it from git, for a sec there I thought it was the 3.5.2 for download off the site...

Glad to see the old center back, after all this isn't a tiling WM is it? hehe... :)

THANKS