XTranslateCoordinates(3)

πŸ’… XTranslateCoordinates(3) πŸ’…

okay bestie, welcome to the XLIB FUNCTIONS corner of the manual β€” this one's about XTranslateCoordinates, and it's honestly such a vibe once you get it. ✨


🌸 NAME 🌸

XTranslateCoordinates β€” translate window coordinates πŸ¦‹

like, you've got coordinates in one window and you want them in another window's language. that's the whole gig. no cap.


✨ SYNTAX ✨

Bool XTranslateCoordinates(Display *display, Window src_w, dest_w, int
       src_x, int src_y, int *dest_x_return, int *dest_y_return, Window
       *child_return);

that's a Bool coming back, so expect True or False β€” and yes, dest_w is chillin' in the middle of the declaration list without its own Window keyword, that's just how the line is written, don't @ me. πŸ™ˆ


πŸŽ€ ARGUMENTS πŸŽ€

  • child_return β€” Returns the child if the coordinates are contained in a mapped child of the destination window. πŸ‘‘ iykyk, this is the "oh and btw, here's which child you landed in" slot.
  • dest_w β€” Specifies the destination window. 🌈 the place you're translating to, bestie.
  • dest_x_return, dest_y_return β€” Return the x and y coordinates within the destination window. πŸ’– these are output params, so pass pointers, and the answers land here.
  • display β€” Specifies the connection to the X server. 🫢 your whole link to the server, obviously.
  • src_w β€” Specifies the source window. 🌸 the place you're translating from.
  • src_x, src_y β€” Specify the x and y coordinates within the source window. ⭐ the actual numbers you're handing over.

πŸ’œ DESCRIPTION πŸ’œ

okay so here's the tea, fr fr. πŸ“

If XTranslateCoordinates returns True, it takes the src_x and src_y coordinates relative to the source window's origin and returns these coordinates to dest_x_return and dest_y_return relative to the destination window's origin. πŸ”₯ literally just moving your point from one window's frame of reference into another's. iconic behavior.

If XTranslateCoordinates returns False, src_w and dest_w are on different screens, and dest_x_return and dest_y_return are zero. πŸ’€ yeah, different screens means the math just doesn't math, so you get zeros back.

If the coordinates are contained in a mapped child of dest_w, that child is returned to child_return. πŸ‘‘ cute bonus info. Otherwise, child_return is set to None. πŸŽ€

⚠️ heads up bestie: XTranslateCoordinates can generate a BadWindow error. not me finding out the hard way 😭

πŸ¦‹ DIAGNOSTICS πŸ¦‹

  • BadWindow β€” A value for a Window argument does not name a defined Window. πŸ’… so if you passed something that isn't a real, defined window... yeah. that.

🌟 SEE ALSO 🌟

  • Xlib - C Language X Interface

mwah, that's the whole page, you ate it πŸ’…βœ¨

β€” cute little sign-off from your girl: this one's from X Version 11, libX11 1.8.14, and yes the page is dated with that same release info, so like... that's the version, bestie. πŸŽ€πŸ«Ά go forth and translate some coordinates, no cap. πŸŒˆπŸ‘‘

πŸ“¦ where this page comes from