1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef REMOTING_PROTOCOL_MOUSE_INPUT_FILTER_H_ 6 #define REMOTING_PROTOCOL_MOUSE_INPUT_FILTER_H_ 7 8 #include "base/compiler_specific.h" 9 #include "base/macros.h" 10 #include "remoting/protocol/display_size.h" 11 #include "remoting/protocol/input_filter.h" 12 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" 13 14 namespace remoting { 15 namespace protocol { 16 17 // Filtering InputStub implementation which scales mouse events based on the 18 // supplied input and output dimensions, and clamps their coordinates to the 19 // output dimensions, before passing events on to |input_stub|. 20 class MouseInputFilter : public InputFilter { 21 public: 22 MouseInputFilter(); 23 explicit MouseInputFilter(InputStub* input_stub); 24 ~MouseInputFilter() override; 25 26 // Specify the input dimensions (DIPs or pixels) for mouse events. 27 // Deoending on the protocol, the input size can be in either pixels (for 28 // ICE protocol) or DIPs (for webrtc - except for Mac, which is pixels). 29 void set_input_size(const int32_t x, const int32_t y); 30 31 // Specify the output dimensions (DIPs or pixels, depending on platform). 32 // The output size is the scale that we should apply to the incoming mouse 33 // events before injecting them using the platform native APIs. 34 void set_output_size(const int32_t x, const int32_t y); 35 36 // Offset to display origin, in DIPs or pixels depending on the native 37 // platform. This will typically be (0,0), but may take on other values 38 // when there are multiple displays. 39 void set_output_offset(const webrtc::DesktopVector& v); 40 41 // InputStub overrides. 42 void InjectMouseEvent(const protocol::MouseEvent& event) override; 43 44 private: 45 int32_t x_input_, y_input_; 46 int32_t x_output_, y_output_; 47 48 webrtc::DesktopVector output_offset_; 49 50 DISALLOW_COPY_AND_ASSIGN(MouseInputFilter); 51 }; 52 53 } // namespace protocol 54 } // namespace remoting 55 56 #endif // REMOTING_PROTOCOL_MOUSE_INPUT_FILTER_H_ 57