From b80ee2b7b9e0ff31b651cbc639e74babb58798f3 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 21 Sep 2014 21:48:59 +0200 Subject: Windows : display the correct tray icon when explorer is restarted (i.e. after an explorer crash). --- src/Mount/Mount.c | 28 +++++++++++++++++----------- src/Mount/Mount.h | 2 +- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 82e6b794..d95124e9 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -4404,7 +4404,7 @@ static void Benchmark (HWND hwndDlg) } -static BOOL CheckMountList () +static BOOL CheckMountList (BOOL bForceTaskBarUpdate) { MOUNT_LIST_STRUCT current; static BootEncryptionStatus newBootEncStatus; @@ -4413,7 +4413,7 @@ static BOOL CheckMountList () GetMountList (¤t); - if ((current.ulMountedDrives != lastUlMountedDrives || bUseDifferentTrayIconIfVolMounted != lastbUseDifferentTrayIconIfVolMounted) + if ((bForceTaskBarUpdate || current.ulMountedDrives != lastUlMountedDrives || bUseDifferentTrayIconIfVolMounted != lastbUseDifferentTrayIconIfVolMounted) && TaskBarIconMutex != NULL) { lastUlMountedDrives = current.ulMountedDrives; @@ -4422,6 +4422,11 @@ static BOOL CheckMountList () TaskBarIconChange (MainDlg, current.ulMountedDrives != 0 && bUseDifferentTrayIconIfVolMounted ? IDI_TRUECRYPT_MOUNTED_ICON : IDI_TRUECRYPT_ICON); } + if (bForceTaskBarUpdate) + { + return TRUE; + } + if (LastKnownLogicalDrives != GetLogicalDrives() || memcmp (&LastKnownMountList, ¤t, sizeof (current)) != 0) { @@ -4910,7 +4915,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa Silent = FALSE; GetMountList (&LastKnownMountList); - SetTimer (hwndDlg, TIMER_ID_MAIN, TIMER_INTERVAL_MAIN, NULL); + SetTimer (hwndDlg, TIMER_ID_MAIN, TIMER_INTERVAL_MAIN, NULL); taskBarCreatedMsg = RegisterWindowMessage ("TaskbarCreated"); @@ -5065,7 +5070,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa case WM_TIMER: { // Check mount list and update GUI if needed - CheckMountList (); + CheckMountList (FALSE); // Cache status if (IsPasswordCacheEmpty() == IsWindowEnabled (GetDlgItem (hwndDlg, IDC_WIPE_CACHE))) @@ -5340,7 +5345,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa } else if (sel >= TRAYICON_MENU_DRIVE_OFFSET + 26 && sel < TRAYICON_MENU_DRIVE_OFFSET + 26*2) { - if (CheckMountList ()) + if (CheckMountList (FALSE)) { if (Dismount (hwndDlg, sel - TRAYICON_MENU_DRIVE_OFFSET - 26)) { @@ -5524,7 +5529,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa KeyFilesApply (&mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile); } - if (CheckMountList ()) + if (CheckMountList (FALSE)) Mount (hwndDlg, 0, 0); } return 1; @@ -5620,7 +5625,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa break; case IDM_UNMOUNT_VOLUME: - if (CheckMountList ()) + if (CheckMountList (FALSE)) Dismount (hwndDlg, 0); break; @@ -5651,7 +5656,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa mountOptions = defaultMountOptions; bPrebootPasswordDlgMode = FALSE; - if (CheckMountList ()) + if (CheckMountList (FALSE)) Mount (hwndDlg, 0, 0); } break; @@ -5708,7 +5713,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa return 1; } - if (CheckMountList ()) + if (CheckMountList (FALSE)) Dismount (hwndDlg, 0); return 1; } @@ -5794,7 +5799,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa mountOptions.PartitionInInactiveSysEncScope = TRUE; bPrebootPasswordDlgMode = TRUE; - if (CheckMountList ()) + if (CheckMountList (FALSE)) Mount (hwndDlg, 0, 0); bPrebootPasswordDlgMode = FALSE; @@ -6509,6 +6514,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { TaskBarIconRemove (hwndDlg); TaskBarIconAdd (hwndDlg); + CheckMountList(TRUE); return 1; } } @@ -8529,7 +8535,7 @@ void MountSelectedVolume (HWND hwndDlg, BOOL mountWithOptions) KeyFilesApply (&mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile); } - if (CheckMountList ()) + if (CheckMountList (FALSE)) Mount (hwndDlg, 0, 0); } else diff --git a/src/Mount/Mount.h b/src/Mount/Mount.h index 7509542c..f0f5885f 100644 --- a/src/Mount/Mount.h +++ b/src/Mount/Mount.h @@ -85,7 +85,7 @@ static BOOL Dismount (HWND hwndDlg, int nDosDriveNo); static BOOL DismountAll (HWND hwndDlg, BOOL forceUnmount, BOOL interact, int dismountMaxRetries, int dismountAutoRetryDelay); static void KeyfileDefaultsDlg (HWND hwndDlg); static void HandleHotKey (HWND hwndDlg, WPARAM wParam); -static BOOL CheckMountList (); +static BOOL CheckMountList (BOOL bForceTaskBarUpdate); int GetCipherBlockSizeByDriveNo (int nDosDriveNo); int GetModeOfOperationByDriveNo (int nDosDriveNo); void ChangeMainWindowVisibility (); -- cgit v1.2.3