Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 1906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1917 window_->MoveCursorTo(center); | 1917 window_->MoveCursorTo(center); |
| 1918 return; | 1918 return; |
| 1919 } | 1919 } |
| 1920 | 1920 |
| 1921 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); | 1921 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); |
| 1922 | 1922 |
| 1923 bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED || | 1923 bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED || |
| 1924 event->type() == ui::ET_MOUSE_DRAGGED) && | 1924 event->type() == ui::ET_MOUSE_DRAGGED) && |
| 1925 mouse_event.x == center.x() && mouse_event.y == center.y(); | 1925 mouse_event.x == center.x() && mouse_event.y == center.y(); |
| 1926 | 1926 |
| 1927 // For fractional scale factors, the conversion from pixels to dip and | |
| 1928 // vice versa could result in off by 1 or 2 errors which hurts us because | |
| 1929 // we want to avoid sending the artificial move to center event to the | |
| 1930 // renderer. Sending the move to center to the renderer cause the cursor | |
| 1931 // to bounce around the center of the screen leading to the lock operation | |
| 1932 // not working correctly. | |
| 1933 // Workaround is to treat a mouse move or drag event off by at most 2 px | |
| 1934 // from the center as a move to center event. | |
| 1935 if (synthetic_move_sent_ && (current_device_scale_factor_ != 1)) { | |
|
cpu_(ooo_6.6-7.5)
2015/03/19 03:06:11
but !=1 does not mean fractional scale ..
ananta
2015/03/19 19:49:17
Yeah. I added a function called IsFractionalScaleF
| |
| 1936 if (event->type() == ui::ET_MOUSE_MOVED || | |
| 1937 event->type() == ui::ET_MOUSE_DRAGGED) { | |
| 1938 if ((abs(mouse_event.x - center.x()) <= 2) && | |
| 1939 (abs(mouse_event.y - center.y()) <= 2)) { | |
| 1940 is_move_to_center_event = true; | |
| 1941 } | |
| 1942 } | |
| 1943 } | |
| 1944 | |
| 1927 ModifyEventMovementAndCoords(&mouse_event); | 1945 ModifyEventMovementAndCoords(&mouse_event); |
| 1928 | 1946 |
| 1929 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_; | 1947 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_; |
| 1930 if (should_not_forward) { | 1948 if (should_not_forward) { |
| 1931 synthetic_move_sent_ = false; | 1949 synthetic_move_sent_ = false; |
| 1932 } else { | 1950 } else { |
| 1933 // Check if the mouse has reached the border and needs to be centered. | 1951 // Check if the mouse has reached the border and needs to be centered. |
| 1934 if (ShouldMoveToCenter()) { | 1952 if (ShouldMoveToCenter()) { |
| 1935 synthetic_move_sent_ = true; | 1953 synthetic_move_sent_ = true; |
| 1936 window_->MoveCursorTo(center); | 1954 window_->MoveCursorTo(center); |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2681 | 2699 |
| 2682 //////////////////////////////////////////////////////////////////////////////// | 2700 //////////////////////////////////////////////////////////////////////////////// |
| 2683 // RenderWidgetHostViewBase, public: | 2701 // RenderWidgetHostViewBase, public: |
| 2684 | 2702 |
| 2685 // static | 2703 // static |
| 2686 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2704 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2687 GetScreenInfoForWindow(results, NULL); | 2705 GetScreenInfoForWindow(results, NULL); |
| 2688 } | 2706 } |
| 2689 | 2707 |
| 2690 } // namespace content | 2708 } // namespace content |
| OLD | NEW |