From d20ee34a0d4bc021a9ebaf000a409c6641ff57cf Mon Sep 17 00:00:00 2001 From: Michael Belyaev Date: Mon, 6 Nov 2017 11:31:59 +0300 Subject: [PATCH] Refresh status menu when monitor is connected, disconnected or its resolution is changed not through RDM --- SRApplicationDelegate.h | 2 +- SRApplicationDelegate.mm | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/SRApplicationDelegate.h b/SRApplicationDelegate.h index ee197e5..4157d0d 100644 --- a/SRApplicationDelegate.h +++ b/SRApplicationDelegate.h @@ -6,6 +6,6 @@ NSMenu* statusMenu; NSStatusItem* statusItem; } - +- (void) refreshStatusMenu; @end diff --git a/SRApplicationDelegate.mm b/SRApplicationDelegate.mm index 7226fb4..b97feae 100644 --- a/SRApplicationDelegate.mm +++ b/SRApplicationDelegate.mm @@ -9,6 +9,13 @@ #import "ResMenuItem.h" +void DisplayReconfigurationCallback(CGDirectDisplayID cg_id, + CGDisplayChangeSummaryFlags change_flags, + void *app_delegate) +{ + SRApplicationDelegate *appDelegate = (SRApplicationDelegate*)app_delegate; + [appDelegate refreshStatusMenu]; +} @@ -253,7 +260,7 @@ - (void) applicationDidFinishLaunching: (NSNotification*) notification } [self refreshStatusMenu]; - + CGDisplayRegisterReconfigurationCallback(DisplayReconfigurationCallback, self); } @end