Combine title and message in tray icon tip text

Also change scope of tip_msgi[] to local

Co-authored-by: Lev Stipakov <lstipakov@gmail.com>
Signed-off-by: Selva Nair <selva.nair@gmail.com>
pull/658/merge
Selva Nair 10 months ago
parent 0c9ae87e0f
commit 264d025bc6

@ -50,7 +50,6 @@ HBITMAP hbmpConnecting;
NOTIFYICONDATA ni; NOTIFYICONDATA ni;
HWND traytip; /* handle of tooltip window for tray icon */ HWND traytip; /* handle of tooltip window for tray icon */
TOOLINFO ti; /* global tool info structure for tool tip of tray icon*/ TOOLINFO ti; /* global tool info structure for tool tip of tray icon*/
WCHAR tip_msg[500]; /* global buffer for tray tip message */
extern options_t o; extern options_t o;
@ -515,9 +514,8 @@ ShowTrayIcon()
ti.uId = (UINT_PTR) traytip; ti.uId = (UINT_PTR) traytip;
ti.uFlags = TTF_ABSOLUTE|TTF_TRACK|TTF_IDISHWND; ti.uFlags = TTF_ABSOLUTE|TTF_TRACK|TTF_IDISHWND;
ti.hwnd = o.hWnd; ti.hwnd = o.hWnd;
ti.lpszText = L" "; ti.lpszText = _T(PACKAGE_NAME);
SendMessage(traytip, TTM_ADDTOOL, 0, (LPARAM)&ti); SendMessage(traytip, TTM_ADDTOOL, 0, (LPARAM)&ti);
SendMessage(traytip, TTM_SETTITLE, TTI_NONE, (LPARAM) _T(PACKAGE_NAME));
SendMessage(traytip, TTM_SETMAXTIPWIDTH, 0, (LPARAM) cx); SendMessage(traytip, TTM_SETMAXTIPWIDTH, 0, (LPARAM) cx);
} }
} }
@ -525,6 +523,7 @@ ShowTrayIcon()
void void
SetTrayIcon(conn_state_t state) SetTrayIcon(conn_state_t state)
{ {
WCHAR tip_msg[500];
TCHAR msg_connected[100]; TCHAR msg_connected[100];
TCHAR msg_connecting[100]; TCHAR msg_connecting[100];
BOOL first_conn; BOOL first_conn;
@ -534,7 +533,7 @@ SetTrayIcon(conn_state_t state)
_tcsncpy(msg_connected, LoadLocalizedString(IDS_TIP_CONNECTED), _countof(msg_connected)); _tcsncpy(msg_connected, LoadLocalizedString(IDS_TIP_CONNECTED), _countof(msg_connected));
_tcsncpy(msg_connecting, LoadLocalizedString(IDS_TIP_CONNECTING), _countof(msg_connecting)); _tcsncpy(msg_connecting, LoadLocalizedString(IDS_TIP_CONNECTING), _countof(msg_connecting));
tip_msg[0] = L'\0'; wcsncpy_s(tip_msg, _countof(tip_msg), _T(PACKAGE_NAME), _TRUNCATE);
first_conn = TRUE; first_conn = TRUE;
for (connection_t *c = o.chead; c; c = c->next) for (connection_t *c = o.chead; c; c = c->next)
{ {
@ -605,17 +604,12 @@ SetTrayIcon(conn_state_t state)
if (traytip) if (traytip)
{ {
/* Set msg as the tool tip text -- skip the leading "\n" */ ti.lpszText = tip_msg;
WCHAR *msgp = tip_msg;
msgp += (msgp[0] == L'\n') ? 1 : 0;
/* tool tip window needs a non-empty text to show */
ti.lpszText = wcslen(msgp) ? msgp : L" ";
SendMessage(traytip, TTM_UPDATETIPTEXT, 0, (LPARAM) &ti); SendMessage(traytip, TTM_UPDATETIPTEXT, 0, (LPARAM) &ti);
} }
else else
{ {
wcsncpy_s(ni.szTip, _countof(ni.szTip), _T(PACKAGE_NAME), _TRUNCATE); wcsncpy_s(ni.szTip, _countof(ni.szTip), tip_msg, _TRUNCATE);
wcsncat_s(ni.szTip, _countof(ni.szTip), tip_msg, _TRUNCATE);
ni.uFlags |= NIF_TIP; ni.uFlags |= NIF_TIP;
} }

Loading…
Cancel
Save