From 7c2303c758740d78576d77e8592420dadb48079d Mon Sep 17 00:00:00 2001 From: htk3 Date: Mon, 21 May 2018 10:52:04 +0900 Subject: [PATCH] Correct app-command name of APPCOMMAND_MEDIA_PLAY_PAUSE (#12408) * correct app-command name * add compatibility with old app-command name * add temporary compatibility with old app-command name * add a comment saying that media-play_pause is deprecated * fix lint --- atom/browser/native_window_views_win.cc | 7 ++++++- docs/tutorial/planned-breaking-changes.md | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/atom/browser/native_window_views_win.cc b/atom/browser/native_window_views_win.cc index 86e65baf0497..430f30904a91 100644 --- a/atom/browser/native_window_views_win.cc +++ b/atom/browser/native_window_views_win.cc @@ -44,7 +44,7 @@ const char* AppCommandToString(int command_id) { case APPCOMMAND_MEDIA_STOP: return "media-stop"; case APPCOMMAND_MEDIA_PLAY_PAUSE: - return "media-play_pause"; + return "media-play-pause"; case APPCOMMAND_LAUNCH_MAIL: return "launch-mail"; case APPCOMMAND_LAUNCH_MEDIA_SELECT: @@ -142,6 +142,11 @@ HHOOK NativeWindowViews::mouse_hook_ = NULL; bool NativeWindowViews::ExecuteWindowsCommand(int command_id) { std::string command = AppCommandToString(command_id); NotifyWindowExecuteWindowsCommand(command); + + if (command_id == APPCOMMAND_MEDIA_PLAY_PAUSE) + // FIXME(htk3): Remove media-play_pause in 3.0 + NotifyWindowExecuteWindowsCommand("media-play_pause"); + return false; } diff --git a/docs/tutorial/planned-breaking-changes.md b/docs/tutorial/planned-breaking-changes.md index 727d4ce5b350..08fa88491af4 100644 --- a/docs/tutorial/planned-breaking-changes.md +++ b/docs/tutorial/planned-breaking-changes.md @@ -23,6 +23,19 @@ let windowA = new BrowserWindow(optionsA) // Replace with let optionsB = {webPreferences: {enableBlinkFeatures: ''}} let windowB = new BrowserWindow(optionsB) + +// Deprecated +window.on('app-command', (e, cmd) => { + if (cmd === 'media-play_pause') { + // do something + } +}) +// Replace with +window.on('app-command', (e, cmd) => { + if (cmd === 'media-play-pause') { + // do something + } +}) ``` ## `clipboard`