X11::P...:Other(3pm)

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

πŸ’– X11::Protocol::Other β€” the manual, but make it make sense ✨

okay bestie, you found the X11::Protocol::Other(3pm) page β€” it's a User Contributed Perl Documentation joint, and it's literally just a lil grab-bag of helpers for X11::Protocol. Not a whole framework, not a lifestyle, just some functions that do stuff you'd otherwise hand-roll. Let's get into it 🫢


✨ NAME ✨

X11::Protocol::Other β€” miscellaneous X11::Protocol helpers. That's it, that's the whole vibe. πŸ’…


🌸 SYNOPSIS 🌸

use X11::Protocol::Other;

yeah. that's the synopsis. iconic minimalism, honestly. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

This is some helper functions for X11::Protocol. Short king description. We move.


πŸŽ€ EXPORTS πŸŽ€

Okay so β€” nothing is exported by default, no cap. But you can ask for the functions in the usual Exporter style:

use X11::Protocol::Other 'visual_is_dynamic';
if (visual_is_dynamic ($X, $visual_id)) {
  ...
}

Or you can just call them with the full package name, which is giving "I don't trust import lists" energy:

use X11::Protocol::Other;
if (X11::Protocol::Other::visual_is_dynamic ($X, $visual_id)) {
  ...
}

And here's the tea: there's no ":all" tag. Why? Because this module is meant as a grab-bag of functions, and importing as-yet unknown things would be asking for name clashes. She's protecting you from future-you. πŸ›‘οΈβœ¨


πŸ”₯ FUNCTIONS πŸ”₯

πŸ’œ Screen Finding

  • $number = root_to_screen ($X, $root)
  • $hashref = root_to_screen_info ($X, $root)

Return the screen number or screen info hash for a given root window. $root can be any XID integer on $X. And if it's not one of the root windows? The return is undef. No drama, just undef. πŸ’€

  • $number = default_colormap_to_screen ($X, $colormap)
  • $hashref = default_colormap_to_screen_info ($X, $colormap)

Return the screen number or screen info hash for a given default colormap. $colormap can be any XID integer on $X. If it's not one of the screen default colormaps, the return is undef. Same energy, different lookup. 🌈


🧚 Visuals

  • $bool = visual_is_dynamic ($X, $visual_id)
  • $bool = visual_class_is_dynamic ($X, $visual_class)

Return true if the given visual is dynamic β€” meaning colormap entries on it can be changed to change the colour of a given pixel value. Yes, dynamic like that. πŸ”₯

$visual_id is one of the visual ID numbers, ie. one of the keys in $X->{'visuals'}. Or $visual_class is a VisualClass string like PseudoColor or corresponding integer such as 3.


πŸ“ Window Info

  • ($width, $height) = window_size ($X, $window)
  • $visual_id = window_visual ($X, $window)

Return the size or visual ID of a given window.

$window is an integer XID on $X. If it's one of the root windows then the return values are from the screen info hash in $X, otherwise the server is queried with GetGeometry() (for the size) or GetWindowAttributes() (for the visual).

These functions are handy when there's a good chance $window might be a root window and therefore not need a server round trip. Saving round trips = self care, fr fr. 🫢

  • @atoms = get_property_atoms($X, $window, $property)

Get from $window (integer XID) a list-of-atoms property $property (atom integer). The return is a list of atom integers, possibly an empty list. If $property doesn't exist or is not atoms then return an empty list. Empty list, not a crisis. πŸ’…

  • set_property_atoms($X, $window, $property, @atoms)

Set on $window (integer XID) a list-of-atoms property $property (atom integer) as the given list of @atoms (possibly empty).


🌸 Colour Parsing

  • ($red16, $green16, $blue16) = hexstr_to_rgb($str)

Parse a given RGB colour string like "#FF00FF" into 16-bit red, green, blue components. The return values are always in the range 0 to 65535. The strings recognised are 1, 2, 3 or 4 digit hex:

#RGB
#RRGGBB
#RRRGGGBBB
#RRRRGGGGBBBB

If $str is unrecognised then the return is an empty list, so for instance:

my @rgb = hexstr_to_rgb($str)
  or die "Unrecognised colour: $str";

The digits of the 1, 2 and 3 forms are replicated as necessary to give a 16-bit range. For example 3-digit style "#321FFF000" gives return values 0x3213, 0xFFFF, 0. Or 1-digit "#F0F" is 0xFFFF, 0, 0xFFFF. Notice "F" expands to 0xFFFF so an "F", "FF" or "FFF" all mean full saturation the same as a 4-digit "FFFF". maximum saturation every time, she ate. ✨

And then there's this lil musing, which I'm quoting the vibe of: would it be worth recognising the Xcms style "rgb:RR/GG/BB"? Perhaps that's best left to full Xcms, or general colour conversion modules. The X11R6 X(7) man page describes the "rgb:" form, but just "#" is much more common. (so: noted, not implemented. don't come for her. πŸ™ˆ)


πŸ‘‘ SEE ALSO πŸ‘‘

  • X11::Protocol, X11::Protocol::GrabServer
  • Color::Library (many named colours), Convert::Color, Graphics::Color (Moose based) for more colour parsing
  • X11::AtomConstants, X11::CursorFont

🌈 HOME PAGE 🌈

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

go visit, it's giving classic Perl module homepage and we respect the heritage. πŸŽ€


⭐ LICENSE ⭐

Copyright 2010, 2011, 2012, 2013, 2014, 2017, 2019 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.

⚠️ okay bestie, this part is not a joke β€” the no warranty thing is real and it's in all caps for a reason. Read it, mean it.

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/>.


and that's the whole page, you're welcome πŸ’– this beauty was served up by perl v5.28.1, dated 2019-08-26, under the X11::P...:Other(3pm) manual. mwah, go forth and parse colours responsibly. πŸ¦‹πŸ’…βœ¨

πŸ“¦ where this page comes from