From 2d0a6c90d6c70a61d1b95a24c450f05ff9deed50 Mon Sep 17 00:00:00 2001 From: marha Date: Wed, 16 Sep 2009 12:44:59 +0000 Subject: Display the number of active clients in the tray icon tooltip. --- xorg-server/hw/xwin/wintrayicon.c | 43 ++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 14 deletions(-) (limited to 'xorg-server/hw/xwin/wintrayicon.c') diff --git a/xorg-server/hw/xwin/wintrayicon.c b/xorg-server/hw/xwin/wintrayicon.c index a813bbfee..b6ffed83f 100644 --- a/xorg-server/hw/xwin/wintrayicon.c +++ b/xorg-server/hw/xwin/wintrayicon.c @@ -36,39 +36,43 @@ #include #include "winprefs.h" +static NOTIFYICONDATA nid; /* * Initialize the tray icon */ void -winInitNotifyIcon (winPrivScreenPtr pScreenPriv) +winInitNotifyIcon (winPrivScreenPtr pScreenPriv, Bool Modify) { winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; - NOTIFYICONDATA nid = {0}; char HostName[256]; - nid.cbSize = sizeof (NOTIFYICONDATA); - nid.hWnd = pScreenPriv->hwndScreen; - nid.uID = pScreenInfo->dwScreen; - nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; - nid.uCallbackMessage = WM_TRAYICON; - nid.hIcon = winTaskbarIcon (); + if (!Modify) + { + nid.cbSize = sizeof (NOTIFYICONDATA); + nid.hWnd = pScreenPriv->hwndScreen; + nid.uID = pScreenInfo->dwScreen; + nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; + nid.uCallbackMessage = WM_TRAYICON; + nid.hIcon = winTaskbarIcon (); + + /* Save handle to the icon so it can be freed later */ + pScreenPriv->hiconNotifyIcon = nid.hIcon; + } - /* Save handle to the icon so it can be freed later */ - pScreenPriv->hiconNotifyIcon = nid.hIcon; - gethostname(HostName,256); /* Set display and screen-specific tooltip text */ snprintf (nid.szTip, sizeof (nid.szTip), - PROJECT_NAME " Server - %s:%s.%d", + PROJECT_NAME " Server - %s:%s.%d - %d clients", HostName, display, - (int) pScreenInfo->dwScreen); + (int) pScreenInfo->dwScreen, + pScreenPriv->iConnectedClients); /* Add the tray icon */ - if (!Shell_NotifyIcon (NIM_ADD, &nid)) + if (!Shell_NotifyIcon ((Modify) ? NIM_MODIFY : NIM_ADD, &nid)) ErrorF ("winInitNotifyIcon - Shell_NotifyIcon Failed\n"); } @@ -123,6 +127,17 @@ winHandleIconMessage (HWND hwnd, UINT message, switch (lParam) { + case WM_MOUSEMOVE: + { + static int PrevNrClients; + int NrClients=GetLiveClients(pScreenPriv); + if (NrClients!=PrevNrClients) + { + PrevNrClients=NrClients; + winInitNotifyIcon (pScreenPriv, TRUE); + } + } + break; case WM_LBUTTONUP: /* Restack and bring all windows to top */ SetForegroundWindow (hwnd); -- cgit v1.2.3