Like attached my photo, I want to get "Windowed Window's Screen coordinate of each Corner in X-window". (I draw red dots, which I want to get as Screen coordinates, in the following image. What I am going to do later is to get exact middle point of my OpenGL window in 2D screen coordinate.

I tried following code already:
int* getWindowPos(Display *dpy) { int winPos[2];
Window myWin; myWin = XRootWindow(dpy, 0); XWindowAttributes xwa; XGetWindowAttributes(dpy, myWin, &xwa); // printf("%d %d\n", xwa.x, xwa.y); return winPos; }
but this "XWindowAttributes" always gives me 0 in x point ,0 in y point, and width 1600 and height 900, which is same as my screen resolution.
following is what I coded to create this windowed window.
GLWin.win = XCreateWindow(GLWin.dpy, RootWindow(GLWin.dpy, vi->screen), 0, 0, 800, 600, 0, vi->depth, InputOutput, vi->visual, CWBorderPixel | CWColormap | CWEventMask, &GLWin.attr);