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

Unified Diff: remoting/client/plugin/chromoting_instance.cc

Issue 8985007: Refactoring of the client-side input pipeline and scaling dimension management. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 9 years 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
Index: remoting/client/plugin/chromoting_instance.cc
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc
index e6dea0eebec720a1c39eb89dd7c906838a7de2a8..d3f7b625f4c8a51f378f23d79f504f3077788dde 100644
--- a/remoting/client/plugin/chromoting_instance.cc
+++ b/remoting/client/plugin/chromoting_instance.cc
@@ -24,14 +24,15 @@
#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"
-#include "remoting/client/plugin/pepper_view_proxy.h"
#include "remoting/client/plugin/pepper_xmpp_proxy.h"
#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 {
@@ -82,16 +83,11 @@ ChromotingInstance::~ChromotingInstance() {
done_event.Wait();
}
- // Stopping the context shutdown all chromoting threads. This is a requirement
- // before we can call Detach() on |view_proxy_|.
+ // Stopping the context shuts down all chromoting threads.
context_.Stop();
- if (view_proxy_.get()) {
- view_proxy_->Detach();
- }
-
// Delete |thread_proxy_| before we detach |plugin_message_loop_|,
- // otherwise ScopedThreadProxy may DCHECK when destroying.
+ // otherwise ScopedThreadProxy may DCHECK when being destroyed.
thread_proxy_.reset();
plugin_message_loop_->Detach();
@@ -117,9 +113,8 @@ bool ChromotingInstance::Init(uint32_t argc,
// Create the chromoting objects that don't depend on the network connection.
view_.reset(new PepperView(this, &context_));
- view_proxy_ = new PepperViewProxy(this, view_.get(), plugin_message_loop_);
rectangle_decoder_ = new RectangleUpdateDecoder(
- context_.decode_message_loop(), view_proxy_);
+ context_.decode_message_loop(), view_.get());
// Default to a medium grey.
view_->SetSolidFill(0xFFCDCDCD);
@@ -132,14 +127,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()));
+ view_.get(), rectangle_decoder_.get(),
+ base::Closure()));
LOG(INFO) << "Connecting to " << config.host_jid
<< ". Local jid: " << config.local_jid << ".";
@@ -175,6 +165,8 @@ void ChromotingInstance::Disconnect() {
}
input_handler_.reset();
+ key_event_tracker_.reset();
+ mouse_input_filter_.reset();
host_connection_.reset();
GetScriptableObject()->SetConnectionStatus(
@@ -186,87 +178,44 @@ 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_->SetViewSize(new_size)) {
+ if (mouse_input_filter_.get()) {
+ mouse_input_filter_->set_input_size(new_size);
+ }
+ rectangle_decoder_->SetOutputSize(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_->set_input_size(view_->get_view_size());
+ 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;
- }
-
- 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;
- }
+ // TODO(wez): When we have a good hook into Host dimensions changes, move
+ // this there.
+ mouse_input_filter_->set_output_size(view_->get_host_size());
- 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() {
@@ -280,25 +229,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());
@@ -403,11 +333,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

Powered by Google App Engine
This is Rietveld 408576698