Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a fallback to let mplayer control the screensaver #1085

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1851,7 +1851,11 @@ void Core::startMplayer( QString file, double seek ) {
#ifndef USE_POWERSAVING
proc->setOption("stop-xscreensaver", pref->disable_screensaver);
#else
proc->setOption("stop-xscreensaver", false);
if (screensaver->isValid()) {
proc->setOption("stop-xscreensaver", false);
} else { // fallback to let mplayer control the screensaver
proc->setOption("stop-xscreensaver", pref->disable_screensaver);
}
#endif
#endif

Expand Down
2 changes: 2 additions & 0 deletions src/mplayeroptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,10 @@ void MplayerProcess::setOption(const QString & option_name, const QVariant & val
}
else
if (option_name == "stop-xscreensaver") {
#ifdef OS_UNIX_NOT_MAC
bool stop_ss = value.toBool();
if (stop_ss) arg << "-stop-xscreensaver"; else arg << "-nostop-xscreensaver";
#endif
}
else
if (option_name == "correct-pts") {
Expand Down
4 changes: 4 additions & 0 deletions src/powersaving.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ PowerSaving::PowerSaving(QObject * parent)
PowerSaving::~PowerSaving() {
}

bool PowerSaving::isValid() {
return interface->isValid();
}

void PowerSaving::inhibit() {
qDebug("PowerSaving::inhibit");
QDBusReply<uint> reply = interface->call("Inhibit", "smplayer", "Playing media");
Expand Down
2 changes: 2 additions & 0 deletions src/powersaving.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class PowerSaving : public QObject
PowerSaving(QObject * parent = 0);
~PowerSaving();

bool isValid();

public slots:
void inhibit();
void uninhibit();
Expand Down
4 changes: 4 additions & 0 deletions src/powersaving_mac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ PowerSaving::PowerSaving(QObject * parent)
PowerSaving::~PowerSaving() {
}

bool PowerSaving::isValid() {
return true;
}

void PowerSaving::inhibit() {
qDebug("PowerSaving::inhibit");

Expand Down
2 changes: 2 additions & 0 deletions src/powersaving_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class PowerSaving : public QObject
PowerSaving(QObject * parent = 0);
~PowerSaving();

bool isValid();

public slots:
void inhibit();
void uninhibit();
Expand Down
8 changes: 8 additions & 0 deletions src/screensaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ ScreenSaver::~ScreenSaver() {
#endif
}

bool ScreenSaver::isValid() {
#ifdef Q_OS_WIN
return win_screensaver->isValid();
#else
return power_saving->isValid();
#endif
}

void ScreenSaver::enable() {
#ifdef Q_OS_WIN
win_screensaver->enable();
Expand Down
2 changes: 2 additions & 0 deletions src/screensaver.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class ScreenSaver : public QObject
ScreenSaver(QObject * parent = 0);
~ScreenSaver();

bool isValid();

public slots:
void enable();
void disable();
Expand Down
8 changes: 8 additions & 0 deletions src/winscreensaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ WinScreenSaver::~WinScreenSaver() {
#endif
}

bool WinScreenSaver::isValid() {
#ifndef Q_OS_OS2
return true;
#else
return SSCore_TempDisable && SSCore_TempEnable;
#endif
}

void WinScreenSaver::retrieveState() {
qDebug("WinScreenSaver::retrieveState");

Expand Down
2 changes: 2 additions & 0 deletions src/winscreensaver.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class WinScreenSaver
WinScreenSaver();
~WinScreenSaver();

bool isValid();

void disable();
void enable();

Expand Down