jellyfin / jellyfin-media-player

Jellyfin Desktop Client
GNU General Public License v2.0
3.3k stars 326 forks source link

Need screensaver deactivated when libcec detects activate (HDMI TV ON) #392

Open satmandu opened 1 year ago

satmandu commented 1 year ago

Describe the bug I'm using 1.8.1 on Ubuntu/lunar, with JMP set to Fullscreen, and using a tv remote to communicate with JMP using CEC.

When JMP is idle, gnome blanks the screen after a timeout, which is great. However, I can not use the remote to unblank the screen.

To Reproduce Steps to reproduce the behavior: Start JMP Set gnome to automatically blank the screen when idle. Let JMP go idle, and watch the screen get blanked. Notice that the remote doesn't work in waking the screen. Expected behavior Pressing buttons on the remote (such as arrow keys) should wake the remote. (It does for Kodi.)

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

satmandu commented 1 year ago

(To be clear: moving the mouse works to bring JMP back. Just using the remote does not.)

satmandu commented 7 months ago

I actually think that a simple modification of the method suggested in https://github.com/lxqt/lxqt-powermanagement/issues/327#issuecomment-1154529199 might work here. I am trying this:

--- a/jellyfin-media-player/src/input/InputCEC.cpp      2024-04-30 19:47:59.427133918 -0400
+++ b/jellyfin-media-player/src/input/InputCEC.cpp        2024-04-30 19:40:34.337249916 -0400
@@ -1,5 +1,7 @@

+#include <QCursor>
 #include <QDebug>
+#include <QPoint>
 #include "InputCEC.h"
 #include "settings/SettingsComponent.h"
 #include "power/PowerComponent.h"
@@ -196,6 +198,14 @@ void InputCECWorker::checkAdapter()
 void InputCECWorker::sendReceivedInput(const QString &source, const QString &keycode, InputBase::InputkeyState keyState)
 {
   emit receivedInput(source, keycode, keyState);
+  QPoint curPos = QCursor::pos();
+  QCursor::setPos(QCursor::pos() + QPoint(1, 0));
+  if (curPos == QCursor::pos()) {
+    QCursor::setPos(QCursor::pos() + QPoint(-1, 0));
+    QCursor::setPos(QCursor::pos() + QPoint(1, 0));
+  }
+  else
+    QCursor::setPos(QCursor::pos() + QPoint(-1, 0));
 }

 ///////////////////////////////////////////////////////////////////////////////////////////////////
satmandu commented 7 months ago

Hmm... That's not working to bring it out of sleep... If I jiggle the actual mouse, it does on the other hand briefly show the screensaver before the screensaver turns off.

satmandu commented 7 months ago

I'll move the questions to discord...

This isn't working either...

void InputCECWorker::sendReceivedInput(const QString &source, const QString &keycode, InputBase::InputkeyState keyState)
{
  emit receivedInput(source, keycode, keyState);
  PowerComponent::Get().setScreensaverEnabled(false);
}
satmandu commented 7 months ago

Ok the problem is that https://github.com/jellyfin/jellyfin-web/blob/master/src/scripts/screensavermanager.js has this section:

https://github.com/jellyfin/jellyfin-web/blob/850ac3837a2b470cc4dbe034bb34c7886faae063/src/scripts/screensavermanager.js#L64C1-L72C10

        if (screensaver.hideOnClick !== false) {
            window.addEventListener('click', hide, true);
        }
        if (screensaver.hideOnMouse !== false) {
            window.addEventListener('mousemove', hide, true);
        }
        if (screensaver.hideOnKey !== false) {
            window.addEventListener('keydown', hide, true);
        }

window.addEventListener('keydown', hide, true); is not triggering on a CEC event, e.g.,

[debug] InputComponent::remapInput @ 158 - Input received: source: "CEC" keycode: "KEY_DOWN" : InputBase::KeyDown

I guess the question is: Can we make jellyfin-media-player emit keydown from CEC events so that jellyfin-web is happy?

satmandu commented 7 months ago

OK i just realized the above jellyfin-web code is from master... so I need to figure out how to build jellyfin-media-player with the master version of jellyfin-web...

satmandu commented 7 months ago

Same issue with jellyfin-web from master built into JMP:

2024-05-01 22:51:18.374 [info] SystemComponent::info @ 184 - JS: Received KeepAlive from server.
2024-05-01 22:51:27.947 [info] SystemComponent::info @ 184 - JS: Showing screensaver BackdropScreensaver
2024-05-01 22:51:27.948 [info] SystemComponent::info @ 184 - JS: Requesting https://myjfhost:port/Users/c3ccb8c4ae8a4ba39e9048cfb59396da/Items?ImageTypes=Backdrop&EnableImageTypes=Backdrop&IncludeItemTypes=Movie%2CSeries%2CMusicArtist&SortBy=Random&Recursive=true&Fields=Taglines&ImageTypeLimit=10&StartIndex=0&Limit=200
2024-05-01 22:51:48.369 [info] SystemComponent::info @ 184 - JS: Sending web socket message: KeepAlive
2024-05-01 22:51:48.371 [info] SystemComponent::info @ 184 - JS: Received KeepAlive from server.
2024-05-01 22:52:15.061 [debug] InputComponent::remapInput @ 158 - Input received: source: "CEC" keycode: "KEY_DOWN" : InputBase::KeyDown
2024-05-01 22:52:15.061 [debug] InputComponent::remapInput @ 228 - Emit input action: ("down")
2024-05-01 22:52:15.268 [debug] InputComponent::remapInput @ 158 - Input received: source: "CEC" keycode: "KEY_SELECT" : InputBase::KeyUp
2024-05-01 22:52:16.363 [debug] InputComponent::remapInput @ 158 - Input received: source: "CEC" keycode: "KEY_DOWN" : InputBase::KeyDown
2024-05-01 22:52:16.363 [debug] InputComponent::remapInput @ 228 - Emit input action: ("down")
satmandu commented 7 months ago

The input received is picked up just fine when the BackdropScreensaver isn't running, but when it is running, the CEC input received does not trigger the screensaver to hide like keyboard or mouse input does.