Ensure display hardware is powered up during Chromoting sessions.

This CL uses SetThreadExecutionState to:
* Re-set the display suspend timeout before every capture.
* Re-set the system idle timeout before every input injection.

The latter is not generally very useful, since it really only affects hosts configured to power-down when idle, at which point the host won't be accessible anyway, but it does mean that such a host could be powered-up manually and then used via Chromoting, without it powering down mid-session.

BUG=120429
TEST=Configure a Windows system with a very short display timeout, and display power-saving, and connect to a host running on it. Upon connection the display should power on and the host should be usable.


Review URL: http://codereview.chromium.org/9968071

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130321 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/remoting/host/event_executor_win.cc b/remoting/host/event_executor_win.cc
index 07416c2..035ae5f 100644
--- a/remoting/host/event_executor_win.cc
+++ b/remoting/host/event_executor_win.cc
@@ -94,10 +94,12 @@
 }
 
 void EventExecutorWin::HandleKey(const KeyEvent& event) {
-  int key = event.keycode();
-  bool down = event.pressed();
+  // Reset the system idle suspend timeout.
+  SetThreadExecutionState(ES_SYSTEM_REQUIRED);
 
   // Calculate scan code from key event.
+  int key = event.keycode();
+  bool down = event.pressed();
   int scancode = INVALID_KEYCODE;
   if (event.has_usb_keycode() && event.usb_keycode() != 0) {
     scancode = UsbKeycodeToWinScancode(event.usb_keycode());
@@ -138,6 +140,9 @@
 }
 
 void EventExecutorWin::HandleMouse(const MouseEvent& event) {
+  // Reset the system idle suspend timeout.
+  SetThreadExecutionState(ES_SYSTEM_REQUIRED);
+
   // TODO(garykac) Collapse mouse (x,y) and button events into a single
   // input event when possible.
   if (event.has_x() && event.has_y()) {