Skip to content

Commit

Permalink
Resolve #26 and update GUI window only when active
Browse files Browse the repository at this point in the history
  • Loading branch information
eschan145 authored Jan 19, 2025
1 parent 80e207a commit 284f640
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM,
OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.f
PROJECT NAME: DieKnow
FILENAME: src/gui.cpp
Expand Down Expand Up @@ -611,6 +611,12 @@ LRESULT CALLBACK Application::WindowProc(
app->manage_command(app, hwnd, uMsg, wParam, lParam);
break;

case WM_ACTIVATE: {
if ((wParam == WA_ACTIVE) || (wParam == WA_CLICKACTIVE)) {
app->update(hwnd, uMsg, wParam, lParam);
}
break;
}
case WM_CTLCOLORSTATIC: {
auto label = (HWND)lParam;
if (label == app->state) {
Expand Down Expand Up @@ -749,6 +755,11 @@ inline void Application::update(
}
}

settings.update();

if (IsIconic(this->hwnd))
return;

std::string state_message = std::string("DyKnow state: ") +
(dieknow::is_monitoring() ? "True" : "False");

Expand Down Expand Up @@ -841,8 +852,6 @@ inline void Application::update(

this->update_windows(current_windows);

settings.update();

if ((GetFocus() != widgets[Widgets::INTERVAL]) &&
(GetFocus() != widgets[Widgets::INTERVAL_SET])) {
// Get cursor position to restore
Expand Down

0 comments on commit 284f640

Please sign in to comment.