Fix macos cursor hiding outside of Jellyfin Desktop

This commit is contained in:
Andrew Rabert committed 2025-12-30 18:10:28 -05:00
1 parent f3d2382530
commit b3885236f1
2 files changed
+37 -1

No files matched your search

+33 -1
View File
@@ -9,6 +9,7 @@
#include "utils/Utils.h"
#include <QCursor>
#include <QEvent>
#include <QGuiApplication>
#include <QScreen>
#include <QDebug>
@@ -28,6 +29,7 @@ WindowManager::WindowManager(QObject* parent)
m_enforcingZoom(false),
m_ignoreFullscreenSettingsChange(0),
m_cursorVisible(true),
m_cursorInsideWindow(true),
m_previousVisibility(QWindow::Windowed),
m_geometrySaveTimer(nullptr),
m_initialSize(),
@@ -62,6 +64,9 @@ void WindowManager::initializeWindow(QQuickWindow* window)
DisplayComponent::Get().setApplicationWindow(m_window);
TaskbarComponent::Get().setWindow(m_window);
// Install event filter to track cursor enter/leave
m_window->installEventFilter(this);
// Register host command for fullscreen toggle
InputComponent::Get().registerHostCommand("fullscreen", this, "toggleFullscreen");
@@ -249,10 +254,37 @@ void WindowManager::setCursorVisibility(bool visible)
qApp->setOverrideCursor(QCursor(Qt::BlankCursor));
#ifdef Q_OS_MAC
OSXUtils::SetCursorVisible(visible);
// Only apply macOS global cursor hiding when cursor is inside window
if (m_cursorInsideWindow)
OSXUtils::SetCursorVisible(visible);
#endif
}
///////////////////////////////////////////////////////////////////////////////////////////////////
bool WindowManager::eventFilter(QObject* watched, QEvent* event)
{
if (watched == m_window)
{
if (event->type() == QEvent::Enter)
{
m_cursorInsideWindow = true;
#ifdef Q_OS_MAC
// Re-hide cursor if it should be hidden
if (!m_cursorVisible)
OSXUtils::SetCursorVisible(false);
#endif
}
else if (event->type() == QEvent::Leave)
{
m_cursorInsideWindow = false;
#ifdef Q_OS_MAC
// Always show cursor when leaving window
OSXUtils::SetCursorVisible(true);
#endif
}
}
return ComponentBase::eventFilter(watched, event);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
void WindowManager::raiseWindow()
+4
View File
@@ -47,6 +47,9 @@ public:
// Cursor visibility
Q_INVOKABLE void setCursorVisibility(bool visible);
// Event filter for cursor enter/leave tracking
bool eventFilter(QObject* watched, QEvent* event) override;
// Window activation
Q_INVOKABLE void raiseWindow();
@@ -104,6 +107,7 @@ private:
QString m_currentScreenName;
int m_ignoreFullscreenSettingsChange;
bool m_cursorVisible;
bool m_cursorInsideWindow;
// Window state
QWindow::Visibility m_previousVisibility; // State before fullscreen