From cd29d500d627ad79606d566c0f8b6d39b8d28b20 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Tue, 15 Sep 2009 18:56:04 +0200 Subject: XMonadContrib: add a utility module to set the default cursor Ignore-this: b0559b7b2617db90506492aa1479cde This adds XMonad.Util.Cursor, which defines a function that allows setting the default mouse cursor. This can be useful for (for example) gnomeConfig, to ensure that the root cursor is changed from X_cursor to left_ptr. darcs-hash:20090915165604-40516-682a702c21bdb6b712bdab38a370849932e9f632.gz --- XMonad/Util/Cursor.hs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 XMonad/Util/Cursor.hs (limited to 'XMonad/Util') diff --git a/XMonad/Util/Cursor.hs b/XMonad/Util/Cursor.hs new file mode 100644 index 0000000..45a3087 --- /dev/null +++ b/XMonad/Util/Cursor.hs @@ -0,0 +1,42 @@ +---------------------------------------------------------------------------- +-- | +-- Module : XMonad.Util.Cursor +-- Copyright : (c) 2009 Collabora Ltd +-- License : BSD-style (see xmonad/LICENSE) +-- +-- Maintainer : Andres Salomon +-- 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 -- cgit v1.2.3