[PATCH 1/2] XMonadContrib: add a utility module to set the default cursor
Based upon comments on the list and IRC, here's an updated set of patches. I went with "xc_" as the cursor name prefix as opposed to haskell-x11's "xC_"/"xK_" convention so that if haskell-x11 starts exporting the symbols, we won't have any namespace issues. From c7723b6cfc9dc8b1225ca2f184e282d502925af2 Mon Sep 17 00:00:00 2001 From: Andres Salomon <dilinger@collabora.co.uk> Date: Tue, 15 Sep 2009 00:16:21 -0400 Subject: [PATCH 1/2] XMonadContrib: add a utility module to set the default cursor 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. Signed-off-by: Andres Salomon <dilinger@collabora.co.uk> --- XMonad/Doc/Extending.hs | 2 + XMonad/Util/Cursor.hsc | 354 +++++++++++++++++++++++++++++++++++++++++++++++ xmonad-contrib.cabal | 1 + 3 files changed, 357 insertions(+), 0 deletions(-) create mode 100644 XMonad/Util/Cursor.hsc diff --git a/XMonad/Doc/Extending.hs b/XMonad/Doc/Extending.hs index 39e11a2..1c07b56 100644 --- a/XMonad/Doc/Extending.hs +++ b/XMonad/Doc/Extending.hs @@ -448,6 +448,8 @@ external utilities. A non complete list with a brief description: +* "XMonad.Util.Cursor": configure the default cursor/pointer glyph. + * "XMonad.Util.CustomKeys": configure key bindings (see "XMonad.Doc.Extending#Editing_key_bindings"). diff --git a/XMonad/Util/Cursor.hsc b/XMonad/Util/Cursor.hsc new file mode 100644 index 0000000..10e3d31 --- /dev/null +++ b/XMonad/Util/Cursor.hsc @@ -0,0 +1,354 @@ +---------------------------------------------------------------------------- +-- | +-- 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 + setDefaultCursor, + xc_X_cursor, + xc_arrow, + xc_based_arrow_down, + xc_based_arrow_up, + xc_boat, + xc_bogosity, + xc_bottom_left_corner, + xc_bottom_right_corner, + xc_bottom_side, + xc_bottom_tee, + xc_box_spiral, + xc_center_ptr, + xc_circle, + xc_clock, + xc_coffee_mug, + xc_cross, + xc_cross_reverse, + xc_crosshair, + xc_diamond_cross, + xc_dot, + xc_dotbox, + xc_double_arrow, + xc_draft_large, + xc_draft_small, + xc_draped_box, + xc_exchange, + xc_fleur, + xc_gobbler, + xc_gumby, + xc_hand1, + xc_hand2, + xc_heart, + xc_icon, + xc_iron_cross, + xc_left_ptr, + xc_left_side, + xc_left_tee, + xc_leftbutton, + xc_ll_angle, + xc_lr_angle, + xc_man, + xc_middlebutton, + xc_mouse, + xc_pencil, + xc_pirate, + xc_plus, + xc_question_arrow, + xc_right_ptr, + xc_right_side, + xc_right_tee, + xc_rightbutton, + xc_rtl_logo, + xc_sailboat, + xc_sb_down_arrow, + xc_sb_h_double_arrow, + xc_sb_left_arrow, + xc_sb_right_arrow, + xc_sb_up_arrow, + xc_sb_v_double_arrow, + xc_shuttle, + xc_sizing, + xc_spider, + xc_spraycan, + xc_star, + xc_target, + xc_tcross, + xc_top_left_arrow, + xc_top_left_corner, + xc_top_right_corner, + xc_top_side, + xc_top_tee, + xc_trek, + xc_ul_angle, + xc_umbrella, + xc_ur_angle, + xc_watch, + xc_xterm + ) where + +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! + + +-- | Import the cursor font names from cursorfont.h + +#include <X11/cursorfont.h> + +xc_X_cursor :: Glyph +xc_X_cursor = #const XC_X_cursor + +xc_arrow :: Glyph +xc_arrow = #const XC_arrow + +xc_based_arrow_down :: Glyph +xc_based_arrow_down = #const XC_based_arrow_down + +xc_based_arrow_up :: Glyph +xc_based_arrow_up = #const XC_based_arrow_up + +xc_boat :: Glyph +xc_boat = #const XC_boat + +xc_bogosity :: Glyph +xc_bogosity = #const XC_bogosity + +xc_bottom_left_corner :: Glyph +xc_bottom_left_corner = #const XC_bottom_left_corner + +xc_bottom_right_corner :: Glyph +xc_bottom_right_corner = #const XC_bottom_right_corner + +xc_bottom_side :: Glyph +xc_bottom_side = #const XC_bottom_side + +xc_bottom_tee :: Glyph +xc_bottom_tee = #const XC_bottom_tee + +xc_box_spiral :: Glyph +xc_box_spiral = #const XC_box_spiral + +xc_center_ptr :: Glyph +xc_center_ptr = #const XC_center_ptr + +xc_circle :: Glyph +xc_circle = #const XC_circle + +xc_clock :: Glyph +xc_clock = #const XC_clock + +xc_coffee_mug :: Glyph +xc_coffee_mug = #const XC_coffee_mug + +xc_cross :: Glyph +xc_cross = #const XC_cross + +xc_cross_reverse :: Glyph +xc_cross_reverse = #const XC_cross_reverse + +xc_crosshair :: Glyph +xc_crosshair = #const XC_crosshair + +xc_diamond_cross :: Glyph +xc_diamond_cross = #const XC_diamond_cross + +xc_dot :: Glyph +xc_dot = #const XC_dot + +xc_dotbox :: Glyph +xc_dotbox = #const XC_dotbox + +xc_double_arrow :: Glyph +xc_double_arrow = #const XC_double_arrow + +xc_draft_large :: Glyph +xc_draft_large = #const XC_draft_large + +xc_draft_small :: Glyph +xc_draft_small = #const XC_draft_small + +xc_draped_box :: Glyph +xc_draped_box = #const XC_draped_box + +xc_exchange :: Glyph +xc_exchange = #const XC_exchange + +xc_fleur :: Glyph +xc_fleur = #const XC_fleur + +xc_gobbler :: Glyph +xc_gobbler = #const XC_gobbler + +xc_gumby :: Glyph +xc_gumby = #const XC_gumby + +xc_hand1 :: Glyph +xc_hand1 = #const XC_hand1 + +xc_hand2 :: Glyph +xc_hand2 = #const XC_hand2 + +xc_heart :: Glyph +xc_heart = #const XC_heart + +xc_icon :: Glyph +xc_icon = #const XC_icon + +xc_iron_cross :: Glyph +xc_iron_cross = #const XC_iron_cross + +xc_left_ptr :: Glyph +xc_left_ptr = #const XC_left_ptr + +xc_left_side :: Glyph +xc_left_side = #const XC_left_side + +xc_left_tee :: Glyph +xc_left_tee = #const XC_left_tee + +xc_leftbutton :: Glyph +xc_leftbutton = #const XC_leftbutton + +xc_ll_angle :: Glyph +xc_ll_angle = #const XC_ll_angle + +xc_lr_angle :: Glyph +xc_lr_angle = #const XC_lr_angle + +xc_man :: Glyph +xc_man = #const XC_man + +xc_middlebutton :: Glyph +xc_middlebutton = #const XC_middlebutton + +xc_mouse :: Glyph +xc_mouse = #const XC_mouse + +xc_pencil :: Glyph +xc_pencil = #const XC_pencil + +xc_pirate :: Glyph +xc_pirate = #const XC_pirate + +xc_plus :: Glyph +xc_plus = #const XC_plus + +xc_question_arrow :: Glyph +xc_question_arrow = #const XC_question_arrow + +xc_right_ptr :: Glyph +xc_right_ptr = #const XC_right_ptr + +xc_right_side :: Glyph +xc_right_side = #const XC_right_side + +xc_right_tee :: Glyph +xc_right_tee = #const XC_right_tee + +xc_rightbutton :: Glyph +xc_rightbutton = #const XC_rightbutton + +xc_rtl_logo :: Glyph +xc_rtl_logo = #const XC_rtl_logo + +xc_sailboat :: Glyph +xc_sailboat = #const XC_sailboat + +xc_sb_down_arrow :: Glyph +xc_sb_down_arrow = #const XC_sb_down_arrow + +xc_sb_h_double_arrow :: Glyph +xc_sb_h_double_arrow = #const XC_sb_h_double_arrow + +xc_sb_left_arrow :: Glyph +xc_sb_left_arrow = #const XC_sb_left_arrow + +xc_sb_right_arrow :: Glyph +xc_sb_right_arrow = #const XC_sb_right_arrow + +xc_sb_up_arrow :: Glyph +xc_sb_up_arrow = #const XC_sb_up_arrow + +xc_sb_v_double_arrow :: Glyph +xc_sb_v_double_arrow = #const XC_sb_v_double_arrow + +xc_shuttle :: Glyph +xc_shuttle = #const XC_shuttle + +xc_sizing :: Glyph +xc_sizing = #const XC_sizing + +xc_spider :: Glyph +xc_spider = #const XC_spider + +xc_spraycan :: Glyph +xc_spraycan = #const XC_spraycan + +xc_star :: Glyph +xc_star = #const XC_star + +xc_target :: Glyph +xc_target = #const XC_target + +xc_tcross :: Glyph +xc_tcross = #const XC_tcross + +xc_top_left_arrow :: Glyph +xc_top_left_arrow = #const XC_top_left_arrow + +xc_top_left_corner :: Glyph +xc_top_left_corner = #const XC_top_left_corner + +xc_top_right_corner :: Glyph +xc_top_right_corner = #const XC_top_right_corner + +xc_top_side :: Glyph +xc_top_side = #const XC_top_side + +xc_top_tee :: Glyph +xc_top_tee = #const XC_top_tee + +xc_trek :: Glyph +xc_trek = #const XC_trek + +xc_ul_angle :: Glyph +xc_ul_angle = #const XC_ul_angle + +xc_umbrella :: Glyph +xc_umbrella = #const XC_umbrella + +xc_ur_angle :: Glyph +xc_ur_angle = #const XC_ur_angle + +xc_watch :: Glyph +xc_watch = #const XC_watch + +xc_xterm :: Glyph +xc_xterm = #const XC_xterm + + +-- | 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 diff --git a/xmonad-contrib.cabal b/xmonad-contrib.cabal index 0d056a0..4b2a850 100644 --- a/xmonad-contrib.cabal +++ b/xmonad-contrib.cabal @@ -209,6 +209,7 @@ library XMonad.Prompt.Window XMonad.Prompt.Workspace XMonad.Prompt.XMonad + XMonad.Util.Cursor XMonad.Util.CustomKeys XMonad.Util.Dmenu XMonad.Util.Dzen -- 1.6.3.3
On Tue, Sep 15, 2009 at 02:22:38AM -0400, Andres Salomon wrote:
Based upon comments on the list and IRC, here's an updated set of patches. I went with "xc_" as the cursor name prefix as opposed to haskell-x11's "xC_"/"xK_" convention so that if haskell-x11 starts exporting the symbols, we won't have any namespace issues.
This ought to be a patch for the X11 library, perhaps a new module under Graphics.X11.ExtraTypes? The maintainers and hackers of X11 all work on xmonad, so we can make sure that a new release of X11 is made in order for us to use the new cursor fonts. Also, can you send your patches in darcs patch form? Quick quide: $ darcs get http://code.haskell.org/XMonadContrib # grab the repo $ vi foo # make your edits $ darcs record # interactively make a patch out of your changes $ darcs send -o mypatch.dpatch # make a file you can email Cheers, Spencer Janssen
spencerjanssen:
On Tue, Sep 15, 2009 at 02:22:38AM -0400, Andres Salomon wrote:
Based upon comments on the list and IRC, here's an updated set of patches. I went with "xc_" as the cursor name prefix as opposed to haskell-x11's "xC_"/"xK_" convention so that if haskell-x11 starts exporting the symbols, we won't have any namespace issues.
This ought to be a patch for the X11 library, perhaps a new module under Graphics.X11.ExtraTypes? The maintainers and hackers of X11 all work on xmonad, so we can make sure that a new release of X11 is made in order for us to use the new cursor fonts.
Also, can you send your patches in darcs patch form?
Quick quide:
$ darcs get http://code.haskell.org/XMonadContrib # grab the repo $ vi foo # make your edits $ darcs record # interactively make a patch out of your changes $ darcs send -o mypatch.dpatch # make a file you can email
I'm happy to apply patches to X11 for basic functionality like this.
participants (3)
-
Andres Salomon -
Don Stewart -
Spencer Janssen