XMCLIPBOARDREGISTERFORMAT(3)

πŸ“¦
version 2.5.2 Β· 2 versions
, in alpine 3.24, arch rolling, centos-stream 9, epel 10, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0

πŸ’– XmClipboardRegisterFormat πŸ’–

okay so bestie, welcome to XmClipboardRegisterFormat β€” a lil library call from the Xm clipboard universe that registers a brand new format. yes, the manual name is literally "library call," she's a C function, she lives in a header, and she's here to make sure your clipboard data doesn't get its bytes scrambled the second it hops platforms. iconic behavior honestly.


✨ NAME ✨

XmClipboardRegisterFormat β€” a clipboard function that registers a new format πŸŽ€


🌸 SYNOPSIS 🌸

#include <Xm/CutPaste.h>
int XmClipboardRegisterFormat (display, format_name, format_length)
        Display * display;
        char    * format_name;
        int     format_length;
(void)

πŸ¦‹ DESCRIPTION πŸ¦‹

so XmClipboardRegisterFormat registers a new format. periodt. πŸ’…

every single format stored on the clipboard should have a length attached to it, and that length must be known to the clipboard routines. like, no length, no service. and here's the fun lore: formats are known as targets in the Inter-Client Communication Conventions Manual, aka the ICCCM (iykyk). 🌈

now the tea: all of the formats specified by version 1.1 of the ICCCM conventions are preregistered. already done, no notes, they came ready. but any other format your app wants to use has to either be:

  • 8-bit data, or
  • registered via this routine (hi, that's what we're doing here πŸ‘‹)
bestie listen 😭 if you fail to register the length of the data, the result is incompatible applications across platforms having different byte-swapping orders. that's not a vibe. that's a disaster. register the length.

and here are the args, mwah:

  • display β€” a pointer to the Display structure that was returned in a previous call to XOpenDisplay or XtDisplay. she's already been introduced, don't be weird about it.
  • format_name β€” the string name for the new format (the target). yes, a string, a whole name, slay.
  • format_length β€” the format length in bits, and it's gotta be 8, 16, or 32. those are the only options, don't try to be different 🫢

πŸ‘‘ RETURN πŸ‘‘

the function hands you back one of these, and each one has a whole personality:

  • XmClipboardBadFormat β€” format_name must not be NULL, and format_length must be 8, 16, or 32. that's the rule, that's the boundary, respect it. πŸ’€
  • XmClipboardSuccess β€” the function was successful. we ate. πŸ”₯
  • XmClipboardLocked β€” the function failed because the clipboard was locked by another application. okay so the move here is: you can keep calling the function again with the same parameters until the lock goes away. this is actually a gift, because it gives the application the opportunity to ask the user whether they wanna keep trying or just give up on the operation. user choice, main character energy. ✨
  • XmClipboardFail β€” the function failed because the specified format was already registered with a different length from the one specified now. and oop β€” but if a specified format was already registered with the same length as the one specified now, then XmClipboardSuccess is returned instead. consistency wins. 🌟


okay that's the whole page, you're so welcome, go register those formats responsibly 🧚

XmClipboardRegisterFormat(library call) β€” that's the footer bestie, that's the whole signature of this page, and it's giving library call realness, no cap. bye mwah πŸ’–πŸŒΈπŸŽ€