Tk_MoveToplevelWindow(3tk)

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

πŸ’– NAME πŸ’–

Tk_MoveToplevelWindow β€” ok so bestie, this one adjusts the position of a top-level window. That's the whole vibe. It's in the Tk Library Procedures squad, and yes it is exactly as niche and exactly as useful as it sounds. πŸ’…


✨ SYNOPSIS ✨

#include <tk.h>

Tk_MoveToplevelWindow(tkwin, x, y)

πŸŽ€ ARGUMENTS πŸŽ€

  • Tk_Window tkwin (in) β€” the token for the top-level window you wanna move. Your little window passport, if you will. πŸ›‚
  • int x (in) β€” the new x-coordinate for the top-left pixel of tkwin's border, or the top-left pixel of the decorative border that the window manager supplies for tkwin, if there is one. (If there's a WM doing its little decoration thing, that's the corner we're talking about. πŸ’…)
  • int y (in) β€” the new y-coordinate, same deal: top-left pixel of tkwin's border, or the top-left pixel of the decorative border the window manager supplies for tkwin if there is one.

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so here's the tea, and it's lowkey important: in general, a window should never set its own position. That job belongs to the geometry manager that's responsible for the window, periodt. Not the window's business. Stay in your lane, window. 🚫

For top-level windows, the window manager is effectively the geometry manager β€” that's just the arrangement. And Tk runs interface code between your application and the window manager so your app's hopes and dreams actually get conveyed to the geometry manager like a little messenger pigeon. πŸ•ŠοΈ

Want a specific size for your top-level window? That's the usual Tk_GeometryRequest mechanism, classic, iconic, no notes.

Want a specific position? That's where Tk_MoveToplevelWindow comes in β€” your application can use it to request a particular position for a top-level window. It's basically the same function as the wm geometry Tcl command, except that negative offsets cannot be specified. That's the one difference, so don't come for me when the negatives don't work. 😭

Widgets like menus use it when they want to pop up at a particular place on the screen. Very main character of them.

And here's the part where it gets sneaky: when you call Tk_MoveToplevelWindow, it does not immediately hand the new desired location over to the window manager. It defers that whole action until all other outstanding work has been completed, using the Tcl_DoWhenIdle mechanism. So it's giving "I'll get to it, I promise, once I'm done with literally everything else." 🫢

ngl, the deferral is the whole personality of this procedure. Don't expect the move to be instant β€” expect it to be eventually, properly, once the coast is clear.

πŸ‘‘ KEYWORDS πŸ‘‘

position, top-level window, window manager 🌈


And that's the page, bestie! This one's straight out of the Tk library docs β€” page Tk_MoveToplevelWindow(3tk), no date stamp in sight, just timeless energy. Go forth and defer your geometry requests like a queen. πŸŽ€βœ¨πŸ’œ

πŸ“¦ where this page comes from