| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "remoting/protocol/input_filter.h" | 5 #include "remoting/protocol/input_filter.h" |
| 6 | 6 |
| 7 #include "remoting/proto/event.pb.h" | 7 #include "remoting/proto/event.pb.h" |
| 8 | 8 |
| 9 namespace remoting { | 9 namespace remoting { |
| 10 | 10 |
| 11 // NormalizingInputFilterCros addresses the problems generated by key rewritings | 11 // NormalizingInputFilterCros addresses the problems generated by key rewritings |
| 12 // such as Down->PageDown, 1->F1, etc, when keys are pressed in combination with | 12 // such as Down->PageDown, 1->F1, etc, when keys are pressed in combination with |
| 13 // the OSKey (aka Search). Rewriting OSKey+Down, for example, causes us to | 13 // the OSKey (aka Search). Rewriting OSKey+Down, for example, causes us to |
| 14 // receive the following: | 14 // receive the following: |
| 15 // | 15 // |
| 16 // keydown OSKey | 16 // keydown OSKey |
| 17 // keydown PageDown | 17 // keydown PageDown |
| 18 // keyup PageDown | 18 // keyup PageDown |
| 19 // keyup OSKey | 19 // keyup OSKey |
| 20 // | 20 // |
| 21 // The host system will therefore behave as if OSKey+PageDown were pressed, | 21 // The host system will therefore behave as if OSKey+PageDown were pressed, |
| 22 // rather than PageDown alone. | 22 // rather than PageDown alone. |
| 23 class NormalizingInputFilterCros : public protocol::InputFilter { | 23 class NormalizingInputFilterCros : public protocol::InputFilter { |
| 24 public: | 24 public: |
| 25 explicit NormalizingInputFilterCros(protocol::InputStub* input_stub); | 25 explicit NormalizingInputFilterCros(protocol::InputStub* input_stub); |
| 26 virtual ~NormalizingInputFilterCros(); | 26 virtual ~NormalizingInputFilterCros(); |
| 27 | 27 |
| 28 // InputFilter overrides. | 28 // InputFilter overrides. |
| 29 virtual void InjectKeyEvent(const protocol::KeyEvent& event) OVERRIDE; | 29 virtual void InjectKeyEvent(const protocol::KeyEvent& event) override; |
| 30 virtual void InjectMouseEvent(const protocol::MouseEvent& event) OVERRIDE; | 30 virtual void InjectMouseEvent(const protocol::MouseEvent& event) override; |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 void ProcessKeyDown(const protocol::KeyEvent& event); | 33 void ProcessKeyDown(const protocol::KeyEvent& event); |
| 34 void ProcessKeyUp(const protocol::KeyEvent& event); | 34 void ProcessKeyUp(const protocol::KeyEvent& event); |
| 35 | 35 |
| 36 void SwitchRewritingKeyToModifying(); | 36 void SwitchRewritingKeyToModifying(); |
| 37 | 37 |
| 38 // Holds the keydown event for the most recent OSKey to have been pressed, | 38 // Holds the keydown event for the most recent OSKey to have been pressed, |
| 39 // while it is Rewriting, or we are not yet sure whether it is Normal, | 39 // while it is Rewriting, or we are not yet sure whether it is Normal, |
| 40 // Rewriting or Modifying. The event is sent on if we switch to Modifying, or | 40 // Rewriting or Modifying. The event is sent on if we switch to Modifying, or |
| 41 // discarded if the OSKey is released while in Rewriting mode. | 41 // discarded if the OSKey is released while in Rewriting mode. |
| 42 protocol::KeyEvent deferred_keydown_event_; | 42 protocol::KeyEvent deferred_keydown_event_; |
| 43 | 43 |
| 44 // True while the |rewrite_keydown_event_| key is Rewriting, i.e. was followed | 44 // True while the |rewrite_keydown_event_| key is Rewriting, i.e. was followed |
| 45 // by one or more Rewritten key events, and not by any Modified events. | 45 // by one or more Rewritten key events, and not by any Modified events. |
| 46 bool deferred_key_is_rewriting_; | 46 bool deferred_key_is_rewriting_; |
| 47 | 47 |
| 48 // Stores the code of the OSKey while it is pressed for use as a Modifier. | 48 // Stores the code of the OSKey while it is pressed for use as a Modifier. |
| 49 uint32 modifying_key_; | 49 uint32 modifying_key_; |
| 50 | 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(NormalizingInputFilterCros); | 51 DISALLOW_COPY_AND_ASSIGN(NormalizingInputFilterCros); |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 } // namespace remoting | 54 } // namespace remoting |
| OLD | NEW |