xmonad / xmonad-contrib

Contributed modules for xmonad
https://xmonad.org
BSD 3-Clause "New" or "Revised" License
589 stars 274 forks source link

X.A.Submap: Add `visualSubmap` #680

Closed slotThe closed 2 years ago

slotThe commented 2 years ago

Description

tl;dr: screenshot of the new behaviour.

I'm not quite happy with this, but the reason I'm posting it anyways is that I'm interested in feedback. We could make this use X.U.NamedActions, which may be conceptually nicer and could make the specification of descriptions a bit cleaner. This would, however, introduce a regression with regards to submapNamed—it could not be in X.U.NamedActions anymore, as we would need to import that module from X.A.Submap. It may also not be clear which submap implementation is chosen when one specifies named actions via EZConfig (which is something that I haven't touched on at all here).

X.Prelude: Add keymaskToString, keyToString

This technically introduces a regression with regards to the way that modifier masks are printed in X.U.NamedActions and X.H.DebugEvents. However, since this way of printing masks is move in line with X.U.EZConfig, I personally don't think that this is noteworthy.

X.U.XUtils: Add framework for manipulating simple windows

Adds several new functions and type for manipulating "simple windows".

There are several ways to draw windows in X.U.XUtils and other places already, but they are all quite manual. Most of the time one does not want to think about dimensions much and assumes that the code is smart enough to "figure it out"; this is an attempt to do exactly that.

There is a less-managed version showSimpleWindow, which just creates and shows the windows, as well as a wrapper-like withSimpleWindow that also destroys the window once some action finishes executing.

With these functions it should be possible to refactor some contrib modules that currently draw windows manually, like X.U.EasyMotion.

X.A.Submap: Add visualSubmap

Add a visualSubmap function, which works much like the regular submap one, except that it visualises the available choices in a pop-up window.

Related: https://github.com/xmonad/xmonad-contrib/issues/472

Checklist

slotThe commented 2 years ago

After some more experiments with NamedActions, I've concluded that it's not worth it. This is pretty much as good as I'm able to make it; I will merge in a bit if no one has any other objections

liskin commented 2 years ago

After some more experiments with NamedActions, I've concluded that it's not worth it. This is pretty much as good as I'm able to make it; I will merge in a bit if no one has any other objections

Have you considered simply putting visualSubmap into NamedActions or perhaps into a separate module? (Probably have, just checking. I don't really know if NamedActions are good/popular enough to try very hard to use it.)

slotThe commented 2 years ago

Have you considered simply putting visualSubmap into NamedActions or perhaps into a separate module? (Probably have, just checking. I don't really know if NamedActions are good/popular enough to try very hard to use it.)

I have, yeah, but both options feel very wrong to me as this is decidedly a submap thing (NamedActions already weirdly has submapName and I really don't want to further muddle the waters)

It's not a huge boost in this case, I doubt we'd gain very much from using NamedActions (just that it would be conceptually nicer)