Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a LayoutClass to allow different layouts for portrait and landscape monitors. #354

Open
1 of 2 tasks
gcoakes opened this issue Jun 9, 2020 · 4 comments
Open
1 of 2 tasks

Comments

@gcoakes
Copy link

gcoakes commented Jun 9, 2020

Problem Description

I wrote a simple instance of LayoutClass which will allow you to specify two different layouts, one for portrait and one for landscape. I wanted to scope out whether this would be accepted as a PR before I took the effort of integrating it with xmonad-contrib directly rather than just in my config.

Configuration File

Please include the smallest configuration file that reproduces the
problem you are experiencing:

data EitherRatio p l a = EitherRatio (p a) (l a)
  deriving (Show, Read)

instance (LayoutClass p a, LayoutClass l a) => LayoutClass (EitherRatio p l) a where
  runLayout (W.Workspace i (EitherRatio p l) ms) r@(Rectangle rx ry rw rh)
    | rw < rh = do
        (lrs, newP) <- runLayout (W.Workspace i p ms) r
        return $ (lrs, fmap (`EitherRatio` l) newP)
    | rw >= rh = do
        (lrs, newL) <- runLayout (W.Workspace i l ms) r
        return $ (lrs, fmap (EitherRatio p) newL)

  handleMessage (EitherRatio p l) msg = do
    mp <- handleMessage p msg
    ml <- handleMessage l msg
    return $ case (mp, ml) of
      (Just np, Just nl) -> Just $ EitherRatio np nl
      (Just np, Nothing) -> Just $ EitherRatio np l
      (Nothing, Just nl) -> Just $ EitherRatio p nl
      _                  -> Nothing

  description (EitherRatio p l) =
    "[ " ++ description p ++ " | " ++ description l ++ " ]"

Checklist

@geekosaur
Copy link
Contributor

There's already a layout modifier that does this by comparing to a fixed horizontal size, which is less than ideal, so I don't see a reason it would be rejected.

@liskin
Copy link
Member

liskin commented Jun 9, 2020

Might be a good idea to have them both in one module, but the XMonad.Layout.PerScreen name seems non-intuitive to me (I wouldn't look there if I was trying to find it), so maybe it's not as good an idea after all. :-)

@byorgey
Copy link
Member

byorgey commented Jun 9, 2020

Looks great to me! And generally speaking, the bar for including new modules in xmonad-contrib is not that high---as long as it won't make xmonad crash and would be useful to someone, there's no good reason to exclude it. So your contribution would be most welcome.

@gcoakes
Copy link
Author

gcoakes commented Jun 21, 2020

I'm not going to be pursuing this PR anymore. There were some issues associated with stale window decorations, and I've since stopped using it. If anyone wants to pick this up, I still think it would be useful to the project, but I won't personally be using it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants