Fix: Window centering in XFCE does not work properly

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:

xfce windows placement optionsThat is everything you need to do.

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:

xfce windows centering does not workThis 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:

/home/hb860/.themes/BlueMenta/xfwm4/themerc

Comment out the "placement_ratio" line as shown below:

xfce themercRe-apply your theme in Settings -> Window Manager -> Style. Now window placement will work properly and new windows will be opened at the center of the screen.

xfce windows placement worksThat'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.

3 thoughts on “Fix: Window centering in XFCE does not work properly

  1. André Miranda

    Many thanks, it really solved my problem with Adwaita-X-dark and spared me from a couple of hours trying to figure this out ;)

    Reply
    1. Sergey Tkachenko Post author

      You are welcome. I spent a bunch of time on this issue, so I should share this tip.

      Reply
  2. Sage

    Thanks so much for taking the time to post this – I really like Mint and was so happy to find a solution to the windows centering problem.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *