diff options
Diffstat (limited to 'plugins/BossKeyPlus/src')
-rw-r--r-- | plugins/BossKeyPlus/src/BossKey.cpp | 34 | ||||
-rw-r--r-- | plugins/BossKeyPlus/src/BossKeyIdle.cpp | 27 | ||||
-rw-r--r-- | plugins/BossKeyPlus/src/Options.cpp | 27 | ||||
-rw-r--r-- | plugins/BossKeyPlus/src/resource.h | 1 | ||||
-rw-r--r-- | plugins/BossKeyPlus/src/stdafx.h | 40 | ||||
-rw-r--r-- | plugins/BossKeyPlus/src/version.h | 14 |
6 files changed, 56 insertions, 87 deletions
diff --git a/plugins/BossKeyPlus/src/BossKey.cpp b/plugins/BossKeyPlus/src/BossKey.cpp index 1b73a0f61b..97b667d74b 100644 --- a/plugins/BossKeyPlus/src/BossKey.cpp +++ b/plugins/BossKeyPlus/src/BossKey.cpp @@ -436,7 +436,7 @@ INT_PTR BossKeyHideMiranda(WPARAM, LPARAM) // for service :) return 0;
}
-static wchar_t *HokeyVkToName(WORD vkKey)
+static wchar_t* HotkeyVkToName(WORD vkKey)
{
static wchar_t buf[32] = { 0 };
DWORD code = MapVirtualKey(vkKey, 0) << 16;
@@ -472,20 +472,20 @@ static wchar_t *HokeyVkToName(WORD vkKey) return buf;
}
-static wchar_t *GetBossKeyText(void)
+static wchar_t* GetBossKeyText(void)
{
WORD wHotKey = db_get_w(0, "SkinHotKeys", "Hide/Show Miranda", HOTKEYCODE(HOTKEYF_CONTROL, VK_F12));
BYTE key = LOBYTE(wHotKey);
BYTE shift = HIBYTE(wHotKey);
- static wchar_t buf[128] = { 0 };
+ static wchar_t buf[128];
mir_snwprintf(buf, L"%s%s%s%s%s",
(shift & HOTKEYF_CONTROL) ? L"Ctrl + " : L"",
(shift & HOTKEYF_SHIFT) ? L"Shift + " : L"",
(shift & HOTKEYF_ALT) ? L"Alt + " : L"",
(shift & HOTKEYF_EXT) ? L"Win + " : L"",
- HokeyVkToName(key));
+ HotkeyVkToName(key));
return buf;
}
@@ -497,15 +497,13 @@ static IconItem iconList[] = static int GenMenuInit(WPARAM, LPARAM) // Modify menu item text before to show the main menu
{
- if (g_hMenuItem) {
- wchar_t buf[128];
- mir_snwprintf(buf, L"%s [%s]", TranslateT("Hide"), GetBossKeyText());
- Menu_ModifyItem(g_hMenuItem, buf);
- }
+ wchar_t buf[128];
+ mir_snwprintf(buf, L"%s [%s]", TranslateT("Hide"), GetBossKeyText());
+ Menu_ModifyItem(g_hMenuItem, buf);
return 0;
}
-void BossKeyMenuItemInit(void) // Add menu item
+static void BossKeyMenuItemInit(void) // Add menu item
{
CMenuItem mi(&g_plugin);
SET_UID(mi, 0x42428114, 0xfac7, 0x44c2, 0x9a, 0x11, 0x18, 0xbe, 0x81, 0xd4, 0xa9, 0xe3);
@@ -519,13 +517,7 @@ void BossKeyMenuItemInit(void) // Add menu item HookEvent(ME_CLIST_PREBUILDMAINMENU, GenMenuInit);
}
-void BossKeyMenuItemUnInit(void) // Remove menu item
-{
- Menu_RemoveItem(g_hMenuItem);
- g_hMenuItem = nullptr;
-}
-
-void RegisterCoreHotKeys(void)
+static void RegisterCoreHotKeys(void)
{
HOTKEYDESC hotkey = {};
hotkey.pszName = "Hide/Show Miranda";
@@ -631,8 +623,8 @@ static int MirandaLoaded(WPARAM, LPARAM) if (hDwmApi)
dwmIsCompositionEnabled = (PFNDwmIsCompositionEnabled)GetProcAddress(hDwmApi, "DwmIsCompositionEnabled");
}
- if (g_wMaskAdv & OPT_MENUITEM)
- BossKeyMenuItemInit();
+
+ BossKeyMenuItemInit();
// Register token for variables plugin
if (ServiceExists(MS_VARS_REGISTERTOKEN)) {
@@ -648,7 +640,6 @@ static int MirandaLoaded(WPARAM, LPARAM) }
EnumProtos(0, 0);
- InitIdleTimer();
if (g_bOldSetting && !(g_wMaskAdv & OPT_RESTORE)) // Restore settings if Miranda was crushed or killed in hidden mode and "Restore hiding on startup after failure" option is disabled
RestoreOldSettings();
@@ -656,6 +647,7 @@ static int MirandaLoaded(WPARAM, LPARAM) if ((g_wMaskAdv & OPT_HIDEONSTART) || (g_wMaskAdv & OPT_RESTORE && g_bOldSetting))
BossKeyHideMiranda(0, 0);
+ g_plugin.impl.m_timer.Start(2000);
return 0;
}
@@ -688,7 +680,7 @@ int CMPlugin::Load() int CMPlugin::Unload()
{
- UninitIdleTimer();
+ impl.m_timer.Stop();
if (g_hWinHook != nullptr)
UnhookWinEvent(g_hWinHook);
diff --git a/plugins/BossKeyPlus/src/BossKeyIdle.cpp b/plugins/BossKeyPlus/src/BossKeyIdle.cpp index b78222cb72..19d07b5119 100644 --- a/plugins/BossKeyPlus/src/BossKeyIdle.cpp +++ b/plugins/BossKeyPlus/src/BossKeyIdle.cpp @@ -24,40 +24,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h"
-POINT mousepos;
-UINT_PTR hTimer;
-UINT mouseidle, minutes;
-
-VOID CALLBACK IdleTimer(HWND hwnd, UINT umsg, UINT idEvent, DWORD dwTime);
-
static bool IsUserIdle()
{
+ UINT dwPeriod = g_plugin.getByte("time", 10) * 60 * 1000;
+
if (g_wMaskAdv & OPT_HIDEIFMIRIDLE) {
DWORD dwTick = Miranda_GetIdle();
- return GetTickCount() - dwTick > (minutes * 60 * 1000);
+ return GetTickCount() - dwTick > dwPeriod;
}
LASTINPUTINFO ii = { sizeof(ii) };
if (GetLastInputInfo(&ii))
- return GetTickCount() - ii.dwTime > (minutes * 60 * 1000);
+ return GetTickCount() - ii.dwTime > dwPeriod;
return FALSE;
}
-VOID CALLBACK IdleTimer(HWND, UINT, UINT_PTR idEvent, DWORD)
+void CMPlugin::Impl::onTimer(CTimer *)
{
- if (hTimer == idEvent && !g_bWindowHidden && ((g_wMaskAdv & (OPT_HIDEIFWINIDLE | OPT_HIDEIFMIRIDLE) && IsUserIdle()) ||
+ if (!g_bWindowHidden && ((g_wMaskAdv & (OPT_HIDEIFWINIDLE | OPT_HIDEIFMIRIDLE) && IsUserIdle()) ||
(g_wMaskAdv & OPT_HIDEIFSCRSVR) && IsScreenSaverRunning()))
BossKeyHideMiranda(0, 0);
}
-
-void InitIdleTimer()
-{
- minutes = g_plugin.getByte("time", 10);
- hTimer = SetTimer(nullptr, 0, 2000, IdleTimer);
-}
-
-void UninitIdleTimer()
-{
- KillTimer(nullptr, hTimer);
-}
diff --git a/plugins/BossKeyPlus/src/Options.cpp b/plugins/BossKeyPlus/src/Options.cpp index 006354b216..febde01740 100644 --- a/plugins/BossKeyPlus/src/Options.cpp +++ b/plugins/BossKeyPlus/src/Options.cpp @@ -21,7 +21,6 @@ bool g_fOptionsOpen;
bool g_fReqRass;
-extern HGENMENU g_hMenuItem;
class COptMainDlg : public CDlgBase
{
@@ -208,7 +207,7 @@ public: class COptAdvDlg : public CDlgBase
{
- CCtrlCheck m_chkHideIfLock, m_chkHideIfScrSvr, m_chkHideIfWinIdle, m_chkHideIfMirIdle, m_chkHideOnStart, m_chkMenuItem, m_chkRestore;
+ CCtrlCheck m_chkHideIfLock, m_chkHideIfScrSvr, m_chkHideIfWinIdle, m_chkHideIfMirIdle, m_chkHideOnStart, m_chkRestore;
CCtrlEdit m_edtTime;
CCtrlSpin m_spnTime;
@@ -222,7 +221,6 @@ public: m_edtTime(this, IDC_MAINOPT_TIME),
m_spnTime(this, IDC_MAINOPT_SPIN_TIME, 99, 1),
m_chkHideOnStart(this, IDC_MAINOPT_HIDEONSTART),
- m_chkMenuItem(this, IDC_MAINOPT_MENUITEM),
m_chkRestore(this, IDC_MAINOPT_RESTORE)
{
m_chkHideIfWinIdle.OnChange = Callback(this, &COptAdvDlg::OnHideIfWinIdleChange);
@@ -233,13 +231,9 @@ public: {
g_fOptionsOpen = true;
- minutes = g_plugin.getByte("time", 10);
- wchar_t szMinutes[4] = { 0 };
- _itow(minutes, szMinutes, 10);
m_edtTime.SendMsg(EM_LIMITTEXT, 2, 0);
- m_edtTime.SetText(szMinutes);
+ m_edtTime.SetInt(g_plugin.getByte("time", 10));
m_chkHideIfLock.SetState(g_wMaskAdv & OPT_HIDEIFLOCK);
- m_chkMenuItem.SetState(g_wMaskAdv & OPT_MENUITEM);
m_chkHideIfWinIdle.SetState(g_wMaskAdv & OPT_HIDEIFWINIDLE);
m_chkHideIfMirIdle.SetState(g_wMaskAdv & OPT_HIDEIFMIRIDLE);
m_chkHideIfScrSvr.SetState(g_wMaskAdv & OPT_HIDEIFSCRSVR);
@@ -264,17 +258,9 @@ public: if (m_chkRestore.GetState())
wMaskAdv |= OPT_RESTORE;
- if (m_chkMenuItem.GetState()) {
- if (g_hMenuItem == nullptr)
- BossKeyMenuItemInit();
- wMaskAdv |= OPT_MENUITEM;
- }
- else if (g_hMenuItem != nullptr)
- BossKeyMenuItemUnInit();
-
wchar_t szMinutes[4] = { 0 };
m_edtTime.GetText(szMinutes, _countof(szMinutes));
- minutes = _wtoi(szMinutes);
+ UINT minutes = _wtoi(szMinutes);
if (minutes < 1)
minutes = 1;
g_plugin.setByte("time", minutes);
@@ -304,15 +290,16 @@ public: int OptsDlgInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE optDi = {};
- optDi.pDialog = new COptMainDlg;
+ optDi.flags = ODPF_BOLDGROUPS;
optDi.szTitle.a = LPGEN("BossKey");
optDi.szGroup.a = LPGEN("Events");
+
optDi.szTab.a = LPGEN("Main");
- optDi.flags = ODPF_BOLDGROUPS;
+ optDi.pDialog = new COptMainDlg();
g_plugin.addOptions(wParam, &optDi);
optDi.szTab.a = LPGEN("Advanced");
- optDi.pDialog = new COptAdvDlg;
+ optDi.pDialog = new COptAdvDlg();
g_plugin.addOptions(wParam, &optDi);
return 0;
}
diff --git a/plugins/BossKeyPlus/src/resource.h b/plugins/BossKeyPlus/src/resource.h index 4e8c625562..b13300bb03 100644 --- a/plugins/BossKeyPlus/src/resource.h +++ b/plugins/BossKeyPlus/src/resource.h @@ -27,7 +27,6 @@ #define IDC_MAINOPT_HIDEIFSCRSVR 1027
#define IDC_MAINOPT_TIME 1028
#define IDC_MAINOPT_SPIN_TIME 1029
-#define IDC_MAINOPT_MENUITEM 1030
#define IDC_MAINOPT_HIDEONSTART 1031
#define IDC_MAINOPT_RESTORE 1032
diff --git a/plugins/BossKeyPlus/src/stdafx.h b/plugins/BossKeyPlus/src/stdafx.h index 75f6861180..faf4c00535 100644 --- a/plugins/BossKeyPlus/src/stdafx.h +++ b/plugins/BossKeyPlus/src/stdafx.h @@ -52,6 +52,18 @@ struct CMPlugin : public PLUGIN<CMPlugin>
{
+ struct Impl
+ {
+ Impl() : m_timer(Miranda_GetSystemWindow(), (UINT_PTR)this)
+ {
+ m_timer.OnEvent = Callback(this, &Impl::onTimer);
+ }
+
+ CTimer m_timer;
+ void onTimer(CTimer *);
+ }
+ impl;
+
CMPlugin();
int Load() override;
@@ -67,19 +79,18 @@ struct CMPlugin : public PLUGIN<CMPlugin> #define OLD_FLTCONT 4
#define OLD_WASHIDDEN 128
-#define OPT_SETONLINEBACK 1
-#define OPT_CHANGESTATUS 2
-#define OPT_DISABLESNDS 8
-#define OPT_REQPASS 16
-#define OPT_ONLINEONLY 32
-#define OPT_USEDEFMSG 128
-#define OPT_TRAYICON 256
+#define OPT_SETONLINEBACK 1
+#define OPT_CHANGESTATUS 2
+#define OPT_DISABLESNDS 8
+#define OPT_REQPASS 16
+#define OPT_ONLINEONLY 32
+#define OPT_USEDEFMSG 128
+#define OPT_TRAYICON 256
#define OPT_HIDEIFLOCK 1
#define OPT_HIDEIFWINIDLE 2
#define OPT_HIDEIFMIRIDLE 4
#define OPT_HIDEIFSCRSVR 8
-#define OPT_MENUITEM 16
#define OPT_HIDEONSTART 32
#define OPT_RESTORE 64
@@ -90,22 +101,17 @@ const unsigned STATUS_ARR_TO_ID[] = { ID_STATUS_OFFLINE, ID_STATUS_ONLINE, ID_ST extern bool g_fOptionsOpen; // options dialog is open. be sure not to hide anything while we're there.
extern WORD g_wMask, g_wMaskAdv;
extern bool g_bWindowHidden;
-extern UINT minutes;
int OptsDlgInit(WPARAM wParam, LPARAM lParam);
INT_PTR BossKeyHideMiranda(WPARAM wParam, LPARAM lParam);
-void BossKeyMenuItemInit(void);
-void BossKeyMenuItemUnInit(void);
-static wchar_t *GetBossKeyText(void);
-void InitIdleTimer(void);
-void UninitIdleTimer(void);
+
wchar_t* GetDefStatusMsg(unsigned uMode, const char* szProto);
// I never really liked STL's vector... hmm this is nicer anyway, more flexible
-typedef struct HWND_ITEM_TYPE
+struct HWND_ITEM
{
HWND hWnd;
- HWND_ITEM_TYPE *next;
-} HWND_ITEM;
+ HWND_ITEM *next;
+};
typedef HRESULT(WINAPI *PFNDwmIsCompositionEnabled)(BOOL *);
diff --git a/plugins/BossKeyPlus/src/version.h b/plugins/BossKeyPlus/src/version.h index 8bae3d9f5d..40e0700b03 100644 --- a/plugins/BossKeyPlus/src/version.h +++ b/plugins/BossKeyPlus/src/version.h @@ -1,13 +1,13 @@ -#define __MAJOR_VERSION 0
-#define __MINOR_VERSION 5
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 5
#define __RELEASE_NUM 0
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#include <stdver.h>
#define __PLUGIN_NAME "BossKey+"
#define __FILENAME "BossKey.dll"
-#define __DESCRIPTION "Anti-Boss plugin. Makes your Miranda NG hidden or password-protected."
-#define __AUTHOR "Goblineye Entertainment, Billy_Bons"
-#define __AUTHORWEB "https://miranda-ng.org/p/BossKey/"
-#define __COPYRIGHT "© 2002-2003 Goblineye Entertainment, 2007-2010 Billy_Bons"
+#define __DESCRIPTION "Anti-Boss plugin. Makes your Miranda NG hidden or password-protected."
+#define __AUTHOR "Goblineye Entertainment, Billy_Bons"
+#define __AUTHORWEB "https://miranda-ng.org/p/BossKey/"
+#define __COPYRIGHT "© 2002-2003 Goblineye Entertainment, 2007-2010 Billy_Bons"
|