diff options
| author | 2010-05-31 04:18:55 +0000 | |
|---|---|---|
| committer | 2010-05-31 04:18:55 +0000 | |
| commit | 16f54c48caccd2e9b82711b893401f1a436cdee1 (patch) | |
| tree | 0cdae642d7e78ff329988d554da1cf872021bfa8 /src | |
| parent | Fix for bug #488 (diff) | |
| download | KVIrc-16f54c48caccd2e9b82711b893401f1a436cdee1.tar.gz KVIrc-16f54c48caccd2e9b82711b893401f1a436cdee1.tar.bz2 KVIrc-16f54c48caccd2e9b82711b893401f1a436cdee1.zip | |
Fix for #445 on KDE and windows
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@4403 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvirc/kernel/kvi_options.cpp | 3 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_options.h | 3 | ||||
| -rw-r--r-- | src/modules/notifier/notifierwindow.cpp | 63 | ||||
| -rw-r--r-- | src/modules/options/optw_notifier.cpp | 45 |
4 files changed, 106 insertions, 8 deletions
diff --git a/src/kvirc/kernel/kvi_options.cpp b/src/kvirc/kernel/kvi_options.cpp index 147726153..4ca27ad35 100644 --- a/src/kvirc/kernel/kvi_options.cpp +++ b/src/kvirc/kernel/kvi_options.cpp @@ -324,7 +324,8 @@ KviBoolOption g_boolOptionsTable[KVI_NUM_BOOL_OPTIONS]= BOOL_OPTION("DisableQuietBanListRequestOnJoin",true,KviOption_sectFlagConnection), BOOL_OPTION("UseSaslIfAvailable",true,KviOption_sectFlagConnection), BOOL_OPTION("FrameIsMaximized",false,KviOption_sectFlagGeometry), - BOOL_OPTION("PrependNickColorInfoToRealname",true,KviOption_sectFlagConnection) + BOOL_OPTION("PrependNickColorInfoToRealname",true,KviOption_sectFlagConnection), + BOOL_OPTION("DontShowNotifierIfActiveWindowIsFullScreen",false,KviOption_sectFlagFrame) }; #define STRING_OPTION(_txt,_val,_flags) KviStringOption(KVI_STRING_OPTIONS_PREFIX _txt,_val,_flags) diff --git a/src/kvirc/kernel/kvi_options.h b/src/kvirc/kernel/kvi_options.h index e317911e0..9d5efc058 100644 --- a/src/kvirc/kernel/kvi_options.h +++ b/src/kvirc/kernel/kvi_options.h @@ -333,8 +333,9 @@ DECLARE_OPTION_STRUCT(KviStringListOption,QStringList) #define KviOption_boolUseSaslIfAvailable 239 #define KviOption_boolFrameIsMaximized 240 /* internal */ #define KviOption_boolPrependNickColorInfoToRealname 241 +#define KviOption_boolDontShowNotifierIfActiveWindowIsFullScreen 242 /* notifier */ -#define KVI_NUM_BOOL_OPTIONS 242 +#define KVI_NUM_BOOL_OPTIONS 243 #define KVI_STRING_OPTIONS_PREFIX "string" diff --git a/src/modules/notifier/notifierwindow.cpp b/src/modules/notifier/notifierwindow.cpp index 10a039cca..fb7ab3f8a 100644 --- a/src/modules/notifier/notifierwindow.cpp +++ b/src/modules/notifier/notifierwindow.cpp @@ -257,14 +257,75 @@ void KviNotifierWindow::stopAutoHideTimer() m_pProgressBar->setValue(0); } +// FIXME: The code for detecting fullscreen window does NOT take into account multi-screen setups. +// We also lack the code for MacOSX and Qt-only-X11 compilation. + +#if COMPILE_KDE_SUPPORT + + #include <kwindowsystem.h> + + static bool active_window_is_full_screen() + { + WId activeId = KWindowSystem::activeWindow(); + KWindowInfo wi = KWindowSystem::windowInfo(activeId, NET::WMState); + return (wi.valid() && wi.hasState(NET::FullScreen)); + } + +#else //!COMPILE_KDE_SUPPORT + #if defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) + + #include <windows.h> + + static bool active_window_is_full_screen() + { + HWND hForeground = ::GetForegroundWindow(); + if(!hForeground) + return false; + + HWND hDesktop = ::GetDesktopWindow(); + if(hForeground == hDesktop) + return false; + + HWND hShell = ::GetShellWindow(); + if(hForeground == hShell) + return false; + + RECT rct; + ::GetWindowRect(hForeground,&rct); + + if((rc.right - rc.left) < GetSystemMetrics(SM_CXSCREEN)) + return false; + + if((rc.bottom - rc.top) < GetSystemMetrics(SM_CYSCREEN)) + return false; + + return true; + } + + #endif //COMPILE_ON_WINDOWS || COMPILE_ON_MINGW +#endif //!COMPILE_KDE_SUPPORT + + void KviNotifierWindow::doShow(bool bDoAnimate) { - if(!KVI_OPTION_BOOL(KviOption_boolEnableNotifier))return; + if(!KVI_OPTION_BOOL(KviOption_boolEnableNotifier)) + return; kvi_time_t tNow = kvi_unixTime(); if(g_tNotifierDisabledUntil > tNow)return; g_tNotifierDisabledUntil = 0; +#if defined(COMPILE_KDE_SUPPORT) || defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) + + if(KVI_OPTION_BOOL(KviOption_boolDontShowNotifierIfActiveWindowIsFullScreen)) + { + // check if the active window is full screen + if(active_window_is_full_screen()) + return; + } + +#endif //COMPILE_KDE_SUPPORT || COMPILE_ON_WINDOWS || COMPILE_ON_MINGW + switch(m_eState) { case Showing: diff --git a/src/modules/options/optw_notifier.cpp b/src/modules/options/optw_notifier.cpp index 9ea49a25e..bfd6660d6 100644 --- a/src/modules/options/optw_notifier.cpp +++ b/src/modules/options/optw_notifier.cpp @@ -139,7 +139,9 @@ KviNotifierOptionsWidget::KviNotifierOptionsWidget(QWidget * parent) createLayout(); - KviBoolSelector * b = addBoolSelector(0,0,0,0,__tr2qs_ctx("Enable the notifier","options"),KviOption_boolEnableNotifier); + int iRow = 0; + + KviBoolSelector * b = addBoolSelector(0,iRow,0,iRow,__tr2qs_ctx("Enable the notifier","options"),KviOption_boolEnableNotifier); QString tip = "<center>"; tip += __tr2qs_ctx("This is an option for the impatient: it allows to forcibly and permanently disable " \ "the notifier window. Please note that if this option is activated then " \ @@ -148,10 +150,43 @@ KviNotifierOptionsWidget::KviNotifierOptionsWidget(QWidget * parent) "will make all the /notifier.* commands fail silently.","options"); tip += "</center>"; mergeTip(b,tip); - addBoolSelector(0,1,0,1,__tr2qs_ctx("Enable notifier window flashing","options"),KviOption_boolNotifierFlashing); - KviBoolSelector * b2 = addBoolSelector(0,2,0,2,__tr2qs_ctx("Enable notifier window fade effect","options"),KviOption_boolNotifierFading); - KviTalGroupBox *g = addGroupBox(0,3,0,3,Qt::Horizontal,__tr2qs_ctx("Advanced configuration","options")); + iRow++; + +#if defined(COMPILE_KDE_SUPPORT) || defined(COMPILE_ON_WINDOWS) || defined(COMPILE_ON_MINGW) + + KviBoolSelector * b2 = addBoolSelector(0,iRow,0,iRow,__tr2qs_ctx("Don't show notifier when there is an active fullscreen window","options"),KviOption_boolDontShowNotifierIfActiveWindowIsFullScreen); + + tip = "<center>"; + tip += __tr2qs_ctx("This option stops the notifier from being displayed when there is an active fullscreen window. " \ + "This is useful for gaming sessions where you may be distracted by the notifier or it may even switch " \ + "your game from fullscreen to window mode.","options"); + tip += "</center>"; + mergeTip(b2,tip); + + b2->setEnabled(KVI_OPTION_BOOL(KviOption_boolEnableNotifier)); + QObject::connect(b,SIGNAL(toggled(bool)),b2,SLOT(setEnabled(bool))); + + iRow++; + +#endif //COMPILE_KDE_SUPPORT || COMPILE_ON_WINDOWS || COMPILE_ON_MINGW + + b2 = addBoolSelector(0,iRow,0,iRow,__tr2qs_ctx("Enable notifier window flashing","options"),KviOption_boolNotifierFlashing); + + b2->setEnabled(KVI_OPTION_BOOL(KviOption_boolEnableNotifier)); + QObject::connect(b,SIGNAL(toggled(bool)),b2,SLOT(setEnabled(bool))); + + + iRow++; + + b2 = addBoolSelector(0,iRow,0,iRow,__tr2qs_ctx("Enable notifier window fade effect","options"),KviOption_boolNotifierFading); + + b2->setEnabled(KVI_OPTION_BOOL(KviOption_boolEnableNotifier)); + QObject::connect(b,SIGNAL(toggled(bool)),b2,SLOT(setEnabled(bool))); + + iRow++; + + KviTalGroupBox *g = addGroupBox(0,iRow,0,iRow,Qt::Horizontal,__tr2qs_ctx("Advanced configuration","options")); connect(b,SIGNAL(toggled(bool)),g,SLOT(setEnabled(bool))); connect(b, @@ -175,7 +210,7 @@ KviNotifierOptionsWidget::KviNotifierOptionsWidget(QWidget * parent) 0,100,40,KVI_OPTION_BOOL(KviOption_boolNotifierFading)), SLOT(setEnabled(bool))); - addRowSpacer(0,4,0,4); + addRowSpacer(0,iRow,0,iRow); } KviNotifierOptionsWidget::~KviNotifierOptionsWidget() |
