mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-05 06:31:53 -07:00
.github
XMonad
Actions
AfterDrag.hs
BluetileCommands.hs
Commands.hs
ConstrainedResize.hs
CopyWindow.hs
CycleRecentWS.hs
CycleSelectedLayouts.hs
CycleWS.hs
CycleWindows.hs
CycleWorkspaceByScreen.hs
DeManage.hs
DwmPromote.hs
DynamicProjects.hs
DynamicWorkspaceGroups.hs
DynamicWorkspaceOrder.hs
DynamicWorkspaces.hs
EasyMotion.hs
FindEmptyWorkspace.hs
FlexibleManipulate.hs
FlexibleResize.hs
FloatKeys.hs
FloatSnap.hs
FocusNth.hs
GridSelect.hs
GroupNavigation.hs
KeyRemap.hs
Launcher.hs
LinkWorkspaces.hs
MessageFeedback.hs
Minimize.hs
MostRecentlyUsed.hs
MouseGestures.hs
MouseResize.hs
Navigation2D.hs
NoBorders.hs
OnScreen.hs
PerLayoutKeys.hs
PerWindowKeys.hs
PerWorkspaceKeys.hs
PhysicalScreens.hs
Plane.hs
Prefix.hs
Profiles.hs
Promote.hs
RandomBackground.hs
RepeatAction.hs
Repeatable.hs
RotSlaves.hs
RotateSome.hs
Search.hs
ShowText.hs
Sift.hs
SimpleDate.hs
SinkAll.hs
SpawnOn.hs
Submap.hs
SwapPromote.hs
SwapWorkspaces.hs
TagWindows.hs
TiledWindowDragging.hs
ToggleFullFloat.hs
TopicSpace.hs
TreeSelect.hs
UpKeys.hs
UpdateFocus.hs
UpdatePointer.hs
Warp.hs
WindowBringer.hs
WindowGo.hs
WindowMenu.hs
WindowNavigation.hs
WithAll.hs
Workscreen.hs
WorkspaceCursors.hs
WorkspaceNames.hs
Config
Doc
Hooks
Layout
Prompt
Util
Doc.hs
Prelude.hs
Prompt.hs
scripts
tests
.gitignore
.hlint.yaml
.mailmap
CHANGES.md
CONTRIBUTING.md
LICENSE
NIX.md
README.md
Setup.lhs
cabal.haskell-ci
cabal.project
flake.nix
stack-master.yaml
stack.yaml
xmonad-contrib.cabal
With XDG support so firmly ingrained now, it's about time we stop hard-coding the configuration path in the docs.
79 lines
2.8 KiB
Haskell
79 lines
2.8 KiB
Haskell
----------------------------------------------------------------------------
|
|
-- |
|
|
-- Module : XMonad.Actions.WindowMenu
|
|
-- Description : Display window management actions in the center of the focused window.
|
|
-- Copyright : (c) Jan Vornberger 2009
|
|
-- License : BSD3-style (see LICENSE)
|
|
--
|
|
-- Maintainer : jan.vornberger@informatik.uni-oldenburg.de
|
|
-- Stability : unstable
|
|
-- Portability : not portable
|
|
--
|
|
-- Uses "XMonad.Actions.GridSelect" to display a number of actions related to
|
|
-- window management in the center of the focused window. Actions include: Closing,
|
|
-- maximizing, minimizing and shifting the window to another workspace.
|
|
--
|
|
-- Note: For maximizing and minimizing to actually work, you will need
|
|
-- to integrate "XMonad.Layout.Maximize" and "XMonad.Layout.Minimize" into your
|
|
-- setup. See the documentation of those modules for more information.
|
|
--
|
|
-----------------------------------------------------------------------------
|
|
|
|
module XMonad.Actions.WindowMenu (
|
|
-- * Usage
|
|
-- $usage
|
|
windowMenu
|
|
) where
|
|
|
|
import XMonad
|
|
import qualified XMonad.StackSet as W
|
|
import XMonad.Actions.GridSelect
|
|
import XMonad.Layout.Maximize
|
|
import XMonad.Actions.Minimize
|
|
import XMonad.Prelude (fi)
|
|
|
|
-- $usage
|
|
--
|
|
-- You can use this module with the following in your @xmonad.hs@:
|
|
--
|
|
-- > import XMonad.Actions.WindowMenu
|
|
--
|
|
-- Then add a keybinding, e.g.
|
|
--
|
|
-- > , ((modm, xK_o ), windowMenu)
|
|
|
|
colorizer :: a -> Bool -> X (String, String)
|
|
colorizer _ isFg = do
|
|
fBC <- asks (focusedBorderColor . config)
|
|
nBC <- asks (normalBorderColor . config)
|
|
return $ if isFg
|
|
then (fBC, nBC)
|
|
else (nBC, fBC)
|
|
|
|
windowMenu :: X ()
|
|
windowMenu = withFocused $ \w -> withDisplay $ \d -> withWindowAttributes d w $ \wa -> do
|
|
tags <- asks (workspaces . config)
|
|
let Rectangle x y wh ht = getSize wa
|
|
Rectangle sx sy swh sht <- gets $ screenRect . W.screenDetail . W.current . windowset
|
|
let originFractX = (fi x - fi sx + fi wh / 2) / fi swh
|
|
originFractY = (fi y - fi sy + fi ht / 2) / fi sht
|
|
gsConfig = (buildDefaultGSConfig colorizer)
|
|
{ gs_originFractX = originFractX
|
|
, gs_originFractY = originFractY }
|
|
actions = [ ("Cancel menu", return ())
|
|
, ("Close" , kill)
|
|
, ("Maximize" , sendMessage $ maximizeRestore w)
|
|
, ("Minimize" , minimizeWindow w)
|
|
] ++
|
|
[ ("Move to " ++ tag, windows $ W.shift tag)
|
|
| tag <- tags ]
|
|
runSelectedAction gsConfig actions
|
|
|
|
getSize :: WindowAttributes -> Rectangle
|
|
getSize wa =
|
|
let x = fi $ wa_x wa
|
|
y = fi $ wa_y wa
|
|
wh = fi $ wa_width wa
|
|
ht = fi $ wa_height wa
|
|
in Rectangle x y wh ht
|