From 0a144e8fedc0b258ecc91c834ae89bb7d63d9889 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sat, 5 Nov 2016 13:55:28 +0000 Subject: added feature to disable notifications when another app is in full screen mode git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@6868 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/General/notifier/notifier.cpp | 64 +++++++++++++++++++++++-- src/plugins/General/notifier/notifier.h | 8 +++- src/plugins/General/notifier/settingsdialog.cpp | 2 + src/plugins/General/notifier/settingsdialog.ui | 64 ++++++++++++++----------- 4 files changed, 105 insertions(+), 33 deletions(-) (limited to 'src/plugins/General/notifier') diff --git a/src/plugins/General/notifier/notifier.cpp b/src/plugins/General/notifier/notifier.cpp index a12034b16..212f8bab1 100644 --- a/src/plugins/General/notifier/notifier.cpp +++ b/src/plugins/General/notifier/notifier.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2013 by Ilya Kotov * + * Copyright (C) 2008-2016 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -22,7 +22,17 @@ #include #include #include +#define Visual VisualQmmp #include +#undef Visual + +#ifdef Q_WS_X11 +#include +#include +#include +#include +#include +#endif #include "popupwidget.h" #include "notifier.h" @@ -39,6 +49,7 @@ Notifier::Notifier(QObject *parent) : QObject(parent) m_resumeNotification = settings.value("resume_notification", false).toBool(); m_showVolume = settings.value("volume_notification", true).toBool(); m_psi = settings.value("psi_notification", false).toBool(); + m_disableForFullScreen = settings.value("disable_fullscreen", false).toBool(); settings.endGroup(); m_core = SoundCore::instance(); connect (m_core, SIGNAL(metaDataChanged ()), SLOT(showMetaData())); @@ -108,7 +119,7 @@ void Notifier::setState(Qmmp::State state) void Notifier::showMetaData() { - if (m_desktop) + if (m_desktop && !hasFullscreenWindow()) { if (!m_popupWidget) m_popupWidget = new PopupWidget(); @@ -135,7 +146,6 @@ void Notifier::showMetaData() file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate); file.write(data); file.close(); - continue; } } @@ -143,7 +153,7 @@ void Notifier::showVolume(int l, int r) { if (((m_l != l) || (m_r != r)) && m_showVolume) { - if (m_l >= 0) + if (m_l >= 0 && !hasFullscreenWindow()) { if (!m_popupWidget) m_popupWidget = new PopupWidget(); @@ -162,3 +172,49 @@ void Notifier::removePsiTuneFiles() QFile::remove(path); } } + +#ifdef Q_WS_X11 +bool Notifier::hasFullscreenWindow() const +{ + if(m_disableForFullScreen) + return false; + Atom type = None; + int format = 0; + unsigned long nitems = 0, bytes_after = 0; + unsigned char *prop; + + Display *display = QX11Info::display(); + + Atom filter = XInternAtom(display, "_NET_WM_STATE_FULLSCREEN", False); + Atom net_wm_state = XInternAtom(display, "_NET_WM_STATE", False); + + Window window; + int ret; + XGetInputFocus(display, &window, &ret); + + + int status = XGetWindowProperty(display, window, net_wm_state, 0, 256, + False, XA_ATOM, &type, &format, &nitems, + &bytes_after, &prop); + if(status != Success || type == None) + return false; + + Atom *atoms = (Atom *)prop; + + for (unsigned long i = 0; i < nitems; i++) + { + if (atoms[i] == filter) + { + XFree(prop); + return true; + } + } + XFree(prop); + return false; +} +#else +bool Notifier::hasFullscreenWindow() const +{ + return false; +} +#endif diff --git a/src/plugins/General/notifier/notifier.h b/src/plugins/General/notifier/notifier.h index 2576a9b86..ba5bc8b23 100644 --- a/src/plugins/General/notifier/notifier.h +++ b/src/plugins/General/notifier/notifier.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2008-2013 by Ilya Kotov * + * Copyright (C) 2008-2016 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -46,13 +46,17 @@ private slots: void setState(Qmmp::State state); private: - QPointer m_popupWidget; void removePsiTuneFiles(); +#ifdef Q_WS_X11 + bool hasFullscreenWindow() const; +#endif + QPointer m_popupWidget; bool m_desktop, m_showVolume; bool m_psi; int m_l, m_r; bool m_isPaused; bool m_resumeNotification; + bool m_disableForFullScreen; SoundCore *m_core; QStringList m_psiTuneFiles; diff --git a/src/plugins/General/notifier/settingsdialog.cpp b/src/plugins/General/notifier/settingsdialog.cpp index 672ab7c51..6adeaf03e 100644 --- a/src/plugins/General/notifier/settingsdialog.cpp +++ b/src/plugins/General/notifier/settingsdialog.cpp @@ -50,6 +50,7 @@ SettingsDialog::SettingsDialog(QWidget *parent) m_ui.resumeCheckBox->setChecked(settings.value("resume_notification", false).toBool()); m_ui.songCheckBox->setChecked(settings.value("song_notification", true).toBool()); m_ui.volumeCheckBox->setChecked(settings.value("volume_notification", true).toBool()); + m_ui.disableForFScheckBox->setChecked(settings.value("disable_fullscreen", false).toBool()); m_ui.transparencySlider->setValue(100 - settings.value("opacity", 1.0).toDouble()*100); QString fontname = settings.value ("font").toString(); m_ui.coverSizeSlider->setValue(settings.value ("cover_size", 64).toInt()); @@ -82,6 +83,7 @@ void SettingsDialog::accept() settings.setValue("resume_notification", m_ui.resumeCheckBox->isChecked()); settings.setValue("song_notification", m_ui.songCheckBox->isChecked()); settings.setValue("volume_notification", m_ui.volumeCheckBox->isChecked()); + settings.setValue("disable_fullscreen", m_ui.disableForFScheckBox->isChecked()); settings.setValue("opacity", 1.0 - (double)m_ui.transparencySlider->value()/100); settings.setValue("font", m_ui.fontLabel->font().toString()); settings.setValue("cover_size", m_ui.coverSizeSlider->value()); diff --git a/src/plugins/General/notifier/settingsdialog.ui b/src/plugins/General/notifier/settingsdialog.ui index 9a4ca4e4f..f500dd840 100644 --- a/src/plugins/General/notifier/settingsdialog.ui +++ b/src/plugins/General/notifier/settingsdialog.ui @@ -6,8 +6,8 @@ 0 0 - 309 - 459 + 310 + 512 @@ -35,14 +35,24 @@ Desktop Notification - + + + + 90 + + + Qt::Horizontal + + + + Font: - + QFrame::StyledPanel @@ -55,28 +65,28 @@ - + ... - + 0 - + Transparency: - + 3 @@ -213,14 +223,14 @@ - + Position - + Qt::Vertical @@ -233,7 +243,7 @@ - + @@ -257,17 +267,7 @@ - - - - 90 - - - Qt::Horizontal - - - - + @@ -280,7 +280,7 @@ - + Qt::Vertical @@ -293,14 +293,14 @@ - + Cover size: - + 32 @@ -326,7 +326,7 @@ - + Delay (ms): @@ -336,7 +336,7 @@ - + 100 @@ -369,6 +369,16 @@ + + + + Disable notifications when another application is in the Full Screen Mode + + + Disable for full screen windows + + + -- cgit v1.2.3-13-gbd6f