diff --git a/src/compositor/wayland_wrapper/wlsurface.cpp b/src/compositor/wayland_wrapper/wlsurface.cpp
index 223a350c42027f135d77ebabff77947d99b676ff..92acac0c2c7cb57f035e41f26e5f04622d2fc3b0 100644
--- a/src/compositor/wayland_wrapper/wlsurface.cpp
+++ b/src/compositor/wayland_wrapper/wlsurface.cpp
@@ -428,11 +428,10 @@ WaylandSurface::Type Surface::type() const
 
 bool Surface::isYInverted() const
 {
+    bool ret = false;
 #ifdef QT_COMPOSITOR_WAYLAND_GL
     Q_D(const Surface);
 
-    bool ret = false;
-
     static bool negateReturn = qgetenv("QT_COMPOSITOR_NEGATE_INVERTED_Y").toInt();
 
     if (!d->surfaceBuffer) {
@@ -443,7 +442,7 @@ bool Surface::isYInverted() const
 #endif
         ret = true;
 
-    return ret^negateReturn;
+    return ret != negateReturn;
 }
 
 bool Surface::visible() const