From 355dca31c1de6294f8d4136cfbcb8fc0d4c38247 Mon Sep 17 00:00:00 2001 From: Dimitriy Ryazantcev Date: Sun, 20 May 2012 00:03:51 +0300 Subject: [PATCH] Kinotify: added check whether the current window is LeechCraft window Signed-off-by: Dimitriy Ryazantcev --- src/plugins/kinotify/fswinwatcher.h | 4 ++- src/plugins/kinotify/fswinwatcher_win.cpp | 30 ++++++++++++++++++---------- src/plugins/kinotify/fswinwatcher_x11.cpp | 4 +- src/plugins/kinotify/kinotify.cpp | 2 +- 4 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/plugins/kinotify/fswinwatcher.h b/src/plugins/kinotify/fswinwatcher.h index f573265..26bc79c 100644 --- a/src/plugins/kinotify/fswinwatcher.h +++ b/src/plugins/kinotify/fswinwatcher.h @@ -19,6 +19,7 @@ #pragma once #include +#include namespace LeechCraft { @@ -26,8 +27,9 @@ namespace Kinotify { class FSWinWatcher : public QObject { + ICoreProxy_ptr Proxy_; public: - FSWinWatcher (QObject* = 0); + FSWinWatcher (ICoreProxy_ptr, QObject* = 0); bool IsCurrentFS (); }; diff --git a/src/plugins/kinotify/fswinwatcher_win.cpp b/src/plugins/kinotify/fswinwatcher_win.cpp index 3768be4..d630703 100644 --- a/src/plugins/kinotify/fswinwatcher_win.cpp +++ b/src/plugins/kinotify/fswinwatcher_win.cpp @@ -16,15 +16,17 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . **********************************************************************/ -#include + #include "fswinwatcher.h" +#include +#include namespace LeechCraft { namespace Kinotify { - FSWinWatcher::FSWinWatcher (QObject *parent) - : QObject (parent) + FSWinWatcher::FSWinWatcher (ICoreProxy_ptr proxy, QObject *parent) + : Proxy_ (proxy), QObject (parent) { } @@ -34,15 +36,21 @@ namespace Kinotify if (hWnd) { HMONITOR monitor = MonitorFromWindow (hWnd, MONITOR_DEFAULTTONULL); - MONITORINFO lpmi; - lpmi.cbSize = sizeof(lpmi); - if (GetMonitorInfo (monitor, &lpmi)) + if (monitor) { - RECT monitorRect = lpmi.rcMonitor; - RECT windowRect; - GetWindowRect (hWnd, &windowRect); - if (EqualRect (&windowRect, &monitorRect)) - return true; + MONITORINFO lpmi; + lpmi.cbSize = sizeof (lpmi); + if (GetMonitorInfo (monitor, &lpmi)) + { + RECT monitorRect = lpmi.rcMonitor; + RECT windowRect; + GetWindowRect (hWnd, &windowRect); + if (EqualRect (&windowRect, &monitorRect)) + { + if(Proxy_->GetMainWindow ()->effectiveWinId () != hWnd) + return true; + } + } } } return false; diff --git a/src/plugins/kinotify/fswinwatcher_x11.cpp b/src/plugins/kinotify/fswinwatcher_x11.cpp index 7c79ef3..ede0cd7 100644 --- a/src/plugins/kinotify/fswinwatcher_x11.cpp +++ b/src/plugins/kinotify/fswinwatcher_x11.cpp @@ -22,8 +22,8 @@ namespace LeechCraft { namespace Kinotify { - FSWinWatcher::FSWinWatcher (QObject *parent) - : QObject (parent) + FSWinWatcher::FSWinWatcher (ICoreProxy_ptr proxy, QObject *parent) + : Proxy_ (proxy), QObject (parent) { } diff --git a/src/plugins/kinotify/kinotify.cpp b/src/plugins/kinotify/kinotify.cpp index 015d042..8fe2040 100644 --- a/src/plugins/kinotify/kinotify.cpp +++ b/src/plugins/kinotify/kinotify.cpp @@ -52,7 +52,7 @@ namespace Kinotify SettingsDialog_->SetDataSource ("NotificatorStyle", ThemeLoader_->GetSubElemModel ()); - FSWinWatcher_.reset (new FSWinWatcher); + FSWinWatcher_.reset (new FSWinWatcher (Proxy_)); } void Plugin::SecondInit () -- 1.7.8.msysgit.0