Index: remoting/client/plugin/chromoting_instance.cc |
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc |
index a65a2a0a3343db1cbbca528116c5d0528c7b27d0..383d53000179444376238fffc1e59bc774421cc7 100644 |
--- a/remoting/client/plugin/chromoting_instance.cc |
+++ b/remoting/client/plugin/chromoting_instance.cc |
@@ -25,6 +25,7 @@ |
#include "remoting/base/util.h" |
#include "remoting/client/client_config.h" |
#include "remoting/client/chromoting_client.h" |
+#include "remoting/client/mouse_input_filter.h" |
#include "remoting/client/plugin/chromoting_scriptable_object.h" |
#include "remoting/client/plugin/pepper_input_handler.h" |
#include "remoting/client/plugin/pepper_view.h" |
@@ -33,6 +34,7 @@ |
#include "remoting/client/rectangle_update_decoder.h" |
#include "remoting/protocol/connection_to_host.h" |
#include "remoting/protocol/host_stub.h" |
+#include "remoting/protocol/key_event_tracker.h" |
namespace remoting { |
@@ -133,14 +135,9 @@ void ChromotingInstance::Connect(const ClientConfig& config) { |
host_connection_.reset(new protocol::ConnectionToHost( |
context_.network_message_loop(), this, true)); |
- |
- input_handler_.reset(new PepperInputHandler(&context_, |
- host_connection_.get(), |
- view_proxy_)); |
- |
client_.reset(new ChromotingClient(config, &context_, host_connection_.get(), |
view_proxy_, rectangle_decoder_.get(), |
- input_handler_.get(), base::Closure())); |
+ base::Closure())); |
LOG(INFO) << "Connecting to " << config.host_jid |
<< ". Local jid: " << config.local_jid << "."; |
@@ -176,6 +173,8 @@ void ChromotingInstance::Disconnect() { |
} |
input_handler_.reset(); |
+ key_event_tracker_.reset(); |
+ mouse_input_filter_.reset(); |
host_connection_.reset(); |
GetScriptableObject()->SetConnectionStatus( |
@@ -187,87 +186,45 @@ void ChromotingInstance::DidChangeView(const pp::Rect& position, |
const pp::Rect& clip) { |
DCHECK(plugin_message_loop_->BelongsToCurrentThread()); |
- view_->SetPluginSize(SkISize::Make(position.width(), position.height())); |
- |
- // TODO(wez): Pass the dimensions of the plugin to the RectangleDecoder |
- // and let it generate the necessary refresh events. |
- // If scale-to-fit is enabled then update the scaling ratios. |
- // We also force a full-frame refresh, in case the ratios changed. |
- if (scale_to_fit_) { |
- rectangle_decoder_->SetScaleRatios(view_->GetHorizontalScaleRatio(), |
- view_->GetVerticalScaleRatio()); |
- rectangle_decoder_->RefreshFullFrame(); |
+ SkISize new_size = SkISize::Make(position.width(), position.height()); |
+ if (view_->GetViewDimensions() != new_size) { |
+ view_->SetPluginSize(new_size); |
+ if (mouse_input_filter_.get()) { |
+ mouse_input_filter_->SetInputDimensions(new_size); |
+ } |
+ rectangle_decoder_->SetOutputDimensions(new_size); |
} |
- // Notify the RectangleDecoder of the new clip rect. |
rectangle_decoder_->UpdateClipRect( |
SkIRect::MakeXYWH(clip.x(), clip.y(), clip.width(), clip.height())); |
} |
bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) { |
DCHECK(plugin_message_loop_->BelongsToCurrentThread()); |
- if (!input_handler_.get()) { |
+ |
+ // Never inject events if the end of the input pipeline doesn't exist. |
+ // If it does exist but the pipeline doesn't, construct a pipeline. |
+ // TODO(wez): This is really ugly. We should create the pipeline when |
+ // the ConnectionToHost's InputStub exists. |
+ if (!host_connection_.get()) { |
return false; |
+ } else if (!input_handler_.get()) { |
+ protocol::InputStub* input_stub = host_connection_->input_stub(); |
+ if (!input_stub) |
+ return false; |
+ mouse_input_filter_.reset(new MouseInputFilter(input_stub)); |
+ mouse_input_filter_->SetInputDimensions(view_->GetViewDimensions()); |
+ key_event_tracker_.reset( |
+ new protocol::KeyEventTracker(mouse_input_filter_.get())); |
+ input_handler_.reset( |
+ new PepperInputHandler(key_event_tracker_.get())); |
} |
- PepperInputHandler* pih |
- = static_cast<PepperInputHandler*>(input_handler_.get()); |
- |
- switch (event.GetType()) { |
- case PP_INPUTEVENT_TYPE_MOUSEDOWN: { |
- pih->HandleMouseButtonEvent(true, pp::MouseInputEvent(event)); |
- return true; |
- } |
- |
- case PP_INPUTEVENT_TYPE_MOUSEUP: { |
- pih->HandleMouseButtonEvent(false, pp::MouseInputEvent(event)); |
- return true; |
- } |
- |
- case PP_INPUTEVENT_TYPE_MOUSEMOVE: |
- case PP_INPUTEVENT_TYPE_MOUSEENTER: |
- case PP_INPUTEVENT_TYPE_MOUSELEAVE: { |
- pih->HandleMouseMoveEvent(pp::MouseInputEvent(event)); |
- return true; |
- } |
+ // TODO(wez): When we have a good hook into Host dimensions changes, move |
+ // this there. |
+ mouse_input_filter_->SetOutputDimensions(view_->GetHostDimensions()); |
- case PP_INPUTEVENT_TYPE_WHEEL: { |
- pih->HandleMouseWheelEvent(pp::WheelInputEvent(event)); |
- return true; |
- } |
- |
- case PP_INPUTEVENT_TYPE_CONTEXTMENU: { |
- // We need to return true here or else we'll get a local (plugin) context |
- // menu instead of the mouseup event for the right click. |
- return true; |
- } |
- |
- case PP_INPUTEVENT_TYPE_KEYDOWN: { |
- pp::KeyboardInputEvent key = pp::KeyboardInputEvent(event); |
- VLOG(3) << "PP_INPUTEVENT_TYPE_KEYDOWN" << " key=" << key.GetKeyCode(); |
- pih->HandleKeyEvent(true, key); |
- return true; |
- } |
- |
- case PP_INPUTEVENT_TYPE_KEYUP: { |
- pp::KeyboardInputEvent key = pp::KeyboardInputEvent(event); |
- VLOG(3) << "PP_INPUTEVENT_TYPE_KEYUP" << " key=" << key.GetKeyCode(); |
- pih->HandleKeyEvent(false, key); |
- return true; |
- } |
- |
- case PP_INPUTEVENT_TYPE_CHAR: { |
- pih->HandleCharacterEvent(pp::KeyboardInputEvent(event)); |
- return true; |
- } |
- |
- default: { |
- LOG(INFO) << "Unhandled input event: " << event.GetType(); |
- break; |
- } |
- } |
- |
- return false; |
+ return input_handler_->HandleInputEvent(event); |
} |
ChromotingScriptableObject* ChromotingInstance::GetScriptableObject() { |
@@ -281,25 +238,6 @@ ChromotingScriptableObject* ChromotingInstance::GetScriptableObject() { |
return NULL; |
} |
-void ChromotingInstance::SetScaleToFit(bool scale_to_fit) { |
- DCHECK(plugin_message_loop_->BelongsToCurrentThread()); |
- |
- if (scale_to_fit == scale_to_fit_) |
- return; |
- |
- scale_to_fit_ = scale_to_fit; |
- if (scale_to_fit) { |
- rectangle_decoder_->SetScaleRatios(view_->GetHorizontalScaleRatio(), |
- view_->GetVerticalScaleRatio()); |
- } else { |
- rectangle_decoder_->SetScaleRatios(1.0, 1.0); |
- } |
- |
- // TODO(wez): The RectangleDecoder should generate refresh events |
- // as necessary in response to any scaling change. |
- rectangle_decoder_->RefreshFullFrame(); |
-} |
- |
// static |
void ChromotingInstance::RegisterLogMessageHandler() { |
base::AutoLock lock(g_logging_lock.Get()); |
@@ -404,11 +342,9 @@ ChromotingStats* ChromotingInstance::GetStats() { |
} |
void ChromotingInstance::ReleaseAllKeys() { |
- if (!input_handler_.get()) { |
- return; |
+ if (key_event_tracker_.get()) { |
+ key_event_tracker_->ReleaseAllKeys(); |
} |
- |
- input_handler_->ReleaseAllKeys(); |
} |
} // namespace remoting |