How could I get any widgets position?

As Tim Janik pointed out, there are different cases, and each case requires a different solution.

Your choice of Window Manager will have an effect of the results of the above functions. You should keep this in mind when writing your application. This is dependant upon how the Window Managers manage the decorations that they add around windows.