Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(925)

Unified Diff: remoting/host/disconnect_window_win.cc

Issue 7613009: Add support for Disconnect hot key in Windows. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/disconnect_window_win.cc
===================================================================
--- remoting/host/disconnect_window_win.cc (revision 96410)
+++ remoting/host/disconnect_window_win.cc (working copy)
@@ -25,6 +25,8 @@
// SimpleHost: simple_host_process.cc
extern HMODULE g_hModule;
+const int DISCONNECT_HOTKEY_ID = 1000;
Wez 2011/08/11 22:15:24 Is there any significance to this choice of value?
garykac 2011/08/11 23:04:49 It must be between 0x0000 and 0xbfff. Having a na
+
namespace remoting {
class DisconnectWindowWin : public DisconnectWindow {
@@ -42,11 +44,14 @@
BOOL OnDialogMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+ void ShutdownHost();
void EndDialog();
+ void RemoveKeyHandler();
remoting::ChromotingHost* host_;
std::string username_;
HWND hwnd_;
+ bool has_hotkey_;
DISALLOW_COPY_AND_ASSIGN(DisconnectWindowWin);
};
@@ -54,7 +59,8 @@
DisconnectWindowWin::DisconnectWindowWin()
: host_(NULL),
username_(""),
- hwnd_(NULL) {
+ hwnd_(NULL),
+ has_hotkey_(false) {
}
DisconnectWindowWin::~DisconnectWindowWin() {
@@ -89,7 +95,8 @@
HWND hwndButton = GetDlgItem(hwnd, IDC_DISCONNECT);
CHECK(hwndButton);
std::wstring w_button = UTF8ToWide(kDisconnectButton);
- w_button += UTF8ToWide(kDisconnectKeysWin);
+ if (has_hotkey_)
+ w_button += UTF8ToWide(kDisconnectKeysWin);
SetWindowText(hwndButton, w_button.c_str());
HWND hwndSharingWith = GetDlgItem(hwnd, IDC_DISCONNECT_SHARINGWITH);
@@ -104,6 +111,12 @@
SetWindowText(hwndUsername, w_username.c_str());
}
return TRUE;
+ case WM_HOTKEY:
+ {
+ ShutdownHost();
+ EndDialog();
+ }
+ return TRUE;
case WM_CLOSE:
// Ignore close messages.
return TRUE;
@@ -115,8 +128,8 @@
switch (LOWORD(wParam)) {
case IDC_DISCONNECT:
{
- CHECK(host_);
- host_->Shutdown(NULL);
+ ShutdownHost();
+ RemoveKeyHandler();
::EndDialog(hwnd, LOWORD(wParam));
hwnd_ = NULL;
Wez 2011/08/11 22:15:24 These lines look almost identical to EndDialog() b
garykac 2011/08/11 23:04:49 I was sortof trying to avoid having a |result| par
garykac 2011/08/11 23:04:49 I was sortof trying to avoid having a |result| par
}
@@ -140,19 +153,37 @@
}
ShowWindow(hwnd_, SW_SHOW);
+
+ // Set up handler for Ctrl-Alt-Esc shortcut.
+ if (!has_hotkey_) {
+ RegisterHotKey(hwnd_, DISCONNECT_HOTKEY_ID, MOD_ALT | MOD_CONTROL,
+ VK_ESCAPE);
Wez 2011/08/11 22:15:24 I thought we were going to not display the hot-key
garykac 2011/08/11 23:04:49 Added SetDisconnectButtonText call here. Previousl
Wez 2011/08/11 23:58:30 My point is not about when you set the button text
garykac 2011/08/12 00:23:16 Argh. I completely missed that point (which Jamie
+ has_hotkey_ = true;
+ }
}
+void DisconnectWindowWin::ShutdownHost() {
+ CHECK(host_);
+ host_->Shutdown(NULL);
+}
+
void DisconnectWindowWin::Hide() {
EndDialog();
}
void DisconnectWindowWin::EndDialog() {
+ RemoveKeyHandler();
if (hwnd_) {
::EndDialog(hwnd_, 0);
hwnd_ = NULL;
}
}
+void DisconnectWindowWin::RemoveKeyHandler() {
Wez 2011/08/11 22:15:24 nit: Does this really need to be a separate functi
garykac 2011/08/11 23:04:49 *need*? No. But it's called from multiple places
Wez 2011/08/11 23:58:30 It's called from two places, both of which then do
garykac 2011/08/12 00:23:16 Actually it's called in 1 place now that EndDialog
+ UnregisterHotKey(hwnd_, DISCONNECT_HOTKEY_ID);
+ has_hotkey_ = false;
+}
+
DisconnectWindow* DisconnectWindow::Create() {
return new DisconnectWindowWin;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698