From d1756f068e59f435597245d2a831a8aa97f7e198 Mon Sep 17 00:00:00 2001 From: Selva Nair Date: Tue, 13 Feb 2024 13:39:22 -0500 Subject: [PATCH] Position tray tooltip above the taskbar Use Shell_NotifyGetRect to find the icon location and place the tip window a fixed distance above/below it. It appears GUID_NULL used for above is not pulled in by shellapi.h. Define locally when absent. Also add TTF_RTLREADING for RTL languages. How to right justify as well in this case is unclear. Signed-off-by: Selva Nair --- tray.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tray.c b/tray.c index bb45937..f2acc98 100644 --- a/tray.c +++ b/tray.c @@ -39,6 +39,11 @@ #include "localization.h" #include "misc.h" +#ifndef GUID_NULL +#include +DEFINE_GUID(GUID_NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +#endif + /* Popup Menus */ HMENU hMenu; HMENU *hMenuConn; @@ -437,9 +442,12 @@ OnNotifyTray(LPARAM lParam) case NIN_POPUPOPEN: if (traytip) { - GetCursorPos(&pt); + NOTIFYICONIDENTIFIER nid = {.cbSize = sizeof(nid), .hWnd = o.hWnd, + .uID = HIWORD(lParam), .guidItem = GUID_NULL}; + RECT r = {0}; + Shell_NotifyIconGetRect(&nid, &r); SendMessageW(traytip, TTM_TRACKACTIVATE, (WPARAM)TRUE, (LPARAM) &ti); - PositionTrayToolTip(pt.x, pt.y); /* taking position from wParam do snot work on Win11! */ + PositionTrayToolTip((r.left+r.right)/2, r.top); } break; @@ -513,6 +521,10 @@ ShowTrayIcon() ti.cbSize = sizeof(ti); ti.uId = (UINT_PTR) traytip; ti.uFlags = TTF_ABSOLUTE|TTF_TRACK|TTF_IDISHWND; + if (LangFlowDirection() == 1) + { + ti.uFlags |= TTF_RTLREADING; + } ti.hwnd = o.hWnd; ti.lpszText = _T(PACKAGE_NAME); SendMessage(traytip, TTM_ADDTOOL, 0, (LPARAM)&ti);