Skip to content

Commit

Permalink
Combine title and message in tray icon tip text
Browse files Browse the repository at this point in the history
Co-authored-by: Lev Stipakov <[email protected]>
Signed-off-by: Selva Nair <[email protected]>
  • Loading branch information
selvanair and lstipakov committed Feb 13, 2024
1 parent 22839ea commit 160754e
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions tray.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,8 @@ ShowTrayIcon()
ti.uId = (UINT_PTR) traytip;
ti.uFlags = TTF_ABSOLUTE|TTF_TRACK|TTF_IDISHWND;
ti.hwnd = o.hWnd;
ti.lpszText = L" ";
ti.lpszText = _T(PACKAGE_NAME);
SendMessage(traytip, TTM_ADDTOOL, 0, (LPARAM)&ti);
SendMessage(traytip, TTM_SETTITLE, TTI_NONE, (LPARAM) _T(PACKAGE_NAME));
SendMessage(traytip, TTM_SETMAXTIPWIDTH, 0, (LPARAM) cx);
}
}
Expand All @@ -534,7 +533,7 @@ SetTrayIcon(conn_state_t state)
_tcsncpy(msg_connected, LoadLocalizedString(IDS_TIP_CONNECTED), _countof(msg_connected));
_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;
for (connection_t *c = o.chead; c; c = c->next)
{
Expand Down Expand Up @@ -605,17 +604,12 @@ SetTrayIcon(conn_state_t state)

if (traytip)
{
/* Set msg as the tool tip text -- skip the leading "\n" */
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" ";
ti.lpszText = tip_msg;
SendMessage(traytip, TTM_UPDATETIPTEXT, 0, (LPARAM) &ti);
}
else
{
wcsncpy_s(ni.szTip, _countof(ni.szTip), _T(PACKAGE_NAME), _TRUNCATE);
wcsncat_s(ni.szTip, _countof(ni.szTip), tip_msg, _TRUNCATE);
wcsncpy_s(ni.szTip, _countof(ni.szTip), tip_msg, _TRUNCATE);
ni.uFlags |= NIF_TIP;
}

Expand Down

0 comments on commit 160754e

Please sign in to comment.