Revert "Add an option to inhibit suspend while playing"
This commit is contained in:
parent
70070ee0bf
commit
c9b0bb2044
@ -344,7 +344,6 @@ set(SOURCES
|
|||||||
ui/globalshortcutgrabber.cpp
|
ui/globalshortcutgrabber.cpp
|
||||||
ui/globalshortcutssettingspage.cpp
|
ui/globalshortcutssettingspage.cpp
|
||||||
ui/iconloader.cpp
|
ui/iconloader.cpp
|
||||||
ui/idlehandler.cpp
|
|
||||||
ui/mainwindow.cpp
|
ui/mainwindow.cpp
|
||||||
ui/networkproxysettingspage.cpp
|
ui/networkproxysettingspage.cpp
|
||||||
ui/networkremotesettingspage.cpp
|
ui/networkremotesettingspage.cpp
|
||||||
@ -353,6 +352,7 @@ set(SOURCES
|
|||||||
ui/organiseerrordialog.cpp
|
ui/organiseerrordialog.cpp
|
||||||
ui/playbacksettingspage.cpp
|
ui/playbacksettingspage.cpp
|
||||||
ui/qtsystemtrayicon.cpp
|
ui/qtsystemtrayicon.cpp
|
||||||
|
ui/screensaver.cpp
|
||||||
ui/settingsdialog.cpp
|
ui/settingsdialog.cpp
|
||||||
ui/settingspage.cpp
|
ui/settingspage.cpp
|
||||||
ui/standarditemiconloader.cpp
|
ui/standarditemiconloader.cpp
|
||||||
@ -863,7 +863,7 @@ optional_source(APPLE
|
|||||||
engines/osxdevicefinder.cpp
|
engines/osxdevicefinder.cpp
|
||||||
networkremote/bonjour.mm
|
networkremote/bonjour.mm
|
||||||
ui/globalshortcutgrabber.mm
|
ui/globalshortcutgrabber.mm
|
||||||
ui/macidlehandler.cpp
|
ui/macscreensaver.cpp
|
||||||
ui/macsystemtrayicon.mm
|
ui/macsystemtrayicon.mm
|
||||||
widgets/osd_mac.mm
|
widgets/osd_mac.mm
|
||||||
HEADERS
|
HEADERS
|
||||||
@ -878,7 +878,7 @@ optional_source(WIN32
|
|||||||
SOURCES
|
SOURCES
|
||||||
engines/directsounddevicefinder.cpp
|
engines/directsounddevicefinder.cpp
|
||||||
networkremote/tinysvcmdns.cpp
|
networkremote/tinysvcmdns.cpp
|
||||||
ui/windowsidlehandler.cpp
|
ui/windowsscreensaver.cpp
|
||||||
widgets/osd_win.cpp
|
widgets/osd_win.cpp
|
||||||
INCLUDE_DIRECTORIES
|
INCLUDE_DIRECTORIES
|
||||||
${CMAKE_SOURCE_DIR}/3rdparty/tinysvcmdns
|
${CMAKE_SOURCE_DIR}/3rdparty/tinysvcmdns
|
||||||
@ -984,7 +984,7 @@ optional_source(HAVE_DBUS
|
|||||||
core/mpris1.cpp
|
core/mpris1.cpp
|
||||||
core/mpris2.cpp
|
core/mpris2.cpp
|
||||||
networkremote/avahi.cpp
|
networkremote/avahi.cpp
|
||||||
ui/dbusidlehandler.cpp
|
ui/dbusscreensaver.cpp
|
||||||
HEADERS
|
HEADERS
|
||||||
core/mpris.h
|
core/mpris.h
|
||||||
core/mpris1.h
|
core/mpris1.h
|
||||||
|
@ -1,78 +0,0 @@
|
|||||||
/* This file is part of Clementine.
|
|
||||||
Copyright 2010, David Sansome <me@davidsansome.com>
|
|
||||||
Copyright 2015, Arun Narayanankutty <n.arun.lifescience@gmail.com>
|
|
||||||
|
|
||||||
Clementine is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Clementine is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "dbusidlehandler.h"
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
#include <QDBusInterface>
|
|
||||||
#include <QDBusReply>
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "core/logging.h"
|
|
||||||
|
|
||||||
DBusIdleHandler::DBusIdleHandler(const QString& service, const QString& path,
|
|
||||||
const QString& interface)
|
|
||||||
: service_(service), path_(path), interface_(interface) {}
|
|
||||||
|
|
||||||
void DBusIdleHandler::Inhibit(const char* reason) {
|
|
||||||
QDBusInterface iface(service_, path_,
|
|
||||||
interface_, QDBusConnection::sessionBus());
|
|
||||||
QDBusReply<quint32> reply;
|
|
||||||
if (service_ == IdleHandler::kGnomePowermanagerService) {
|
|
||||||
reply =
|
|
||||||
iface.call("Inhibit", QCoreApplication::applicationName(),
|
|
||||||
quint32(0), QObject::tr(reason),
|
|
||||||
quint32(Inhibit_Suspend));
|
|
||||||
} else {
|
|
||||||
reply =
|
|
||||||
iface.call("Inhibit", QCoreApplication::applicationName(),
|
|
||||||
QObject::tr("reason"));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reply.isValid()) {
|
|
||||||
cookie_ = reply.value();
|
|
||||||
} else {
|
|
||||||
qLog(Warning) << "Failed to inhibit screensaver/suspend dbus service: "
|
|
||||||
<< service_ << " path: " << path_ << " interface: "
|
|
||||||
<< interface_;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DBusIdleHandler::Uninhibit() {
|
|
||||||
QDBusInterface iface(service_, path_,
|
|
||||||
interface_, QDBusConnection::sessionBus());
|
|
||||||
if (service_ == IdleHandler::kGnomePowermanagerService) {
|
|
||||||
iface.call("Uninhibit", cookie_);
|
|
||||||
} else {
|
|
||||||
iface.call("UnInhibit", cookie_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool DBusIdleHandler::Isinhibited() {
|
|
||||||
QDBusInterface iface(service_, path_,
|
|
||||||
interface_, QDBusConnection::sessionBus());
|
|
||||||
QDBusReply<bool> reply;
|
|
||||||
if (service_ == IdleHandler::kGnomePowermanagerService) {
|
|
||||||
reply = iface.call("IsInhibited", quint32(Inhibit_Suspend));
|
|
||||||
} else {
|
|
||||||
reply = iface.call("HasInhibit");
|
|
||||||
}
|
|
||||||
|
|
||||||
return reply;
|
|
||||||
}
|
|
43
src/ui/dbusscreensaver.cpp
Normal file
43
src/ui/dbusscreensaver.cpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
/* This file is part of Clementine.
|
||||||
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
||||||
|
|
||||||
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Clementine is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "dbusscreensaver.h"
|
||||||
|
|
||||||
|
#include <QCoreApplication>
|
||||||
|
#include <QDBusInterface>
|
||||||
|
#include <QDBusReply>
|
||||||
|
|
||||||
|
DBusScreensaver::DBusScreensaver(const QString& service, const QString& path,
|
||||||
|
const QString& interface)
|
||||||
|
: service_(service), path_(path), interface_(interface) {}
|
||||||
|
|
||||||
|
void DBusScreensaver::Inhibit() {
|
||||||
|
QDBusInterface gnome_screensaver("org.gnome.ScreenSaver", "/",
|
||||||
|
"org.gnome.ScreenSaver");
|
||||||
|
QDBusReply<quint32> reply =
|
||||||
|
gnome_screensaver.call("Inhibit", QCoreApplication::applicationName(),
|
||||||
|
QObject::tr("Visualizations"));
|
||||||
|
if (reply.isValid()) {
|
||||||
|
cookie_ = reply.value();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DBusScreensaver::Uninhibit() {
|
||||||
|
QDBusInterface gnome_screensaver("org.gnome.ScreenSaver", "/",
|
||||||
|
"org.gnome.ScreenSaver");
|
||||||
|
gnome_screensaver.call("UnInhibit", cookie_);
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
/* This file is part of Clementine.
|
/* This file is part of Clementine.
|
||||||
Copyright 2010, David Sansome <me@davidsansome.com>
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
||||||
Copyright 2015, Arun Narayanankutty <n.arun.lifescience@gmail.com>
|
|
||||||
|
|
||||||
Clementine is free software: you can redistribute it and/or modify
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -16,28 +15,22 @@
|
|||||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef DBUSIDLEHANDLER_H
|
#ifndef DBUSSCREENSAVER_H
|
||||||
#define DBUSIDLEHANDLER_H
|
#define DBUSSCREENSAVER_H
|
||||||
|
|
||||||
#include "idlehandler.h"
|
#include "screensaver.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class DBusIdleHandler : public IdleHandler {
|
class DBusScreensaver : public Screensaver {
|
||||||
public:
|
public:
|
||||||
DBusIdleHandler(const QString& service, const QString& path,
|
DBusScreensaver(const QString& service, const QString& path,
|
||||||
const QString& interface);
|
const QString& interface);
|
||||||
|
|
||||||
void Inhibit(const char* reason) override;
|
void Inhibit();
|
||||||
void Uninhibit() override;
|
void Uninhibit();
|
||||||
bool Isinhibited() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum GnomeIdleHandlerFlags {
|
|
||||||
Inhibit_Suspend = 4,
|
|
||||||
Inhibit_Mark_Idle = 8
|
|
||||||
};
|
|
||||||
|
|
||||||
QString service_;
|
QString service_;
|
||||||
QString path_;
|
QString path_;
|
||||||
QString interface_;
|
QString interface_;
|
||||||
@ -45,4 +38,4 @@ class DBusIdleHandler : public IdleHandler {
|
|||||||
quint32 cookie_;
|
quint32 cookie_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DBUSIDLEHANDLER_H
|
#endif
|
@ -1,134 +0,0 @@
|
|||||||
/* This file is part of Clementine.
|
|
||||||
Copyright 2010, David Sansome <me@davidsansome.com>
|
|
||||||
Copyright 2015, Arun Narayanankutty <n.arun.lifescience@gmail.com>
|
|
||||||
|
|
||||||
Clementine is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Clementine is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "config.h"
|
|
||||||
#include "idlehandler.h"
|
|
||||||
#include "core/logging.h"
|
|
||||||
|
|
||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
#ifdef HAVE_DBUS
|
|
||||||
#include "dbusidlehandler.h"
|
|
||||||
#include <QDBusConnection>
|
|
||||||
#include <QDBusConnectionInterface>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_OS_DARWIN
|
|
||||||
#include "macidlehandler.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
|
||||||
#include "windowsidlehandler.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Services
|
|
||||||
const char* IdleHandler::kGnomeScreensaverService
|
|
||||||
= "org.gnome.ScreenSaver";
|
|
||||||
const char* IdleHandler::kFreedesktopScreensaverService
|
|
||||||
= "org.freedesktop.ScreenSaver";
|
|
||||||
const char* IdleHandler::kGnomePowermanagerService
|
|
||||||
= "org.gnome.SessionManager";
|
|
||||||
const char* IdleHandler::kFreedesktopPowermanagerService
|
|
||||||
= "org.freedesktop.PowerManagement";
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
// Gnome Screensaver
|
|
||||||
const char* kGnomeScreensaverPath
|
|
||||||
= "/";
|
|
||||||
const char* kGnomeScreensaverInterface
|
|
||||||
= "org.gnome.ScreenSaver";
|
|
||||||
|
|
||||||
// Freedesktop screensaver
|
|
||||||
const char* kFreedesktopScreensaverPath
|
|
||||||
= "/ScreenSaver";
|
|
||||||
const char* kFreedesktopScreensaverInterface
|
|
||||||
= "org.freedesktop.ScreenSaver";
|
|
||||||
|
|
||||||
// Gnome powermanager
|
|
||||||
const char* kGnomePowermanagerPath
|
|
||||||
= "/org/gnome/SessionManager";
|
|
||||||
const char* kGnomePowermanagerInterface
|
|
||||||
= "org.gnome.SessionManager";
|
|
||||||
|
|
||||||
// Freedesktop powermanager
|
|
||||||
const char* kFreedesktopPowermanagerPath
|
|
||||||
= "/org/freedesktop/PowerManagement/Inhibit";
|
|
||||||
const char* kFreedesktopPowermanagerInterface
|
|
||||||
= "org.freedesktop.PowerManagement.Inhibit";
|
|
||||||
}
|
|
||||||
|
|
||||||
IdleHandler* IdleHandler::screensaver_ = 0;
|
|
||||||
IdleHandler* IdleHandler::suspend_ = 0;
|
|
||||||
|
|
||||||
IdleHandler::Inhibitor IdleHandler::inbtr_;
|
|
||||||
|
|
||||||
IdleHandler* IdleHandler::GetScreensaver() {
|
|
||||||
inbtr_ = Screensaver;
|
|
||||||
if (!screensaver_) {
|
|
||||||
#if defined(HAVE_DBUS)
|
|
||||||
// For gnome
|
|
||||||
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(
|
|
||||||
kGnomeScreensaverService)) {
|
|
||||||
screensaver_ = new DBusIdleHandler(kGnomeScreensaverService,
|
|
||||||
kGnomeScreensaverPath,
|
|
||||||
kGnomeScreensaverInterface);
|
|
||||||
} else if (QDBusConnection::sessionBus().interface()->isServiceRegistered(
|
|
||||||
kFreedesktopScreensaverService)) /* For KDE, XFCE & others */ {
|
|
||||||
screensaver_ = new DBusIdleHandler(kFreedesktopScreensaverService,
|
|
||||||
kFreedesktopScreensaverPath,
|
|
||||||
kFreedesktopScreensaverInterface);
|
|
||||||
} else {
|
|
||||||
qLog(Warning) << "no supported dbus screensaver service available";
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(Q_OS_DARWIN)
|
|
||||||
screensaver_ = new MacIdleHandler();
|
|
||||||
#elif defined(Q_OS_WIN32)
|
|
||||||
screensaver_ = new WindowsIdleHandler();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return screensaver_;
|
|
||||||
}
|
|
||||||
|
|
||||||
IdleHandler* IdleHandler::GetSuspend() {
|
|
||||||
inbtr_ = Suspend;
|
|
||||||
if (!suspend_) {
|
|
||||||
#if defined(HAVE_DBUS)
|
|
||||||
// For gnome
|
|
||||||
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(
|
|
||||||
kGnomePowermanagerService)) {
|
|
||||||
suspend_ = new DBusIdleHandler(kGnomePowermanagerService,
|
|
||||||
kGnomePowermanagerPath,
|
|
||||||
kGnomePowermanagerInterface);
|
|
||||||
} else if (QDBusConnection::sessionBus().interface()->isServiceRegistered(
|
|
||||||
kFreedesktopPowermanagerService)) /* For KDE, XFCE & others */ {
|
|
||||||
suspend_ = new DBusIdleHandler(kFreedesktopPowermanagerService,
|
|
||||||
kFreedesktopPowermanagerPath,
|
|
||||||
kFreedesktopPowermanagerInterface);
|
|
||||||
} else {
|
|
||||||
qLog(Warning) << "no supported dbus powermanager service available";
|
|
||||||
}
|
|
||||||
|
|
||||||
#elif defined(Q_OS_DARWIN)
|
|
||||||
suspend_ = new MacIdleHandler();
|
|
||||||
#elif defined(Q_OS_WIN32)
|
|
||||||
suspend_ = new WindowsIdleHandler();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return suspend_;
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
/* This file is part of Clementine.
|
/* This file is part of Clementine.
|
||||||
Copyright 2010, David Sansome <me@davidsansome.com>
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
||||||
Copyright 2015, Arun Narayanankutty <n.arun.lifescience@gmail.com>
|
|
||||||
|
|
||||||
Clementine is free software: you can redistribute it and/or modify
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -16,40 +15,20 @@
|
|||||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "macidlehandler.h"
|
#include "macscreensaver.h"
|
||||||
|
|
||||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||||
|
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
#include "core/logging.h"
|
|
||||||
#include "core/utilities.h"
|
#include "core/utilities.h"
|
||||||
|
|
||||||
MacIdleHandler::MacIdleHandler() : assertion_id_(0),
|
MacScreensaver::MacScreensaver() : assertion_id_(0) {}
|
||||||
is_inhibit_(false) {}
|
|
||||||
|
|
||||||
void MacIdleHandler::Inhibit(const char* reason) {
|
void MacScreensaver::Inhibit() {
|
||||||
IOReturn reply = IOPMAssertionCreateWithName(
|
IOPMAssertionCreateWithName(
|
||||||
kIOPMAssertPreventUserIdleDisplaySleep, kIOPMAssertionLevelOn,
|
kIOPMAssertPreventUserIdleDisplaySleep, kIOPMAssertionLevelOn,
|
||||||
CFSTR(reason), &assertion_id_);
|
CFSTR("Showing full-screen Clementine visualisations"), &assertion_id_);
|
||||||
|
|
||||||
if (reply == kIOReturnSuccess) {
|
|
||||||
is_inhibit_ = true;
|
|
||||||
} else {
|
|
||||||
qLog(Warning) << "Failed to inhibit screensaver/suspend";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacIdleHandler::Uninhibit() {
|
void MacScreensaver::Uninhibit() { IOPMAssertionRelease(assertion_id_); }
|
||||||
IOReturn reply = IOPMAssertionRelease(assertion_id_);
|
|
||||||
|
|
||||||
if (reply == kIOReturnSuccess) {
|
|
||||||
is_inhibit_ = false;
|
|
||||||
} else {
|
|
||||||
qLog(Warning) << "Failed to uninhibit screensaver/suspend";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MacIdleHandler::Isinhibited() {
|
|
||||||
return is_inhibit_;
|
|
||||||
}
|
|
@ -1,6 +1,5 @@
|
|||||||
/* This file is part of Clementine.
|
/* This file is part of Clementine.
|
||||||
Copyright 2010, David Sansome <me@davidsansome.com>
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
||||||
Copyright 2015, Arun Narayanankutty <n.arun.lifescience@gmail.com>
|
|
||||||
|
|
||||||
Clementine is free software: you can redistribute it and/or modify
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -16,24 +15,22 @@
|
|||||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MACIDLEHANDLER_H
|
#ifndef MACSCREENSAVER_H
|
||||||
#define MACIDLEHANDLER_H
|
#define MACSCREENSAVER_H
|
||||||
|
|
||||||
#include "idlehandler.h"
|
#include "screensaver.h"
|
||||||
|
|
||||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||||
|
|
||||||
class MacIdleHandler : public IdleHandler {
|
class MacScreensaver : public Screensaver {
|
||||||
public:
|
public:
|
||||||
MacIdleHandler();
|
MacScreensaver();
|
||||||
|
|
||||||
void Inhibit(const char* reason) override;
|
void Inhibit();
|
||||||
void Uninhibit() override;
|
void Uninhibit();
|
||||||
bool Isinhibited() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IOPMAssertionID assertion_id_;
|
IOPMAssertionID assertion_id_;
|
||||||
bool is_inhibit_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MACIDLEHANDLER_H
|
#endif
|
@ -195,9 +195,7 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
|
|||||||
saved_playback_state_(Engine::Empty),
|
saved_playback_state_(Engine::Empty),
|
||||||
doubleclick_addmode_(AddBehaviour_Append),
|
doubleclick_addmode_(AddBehaviour_Append),
|
||||||
doubleclick_playmode_(PlayBehaviour_IfStopped),
|
doubleclick_playmode_(PlayBehaviour_IfStopped),
|
||||||
menu_playmode_(PlayBehaviour_IfStopped),
|
menu_playmode_(PlayBehaviour_IfStopped) {
|
||||||
idlehandler_(IdleHandler::GetSuspend()),
|
|
||||||
is_suspend_inhibited_(false) {
|
|
||||||
qLog(Debug) << "Starting";
|
qLog(Debug) << "Starting";
|
||||||
|
|
||||||
connect(app, SIGNAL(ErrorAdded(QString)), SLOT(ShowErrorDialog(QString)));
|
connect(app, SIGNAL(ErrorAdded(QString)), SLOT(ShowErrorDialog(QString)));
|
||||||
@ -1011,12 +1009,6 @@ MainWindow::MainWindow(Application* app, SystemTrayIcon* tray_icon, OSD* osd,
|
|||||||
new WiimotedevShortcuts(osd_, this, app_->player()));
|
new WiimotedevShortcuts(osd_, this, app_->player()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
settings_.endGroup();
|
|
||||||
|
|
||||||
settings_.beginGroup(Engine::Base::kSettingsGroup);
|
|
||||||
inhibit_suspend_while_playing_status_ =
|
|
||||||
settings_.value("InhibitSuspendWhilePlaying", false).toBool();
|
|
||||||
|
|
||||||
CheckFullRescanRevisions();
|
CheckFullRescanRevisions();
|
||||||
|
|
||||||
LoadPlaybackStatus();
|
LoadPlaybackStatus();
|
||||||
@ -1090,7 +1082,6 @@ void MainWindow::MediaStopped() {
|
|||||||
ui_->track_slider->SetStopped();
|
ui_->track_slider->SetStopped();
|
||||||
tray_icon_->SetProgress(0);
|
tray_icon_->SetProgress(0);
|
||||||
tray_icon_->SetStopped();
|
tray_icon_->SetStopped();
|
||||||
HandleInhibitSuspendWhilePlaying(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::MediaPaused() {
|
void MainWindow::MediaPaused() {
|
||||||
@ -1106,7 +1097,6 @@ void MainWindow::MediaPaused() {
|
|||||||
track_slider_timer_->stop();
|
track_slider_timer_->stop();
|
||||||
|
|
||||||
tray_icon_->SetPaused();
|
tray_icon_->SetPaused();
|
||||||
HandleInhibitSuspendWhilePlaying(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::MediaPlaying() {
|
void MainWindow::MediaPlaying() {
|
||||||
@ -1136,7 +1126,6 @@ void MainWindow::MediaPlaying() {
|
|||||||
track_position_timer_->start();
|
track_position_timer_->start();
|
||||||
track_slider_timer_->start();
|
track_slider_timer_->start();
|
||||||
UpdateTrackPosition();
|
UpdateTrackPosition();
|
||||||
HandleInhibitSuspendWhilePlaying(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::VolumeChanged(int volume) {
|
void MainWindow::VolumeChanged(int volume) {
|
||||||
@ -2468,11 +2457,6 @@ void MainWindow::EnsureSettingsDialogCreated() {
|
|||||||
SLOT(SetWiimotedevInterfaceActived(bool)));
|
SLOT(SetWiimotedevInterfaceActived(bool)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Handle suspend status
|
|
||||||
connect(settings_dialog_.get(),
|
|
||||||
SIGNAL(InhibitSuspendWhilePlaying(bool)),
|
|
||||||
SLOT(InhibitSuspendWhilePlaying(bool)));
|
|
||||||
|
|
||||||
// Allows custom notification preview
|
// Allows custom notification preview
|
||||||
connect(settings_dialog_.get(),
|
connect(settings_dialog_.get(),
|
||||||
SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString)),
|
SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString)),
|
||||||
@ -2854,21 +2838,3 @@ void MainWindow::keyPressEvent(QKeyEvent* event) {
|
|||||||
QMainWindow::keyPressEvent(event);
|
QMainWindow::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::InhibitSuspendWhilePlaying(bool status) {
|
|
||||||
inhibit_suspend_while_playing_status_ = status;
|
|
||||||
HandleInhibitSuspendWhilePlaying(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MainWindow::HandleInhibitSuspendWhilePlaying(bool status) {
|
|
||||||
if (idlehandler_) {
|
|
||||||
if (inhibit_suspend_while_playing_status_ &&
|
|
||||||
!is_suspend_inhibited_ && status) {
|
|
||||||
idlehandler_->Inhibit("Clementine is playing");
|
|
||||||
is_suspend_inhibited_ = idlehandler_->Isinhibited();
|
|
||||||
} else if (is_suspend_inhibited_ && !status){
|
|
||||||
idlehandler_->Uninhibit();
|
|
||||||
is_suspend_inhibited_ = idlehandler_->Isinhibited();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include "engines/engine_fwd.h"
|
#include "engines/engine_fwd.h"
|
||||||
#include "library/librarymodel.h"
|
#include "library/librarymodel.h"
|
||||||
#include "playlist/playlistitem.h"
|
#include "playlist/playlistitem.h"
|
||||||
#include "ui/idlehandler.h"
|
|
||||||
#include "ui/settingsdialog.h"
|
#include "ui/settingsdialog.h"
|
||||||
|
|
||||||
class About;
|
class About;
|
||||||
@ -65,7 +64,6 @@ class PlaylistBackend;
|
|||||||
class PlaylistListContainer;
|
class PlaylistListContainer;
|
||||||
class PlaylistManager;
|
class PlaylistManager;
|
||||||
class QueueManager;
|
class QueueManager;
|
||||||
class IdleHandler;
|
|
||||||
class InternetItem;
|
class InternetItem;
|
||||||
class InternetModel;
|
class InternetModel;
|
||||||
class InternetViewContainer;
|
class InternetViewContainer;
|
||||||
@ -280,9 +278,6 @@ signals:
|
|||||||
|
|
||||||
void ShowConsole();
|
void ShowConsole();
|
||||||
|
|
||||||
void InhibitSuspendWhilePlaying(bool status);
|
|
||||||
void HandleInhibitSuspendWhilePlaying(bool status);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ConnectInfoView(SongInfoBase* view);
|
void ConnectInfoView(SongInfoBase* view);
|
||||||
|
|
||||||
@ -378,9 +373,6 @@ signals:
|
|||||||
PlayBehaviour menu_playmode_;
|
PlayBehaviour menu_playmode_;
|
||||||
|
|
||||||
BackgroundStreams* background_streams_;
|
BackgroundStreams* background_streams_;
|
||||||
IdleHandler* idlehandler_;
|
|
||||||
bool inhibit_suspend_while_playing_status_;
|
|
||||||
bool is_suspend_inhibited_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINWINDOW_H
|
#endif // MAINWINDOW_H
|
||||||
|
@ -87,8 +87,6 @@ void PlaybackSettingsPage::Load() {
|
|||||||
s.value("FadeoutPauseEnabled", false).toBool());
|
s.value("FadeoutPauseEnabled", false).toBool());
|
||||||
ui_->fading_pause_duration->setValue(
|
ui_->fading_pause_duration->setValue(
|
||||||
s.value("FadeoutPauseDuration", 250).toInt());
|
s.value("FadeoutPauseDuration", 250).toInt());
|
||||||
ui_->inhibit_suspend_while_playing->setChecked(
|
|
||||||
s.value("InhibitSuspendWhilePlaying", false).toBool());
|
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
s.beginGroup(GstEngine::kSettingsGroup);
|
s.beginGroup(GstEngine::kSettingsGroup);
|
||||||
@ -136,8 +134,6 @@ void PlaybackSettingsPage::Save() {
|
|||||||
s.setValue("NoCrossfadeSameAlbum", ui_->fading_samealbum->isChecked());
|
s.setValue("NoCrossfadeSameAlbum", ui_->fading_samealbum->isChecked());
|
||||||
s.setValue("FadeoutPauseEnabled", ui_->fadeout_pause->isChecked());
|
s.setValue("FadeoutPauseEnabled", ui_->fadeout_pause->isChecked());
|
||||||
s.setValue("FadeoutPauseDuration", ui_->fading_pause_duration->value());
|
s.setValue("FadeoutPauseDuration", ui_->fading_pause_duration->value());
|
||||||
s.setValue("InhibitSuspendWhilePlaying",
|
|
||||||
ui_->inhibit_suspend_while_playing->isChecked());
|
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
GstEngine::OutputDetails details =
|
GstEngine::OutputDetails details =
|
||||||
@ -158,10 +154,6 @@ void PlaybackSettingsPage::Save() {
|
|||||||
ui_->sample_rate->itemData(ui_->sample_rate->currentIndex()).toInt());
|
ui_->sample_rate->itemData(ui_->sample_rate->currentIndex()).toInt());
|
||||||
s.setValue("bufferminfill", ui_->buffer_min_fill->value());
|
s.setValue("bufferminfill", ui_->buffer_min_fill->value());
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
|
|
||||||
//Emit inhibit suspend while playing signal
|
|
||||||
emit InhibitSuspendWhilePlaying(
|
|
||||||
ui_->inhibit_suspend_while_playing->isChecked());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaybackSettingsPage::RgPreampChanged(int value) {
|
void PlaybackSettingsPage::RgPreampChanged(int value) {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>596</width>
|
<width>596</width>
|
||||||
<height>754</height>
|
<height>667</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -25,7 +25,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="fading_groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Fading</string>
|
<string>Fading</string>
|
||||||
</property>
|
</property>
|
||||||
@ -168,25 +168,6 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="power_management_groupBox">
|
|
||||||
<property name="title">
|
|
||||||
<string>System Power Management Options</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="inhibit_suspend_while_playing">
|
|
||||||
<property name="toolTip">
|
|
||||||
<string>If enabled, Clementine will prevent the system from automatically suspending if it is playing a track</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Inhibit automatic suspend if playing</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="replaygain_group">
|
<widget class="QGroupBox" name="replaygain_group">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
|
66
src/ui/screensaver.cpp
Normal file
66
src/ui/screensaver.cpp
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
/* This file is part of Clementine.
|
||||||
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
||||||
|
|
||||||
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Clementine is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
#include "screensaver.h"
|
||||||
|
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#ifdef HAVE_DBUS
|
||||||
|
#include "dbusscreensaver.h"
|
||||||
|
#include <QDBusConnection>
|
||||||
|
#include <QDBusConnectionInterface>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_DARWIN
|
||||||
|
#include "macscreensaver.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN32
|
||||||
|
#include "windowsscreensaver.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
|
const char* Screensaver::kGnomeService = "org.gnome.ScreenSaver";
|
||||||
|
const char* Screensaver::kGnomePath = "/";
|
||||||
|
const char* Screensaver::kGnomeInterface = "org.gnome.ScreenSaver";
|
||||||
|
const char* Screensaver::kKdeService = "org.kde.ScreenSaver";
|
||||||
|
const char* Screensaver::kKdePath = "/ScreenSaver/";
|
||||||
|
const char* Screensaver::kKdeInterface = "org.freedesktop.ScreenSaver";
|
||||||
|
|
||||||
|
Screensaver* Screensaver::screensaver_ = 0;
|
||||||
|
|
||||||
|
Screensaver* Screensaver::GetScreensaver() {
|
||||||
|
if (!screensaver_) {
|
||||||
|
#if defined(HAVE_DBUS)
|
||||||
|
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(
|
||||||
|
kGnomeService)) {
|
||||||
|
screensaver_ =
|
||||||
|
new DBusScreensaver(kGnomeService, kGnomePath, kGnomeInterface);
|
||||||
|
} else if (QDBusConnection::sessionBus().interface()->isServiceRegistered(
|
||||||
|
kKdeService)) {
|
||||||
|
screensaver_ = new DBusScreensaver(kKdeService, kKdePath, kKdeInterface);
|
||||||
|
}
|
||||||
|
#elif defined(Q_OS_DARWIN)
|
||||||
|
screensaver_ = new MacScreensaver();
|
||||||
|
#elif defined(Q_OS_WIN32)
|
||||||
|
screensaver_ = new WindowsScreensaver();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return screensaver_;
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
/* This file is part of Clementine.
|
/* This file is part of Clementine.
|
||||||
Copyright 2010, David Sansome <me@davidsansome.com>
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
||||||
Copyright 2015, Arun Narayanankutty <n.arun.lifescience@gmail.com>
|
|
||||||
|
|
||||||
Clementine is free software: you can redistribute it and/or modify
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -16,35 +15,28 @@
|
|||||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef IDLEHANDLER_H
|
#ifndef SCREENSAVER_H
|
||||||
#define IDLEHANDLER_H
|
#define SCREENSAVER_H
|
||||||
|
|
||||||
class IdleHandler {
|
class Screensaver {
|
||||||
public:
|
public:
|
||||||
virtual ~IdleHandler() {}
|
virtual ~Screensaver() {}
|
||||||
|
|
||||||
virtual void Inhibit(const char* reason) = 0;
|
static const char* kGnomeService;
|
||||||
|
static const char* kGnomePath;
|
||||||
|
static const char* kGnomeInterface;
|
||||||
|
|
||||||
|
static const char* kKdeService;
|
||||||
|
static const char* kKdePath;
|
||||||
|
static const char* kKdeInterface;
|
||||||
|
|
||||||
|
virtual void Inhibit() = 0;
|
||||||
virtual void Uninhibit() = 0;
|
virtual void Uninhibit() = 0;
|
||||||
virtual bool Isinhibited() = 0;
|
|
||||||
|
|
||||||
static IdleHandler* GetScreensaver();
|
static Screensaver* GetScreensaver();
|
||||||
static IdleHandler* GetSuspend();
|
|
||||||
|
|
||||||
enum Inhibitor
|
|
||||||
{
|
|
||||||
Screensaver = 0,
|
|
||||||
Suspend = 1
|
|
||||||
};
|
|
||||||
static Inhibitor inbtr_;
|
|
||||||
|
|
||||||
static const char* kGnomeScreensaverService;
|
|
||||||
static const char* kFreedesktopScreensaverService;
|
|
||||||
static const char* kGnomePowermanagerService;
|
|
||||||
static const char* kFreedesktopPowermanagerService;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static IdleHandler* screensaver_;
|
static Screensaver* screensaver_;
|
||||||
static IdleHandler* suspend_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // IDLEHANDLER_H
|
#endif
|
@ -245,8 +245,6 @@ void SettingsDialog::AddPage(Page id, SettingsPage* page,
|
|||||||
SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString)));
|
SIGNAL(NotificationPreview(OSD::Behaviour, QString, QString)));
|
||||||
connect(page, SIGNAL(SetWiimotedevInterfaceActived(bool)),
|
connect(page, SIGNAL(SetWiimotedevInterfaceActived(bool)),
|
||||||
SIGNAL(SetWiimotedevInterfaceActived(bool)));
|
SIGNAL(SetWiimotedevInterfaceActived(bool)));
|
||||||
connect(page, SIGNAL(InhibitSuspendWhilePlaying(bool)),
|
|
||||||
SIGNAL(InhibitSuspendWhilePlaying(bool)));
|
|
||||||
|
|
||||||
// Create the list item
|
// Create the list item
|
||||||
QTreeWidgetItem* item = new QTreeWidgetItem;
|
QTreeWidgetItem* item = new QTreeWidgetItem;
|
||||||
|
@ -119,7 +119,6 @@ class SettingsDialog : public QDialog {
|
|||||||
signals:
|
signals:
|
||||||
void NotificationPreview(OSD::Behaviour, QString, QString);
|
void NotificationPreview(OSD::Behaviour, QString, QString);
|
||||||
void SetWiimotedevInterfaceActived(bool);
|
void SetWiimotedevInterfaceActived(bool);
|
||||||
void InhibitSuspendWhilePlaying(bool);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void CurrentItemChanged(QTreeWidgetItem* item);
|
void CurrentItemChanged(QTreeWidgetItem* item);
|
||||||
|
@ -45,7 +45,6 @@ class SettingsPage : public QWidget {
|
|||||||
signals:
|
signals:
|
||||||
void NotificationPreview(OSD::Behaviour, QString, QString);
|
void NotificationPreview(OSD::Behaviour, QString, QString);
|
||||||
void SetWiimotedevInterfaceActived(bool);
|
void SetWiimotedevInterfaceActived(bool);
|
||||||
void InhibitSuspendWhilePlaying(bool);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SettingsDialog* dialog_;
|
SettingsDialog* dialog_;
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
/* This file is part of Clementine.
|
|
||||||
Copyright 2015, John Maguire <john.maguire@gmail.com>
|
|
||||||
Copyright 2015, Arun Narayanankutty <n.arun.lifescience@gmail.com>
|
|
||||||
|
|
||||||
Clementine is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
Clementine is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "windowsidlehandler.h"
|
|
||||||
|
|
||||||
#include "core/logging.h"
|
|
||||||
|
|
||||||
// TODO: use PowerCreateRequest on Win7+
|
|
||||||
|
|
||||||
WindowsIdleHandler::WindowsIdleHandler() : previous_state_(0),
|
|
||||||
is_inhibit_(false) {}
|
|
||||||
|
|
||||||
void WindowsIdleHandler::Inhibit(const char*) {
|
|
||||||
switch (IdleHandler::inbtr_) {
|
|
||||||
case IdleHandler::Screensaver :
|
|
||||||
// resetting the display idle timer.
|
|
||||||
previous_state_ =
|
|
||||||
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
|
|
||||||
break;
|
|
||||||
case IdleHandler::Suspend :
|
|
||||||
// resetting the system idle timer.
|
|
||||||
previous_state_ =
|
|
||||||
SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (previous_state_! = 0) {
|
|
||||||
is_inhibit_ = true;
|
|
||||||
} else {
|
|
||||||
qLog(Warning) << "Failed to inhibit screensaver/suspend";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void WindowsIdleHandler::Uninhibit() {
|
|
||||||
previous_state_ =
|
|
||||||
SetThreadExecutionState(ES_CONTINUOUS | previous_state_);
|
|
||||||
if (previous_state_! = 0) {
|
|
||||||
is_inhibit_ = false;
|
|
||||||
} else {
|
|
||||||
qLog(Warning) << "Failed to uninhibit screensaver/suspend";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WindowsIdleHandler::Isinhibited() {
|
|
||||||
return is_inhibit_;
|
|
||||||
}
|
|
30
src/ui/windowsscreensaver.cpp
Normal file
30
src/ui/windowsscreensaver.cpp
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/* This file is part of Clementine.
|
||||||
|
Copyright 2015, John Maguire <john.maguire@gmail.com>
|
||||||
|
|
||||||
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
Clementine is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "windowsscreensaver.h"
|
||||||
|
|
||||||
|
WindowsScreensaver::WindowsScreensaver() : previous_state_(0) {}
|
||||||
|
|
||||||
|
void WindowsScreensaver::Inhibit() {
|
||||||
|
// TODO: use PowerCreateRequest on Win7+
|
||||||
|
previous_state_ =
|
||||||
|
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WindowsScreensaver::Uninhibit() {
|
||||||
|
SetThreadExecutionState(ES_CONTINUOUS | previous_state_);
|
||||||
|
}
|
@ -1,6 +1,5 @@
|
|||||||
/* This file is part of Clementine.
|
/* This file is part of Clementine.
|
||||||
Copyright 2015, John Maguire <john.maguire@gmail.com>
|
Copyright 2015, John Maguire <john.maguire@gmail.com>
|
||||||
Copyright 2015, Arun Narayanankutty <n.arun.lifescience@gmail.com>
|
|
||||||
|
|
||||||
Clementine is free software: you can redistribute it and/or modify
|
Clementine is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -15,24 +14,22 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
along with Clementine. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
#ifndef WINDOWSIDLEHANDLER_H
|
#ifndef WINDOWSSCREENSAVER_H
|
||||||
#define WINDOWSIDLEHANDLER_H
|
#define WINDOWSSCREENSAVER_H
|
||||||
|
|
||||||
#include "idlehandler.h"
|
#include "screensaver.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
class WindowsIdleHandler : public IdleHandler {
|
class WindowsScreensaver : public Screensaver {
|
||||||
public:
|
public:
|
||||||
WindowsIdleHandler();
|
WindowsScreensaver();
|
||||||
|
|
||||||
void Inhibit(const char*) override;
|
void Inhibit() override;
|
||||||
void Uninhibit() override;
|
void Uninhibit() override;
|
||||||
bool Isinhibited() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EXECUTION_STATE previous_state_;
|
EXECUTION_STATE previous_state_;
|
||||||
bool is_inhibit_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WINDOWSIDLEHANDLER_H
|
#endif // WINDOWSSCREENSAVER_H
|
@ -22,7 +22,7 @@
|
|||||||
#include "visualisationselector.h"
|
#include "visualisationselector.h"
|
||||||
#include "engines/gstengine.h"
|
#include "engines/gstengine.h"
|
||||||
#include "ui/iconloader.h"
|
#include "ui/iconloader.h"
|
||||||
#include "ui/idlehandler.h"
|
#include "ui/screensaver.h"
|
||||||
|
|
||||||
#include <QGLWidget>
|
#include <QGLWidget>
|
||||||
#include <QGraphicsProxyWidget>
|
#include <QGraphicsProxyWidget>
|
||||||
@ -265,9 +265,9 @@ void VisualisationContainer::keyReleaseEvent(QKeyEvent* event) {
|
|||||||
void VisualisationContainer::ToggleFullscreen() {
|
void VisualisationContainer::ToggleFullscreen() {
|
||||||
setWindowState(windowState() ^ Qt::WindowFullScreen);
|
setWindowState(windowState() ^ Qt::WindowFullScreen);
|
||||||
|
|
||||||
IdleHandler* screensaver = IdleHandler::GetScreensaver();
|
Screensaver* screensaver = Screensaver::GetScreensaver();
|
||||||
if (screensaver)
|
if (screensaver)
|
||||||
isFullScreen() ? screensaver->Inhibit("Visualisation") : screensaver->Uninhibit();
|
isFullScreen() ? screensaver->Inhibit() : screensaver->Uninhibit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualisationContainer::SetFps(int fps) {
|
void VisualisationContainer::SetFps(int fps) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user