| Index: content/browser/renderer_host/render_widget_host.cc
|
| diff --git a/content/browser/renderer_host/render_widget_host.cc b/content/browser/renderer_host/render_widget_host.cc
|
| index e370fe45b793bd636b9a2228d866e01f9fd1089a..b163947a6088f57d1b4048a1ec3eeb99d92933a1 100644
|
| --- a/content/browser/renderer_host/render_widget_host.cc
|
| +++ b/content/browser/renderer_host/render_widget_host.cc
|
| @@ -183,6 +183,8 @@ bool RenderWidgetHost::OnMessageReceived(const IPC::Message &msg) {
|
| OnMsgImeCancelComposition)
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_DidActivateAcceleratedCompositing,
|
| OnMsgDidActivateAcceleratedCompositing)
|
| + IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnMsgLockMouse)
|
| + IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnMsgUnlockMouse)
|
| #if defined(OS_POSIX)
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_GetScreenInfo, OnMsgGetScreenInfo)
|
| IPC_MESSAGE_HANDLER(ViewHostMsg_GetWindowRect, OnMsgGetWindowRect)
|
| @@ -365,6 +367,9 @@ void RenderWidgetHost::Focus() {
|
| }
|
|
|
| void RenderWidgetHost::Blur() {
|
| + if (IsMouseLocked())
|
| + view_->UnlockMouse();
|
| +
|
| Send(new ViewMsg_SetFocus(routing_id_, false));
|
| }
|
|
|
| @@ -372,7 +377,18 @@ void RenderWidgetHost::LostCapture() {
|
| Send(new ViewMsg_MouseCaptureLost(routing_id_));
|
| }
|
|
|
| +void RenderWidgetHost::LostMouseLock() {
|
| + Send(new ViewMsg_MouseLockLost(routing_id_));
|
| +}
|
| +
|
| void RenderWidgetHost::ViewDestroyed() {
|
| + // TODO(yzshen): Is it necessary to consider the case that this class calls
|
| + // Destory on RenderWidgetHostView, and then we won't get a notification of
|
| + // ViewDestroyed? At that point, does it make sense to send message to the
|
| + // renderer side?
|
| + if (IsMouseLocked())
|
| + view_->UnlockMouse();
|
| +
|
| // TODO(evanm): tracking this may no longer be necessary;
|
| // eliminate this function if so.
|
| SetView(NULL);
|
| @@ -511,7 +527,16 @@ void RenderWidgetHost::ForwardMouseEvent(const WebMouseEvent& mouse_event) {
|
| // more WM_MOUSEMOVE events than we wish to send to the renderer.
|
| if (mouse_event.type == WebInputEvent::MouseMove) {
|
| if (mouse_move_pending_) {
|
| - next_mouse_move_.reset(new WebMouseEvent(mouse_event));
|
| + if (!next_mouse_move_.get()) {
|
| + next_mouse_move_.reset(new WebMouseEvent(mouse_event));
|
| + } else {
|
| + // Accumulate movement deltas.
|
| + int x = next_mouse_move_->movementX;
|
| + int y = next_mouse_move_->movementY;
|
| + *next_mouse_move_ = mouse_event;
|
| + next_mouse_move_->movementX += x;
|
| + next_mouse_move_->movementY += y;
|
| + }
|
| return;
|
| }
|
| mouse_move_pending_ = true;
|
| @@ -766,6 +791,10 @@ void RenderWidgetHost::ImeCancelComposition() {
|
| std::vector<WebKit::WebCompositionUnderline>(), 0, 0));
|
| }
|
|
|
| +bool RenderWidgetHost::IsMouseLocked() const {
|
| + return view_ ? view_->mouse_locked() : false;
|
| +}
|
| +
|
| void RenderWidgetHost::Destroy() {
|
| NotificationService::current()->Notify(
|
| content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
|
| @@ -1111,6 +1140,21 @@ void RenderWidgetHost::OnMsgDidActivateAcceleratedCompositing(bool activated) {
|
| #endif
|
| }
|
|
|
| +void RenderWidgetHost::OnMsgLockMouse() {
|
| + // TODO(yzshen): Only allow to lock the mouse when in fullscreen mode, and
|
| + // make sure that the mouse is unlocked when leaving fullscreen mode.
|
| + if (!view_ || !view_->HasFocus() || !view_->LockMouse()) {
|
| + Send(new ViewMsg_LockMouse_ACK(routing_id_, false));
|
| + } else {
|
| + Send(new ViewMsg_LockMouse_ACK(routing_id_, true));
|
| + }
|
| +}
|
| +
|
| +void RenderWidgetHost::OnMsgUnlockMouse() {
|
| + if (IsMouseLocked())
|
| + view_->UnlockMouse();
|
| +}
|
| +
|
| #if defined(OS_POSIX)
|
| void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId window_id,
|
| WebKit::WebScreenInfo* results) {
|
|
|