Bug 3769 - Support window size and position relative to screen size
Status: REOPENED
Alias: None
Product: Openbox
Classification: Unclassified
Component: general
Version: 3.4.7.2
Hardware: PC Linux
: P2 enhancement
Assignee: Mikachu
QA Contact:
URL:
Depends on:
Blocks:
 
Reported: 2008-09-05 05:17 EDT by kai.grossjohann
Modified: 2013-08-11 08:39:09 EDT
4 users (show)

See Also:


Attachments
First go (6.54 KB, patch)
2010-04-14 13:22 EDT, Mikachu

Description kai.grossjohann 2008-09-05 05:17:27 EDT
I find that I often use specific window sizes and positions:
  - Full screen (= maximized, supported by OB)
  - Left half of screen
  - Right half of screen
  - Top left quarter of screen
  - Top right ...
  - Bottom left ...
  - Bottom right ...
  - On a widescreen monitor, it may make sense to have 6 positions in three columns.

WIBNI the Move-and-Resize operation supported entering these positions/sizes?

One idea is to say that if the width/height are less than one, then they are fractions of the screen width/height.  Or if the value ends in %, then it is percentage of screen dimension.  Or support entering ratios with "/", such as "1/2" or "1/3" or "2/3".

Similar values could be used for x and y position.

For practical usage, it may be sufficient to bind keys to "set the width of this window to 1/2 of screen width" and similar commands, then use the "move in a direction until you hit a window border or screen edge" commands to position the windows.

I guess all computations should take into account the usable screen area, i.e. the area of the screen that would be covered by a maximized window.  When using OB with a panel, that would exclude a margin near a screen edge.

What do people think?
Comment 1 Mikachu 2008-09-05 05:29:18 EDT
If you want to know "what do people think?" you probably want the ml, i'm most likely the only one to look at this :).

i think this is probably a good idea, but for putting windows aligned to the right edge or bottom edge, you can already do that. (see http://icculus.org/openbox/index.php/Help:Actions#MoveResizeTo ).
Comment 2 jchtt 2010-03-28 08:57:52 EDT
I just wonder if there has been a discussion about this bug. Apparently, many people use MoveResizeTo as a way to mimic tiling (a rather effective one, I think) and it seems to me calculating pixels is not a good way of defining something like 50% of vertical screen size, especially if you switch between different display sizes, like I do.
Therefore, is there any chance this feature might get implemented, although the bug has been on "ASSIGNED" status for a long time?
Comment 3 Dana Jansens 2010-03-28 14:20:37 EDT
I'd accept a patch for this.  I like the idea of ratios cuz you can be as precise as you like without using decimal points.  Ratios of > 1 should be treated as 1.
Comment 4 Mikachu 2010-04-14 13:22:36 EDT
Created attachment 2334 [details]
First go

This applies to work and lets you say "32%" or "23/74" instead of a pixel position, and currently applies to moveresizeto and per-app positions only.
Comment 5 Mikachu 2010-04-14 13:25:54 EDT
right now it applies to the left/top edge (or right/bottom if you give a - before as it has always been), but it might make more sense for this stuff to have 0% be aligned to the left and 100% to be aligned to the right.
Comment 6 Dana Jansens 2010-04-14 14:12:17 EDT
(In reply to comment #5)
> right now it applies to the left/top edge (or right/bottom if you give a -
> before as it has always been), but it might make more sense for this stuff to
> have 0% be aligned to the left and 100% to be aligned to the right.

for width, 100% aligned to the left should be the same as 100% aligned to the right.  for position it would be the same as 0% to the right.  right ?
Comment 7 Mikachu 2010-04-14 14:33:44 EDT
(In reply to comment #6)
> (In reply to comment #5)
> > right now it applies to the left/top edge (or right/bottom if you give a -
> > before as it has always been), but it might make more sense for this stuff to
> > have 0% be aligned to the left and 100% to be aligned to the right.
> 
> for width, 100% aligned to the left should be the same as 100% aligned to the
> right.  for position it would be the same as 0% to the right.  right ?

Yeah, but I can see you wanting to put a window that isn't half the width of the screen to the right of the center line, and you can't do both that and center a window without something more clever.

My current idea is to allow you to say <x anchor="foo">bar</x>, foo can be anything that bar can be, but also left/center/right (and top/bottom for y), so that position foo in the window will be aligned with the given position bar on the screen.

This is of course not an issue for sizes, only for positions.
Comment 8 Ivan Sichmann Freitas 2011-10-26 22:14:46 EDT
Is this patch already applied in current openbox? Also, how it behaves in a multi-monitor setup?
Comment 9 Ivan Sichmann Freitas 2011-10-31 10:20:28 EDT
(In reply to comment #8)
> Is this patch already applied in current openbox? Also, how it behaves in a
> multi-monitor setup?

Searching in the git log and trying it myself I see that this patch have already been applied, but no documentation about it was added in the wiki.
Comment 10 Ahti Kitsik 2013-07-22 14:04:37 EDT
Looks like OpenBox 3.5.0 has this patch applied and both 50% and 1/2 style ratios work.

The problem is that they are not "pixel-perfect":

If I have two windows:

a) MoveResizeTo - height:50%, y:0
b) MoveResizeTo - height:50%, y:-0

then they overlap vertically.

If both windows have window decorators disabled then the overlap is only ~2px.

But if the decorators (title bar, close button etc) are turned on then the overlap is bigger.

I could be wrong but looks like the geometry does not take decorators into account.

Should I file this report as a separate bug?

I tried to look up the source but not sure if http://git.icculus.org/?p=mikachu/openbox.git is the latest head, release-3.5.0 tag does not seem to be there.
Comment 11 Dana Jansens 2013-07-22 14:08:19 EDT
http://git.openbox.org/?p=dana/openbox.git;a=summary has the tag you are looking for.

Sounds like we should indeed take window decorations into consideration when applying the % and fraction sizes.
Comment 12 Dana Jansens 2013-08-10 19:17:28 EDT
This is similar to https://bugzilla.icculus.org/show_bug.cgi?id=4952
Comment 13 Dana Jansens 2013-08-10 23:53:24 EDT
It seems like this was done here: https://github.com/danakj/openbox/commit/71ffb4375db0043dda045983c2c5eabf9570a7fb
Comment 14 Mikachu 2013-08-11 08:39:09 EDT
the moveresizeto action has an option for setting client or frame size, and defaults to frame size. the per-app settings always use client size (eg, not including decor).