From 4d55156520ee7c2099a5b5672a712aeb3441737d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Per=C3=A4l=C3=A4?= Date: Thu, 9 Feb 2017 13:58:52 +0200 Subject: [PATCH] Switch to a forked version of MediaKeyTap The previous solution of sending out activation notifications was not really a functional one and other applications might steal focus away from kmbmpdc without of it ever regaining it. In order to fix this, the application is made to use a custom forked version of MediaKeyTap that can manually set itself as the top application on the listener stack. --- CHANGELOG.md | 5 +++++ Cartfile | 2 +- Cartfile.resolved | 2 +- README.md | 2 +- kmbmpdc/Controls.swift | 12 ++++-------- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39ba7fc..73d845a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log ## [Unreleased] +### Changed +- MediaKeyTap switched a forked version to manually update kmbmpdc as the active listener application + +### Fixed +- Pressing any of the menubar buttons now properly sets kmbmpdc as the active listener ## [1.1.0] - 2017-01-29 ### Added diff --git a/Cartfile b/Cartfile index 8a652e9..1a74e9c 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "nhurden/MediaKeyTap" +github "arttuperala/MediaKeyTap" "master" diff --git a/Cartfile.resolved b/Cartfile.resolved index dad2d18..b71bf36 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1 +1 @@ -github "nhurden/MediaKeyTap" "1.0.0" +github "arttuperala/MediaKeyTap" "f5e37a6ba36e405145c69ef06b3c39cc668a8f97" diff --git a/README.md b/README.md index 6468e4c..fdeaf5a 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ The following priority is used for cover art images: * [imeji](https://github.com/arttuperala/imeji) * [libmpdclient](https://www.musicpd.org/libs/libmpdclient/) -* [MediaKeyTap](https://github.com/nhurden/MediaKeyTap) +* forked [MediaKeyTap](https://github.com/arttuperala/MediaKeyTap) #### Requirements diff --git a/kmbmpdc/Controls.swift b/kmbmpdc/Controls.swift index 0c44688..67c7a95 100644 --- a/kmbmpdc/Controls.swift +++ b/kmbmpdc/Controls.swift @@ -46,8 +46,7 @@ class Controls: NSViewController, MediaKeyTapDelegate { // active listener applications exit. mediaKeyTap = MediaKeyTap(delegate: self) mediaKeyTap?.start() - let notification = Notification(name: NSNotification.Name.NSWorkspaceDidActivateApplication) - NotificationCenter.default.post(notification) + mediaKeyTap?.activate() // Set the button images to templates to play nice with dark mode. playPauseButton.image?.isTemplate = true @@ -122,8 +121,7 @@ class Controls: NSViewController, MediaKeyTapDelegate { } @IBAction func menuWasClicked(_ sender: AnyObject) { - let notification = Notification(name: NSNotification.Name.NSWorkspaceDidActivateApplication) - NotificationCenter.default.post(notification) + mediaKeyTap?.activate() guard let delegate = appDelegate else { return @@ -134,8 +132,7 @@ class Controls: NSViewController, MediaKeyTapDelegate { } @IBAction func nextWasClicked(_ sender: AnyObject) { - let notification = Notification(name: NSNotification.Name.NSWorkspaceDidActivateApplication) - NotificationCenter.default.post(notification) + mediaKeyTap?.activate() if MPDController.sharedController.connected { MPDController.sharedController.next() @@ -154,8 +151,7 @@ class Controls: NSViewController, MediaKeyTapDelegate { } @IBAction func playPauseWasClicked(_ sender: AnyObject) { - let notification = Notification(name: NSNotification.Name.NSWorkspaceDidActivateApplication) - NotificationCenter.default.post(notification) + mediaKeyTap?.activate() if MPDController.sharedController.connected { MPDController.sharedController.playPause()