Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Fitting N Xterms On An X by Y screen

by Limbic~Region (Chancellor)
on Jun 04, 2009 at 22:48 UTC ( [id://768607]=perlquestion: print w/replies, xml ) Need Help??

Limbic~Region has asked for the wisdom of the Perl Monks concerning the following question:

All,
Khisanth asked on #perl (freenode) if anyone knew of an algorithm for placing a variable number of Xterms on a screen with a few constraints:
  • Xterms should be as close to the same size as possible
  • As much of the screen space should be used as possible
  • The Xterms should be as reasonably shaped as possible (it is ok to have a very wide Xterm that isn't as high but a skinny long one is of no practical value)

Obviously the last one is somewhat of personal preference so bonus points to an algorithm that has sane defaults but allows it to be configurable. The assumption is that such an algorithm already exists because of windows managers but it seems like a fun diversion.

My initial idea is below though I only spent about 30 seconds thinking about it.

Can you come up with a good algorithm for this (keeping in mind the bonus)?

Cheers - L~R

Replies are listed 'Best First'.
Re: Fitting N Xterms On An X by Y screen
by ig (Vicar) on Jun 05, 2009 at 02:16 UTC

    Here is another approach.

    Features include:

    • Only two sizes of Xterm window (O1)
    • Minimum difference between larger and smaller windows for a given minimum aspect ratio (01)
    • Entire display is covered (O2)
    • All windows exceed a minimum aspect ratio (width/height) (O3)
    • Tunable for target aspect ratio (O3)
Re: Fitting N Xterms On An X by Y screen
by JavaFan (Canon) on Jun 05, 2009 at 07:52 UTC
    Given there's no constraint about overlap, the simple solution is to have all xterms the same size, and the size of the screen. And if you add a constraint about non-overlapping, there still isn't a constraint all xterms need to be visible: I'll take one xterm the size of the screen, place it on the screen, and put the rest of the xterms out of the viewpoint.

    It's a harder question if you add the constraints:

    • No windows may overlap.
    • All windows need to be completely visible.
    • There may be existing windows which should remain completely visible.
    The latter basically means the exercise is more than just tiling a simple rectangle. But it may mean the problem becomes NP-complete.
        This is actually for a xchat script to deal with channel windows so that won't work :)
Re: Fitting N Xterms On An X by Y screen
by spx2 (Deacon) on Jun 05, 2009 at 10:13 UTC
    wmii3 is very good at this problem , maybe studying its algorithm will shed some light on this
Re: Fitting N Xterms On An X by Y screen
by JavaFan (Canon) on Jun 05, 2009 at 12:33 UTC
    The assumption is that such an algorithm already exists because of windows managers but it seems like a fun diversion.
    Is it? I gladly admit I don't know most window managers, but the few I haved used only place one window at a time - they don't seem to be confronted with the problem of placing many windows at once. Furthermore, it's usually not up to the window manager to determine how large a window should be; it's the application that asks "please mister window manager, I've a window of this size, would you please put this on the screen?"
      JavaFan,
      I likely know even less about window managers than you. It was a comment made by Khisanth and I took it at face value. According to spx2, at least 1 windows manager is good at this. Again, I took the statement at face value.

      Cheers - L~R

      Well I seem to recall, in the good'ol' days of Windows 3.1, the Program Manager had an option in the Windows menu which read "Tile Windows" and that did exactly that: tile all open windows so tat all were visible and covered all the screen.
Re: Fitting N Xterms On An X by Y screen
by bsb (Priest) on Jun 05, 2009 at 23:33 UTC
    Xmonad is a tiling window manager, which maybe a useful source of ideas:

    I like the sound this: The XMonad.Layout.LayoutCombinators module provides combinators for easily combining multiple layouts into one composite layout

    I've not even tried xmonad (I'm still using e16)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://768607]
Approved by zwon
Front-paged by almut
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-19 21:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found