[xmonad] ClientMessage events in 0.7?

Andrea Rossato mailing_list at istitutocolli.org
Thu Jan 31 04:10:49 EST 2008


On Thu, Jan 31, 2008 at 09:47:15AM +0100, Joachim Breitner wrote:
> I already submitted that, but then the event was handled once per
> layout, which is too often − I need a way to reliably intercept the
> event exactly once.

I may be wrong, but probably what you need is a layout combinator: you
get the message and you return a new combinator that will decide what
to do next.

with the LayoutCombinator class and the CombinedLayout instance that
would be a trivial task.

But the sense of beauty you may find here would suggest:

data Interceptor l1 l2 a = Intercept Bool DoNex (l1 a) (l2 a) deriving (Read, Show)
data DoNext = Wait | GoTakeACoffee | RunAAlyout | OrJustTakeASnap deriving ...

then you implement a LayoutClass instance for Interceptor with plenty of
unmaintainable boilerplate code:

instance (LayoutClass l1 a, LayoutClass l2 a) => LayoutClass (Interceptor l1 l2) a where
   doLayout
   emptyLayout

to get to:
   handleMessage (Intercept b d l1 l2) m = if b the do do something with do DoNext
				      return (Just Intercept True GoTakeACoffee l1 l2)

but you'll be rewarded with a wonderful pure method for setting the
combinator descriptor. This is real easy:

   description _ = "I'm a pure f***ing string"


You may also want to run the message on those layouts too and then
return them updated. Be careful, if you do everything by hand you can
really mess everything up.

moreover, I will not be of any help when the next API change will
break all you wonderfully designed stuff.

I know, a LayoutCombinator class would make all that quite easy, but
can you imagine how ugly would it be having to write:
   description _ = return "Sorry, Andrea wanted me unpure"

??

;)

cheers,
andrea

I'm just kidding.
:)


More information about the xmonad mailing list