Only convert command ID on Windows
This commit is contained in:
parent
58efb3c018
commit
bff66caaa6
3 changed files with 68 additions and 126 deletions
|
@ -580,14 +580,6 @@ void NativeWindow::NotifyWindowUnresponsive() {
|
||||||
OnRendererUnresponsive());
|
OnRendererUnresponsive());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::NotifyExecuteWindowsCommand(int command_id) {
|
|
||||||
std::string command = AppCommandToString(command_id);
|
|
||||||
|
|
||||||
FOR_EACH_OBSERVER(NativeWindowObserver,
|
|
||||||
observers_,
|
|
||||||
OnExecuteWindowsCommand(command));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
|
void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
|
||||||
const SkBitmap& bitmap,
|
const SkBitmap& bitmap,
|
||||||
|
@ -595,117 +587,4 @@ void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
|
||||||
callback.Run(bitmap);
|
callback.Run(bitmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* NativeWindow::AppCommandToString(int command_id) {
|
|
||||||
switch (command_id) {
|
|
||||||
case APPCOMMAND_BROWSER_BACKWARD:
|
|
||||||
return "browser-backward";
|
|
||||||
case APPCOMMAND_BROWSER_FORWARD:
|
|
||||||
return "browser-forward";
|
|
||||||
case APPCOMMAND_BROWSER_REFRESH:
|
|
||||||
return "browser-refresh";
|
|
||||||
case APPCOMMAND_BROWSER_STOP:
|
|
||||||
return "browser-stop";
|
|
||||||
case APPCOMMAND_BROWSER_SEARCH:
|
|
||||||
return "browser-search";
|
|
||||||
case APPCOMMAND_BROWSER_FAVORITES:
|
|
||||||
return "browser-favorites";
|
|
||||||
case APPCOMMAND_BROWSER_HOME:
|
|
||||||
return "browser-home";
|
|
||||||
case APPCOMMAND_VOLUME_MUTE:
|
|
||||||
return "volume-mute";
|
|
||||||
case APPCOMMAND_VOLUME_DOWN:
|
|
||||||
return "volume-down";
|
|
||||||
case APPCOMMAND_VOLUME_UP:
|
|
||||||
return "volume-up";
|
|
||||||
case APPCOMMAND_MEDIA_NEXTTRACK:
|
|
||||||
return "media-nexttrack";
|
|
||||||
case APPCOMMAND_MEDIA_PREVIOUSTRACK:
|
|
||||||
return "media-previoustrack";
|
|
||||||
case APPCOMMAND_MEDIA_STOP:
|
|
||||||
return "media-stop";
|
|
||||||
case APPCOMMAND_MEDIA_PLAY_PAUSE:
|
|
||||||
return "media-play_pause";
|
|
||||||
case APPCOMMAND_LAUNCH_MAIL:
|
|
||||||
return "launch-mail";
|
|
||||||
case APPCOMMAND_LAUNCH_MEDIA_SELECT:
|
|
||||||
return "launch-media-select";
|
|
||||||
case APPCOMMAND_LAUNCH_APP1:
|
|
||||||
return "launch-app1";
|
|
||||||
case APPCOMMAND_LAUNCH_APP2:
|
|
||||||
return "launch-app2";
|
|
||||||
case APPCOMMAND_BASS_DOWN:
|
|
||||||
return "bass-down";
|
|
||||||
case APPCOMMAND_BASS_BOOST:
|
|
||||||
return "bass-boost";
|
|
||||||
case APPCOMMAND_BASS_UP:
|
|
||||||
return "bass-up";
|
|
||||||
case APPCOMMAND_TREBLE_DOWN:
|
|
||||||
return "treble-down";
|
|
||||||
case APPCOMMAND_TREBLE_UP:
|
|
||||||
return "treble-up";
|
|
||||||
case APPCOMMAND_MICROPHONE_VOLUME_MUTE:
|
|
||||||
return "microphone-volume-mute";
|
|
||||||
case APPCOMMAND_MICROPHONE_VOLUME_DOWN:
|
|
||||||
return "microphone-volume-down";
|
|
||||||
case APPCOMMAND_MICROPHONE_VOLUME_UP:
|
|
||||||
return "microphone-volume-up";
|
|
||||||
case APPCOMMAND_HELP:
|
|
||||||
return "help";
|
|
||||||
case APPCOMMAND_FIND:
|
|
||||||
return "find";
|
|
||||||
case APPCOMMAND_NEW:
|
|
||||||
return "new";
|
|
||||||
case APPCOMMAND_OPEN:
|
|
||||||
return "open";
|
|
||||||
case APPCOMMAND_CLOSE:
|
|
||||||
return "close";
|
|
||||||
case APPCOMMAND_SAVE:
|
|
||||||
return "save";
|
|
||||||
case APPCOMMAND_PRINT:
|
|
||||||
return "print";
|
|
||||||
case APPCOMMAND_UNDO:
|
|
||||||
return "undo";
|
|
||||||
case APPCOMMAND_REDO:
|
|
||||||
return "redo";
|
|
||||||
case APPCOMMAND_COPY:
|
|
||||||
return "copy";
|
|
||||||
case APPCOMMAND_CUT:
|
|
||||||
return "cut";
|
|
||||||
case APPCOMMAND_PASTE:
|
|
||||||
return "paste";
|
|
||||||
case APPCOMMAND_REPLY_TO_MAIL:
|
|
||||||
return "reply-to-mail";
|
|
||||||
case APPCOMMAND_FORWARD_MAIL:
|
|
||||||
return "forward-mail";
|
|
||||||
case APPCOMMAND_SEND_MAIL:
|
|
||||||
return "send-mail";
|
|
||||||
case APPCOMMAND_SPELL_CHECK:
|
|
||||||
return "spell-check";
|
|
||||||
case APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE:
|
|
||||||
return "dictate-or-command-control-toggle";
|
|
||||||
case APPCOMMAND_MIC_ON_OFF_TOGGLE:
|
|
||||||
return "mic-on-off-toggle";
|
|
||||||
case APPCOMMAND_CORRECTION_LIST:
|
|
||||||
return "correction-list";
|
|
||||||
case APPCOMMAND_MEDIA_PLAY:
|
|
||||||
return "media-play";
|
|
||||||
case APPCOMMAND_MEDIA_PAUSE:
|
|
||||||
return "media-pause";
|
|
||||||
case APPCOMMAND_MEDIA_RECORD:
|
|
||||||
return "media-record";
|
|
||||||
case APPCOMMAND_MEDIA_FAST_FORWARD:
|
|
||||||
return "media-fast-forward";
|
|
||||||
case APPCOMMAND_MEDIA_REWIND:
|
|
||||||
return "media-rewind";
|
|
||||||
case APPCOMMAND_MEDIA_CHANNEL_UP:
|
|
||||||
return "media-channel-up";
|
|
||||||
case APPCOMMAND_MEDIA_CHANNEL_DOWN:
|
|
||||||
return "media-channel-down";
|
|
||||||
case APPCOMMAND_DELETE:
|
|
||||||
return "delete";
|
|
||||||
default:
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -198,7 +198,6 @@ class NativeWindow : public content::WebContentsObserver,
|
||||||
void NotifyWindowLeaveFullScreen();
|
void NotifyWindowLeaveFullScreen();
|
||||||
void NotifyWindowEnterHtmlFullScreen();
|
void NotifyWindowEnterHtmlFullScreen();
|
||||||
void NotifyWindowLeaveHtmlFullScreen();
|
void NotifyWindowLeaveHtmlFullScreen();
|
||||||
void NotifyExecuteWindowsCommand(int command_id);
|
|
||||||
|
|
||||||
void AddObserver(NativeWindowObserver* obs) {
|
void AddObserver(NativeWindowObserver* obs) {
|
||||||
observers_.AddObserver(obs);
|
observers_.AddObserver(obs);
|
||||||
|
@ -261,9 +260,6 @@ class NativeWindow : public content::WebContentsObserver,
|
||||||
const SkBitmap& bitmap,
|
const SkBitmap& bitmap,
|
||||||
content::ReadbackResponse response);
|
content::ReadbackResponse response);
|
||||||
|
|
||||||
// Convert Win32 WM_APPCOMMANDS to strings
|
|
||||||
const char* AppCommandToString(int command_id);
|
|
||||||
|
|
||||||
// Observers of this window.
|
// Observers of this window.
|
||||||
ObserverList<NativeWindowObserver> observers_;
|
ObserverList<NativeWindowObserver> observers_;
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,70 @@ bool IsAltModifier(const content::NativeWebKeyboardEvent& event) {
|
||||||
(modifiers == (Modifiers::AltKey | Modifiers::IsRight));
|
(modifiers == (Modifiers::AltKey | Modifiers::IsRight));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(OS_WIN)
|
||||||
|
// Convert Win32 WM_APPCOMMANDS to strings.
|
||||||
|
const char* AppCommandToString(int command_id) {
|
||||||
|
switch (command_id) {
|
||||||
|
case APPCOMMAND_BROWSER_BACKWARD : return "browser-backward";
|
||||||
|
case APPCOMMAND_BROWSER_FORWARD : return "browser-forward";
|
||||||
|
case APPCOMMAND_BROWSER_REFRESH : return "browser-refresh";
|
||||||
|
case APPCOMMAND_BROWSER_STOP : return "browser-stop";
|
||||||
|
case APPCOMMAND_BROWSER_SEARCH : return "browser-search";
|
||||||
|
case APPCOMMAND_BROWSER_FAVORITES : return "browser-favorites";
|
||||||
|
case APPCOMMAND_BROWSER_HOME : return "browser-home";
|
||||||
|
case APPCOMMAND_VOLUME_MUTE : return "volume-mute";
|
||||||
|
case APPCOMMAND_VOLUME_DOWN : return "volume-down";
|
||||||
|
case APPCOMMAND_VOLUME_UP : return "volume-up";
|
||||||
|
case APPCOMMAND_MEDIA_NEXTTRACK : return "media-nexttrack";
|
||||||
|
case APPCOMMAND_MEDIA_PREVIOUSTRACK : return "media-previoustrack";
|
||||||
|
case APPCOMMAND_MEDIA_STOP : return "media-stop";
|
||||||
|
case APPCOMMAND_MEDIA_PLAY_PAUSE : return "media-play_pause";
|
||||||
|
case APPCOMMAND_LAUNCH_MAIL : return "launch-mail";
|
||||||
|
case APPCOMMAND_LAUNCH_MEDIA_SELECT : return "launch-media-select";
|
||||||
|
case APPCOMMAND_LAUNCH_APP1 : return "launch-app1";
|
||||||
|
case APPCOMMAND_LAUNCH_APP2 : return "launch-app2";
|
||||||
|
case APPCOMMAND_BASS_DOWN : return "bass-down";
|
||||||
|
case APPCOMMAND_BASS_BOOST : return "bass-boost";
|
||||||
|
case APPCOMMAND_BASS_UP : return "bass-up";
|
||||||
|
case APPCOMMAND_TREBLE_DOWN : return "treble-down";
|
||||||
|
case APPCOMMAND_TREBLE_UP : return "treble-up";
|
||||||
|
case APPCOMMAND_MICROPHONE_VOLUME_MUTE : return "microphone-volume-mute";
|
||||||
|
case APPCOMMAND_MICROPHONE_VOLUME_DOWN : return "microphone-volume-down";
|
||||||
|
case APPCOMMAND_MICROPHONE_VOLUME_UP : return "microphone-volume-up";
|
||||||
|
case APPCOMMAND_HELP : return "help";
|
||||||
|
case APPCOMMAND_FIND : return "find";
|
||||||
|
case APPCOMMAND_NEW : return "new";
|
||||||
|
case APPCOMMAND_OPEN : return "open";
|
||||||
|
case APPCOMMAND_CLOSE : return "close";
|
||||||
|
case APPCOMMAND_SAVE : return "save";
|
||||||
|
case APPCOMMAND_PRINT : return "print";
|
||||||
|
case APPCOMMAND_UNDO : return "undo";
|
||||||
|
case APPCOMMAND_REDO : return "redo";
|
||||||
|
case APPCOMMAND_COPY : return "copy";
|
||||||
|
case APPCOMMAND_CUT : return "cut";
|
||||||
|
case APPCOMMAND_PASTE : return "paste";
|
||||||
|
case APPCOMMAND_REPLY_TO_MAIL : return "reply-to-mail";
|
||||||
|
case APPCOMMAND_FORWARD_MAIL : return "forward-mail";
|
||||||
|
case APPCOMMAND_SEND_MAIL : return "send-mail";
|
||||||
|
case APPCOMMAND_SPELL_CHECK : return "spell-check";
|
||||||
|
case APPCOMMAND_MIC_ON_OFF_TOGGLE : return "mic-on-off-toggle";
|
||||||
|
case APPCOMMAND_CORRECTION_LIST : return "correction-list";
|
||||||
|
case APPCOMMAND_MEDIA_PLAY : return "media-play";
|
||||||
|
case APPCOMMAND_MEDIA_PAUSE : return "media-pause";
|
||||||
|
case APPCOMMAND_MEDIA_RECORD : return "media-record";
|
||||||
|
case APPCOMMAND_MEDIA_FAST_FORWARD : return "media-fast-forward";
|
||||||
|
case APPCOMMAND_MEDIA_REWIND : return "media-rewind";
|
||||||
|
case APPCOMMAND_MEDIA_CHANNEL_UP : return "media-channel-up";
|
||||||
|
case APPCOMMAND_MEDIA_CHANNEL_DOWN : return "media-channel-down";
|
||||||
|
case APPCOMMAND_DELETE : return "delete";
|
||||||
|
case APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE:
|
||||||
|
return "dictate-or-command-control-toggle";
|
||||||
|
default:
|
||||||
|
return "unkown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
class NativeWindowClientView : public views::ClientView {
|
class NativeWindowClientView : public views::ClientView {
|
||||||
public:
|
public:
|
||||||
NativeWindowClientView(views::Widget* widget,
|
NativeWindowClientView(views::Widget* widget,
|
||||||
|
@ -856,7 +920,10 @@ bool NativeWindowViews::ExecuteWindowsCommand(int command_id) {
|
||||||
} else if ((command_id & sc_mask) == SC_MAXIMIZE) {
|
} else if ((command_id & sc_mask) == SC_MAXIMIZE) {
|
||||||
NotifyWindowMaximize();
|
NotifyWindowMaximize();
|
||||||
} else {
|
} else {
|
||||||
NotifyExecuteWindowsCommand(command_id & sc_mask);
|
std::string command = AppCommandToString(command_id & sc_mask);
|
||||||
|
FOR_EACH_OBSERVER(NativeWindowObserver,
|
||||||
|
observers_,
|
||||||
|
OnExecuteWindowsCommand(command));
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue