Tk_MoveToplevelWindow(3tk)
π 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 oftkwin's border, or the top-left pixel of the decorative border that the window manager supplies fortkwin, 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 oftkwin's border, or the top-left pixel of the decorative border the window manager supplies fortkwinif 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
- debian trixie: tk9.0-doc 9.0.1-3
- ubuntu questing: tk9.0-doc 9.0.2-1
- ubuntu resolute: tk9.0-doc 9.0.3-1
- ubuntu stonking: tk9.0-doc 9.0.4-1
- Copyright (c) 1990-1993 The Regents of the University of California
- Copyright (c) 1994-1996 Sun Microsystems, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms