Skip to content

Commit e8e97f1

Browse files
author
Andrew Rabert
committed
Fix cursor sometimes not hiding in fullscreen
Remove the remaining cursor logic from JMP and rely upon jellyfin-web's behavior exclusively. Resolves #183
1 parent 3085410 commit e8e97f1

5 files changed

Lines changed: 28 additions & 36 deletions

File tree

native/nativeshell.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ window.initCompleted = new Promise(async (resolve) => {
303303
for (const mutation of mutations) {
304304
if (mutation.attributeName === 'class') {
305305
const isIdle = document.body.classList.contains('mouseIdle');
306-
window.api.system.setCursorVisibility(!isIdle);
306+
window.api.window.setCursorVisibility(!isIdle);
307307
}
308308
}
309309
});

src/system/SystemComponent.cpp

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ QMap<SystemComponent::PlatformArch, QString> g_platformArchNames = {
5555

5656

5757
///////////////////////////////////////////////////////////////////////////////////////////////////
58-
SystemComponent::SystemComponent(QObject* parent) : ComponentBase(parent), m_platformType(platformTypeUnknown), m_platformArch(platformArchUnknown), m_doLogMessages(false), m_cursorVisible(true), m_scale(1), m_connectivityCheckReply(nullptr), m_resolveUrlReply(nullptr)
58+
SystemComponent::SystemComponent(QObject* parent) : ComponentBase(parent), m_platformType(platformTypeUnknown), m_platformArch(platformArchUnknown), m_doLogMessages(false), m_scale(1), m_connectivityCheckReply(nullptr), m_resolveUrlReply(nullptr)
5959
{
6060
m_connectivityRetryTimer = new QTimer(this);
6161
m_connectivityRetryTimer->setSingleShot(true);
@@ -100,9 +100,6 @@ bool SystemComponent::componentInitialize()
100100
QDir().mkpath(Paths::dataDir("scripts"));
101101
QDir().mkpath(Paths::dataDir("sounds"));
102102

103-
// Hide mouse pointer on any keyboard input
104-
connect(&InputComponent::Get(), &InputComponent::receivedInput, [=]() { setCursorVisibility(false); });
105-
106103
return true;
107104
}
108105

@@ -421,33 +418,6 @@ void SystemComponent::cancelServerConnectivity()
421418
m_pendingConnectivityUrl.clear();
422419
}
423420

424-
///////////////////////////////////////////////////////////////////////////////////////////////////
425-
void SystemComponent::setCursorVisibility(bool visible)
426-
{
427-
if (SettingsComponent::Get().value(SETTINGS_SECTION_MAIN, "webMode") == "desktop")
428-
visible = true;
429-
430-
if (visible == m_cursorVisible)
431-
return;
432-
433-
m_cursorVisible = visible;
434-
435-
if (visible)
436-
{
437-
qApp->restoreOverrideCursor();
438-
}
439-
else
440-
{
441-
qApp->setOverrideCursor(QCursor(Qt::BlankCursor));
442-
}
443-
444-
#ifdef Q_OS_MAC
445-
// OSX notifications will reset the cursor image (without Qt's knowledge). The
446-
// only thing we can do override this is using Cocoa's native cursor hiding.
447-
OSXUtils::SetCursorVisible(visible);
448-
#endif
449-
}
450-
451421
///////////////////////////////////////////////////////////////////////////////////////////////////
452422
QString SystemComponent::getUserAgent()
453423
{

src/system/SystemComponent.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ class SystemComponent : public ComponentBase
4747
QString extractBaseUrl(const QString& url);
4848
void resolveUrl(const QString& url, std::function<void(const QString&)> callback);
4949

50-
Q_INVOKABLE void setCursorVisibility(bool visible);
51-
5250
Q_INVOKABLE QString getUserAgent();
5351

5452
Q_INVOKABLE QString debugInformation();
@@ -105,7 +103,6 @@ class SystemComponent : public ComponentBase
105103
bool isWebClientConnected() const { return !m_webClientVersion.isEmpty(); }
106104

107105
inline QString authenticationToken() { return m_authenticationToken; }
108-
inline bool cursorVisible() { return m_cursorVisible; }
109106

110107
Q_INVOKABLE void crashApp();
111108

@@ -137,7 +134,6 @@ private Q_SLOTS:
137134
bool m_doLogMessages;
138135
QString m_authenticationToken;
139136
QString m_webClientVersion;
140-
bool m_cursorVisible;
141137
qreal m_scale;
142138
QNetworkReply* m_connectivityCheckReply;
143139
QNetworkReply* m_resolveUrlReply;

src/ui/WindowManager.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
#include "display/DisplayComponent.h"
77
#include "taskbar/TaskbarComponent.h"
88
#include "input/InputComponent.h"
9+
#include "utils/Utils.h"
910

11+
#include <QCursor>
1012
#include <QGuiApplication>
1113
#include <QScreen>
1214
#include <QDebug>
@@ -25,6 +27,7 @@ WindowManager::WindowManager(QObject* parent)
2527
m_ignoreFullscreenSettingsChange(0),
2628
m_maximized(false),
2729
m_fullscreen(false),
30+
m_cursorVisible(true),
2831
m_geometryChangeTimer(nullptr)
2932
{
3033
}
@@ -196,6 +199,25 @@ void WindowManager::toggleFullscreen()
196199
setFullScreen(!isFullScreen());
197200
}
198201

202+
///////////////////////////////////////////////////////////////////////////////////////////////////
203+
void WindowManager::setCursorVisibility(bool visible)
204+
{
205+
if (visible == m_cursorVisible)
206+
return;
207+
208+
m_cursorVisible = visible;
209+
210+
if (visible)
211+
qApp->restoreOverrideCursor();
212+
else
213+
qApp->setOverrideCursor(QCursor(Qt::BlankCursor));
214+
215+
#ifdef Q_OS_MAC
216+
OSXUtils::SetCursorVisible(visible);
217+
#endif
218+
}
219+
220+
199221
///////////////////////////////////////////////////////////////////////////////////////////////////
200222
void WindowManager::raiseWindow()
201223
{

src/ui/WindowManager.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class WindowManager : public ComponentBase
4343
Q_INVOKABLE void setFullScreen(bool enable);
4444
Q_INVOKABLE bool isFullScreen() const;
4545

46+
// Cursor visibility
47+
Q_INVOKABLE void setCursorVisibility(bool visible);
48+
4649
// Window activation
4750
Q_INVOKABLE void raiseWindow();
4851

@@ -86,6 +89,7 @@ private slots:
8689
QRect m_normalGeometry;
8790
bool m_maximized;
8891
bool m_fullscreen;
92+
bool m_cursorVisible;
8993
QTimer* m_geometryChangeTimer;
9094
QRect m_pendingGeometry;
9195
};

0 commit comments

Comments
 (0)