To get the current absolute position of the mouse pointer, use winfo pointerxy $w
(the $w
is used to work out which “display” you're talking about in an X11 sense, and is pretty irrelevant these days; you can actually use any window there, but it is a required argument anyway).
To move a (toplevel) window to the pointer, you set its geometry. Combining the two, you get this:
proc movewintoptr w {
lassign [winfo pointerxy $w] x y
wm geometry $w +$x+$y
}
You might want to consider offsetting the window a bit. (Exactly how best to do that depends on what you are showing in the window; the code gets very application specific.)
To make a toplevel window that has no decorations, do:
toplevel $w
wm overrideredirect $w 1
Be aware that undecorated windows can't be easily manipulated by the user by default. You have to implement all that part yourself (if it is relevant).
And yes, the wm overrideredirect
call should be very soon after the toplevel is created; windows can't usually be swapped between display modes once they're displaying on the screen (and that depends on how window managers work, etc).