aboutsummaryrefslogtreecommitdiffstats
path: root/XMonad/Util/Cursor.hs
blob: 5fc191abe20ab8ea0c59bb153684cfea055bcac6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
----------------------------------------------------------------------------
-- |
-- Module      :  XMonad.Util.Cursor
-- Copyright   :  (c) 2009 Collabora Ltd
-- License     :  BSD-style (see xmonad/LICENSE)
--
-- Maintainer  :  Andres Salomon <dilinger@collabora.co.uk>
-- Stability   :  unstable
-- Portability :  unportable
--
-- A module for setting the default mouse cursor.
--
-- Some ideas shamelessly stolen from Nils Schweinsberg; thanks!
-----------------------------------------------------------------------------

module XMonad.Util.Cursor
    ( -- * Usage:
      -- $usage
      module Graphics.X11.Xlib.Cursor,
      setDefaultCursor
    ) where

import Graphics.X11.Xlib.Cursor
import XMonad

-- $usage
--
-- >   setDefaultCursor xC_left_ptr
--
--   For example, to override the default gnome cursor:
--
-- >   import XMonad.Util.Cursor
-- >   main = xmonad gnomeConfig { startupHook = setDefaultCursor xC_pirate }
--
--   Arrr!

-- | Set the default (root) cursor
setDefaultCursor :: Glyph -> X ()
setDefaultCursor glyph = do
    dpy <- asks display
    rootw <- asks theRoot
    liftIO $ do
        curs <- createFontCursor dpy glyph
        defineCursor dpy rootw curs
        flush dpy
        freeCursor dpy curs