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 +++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 4 deletions(-) (limited to 'src/plugins/General/notifier/notifier.cpp') 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 -- cgit v1.2.3-13-gbd6f