Fix build without X11
Restructure the conditions to avoid a syntax error when HAVE_X11 is false
See https://build.kde.org/job/Frameworks/job/knotifications/job/kf5-qt5%20AndroidQt5.15/112/ and https://build.kde.org/job/Frameworks/job/knotifications/job/kf5-qt5%20WindowsMSVCQt5.15/