Commit 758a02d9 authored by Jamie Walch's avatar Jamie Walch Committed by Commit Bot

Set initial pointer shape on entering pointer lock.

When pointer lock is active on the client, the host composites the
mouse cursor into the desktop image. When pointer lock is deactivated,
it sets a blank cursor to disable compositing, but this resulted in
no compositing after pointer lock was reactivated until the cursor
shape changed.

This CL inserts ClientSession between the MouseShapePump and the
DesktopAndCursorComposer, allowing cursor shape changes that occur
while pointer lock is inactive to be saved so that compositing can
resume when pointer lock is reactived.

Bug: 1043325
Change-Id: I70edc0ae3d1a45595fe5a7d9298c4f02b921d696
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2023519
Auto-Submit: Jamie Walch <jamiewalch@chromium.org>
Reviewed-by: default avatarYuwei Huang <yuweih@chromium.org>
Commit-Queue: Jamie Walch <jamiewalch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735693}
parent 9d14e4b8
......@@ -40,7 +40,6 @@
#include "remoting/protocol/session_config.h"
#include "remoting/protocol/video_frame_pump.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
#include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h"
namespace remoting {
......@@ -390,6 +389,7 @@ void ClientSession::OnConnectionChannelsConnected() {
mouse_shape_pump_.reset(
new MouseShapePump(desktop_environment_->CreateMouseCursorMonitor(),
connection_->client_stub()));
mouse_shape_pump_->SetMouseCursorMonitorCallback(this);
// Create KeyboardLayoutMonitor to send keyboard layout.
// Unretained is sound because callback will never be called after
......@@ -505,15 +505,29 @@ ClientSessionControl* ClientSession::session_control() {
void ClientSession::OnPointerLockChanged(bool active) {
if (active) {
mouse_shape_pump_->SetMouseCursorMonitorCallback(
desktop_and_cursor_composer_raw_);
if (mouse_cursor_ && desktop_and_cursor_composer_raw_)
desktop_and_cursor_composer_raw_->OnMouseCursor(
webrtc::MouseCursor::CopyOf(*mouse_cursor_));
} else if (desktop_and_cursor_composer_raw_) {
mouse_shape_pump_->SetMouseCursorMonitorCallback(nullptr);
webrtc::MouseCursor* empty = new webrtc::MouseCursor(
new webrtc::BasicDesktopFrame(webrtc::DesktopSize(0, 0)),
webrtc::DesktopVector(0, 0));
desktop_and_cursor_composer_raw_->OnMouseCursor(empty);
}
pointer_lock_active_ = active;
}
void ClientSession::OnMouseCursor(webrtc::MouseCursor* mouse_cursor) {
mouse_cursor_.reset(mouse_cursor);
if (pointer_lock_active_ && desktop_and_cursor_composer_raw_)
desktop_and_cursor_composer_raw_->OnMouseCursor(
webrtc::MouseCursor::CopyOf(*mouse_cursor_));
}
void ClientSession::OnMouseCursorPosition(
const webrtc::DesktopVector& position) {
if (pointer_lock_active_ && desktop_and_cursor_composer_raw_)
desktop_and_cursor_composer_raw_->OnMouseCursorPosition(position);
}
void ClientSession::RegisterCreateHandlerCallbackForTesting(
......
......@@ -41,6 +41,7 @@
#include "third_party/webrtc/modules/desktop_capture/desktop_and_cursor_composer.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_types.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
#include "third_party/webrtc/modules/desktop_capture/mouse_cursor.h"
#include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h"
#include "ui/events/event.h"
......@@ -65,7 +66,8 @@ class ClientSession : public protocol::HostStub,
public protocol::VideoStream::Observer,
public ClientSessionControl,
public ClientSessionDetails,
public PointerLockDetector::EventHandler {
public PointerLockDetector::EventHandler,
public webrtc::MouseCursorMonitor::Callback {
public:
// Callback interface for passing events to the ChromotingHost.
class EventHandler {
......@@ -154,6 +156,10 @@ class ClientSession : public protocol::HostStub,
// PointerLockDetector::EventHandler interface
void OnPointerLockChanged(bool active) override;
// webrtc::MouseCursorMonitor::Callback implementation.
void OnMouseCursor(webrtc::MouseCursor* mouse_cursor) override;
void OnMouseCursorPosition(const webrtc::DesktopVector& position) override;
protocol::ConnectionToClient* connection() const { return connection_.get(); }
bool is_authenticated() { return is_authenticated_; }
......@@ -315,6 +321,9 @@ class ClientSession : public protocol::HostStub,
// relative pointer experiment is a success.
webrtc::DesktopAndCursorComposer* desktop_and_cursor_composer_raw_ = nullptr;
std::unique_ptr<webrtc::MouseCursor> mouse_cursor_;
bool pointer_lock_active_ = false;
SEQUENCE_CHECKER(sequence_checker_);
// Used to disable callbacks to |this| once DisconnectSession() has been
......
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