Recently, in the Linux distro I use, I switched from the Fluxbox desktop environment to XFCE, because XFCE provides some unique and nice features for me like the ability to re-order taskbar buttons. In Fluxbox, I had set up all windows to open at the center of the screen with a hack. XFCE also comes with the ability to center new windows out of the box, however, it fails for me from time to time. Here is how to get rid of the issue so windows are centered properly.
How to center new windows in XFCE
The XFCE desktop environment comes with its own window manager called xfwm4. It has the appropriate options to place new windows at the center of the screen. To get it working, you need to go to Settings -> Windows Manager tweaks and adjust the Placement slider to the right position as shown below:
Why window centering does not work and how to fix it
After reboot, I noticed that new windows stopped opening at the center of the screen. Instead, they appeared at the top left corner of the screen:
This is caused by the theme. I switched from the default xfwm4 theme to the Linux Mint theme called "Blue Menta". The issue never happens with the default XFCE themes, but in case of Blue Menta, it was overriding the slider mentioned above with a lower value, so window placement does not work properly.
To fix it, go to the folder of the theme you are using and find the file there called "themerc". It must be in the xfwm4 subfolder. Per-user themes are located in the /home/your_user_name/.themes directory, and system-wide themes are usually located at /usr/shared/themes/.
In my case, I should edit the following file:
Comment out the "placement_ratio" line as shown below:
That's it. Initially, I thought this must be a bug in xfwm4 and even reported it, but thanks to Olivier Fourdan, the creator of XCFE, it is clear now that it is an issue with the theme.