diff options
Diffstat (limited to 'plugins/Clist_modern/src/modern_clisttray.cpp')
-rw-r--r-- | plugins/Clist_modern/src/modern_clisttray.cpp | 151 |
1 files changed, 74 insertions, 77 deletions
diff --git a/plugins/Clist_modern/src/modern_clisttray.cpp b/plugins/Clist_modern/src/modern_clisttray.cpp index 181c1cddd2..f0a42bad28 100644 --- a/plugins/Clist_modern/src/modern_clisttray.cpp +++ b/plugins/Clist_modern/src/modern_clisttray.cpp @@ -283,16 +283,85 @@ void DestroyTrayMenu(HMENU hMenu) DestroyMenu(hMenu);
}
-static HMENU BuildTrayMenu()
+/////////////////////////////////////////////////////////////////////////////////////////
+// Tray menu services
+
+HGENMENU hTrayMainMenuItemProxy, hTrayStatusMenuItemProxy, hTrayHideShowMainMenuItem;
+
+static INT_PTR BuildTrayMenu(WPARAM, LPARAM)
{
+ NotifyEventHooks(g_CluiData.hEventPreBuildTrayMenu, 0, 0);
+
ListParam param = { 0 };
param.MenuObjectHandle = hTrayMenuObject;
HMENU hMenu = CreatePopupMenu();
CallService(MO_BUILDMENU, (WPARAM)hMenu, (LPARAM)¶m);
- return hMenu;
+ return (INT_PTR)hMenu;
+}
+
+static INT_PTR AddTrayMenuItem(WPARAM, LPARAM lParam)
+{
+ CLISTMENUITEM *mi = (CLISTMENUITEM*)lParam;
+
+ TMO_MenuItem tmi;
+ if (!pcli->pfnConvertMenu(mi, &tmi))
+ return NULL;
+
+ tmi.ownerdata = mir_strdup(mi->pszService);
+
+ OptParam op;
+ op.Handle = (HANDLE)CallService(MO_ADDNEWMENUITEM, (WPARAM)hTrayMenuObject, (LPARAM)&tmi);
+ op.Setting = OPT_MENUITEMSETUNIQNAME;
+ op.Value = (INT_PTR)mi->pszService;
+ CallService(MO_SETOPTIONSMENUITEM, 0, (LPARAM)&op);
+ return (INT_PTR)op.Handle;
+}
+
+INT_PTR TrayMenuonAddService(WPARAM wParam, LPARAM lParam)
+{
+ MENUITEMINFO *mii = (MENUITEMINFO*)wParam;
+ if (mii == NULL)
+ return 0;
+
+ if (hTrayHideShowMainMenuItem == (HGENMENU)lParam) {
+ mii->fMask |= MIIM_STATE;
+ mii->fState |= MFS_DEFAULT;
+ }
+
+ if (hTrayMainMenuItemProxy == (HGENMENU)lParam) {
+ mii->fMask |= MIIM_SUBMENU;
+ mii->hSubMenu = (HMENU)CallService(MS_CLIST_MENUGETMAIN, 0, 0);
+ }
+
+ if (hTrayStatusMenuItemProxy == (HGENMENU)lParam) {
+ mii->fMask |= MIIM_SUBMENU;
+ mii->hSubMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS, 0, 0);
+ }
+
+ return(TRUE);
+}
+
+// called with:
+// wparam - ownerdata
+// lparam - lparam from winproc
+INT_PTR TrayMenuExecService(WPARAM wParam, LPARAM lParam)
+{
+ if (wParam != 0)
+ CallService((char*)wParam, 0, lParam);
+
+ return 1;
+}
+
+INT_PTR FreeOwnerDataTrayMenu(WPARAM, LPARAM lParam)
+{
+ mir_free((char*)lParam);
+ return 0;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+// Tray event handler
+
INT_PTR cli_TrayIconProcessMessage(WPARAM wParam, LPARAM lParam)
{
MSG *msg = (MSG*)wParam;
@@ -341,7 +410,7 @@ INT_PTR cli_TrayIconProcessMessage(WPARAM wParam, LPARAM lParam) IS_WM_MOUSE_DOWN_IN_TRAY = 1;
}
else if (msg->lParam == WM_RBUTTONUP) {
- HMENU hMenu = BuildTrayMenu();
+ HMENU hMenu = (HMENU)BuildTrayMenu(0, 0);
g_mutex_bOnTrayRightClick = 1;
SetForegroundWindow(msg->hwnd);
@@ -361,80 +430,8 @@ INT_PTR cli_TrayIconProcessMessage(WPARAM wParam, LPARAM lParam) return corecli.pfnTrayIconProcessMessage(wParam, lParam);
}
-//////////////////////////////TRAY MENU/////////////////////////
-
-HGENMENU hTrayMainMenuItemProxy, hTrayStatusMenuItemProxy, hTrayHideShowMainMenuItem;
-
-static INT_PTR BuildTrayMenu(WPARAM, LPARAM)
-{
- NotifyEventHooks(g_CluiData.hEventPreBuildTrayMenu, 0, 0);
-
- ListParam param = { 0 };
- param.MenuObjectHandle = hTrayMenuObject;
-
- HMENU hMenu = CreatePopupMenu();
- CallService(MO_BUILDMENU, (WPARAM)hMenu, (LPARAM)¶m);
- return (INT_PTR)hMenu;
-}
-
-static INT_PTR AddTrayMenuItem(WPARAM, LPARAM lParam)
-{
- CLISTMENUITEM *mi = (CLISTMENUITEM*)lParam;
-
- TMO_MenuItem tmi;
- if (!pcli->pfnConvertMenu(mi, &tmi))
- return NULL;
-
- tmi.ownerdata = mir_strdup(mi->pszService);
-
- OptParam op;
- op.Handle = (HANDLE)CallService(MO_ADDNEWMENUITEM, (WPARAM)hTrayMenuObject, (LPARAM)&tmi);
- op.Setting = OPT_MENUITEMSETUNIQNAME;
- op.Value = (INT_PTR)mi->pszService;
- CallService(MO_SETOPTIONSMENUITEM, 0, (LPARAM)&op);
- return (INT_PTR)op.Handle;
-}
-
-INT_PTR TrayMenuonAddService(WPARAM wParam, LPARAM lParam)
-{
- MENUITEMINFO *mii = (MENUITEMINFO*)wParam;
- if (mii == NULL)
- return 0;
-
- if (hTrayHideShowMainMenuItem == (HGENMENU)lParam) {
- mii->fMask |= MIIM_STATE;
- mii->fState |= MFS_DEFAULT;
- }
-
- if (hTrayMainMenuItemProxy == (HGENMENU)lParam) {
- mii->fMask |= MIIM_SUBMENU;
- mii->hSubMenu = (HMENU)CallService(MS_CLIST_MENUGETMAIN, 0, 0);
- }
-
- if (hTrayStatusMenuItemProxy == (HGENMENU)lParam) {
- mii->fMask |= MIIM_SUBMENU;
- mii->hSubMenu = (HMENU)CallService(MS_CLIST_MENUGETSTATUS, 0, 0);
- }
-
- return(TRUE);
-}
-
-// called with:
-// wparam - ownerdata
-// lparam - lparam from winproc
-INT_PTR TrayMenuExecService(WPARAM wParam, LPARAM lParam)
-{
- if (wParam != 0)
- CallService((char*)wParam, 0, lParam);
-
- return 1;
-}
-
-INT_PTR FreeOwnerDataTrayMenu(WPARAM, LPARAM lParam)
-{
- mir_free((char*)lParam);
- return 0;
-}
+/////////////////////////////////////////////////////////////////////////////////////////
+// Tray module init
void InitTrayMenus(void)
{
|