Tk_SetClass(3tk)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– Tk_SetClass, Tk_Class β€” setting or grabbing a window's class πŸ’–

okay bestie, this is from the Tk Library Procedures girlies, and it's literally about giving your window a class (yes, like a vibe, but for window managers) πŸ’…


✨ SYNOPSIS ✨

#include <tk.h>

Tk_SetClass(tkwin, class)

Tk_Uid
Tk_Class(tkwin)

πŸŽ€ ARGUMENTS πŸŽ€

  • Tk_Window tkwin (in) β€” the token for the window, aka its lil ID badge πŸͺͺ
  • char *class (in) β€” the new class name you're assigning to the window, slay ✨

πŸ¦‹ DESCRIPTION πŸ¦‹

So <pink>Tk_SetClass</pink> is what you call to associate a class with one specific window. The class string is basically telling everyone what kind of window this is β€” the type of the window, fr fr. Every window that shares the same general class of behavior (button, menu, etc.) should have the same class, no cap. πŸ‘‘

By convention, all class names start with a capital letter β€” and there's a Tcl command with the exact same name as each class (except all in lower-case) that you can use to create and manipulate windows of that class. iykyk. 🌈

Not me forgetting this: a window's class string is initialized to NULL when the window is created. So if you want a class, you gotta set it yourself, bestie. 😭

For main windows, Tk automatically propagates the name and class over to the WM_CLASS property that window managers use. The way that works: this happens either when a main window is actually created (e.g. in Tk_MakeWindowExist), or when Tk_SetClass is called β€” whichever occurs later. ⏰

And if a main window has not been assigned a class? Then Tk will not set the WM_CLASS property for that window. Periodt. πŸ™ˆ

Now, <purple>Tk_Class</purple> is a macro that returns the current value of tkwin's class. It comes back as a Tk_Uid, which you can use just like a string pointer, but it also has the properties of a unique identifier (peep the manual entry for Tk_GetUid for the details, bestie 🫢).

If tkwin has not yet been given a class, then Tk_Class will return NULL. iconic behavior honestly πŸ’€


⭐ KEYWORDS ⭐

class, unique identifier, window, window manager


and that's the whole page, babe πŸ§šπŸ’œ this gem comes to you from Tk, dated with the Tk_SetClass(3tk) footer energy β€” go forth and class-ify ur windows, you main character πŸŒΈπŸ’–

πŸ“¦ where this page comes from