Ver Fonte

3d room finally works, debug output removed

UwU há 2 meses atrás
pai
commit
4c514c96d7

+ 2 - 2
src/WallpaperEngine/Input/Drivers/KDECursorInput.cpp

@@ -46,7 +46,7 @@ bool KDECursorInput::initializeDBus () {
     dbus_connection_set_exit_on_disconnect (m_connection, false);
 
     dbus_error_init (&error);
-    const std::string serviceName = std::string (kServiceName) + "." + std::to_string (getpid ());
+    const std::string serviceName = std::string (kServiceName) + "_" + std::to_string (getpid ());
     const auto requestResult = dbus_bus_request_name (m_connection, serviceName.c_str (), DBUS_NAME_FLAG_DO_NOT_QUEUE, &error);
 
     if (dbus_error_is_set (&error)) {
@@ -94,7 +94,7 @@ bool KDECursorInput::loadKWinScript () {
 	return false;
     }
 
-    const std::string serviceName = std::string (kServiceName) + "." + std::to_string (getpid ());
+    const std::string serviceName = std::string (kServiceName) + "_" + std::to_string (getpid ());
 
     std::ostringstream script;
     script << "function lweReportCursorPos() {\n"

+ 5 - 17
src/WallpaperEngine/Input/Drivers/KDECursorInput.h

@@ -10,19 +10,11 @@
 
 namespace WallpaperEngine::Input::Drivers {
 
-/**
- * @brief Live global cursor position on KDE Plasma Wayland, fed by a small KWin script.
- *
- * Background layer-shell surfaces never receive real pointer motion events, and there is
- * no portable Wayland protocol to ask the compositor "where is the cursor right now". KWin
- * itself always knows (workspace.cursorPos in its scripting API), so this class loads a
- * short script into the running KWin instance via its Scripting D-Bus interface. The script
- * connects to workspace.cursorPosChanged and forwards every update to a small D-Bus service
- * hosted by this class.
- *
- * If D-Bus initialization or script loading fails, @c isInitialized() returns @c false and
- * the caller is expected to fall back to another cursor source (Hyprland IPC, XWayland, ...).
- */
+// Background layer-shell surfaces never receive real pointer motion events, and there's no
+// portable Wayland protocol to just ask the compositor for the cursor position. KWin itself
+// always knows it though, so this loads a small script into the running KWin instance via its
+// Scripting D-Bus interface; the script forwards workspace.cursorPosChanged to a D-Bus service
+// hosted here. If setup fails, isInitialized() is false and callers should fall back elsewhere.
 class KDECursorInput {
 public:
     KDECursorInput ();
@@ -31,10 +23,6 @@ public:
     KDECursorInput (const KDECursorInput&) = delete;
     KDECursorInput& operator= (const KDECursorInput&) = delete;
 
-    /**
-     * Pumps the D-Bus connection and returns the last known global cursor position, if any
-     * has been reported yet.
-     */
     std::optional<glm::dvec2> position ();
 
     [[nodiscard]] bool isInitialized () const;

+ 5 - 56
src/WallpaperEngine/Input/Drivers/WaylandMouseInput.cpp

@@ -1,5 +1,4 @@
 #include "WaylandMouseInput.h"
-#include "WallpaperEngine/Logging/Log.h"
 #include "WallpaperEngine/Render/Drivers/WaylandOpenGLDriver.h"
 #include <chrono>
 #include <cstdlib>
@@ -22,9 +21,6 @@ WaylandMouseInput::WaylandMouseInput (const WallpaperEngine::Render::Drivers::Wa
     m_waylandDriver (driver) { }
 
 void WaylandMouseInput::update () {
-    static auto lastDebugLog = std::chrono::steady_clock::time_point ();
-    const bool shouldLog = std::chrono::steady_clock::now () - lastDebugLog > std::chrono::seconds (1);
-
     if (!this->m_waylandDriver.getApp ().getContext ().settings.mouse.enabled) {
 	this->m_pos = { 0, 0 };
 	return;
@@ -32,21 +28,13 @@ void WaylandMouseInput::update () {
 
     if (m_waylandDriver.viewportInFocus && m_waylandDriver.viewportInFocus->rendering) {
 	this->m_pos = m_waylandDriver.viewportInFocus->mousePos;
-	if (shouldLog) {
-	    lastDebugLog = std::chrono::steady_clock::now ();
-	    sLog.out ("[mouse-debug] using native viewportInFocus->mousePos = ", this->m_pos.x, ",", this->m_pos.y);
-	}
 	return;
     }
 
 #ifdef ENABLE_KDE_EXPERIMENTAL_FEATURES
-    if (const auto kdeCursor = this->m_kdeCursor.position (); kdeCursor.has_value ()) {
-	if (this->matchViewport (*kdeCursor, "kde", shouldLog)) {
-	    if (shouldLog) {
-		lastDebugLog = std::chrono::steady_clock::now ();
-	    }
-	    return;
-	}
+    if (const auto kdeCursor = this->m_kdeCursor.position ();
+	kdeCursor.has_value () && this->matchViewport (*kdeCursor)) {
+	return;
     }
 #endif /* ENABLE_KDE_EXPERIMENTAL_FEATURES */
 
@@ -57,53 +45,17 @@ void WaylandMouseInput::update () {
     this->m_lastGlobalCursorQuery = now;
 
     auto globalCursor = this->queryHyprlandCursorPosition ();
-    const char* source = "hyprland";
 #ifdef ENABLE_X11
     if (!globalCursor.has_value ()) {
 	globalCursor = this->queryX11CursorPosition ();
-	source = "x11";
     }
 #endif /* ENABLE_X11 */
-    if (!globalCursor.has_value ()) {
-	if (shouldLog) {
-	    lastDebugLog = now;
-	    sLog.out ("[mouse-debug] no viewportInFocus and no global cursor query succeeded (hyprland/x11 both failed)");
-	}
+    if (!globalCursor.has_value () || !this->matchViewport (*globalCursor)) {
 	this->m_pos = { 0, 0 };
-	return;
     }
-
-    if (this->matchViewport (*globalCursor, source, shouldLog)) {
-	if (shouldLog) {
-	    lastDebugLog = now;
-	}
-	return;
-    }
-
-    if (shouldLog) {
-	lastDebugLog = now;
-	sLog.out ("[mouse-debug] global cursor (source=", source, ") did not match any viewport bounds");
-    }
-    this->m_pos = { 0, 0 };
 }
 
-bool WaylandMouseInput::matchViewport (const glm::dvec2& globalCursor, const char* source, bool shouldLog) {
-    if (shouldLog) {
-	sLog.out (
-	    "[mouse-debug] source=", source, " global cursor = ", globalCursor.x, ",", globalCursor.y,
-	    " screens=", this->m_waylandDriver.m_screens.size ()
-	);
-	for (const auto* viewport : this->m_waylandDriver.m_screens) {
-	    if (!viewport) {
-		continue;
-	    }
-	    sLog.out (
-		"[mouse-debug]   viewport pos=", viewport->position.x, ",", viewport->position.y,
-		" size=", viewport->size.x, ",", viewport->size.y, " scale=", viewport->scale
-	    );
-	}
-    }
-
+bool WaylandMouseInput::matchViewport (const glm::dvec2& globalCursor) {
     for (const auto* viewport : this->m_waylandDriver.m_screens) {
 	if (!viewport || viewport->size.x <= 0 || viewport->size.y <= 0) {
 	    continue;
@@ -116,9 +68,6 @@ bool WaylandMouseInput::matchViewport (const glm::dvec2& globalCursor, const cha
 	}
 
 	this->m_pos = { localX * viewport->scale, (viewport->size.y - localY) * viewport->scale };
-	if (shouldLog) {
-	    sLog.out ("[mouse-debug] matched viewport (source=", source, "), m_pos = ", this->m_pos.x, ",", this->m_pos.y);
-	}
 	return true;
     }
 

+ 3 - 9
src/WallpaperEngine/Input/Drivers/WaylandMouseInput.h

@@ -51,17 +51,11 @@ private:
     [[nodiscard]] const Render::Drivers::Output::WaylandOutputViewport* getActiveOutputViewport () const;
     [[nodiscard]] std::optional<glm::dvec2> queryHyprlandCursorPosition () const;
 #ifdef ENABLE_X11
-    /**
-     * Fallback for compositors without a compositor-specific IPC (KDE, GNOME, ...): asks XWayland
-     * for the pointer position on the root window, which tracks the real Wayland cursor
-     */
+    // last-resort fallback: XWayland's root window pointer only tracks the real cursor while it's
+    // over an XWayland-backed window, but that's still better than nothing on compositors with no IPC
     [[nodiscard]] std::optional<glm::dvec2> queryX11CursorPosition () const;
 #endif /* ENABLE_X11 */
-    /**
-     * Converts a global (compositor-space) cursor position into local viewport coordinates and
-     * stores it into m_pos if it falls within one of the tracked outputs
-     */
-    bool matchViewport (const glm::dvec2& globalCursor, const char* source, bool shouldLog);
+    bool matchViewport (const glm::dvec2& globalCursor);
 
     /**
      * Wayland: Driver

+ 1 - 0
src/WallpaperEngine/Render/Objects/Effects/CPass.cpp

@@ -878,6 +878,7 @@ void CPass::setupUniforms () {
     this->addUniform ("g_ViewProjectionMatrix", &this->m_viewProjectionMatrix);
     this->addUniform ("g_PointerPosition", scene.getMousePosition ());
     this->addUniform ("g_PointerPositionLast", scene.getMousePositionLast ());
+    this->addUniform ("g_ParallaxPosition", scene.getMousePosition ());
     this->addUniform ("g_EffectTextureProjectionMatrix", glm::mat4 (1.0));
     this->addUniform ("g_EffectTextureProjectionMatrixInverse", glm::mat4 (1.0));
     this->addUniform ("g_TexelSize", glm::vec2 (1.0 / scene.getWidth (), 1.0 / scene.getHeight ()));