Allow mouse-input to be enabled even if the plugin does not have keyboard focus.

BUG=376070

Review URL: https://codereview.chromium.org/296943003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272330 0039d316-1c4b-4281-b951-d872f2087c98
parent fff8e6f1
......@@ -360,6 +360,8 @@ void ChromotingInstance::HandleMessage(const pp::Var& message) {
HandleAllowMouseLockMessage();
} else if (method == "enableMediaSourceRendering") {
HandleEnableMediaSourceRendering();
} else if (method == "sendMouseInputWhenUnfocused") {
HandleSendMouseInputWhenUnfocused();
}
}
......@@ -964,6 +966,10 @@ void ChromotingInstance::HandleEnableMediaSourceRendering() {
use_media_source_rendering_ = true;
}
void ChromotingInstance::HandleSendMouseInputWhenUnfocused() {
input_handler_.set_send_mouse_input_when_unfocused(true);
}
ChromotingStats* ChromotingInstance::GetStats() {
if (!video_renderer_.get())
return NULL;
......
......@@ -209,6 +209,7 @@ class ChromotingInstance :
void HandleExtensionMessage(const base::DictionaryValue& data);
void HandleAllowMouseLockMessage();
void HandleEnableMediaSourceRendering();
void HandleSendMouseInputWhenUnfocused();
// Helper method called from Connect() to connect with parsed config.
void ConnectWithConfig(const ClientConfig& config,
......
......@@ -23,6 +23,7 @@ PepperInputHandler::PepperInputHandler(
input_stub_(NULL),
callback_factory_(this),
has_focus_(false),
send_mouse_input_when_unfocused_(false),
mouse_lock_state_(MouseLockDisallowed),
wheel_delta_x_(0),
wheel_delta_y_(0),
......@@ -74,7 +75,7 @@ bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event) {
case PP_INPUTEVENT_TYPE_MOUSEDOWN:
case PP_INPUTEVENT_TYPE_MOUSEUP: {
if (!has_focus_)
if (!has_focus_ && !send_mouse_input_when_unfocused_)
return false;
pp::MouseInputEvent pp_mouse_event(event);
......@@ -114,7 +115,7 @@ bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event) {
case PP_INPUTEVENT_TYPE_MOUSEMOVE:
case PP_INPUTEVENT_TYPE_MOUSEENTER:
case PP_INPUTEVENT_TYPE_MOUSELEAVE: {
if (!has_focus_)
if (!has_focus_ && !send_mouse_input_when_unfocused_)
return false;
pp::MouseInputEvent pp_mouse_event(event);
......@@ -135,7 +136,7 @@ bool PepperInputHandler::HandleInputEvent(const pp::InputEvent& event) {
}
case PP_INPUTEVENT_TYPE_WHEEL: {
if (!has_focus_)
if (!has_focus_ && !send_mouse_input_when_unfocused_)
return false;
pp::WheelInputEvent pp_wheel_event(event);
......
......@@ -48,6 +48,12 @@ class PepperInputHandler : public pp::MouseLock {
void SetMouseCursor(scoped_ptr<pp::ImageData> image,
const pp::Point& hotspot);
// Enable or disable sending mouse input when the plugin does not have input
// focus.
void set_send_mouse_input_when_unfocused(bool send) {
send_mouse_input_when_unfocused_ = send;
}
private:
enum MouseLockState {
MouseLockDisallowed,
......@@ -90,6 +96,10 @@ class PepperInputHandler : public pp::MouseLock {
// True if the plugin has focus.
bool has_focus_;
// True if the plugin should respond to mouse input even if it does not have
// keyboard focus.
bool send_mouse_input_when_unfocused_;
MouseLockState mouse_lock_state_;
// Accumulated sub-pixel and sub-tick deltas from wheel events.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment