MCPcopy Create free account
hub / github.com/bluescan/tacentview / FocusCallback

Method FocusCallback

Src/TacentView.cpp:4091–4129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4089
4090
4091void Viewer::FocusCallback(GLFWwindow* window, int gotFocus)
4092{
4093 if (!gotFocus)
4094 return;
4095
4096 // If we got focus, rescan the current folder to see if the hash is different.
4097 tList<tSystem::tFileInfo> files;
4098 ImagesDir = FindImagesInImageToLoadDir(files);
4099 PopulateImagesSubDirs();
4100
4101 // In case the OS scale was modified.
4102 UpdateDesiredUISize();
4103
4104 // We sort here so ComputeImagesHash always returns consistent values.
4105 files.Sort(Compare_AlphabeticalAscending, tListSortAlgorithm::Merge);
4106 tuint256 hash = ComputeImagesHash(files);
4107 Config::ProfileData& profile = Config::GetProfileData();
4108
4109 // @todo There is a subtle bug here. If a file was replaced by the Viewer to exactly match what the file was
4110 // when the hash was computed (say from a discard in git), then the hash will not have been updated and it
4111 // will not detect a change.
4112 if (hash != ImagesHash)
4113 {
4114 tPrintf("Hash mismatch. Dir contents changed. Resynching.\n");
4115 PopulateImages();
4116
4117 // It's ok if ImageToLoad is empty.
4118 if (profile.ShowImportRaw && ImportRaw::ImportedDstFile.IsValid())
4119 SetCurrentImage(ImportRaw::ImportedDstFile);
4120 else
4121 SetCurrentImage(ImageToLoad);
4122 }
4123 else
4124 {
4125 tPrintf("Hash match. Dir contents same.\n");
4126 if (profile.ShowImportRaw && ImportRaw::ImportedDstFile.IsValid())
4127 SetCurrentImage(ImportRaw::ImportedDstFile);
4128 }
4129}
4130
4131
4132void Viewer::IconifyCallback(GLFWwindow* window, int iconified)

Callers

nothing calls this directly

Calls 1

IsValidMethod · 0.45

Tested by

no test coverage detected