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:XTranslateCoordinatescan generate aBadWindowerror. not me finding out the hard way π
π¦ DIAGNOSTICS π¦
BadWindowβ A value for aWindowargument does not name a definedWindow. π 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
- alpine 3.24: libx11-doc 1.8.14-r0 Β· X11
- arch rolling: libx11 1.8.14-1 Β· MIT AND X11
- nixos 26.05: libx11 1.8.14
- nixpkgs unstable: libx11 1.8.14
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms