($x, $y, $push_in) = &$menu_pos_func ($menu, $x, $y, $data)
$x,$y inputs are a proposed position based on the mouse pointer (not actually documented in the Gtk manuals). The return should be a desired $x,$y, and an optional $push_in flag. If $push_in is true then Gtk will adjust $x,$y if necessary so the menu is fully visible in the screen width and height.
$menu_pos_func and $data are stored in $menu and may be called again later for a $menu->reposition or some obscure things like a changed set_screen while torn-off. A further $menu->popup call replaces $menu_pos_func and $data.
If $menu is later detached from the widget with $menu->detach then the $detach_func is called as
&$detach_func ($attach_widget, $menu)