X11::CursorFont(3pm)
π 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 Xarrowβ2based_arrow_downβ4based_arrow_upβ6boatβ8bogosityβ10bottom_left_cornerβ12bottom_right_cornerβ14bottom_sideβ16bottom_teeβ18box_spiralβ20β a square spiralcenter_ptrβ22circleβ24clockβ26coffee_mugβ28crossβ30cross_reverseβ32crosshairβ34β"+"shapediamond_crossβ36dotβ38dotboxβ40double_arrowβ42draft_largeβ44draft_smallβ46draped_boxβ48exchangeβ50fleurβ52gobblerβ54gumbyβ56hand1β58hand2β60heartβ62iconβ64iron_crossβ66left_ptrβ68left_sideβ70left_teeβ72leftbuttonβ74ll_angleβ76lr_angleβ78manβ80middlebuttonβ82mouseβ84pencilβ86pirateβ88β skull and crossbonesplusβ90question_arrowβ92right_ptrβ94right_sideβ96right_teeβ98rightbuttonβ100rtl_logoβ102sailboatβ104sb_down_arrowβ106sb_h_double_arrowβ108sb_left_arrowβ110sb_right_arrowβ112sb_up_arrowβ114sb_v_double_arrowβ116shuttleβ118sizingβ120spiderβ122spraycanβ124starβ126targetβ128tcrossβ130top_left_arrowβ132top_left_cornerβ134top_right_cornerβ136top_sideβ138top_teeβ140trekβ142ul_angleβ144umbrellaβ146ur_angleβ148watchβ150β a good"busy"indicatorxtermβ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.hand 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
- debian bookworm: libx11-protocol-other-perl 31-1 Β· GPL-3.0-or-later
- debian trixie: libx11-protocol-other-perl 31-1 Β· GPL-3.0-or-later
- ubuntu jammy: libx11-protocol-other-perl 31-1 Β· GPL-3.0-or-later
- ubuntu noble: libx11-protocol-other-perl 31-1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms