https://git.reactos.org/?p=reactos.git;a=commitdiff;h=2baafa61c6cd9908dca8dfa3c12c94f78cafd056

commit 2baafa61c6cd9908dca8dfa3c12c94f78cafd056
Author:     Eric Kohl <[email protected]>
AuthorDate: Wed Feb 28 20:29:29 2018 +0100
Commit:     Eric Kohl <[email protected]>
CommitDate: Wed Feb 28 20:29:29 2018 +0100

    [STOBJECT] Use timers to distinguish between single and double clicks
    - Volume, Power and Hotplug icon: Use timers to distinguish between single 
and double clicks.
    - Volume icon: Show the tray volume dialog on a single click.
---
 dll/shellext/stobject/csystray.cpp |  6 +++++-
 dll/shellext/stobject/hotplug.cpp  | 11 ++++++++++-
 dll/shellext/stobject/power.cpp    | 11 ++++++++++-
 dll/shellext/stobject/volume.cpp   | 20 ++++++++++++++------
 4 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/dll/shellext/stobject/csystray.cpp 
b/dll/shellext/stobject/csystray.cpp
index d1e51c116e..d73e67e55d 100644
--- a/dll/shellext/stobject/csystray.cpp
+++ b/dll/shellext/stobject/csystray.cpp
@@ -241,8 +241,12 @@ BOOL CSysTray::ProcessWindowMessage(HWND hWnd, UINT uMsg, 
WPARAM wParam, LPARAM
         return TRUE;
 
     case WM_TIMER:
-        UpdateIcons();
+        if (wParam == 1)
+            UpdateIcons();
+        else
+            ProcessIconMessage(uMsg, wParam, lParam, lResult);
         return TRUE;
+
     case WM_DESTROY:
         KillTimer(1);
         ShutdownIcons();
diff --git a/dll/shellext/stobject/hotplug.cpp 
b/dll/shellext/stobject/hotplug.cpp
index 9af5eef972..ed0660f49e 100644
--- a/dll/shellext/stobject/hotplug.cpp
+++ b/dll/shellext/stobject/hotplug.cpp
@@ -280,19 +280,28 @@ HRESULT STDMETHODCALLTYPE Hotplug_Message(_In_ CSysTray * 
pSysTray, UINT uMsg, W
             }
             return S_FALSE;
 
+        case WM_TIMER:
+            if (wParam == HOTPLUG_TIMER_ID)
+            {
+                KillTimer(pSysTray->GetHWnd(), HOTPLUG_TIMER_ID);
+                _ShowContextMenu(pSysTray);
+            }
+            break;
+
         case ID_ICON_HOTPLUG:
             Hotplug_Update(pSysTray);
 
             switch (lParam)
             {
                 case WM_LBUTTONDOWN:
+                    SetTimer(pSysTray->GetHWnd(), HOTPLUG_TIMER_ID, 500, NULL);
                     break;
 
                 case WM_LBUTTONUP:
-                    _ShowContextMenu(pSysTray);
                     break;
 
                 case WM_LBUTTONDBLCLK:
+                    KillTimer(pSysTray->GetHWnd(), HOTPLUG_TIMER_ID);
                     _RunHotplug(pSysTray);
                     break;
 
diff --git a/dll/shellext/stobject/power.cpp b/dll/shellext/stobject/power.cpp
index 12382faf7d..ada4fb1e81 100644
--- a/dll/shellext/stobject/power.cpp
+++ b/dll/shellext/stobject/power.cpp
@@ -374,19 +374,28 @@ HRESULT STDMETHODCALLTYPE Power_Message(_In_ CSysTray * 
pSysTray, UINT uMsg, WPA
             }
             return S_FALSE;
 
+        case WM_TIMER:
+            if (wParam == POWER_TIMER_ID)
+            {
+                KillTimer(pSysTray->GetHWnd(), POWER_TIMER_ID);
+                ShowPowerSchemesPopupMenu(pSysTray);
+            }
+            break;
+
         case ID_ICON_POWER:
             Power_Update(pSysTray);
 
             switch (lParam)
             {
                 case WM_LBUTTONDOWN:
+                    SetTimer(pSysTray->GetHWnd(), POWER_TIMER_ID, 500, NULL);
                     break;
 
                 case WM_LBUTTONUP:
-                    ShowPowerSchemesPopupMenu(pSysTray);
                     break;
 
                 case WM_LBUTTONDBLCLK:
+                    KillTimer(pSysTray->GetHWnd(), POWER_TIMER_ID);
                     _RunPower();
                     break;
 
diff --git a/dll/shellext/stobject/volume.cpp b/dll/shellext/stobject/volume.cpp
index a78bda743b..ba0f905356 100644
--- a/dll/shellext/stobject/volume.cpp
+++ b/dll/shellext/stobject/volume.cpp
@@ -214,10 +214,9 @@ HRESULT Volume_OnDeviceChange(_In_ CSysTray * pSysTray, 
WPARAM wParam, LPARAM lP
     return Volume_FindMixerControl(pSysTray);
 }
 
-static void _RunVolume()
+static void _RunVolume(BOOL bTray)
 {
-    // FIXME: ensure we are loading the right one
-    ShellExecuteW(NULL, NULL, L"sndvol32.exe", NULL, NULL, SW_SHOWNORMAL);
+    ShellExecuteW(NULL, NULL, bTray ? L"sndvol32.exe /t" : L"sndvol32.exe", 
NULL, NULL, SW_SHOWNORMAL);
 }
 
 static void _RunMMCpl()
@@ -250,7 +249,7 @@ static void _ShowContextMenu(CSysTray * pSysTray)
     switch (id)
     {
     case IDS_VOL_OPEN:
-        _RunVolume();
+        _RunVolume(FALSE);
         break;
     case IDS_VOL_ADJUST:
         _RunMMCpl();
@@ -285,6 +284,14 @@ HRESULT STDMETHODCALLTYPE Volume_Message(_In_ CSysTray * 
pSysTray, UINT uMsg, WP
             }
             return S_FALSE;
 
+        case WM_TIMER:
+            if (wParam == VOLUME_TIMER_ID)
+            {
+                KillTimer(pSysTray->GetHWnd(), VOLUME_TIMER_ID);
+                _RunVolume(TRUE);
+            }
+            break;
+
         case ID_ICON_VOLUME:
             TRACE("Volume_Message uMsg=%d, w=%x, l=%x\n", uMsg, wParam, 
lParam);
 
@@ -293,14 +300,15 @@ HRESULT STDMETHODCALLTYPE Volume_Message(_In_ CSysTray * 
pSysTray, UINT uMsg, WP
             switch (lParam)
             {
                 case WM_LBUTTONDOWN:
+                    SetTimer(pSysTray->GetHWnd(), VOLUME_TIMER_ID, 500, NULL);
                     break;
 
                 case WM_LBUTTONUP:
-                    TRACE("TODO: display volume slider\n");
                     break;
 
                 case WM_LBUTTONDBLCLK:
-                    _RunVolume();
+                    KillTimer(pSysTray->GetHWnd(), VOLUME_TIMER_ID);
+                    _RunVolume(FALSE);
                     break;
 
                 case WM_RBUTTONDOWN:

Reply via email to