X11::CursorFont(3pm)

πŸ“¦
version 31 Β· 7 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– NAME πŸ’–

X11::CursorFont β€” cursor font glyph names and numbers, bestie ✨

(Yeah, this is the X11::CursorFont(3pm) page, straight out of the User Contributed Perl Documentation section. Sit with me, it's cute.)


πŸ¦‹ SYNOPSIS πŸ¦‹

use X11::CursorFont '%CURSOR_GLYPH';
my $num = $CURSOR_GLYPH{'fleur'};               # is 52
my $name = $X11::CursorFont::CURSOR_NAME[52];   # is "fleur"

🌸 DESCRIPTION 🌸

Okay so. This module is literally just the names and numbers of the glyphs living inside the X11 cursor font, which is the font that holds all your standard mouse pointer cursors. That's it. That's the whole vibe. And honestly? Iconic. πŸ–±οΈ

%CURSOR_GLYPH maps a glyph name to its character number in the font,

$CURSOR_GLYPH{'fleur'}     # is 52

@CURSOR_NAME is the other way round β€” you index it by character number and it hands you back the glyph name,

$CURSOR_NAME[52]           # is "fleur"

Here's the tea though πŸ«–: every glyph has a mask sitting at character number glyph+1, and that mask is the actual shape of the cursor (aka which pixels show up vs which ones are transparent). So the character numbers are always even, and in @CURSOR_NAME only the even character positions even have names. The odd ones are just vibes. πŸ’€

Wanna see the cursor images with your own eyes? Use the usual xfd font display program:

xfd -fn cursor

The names follow the Xlib /usr/include/X11/cursorfont.h file, except with the XC_ prefixes stripped off. The full list, no skips, no cuts:

  • X_cursor β€” 0 β€” default fat X
  • arrow β€” 2
  • based_arrow_down β€” 4
  • based_arrow_up β€” 6
  • boat β€” 8
  • bogosity β€” 10
  • bottom_left_corner β€” 12
  • bottom_right_corner β€” 14
  • bottom_side β€” 16
  • bottom_tee β€” 18
  • box_spiral β€” 20 β€” a square spiral
  • center_ptr β€” 22
  • circle β€” 24
  • clock β€” 26
  • coffee_mug β€” 28
  • cross β€” 30
  • cross_reverse β€” 32
  • crosshair β€” 34 β€” "+" shape
  • diamond_cross β€” 36
  • dot β€” 38
  • dotbox β€” 40
  • double_arrow β€” 42
  • draft_large β€” 44
  • draft_small β€” 46
  • draped_box β€” 48
  • exchange β€” 50
  • fleur β€” 52
  • gobbler β€” 54
  • gumby β€” 56
  • hand1 β€” 58
  • hand2 β€” 60
  • heart β€” 62
  • icon β€” 64
  • iron_cross β€” 66
  • left_ptr β€” 68
  • left_side β€” 70
  • left_tee β€” 72
  • leftbutton β€” 74
  • ll_angle β€” 76
  • lr_angle β€” 78
  • man β€” 80
  • middlebutton β€” 82
  • mouse β€” 84
  • pencil β€” 86
  • pirate β€” 88 β€” skull and crossbones
  • plus β€” 90
  • question_arrow β€” 92
  • right_ptr β€” 94
  • right_side β€” 96
  • right_tee β€” 98
  • rightbutton β€” 100
  • rtl_logo β€” 102
  • sailboat β€” 104
  • sb_down_arrow β€” 106
  • sb_h_double_arrow β€” 108
  • sb_left_arrow β€” 110
  • sb_right_arrow β€” 112
  • sb_up_arrow β€” 114
  • sb_v_double_arrow β€” 116
  • shuttle β€” 118
  • sizing β€” 120
  • spider β€” 122
  • spraycan β€” 124
  • star β€” 126
  • target β€” 128
  • tcross β€” 130
  • top_left_arrow β€” 132
  • top_left_corner β€” 134
  • top_right_corner β€” 136
  • top_side β€” 138
  • top_tee β€” 140
  • trek β€” 142
  • ul_angle β€” 144
  • umbrella β€” 146
  • ur_angle β€” 148
  • watch β€” 150 β€” a good "busy" indicator
  • xterm β€” 152 β€” a vertical insertion bar

"X_cursor" is the usual default when the server first starts up, or when the root window gets set to cursor "None". So when you see that fat little X, that's her. πŸ‘‘


πŸŽ€ VARIABLES πŸŽ€

  • %X11::CursorFont::CURSOR_GLYPH β€” a mapping of glyph name β†’ cursor font character number.
  • @X11::CursorFont::CURSOR_NAME β€” a table of cursor font character number β†’ glyph name.

✨ EXPORTS ✨

Nothing gets exported by default, bestie, nothing. But %CURSOR_GLYPH and @CURSOR_NAME can absolutely be selected in the usual Exporter style (go peek at Exporter if you need the lore),

use X11::CursorFont '%CURSOR_GLYPH', '@CURSOR_NAME';

πŸ”₯ EXAMPLE πŸ”₯

So say you wanna create a cursor from a glyph you want. Like this:

my $cursor_name = 'spraycan';
my $cursor_glyph = $CURSOR_GLYPH{$cursor_name}; # number

my $cursor_font = $X->new_rsrc;
$X->OpenFont ($cursor_font, "cursor"); # cursor font

my $cursor = $X->new_rsrc;
$X->CreateGlyphCursor
       ($cursor,
        $cursor_font,  # font
        $cursor_font,  # mask font
        $cursor_glyph,      # glyph
        $cursor_glyph + 1,  # and its mask
        0,0,0,                  # foreground, black
        0xFFFF,0xFFFF,0xFFFF);  # background, white

$X->CloseFont ($cursor_font);

# then use $cursor with CreateWindow or ChangeWindowAttributes
#       cursor => $cursor

That $cursor_font could just be kept open if you're gonna use it over and over. Opening and closing isn't a round-trip, so opening it when you actually need it may be enough. Slay, efficiency. πŸ’…

You can hand CreateGlyphCursor() any RGB colours you want, but heads up β€” how it actually looks on screen is limited by the hardware. The hardware has opinions. πŸ™ˆ

Also: all cursors in the core protocol are two-colours, with pixels either fully opaque or fully transparent, exactly as created here. If you want multi-colour and partial transparency, the RENDER extension can do that when it's available (see X11::Protocol::Ext::RENDER).


πŸ’œ SEE ALSO πŸ’œ

  • X11::Protocol, X11::KeySyms
  • /usr/include/X11/cursorfont.h and the listing in the Xlib manual appendix B (http://www.x.org/docs/X11/ or /usr/share/doc/libx11-dev/libX11.txt.gz).
  • Xlib Xmu XmuCursorNameToIndex() (http://www.x.org/docs/Xmu/ or /usr/share/doc/libxmu-headers/Xmu.txt.gz)
  • xfd(1) to display the cursor font.
  • xsetroot(1) to change the root window cursor.

🌈 HOME PAGE 🌈

<http://user42.tuxfamily.org/x11-protocol-other/index.html>


πŸ‘‘ LICENSE πŸ‘‘

Copyright 2011, 2012, 2013, 2014, 2017 Kevin Ryde

X11-Protocol-Other is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

X11-Protocol-Other is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with X11-Protocol-Other. If not, see <http://www.gnu.org/licenses/>.


okay that's the whole page, we did it 🫢 go point at stuff

perl v5.28.1 Β· 2019-08-26 β€” that's the version and date this lil page was born, and that's the last word, periodt πŸ’–βœ¨

πŸ“¦ where this page comes from