| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/ui/ime/ime_window.h" | 5 #include "chrome/browser/ui/ime/ime_window.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/ime/ime_native_window.h" | 11 #include "chrome/browser/ui/ime/ime_native_window.h" |
| 12 #include "chrome/browser/ui/ime/ime_window_observer.h" | 12 #include "chrome/browser/ui/ime/ime_window_observer.h" |
| 13 #include "content/public/browser/notification_service.h" | 13 #include "content/public/browser/notification_service.h" |
| 14 #include "content/public/browser/render_frame_host.h" | 14 #include "content/public/browser/render_frame_host.h" |
| 15 #include "content/public/browser/render_process_host.h" | 15 #include "content/public/browser/render_process_host.h" |
| 16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
| 17 #include "extensions/common/constants.h" | 17 #include "extensions/common/constants.h" |
| 18 #include "extensions/common/extension.h" | 18 #include "extensions/common/extension.h" |
| 19 #include "extensions/common/manifest_handlers/icons_handler.h" | 19 #include "extensions/common/manifest_handlers/icons_handler.h" |
| 20 #include "ui/display/display.h" | 20 #include "ui/display/display.h" |
| 21 #include "ui/display/display_finder.h" |
| 21 #include "ui/display/screen.h" | 22 #include "ui/display/screen.h" |
| 22 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 // The vertical margin between the cursor and the follow-cursor window. | 27 // The vertical margin between the cursor and the follow-cursor window. |
| 27 const int kFollowCursorMargin = 3; | 28 const int kFollowCursorMargin = 3; |
| 28 | 29 |
| 29 // The offset from the left of follow cursor window to the left of cursor. | 30 // The offset from the left of follow cursor window to the left of cursor. |
| 30 const int kFollowCursorOffset = 32; | 31 const int kFollowCursorOffset = 32; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 95 |
| 95 void ImeWindow::SetBounds(const gfx::Rect& bounds) { | 96 void ImeWindow::SetBounds(const gfx::Rect& bounds) { |
| 96 native_window_->SetBounds(bounds); | 97 native_window_->SetBounds(bounds); |
| 97 } | 98 } |
| 98 | 99 |
| 99 void ImeWindow::FollowCursor(const gfx::Rect& cursor_bounds) { | 100 void ImeWindow::FollowCursor(const gfx::Rect& cursor_bounds) { |
| 100 if (mode_ != FOLLOW_CURSOR) | 101 if (mode_ != FOLLOW_CURSOR) |
| 101 return; | 102 return; |
| 102 | 103 |
| 103 gfx::Rect screen_bounds = | 104 gfx::Rect screen_bounds = |
| 104 display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); | 105 display::FindDisplayNearestPoint( |
| 106 display::Screen::GetScreen()->GetAllDisplays(), |
| 107 gfx::Point(cursor_bounds.x(), cursor_bounds.y()))->bounds(); |
| 105 gfx::Rect window_bounds = native_window_->GetBounds(); | 108 gfx::Rect window_bounds = native_window_->GetBounds(); |
| 106 int screen_width = screen_bounds.width(); | 109 int screen_width = screen_bounds.x() + screen_bounds.width(); |
| 107 int screen_height = screen_bounds.height(); | 110 int screen_height = screen_bounds.y() + screen_bounds.height(); |
| 108 int width = window_bounds.width(); | 111 int width = window_bounds.width(); |
| 109 int height = window_bounds.height(); | 112 int height = window_bounds.height(); |
| 110 // By default, aligns the left of the window client area to the left of the | 113 // By default, aligns the left of the window client area to the left of the |
| 111 // cursor, and aligns the top of the window to the bottom of the cursor. | 114 // cursor, and aligns the top of the window to the bottom of the cursor. |
| 112 // If the right of the window would go beyond the screen bounds, aligns the | 115 // If the right of the window would go beyond the screen bounds, aligns the |
| 113 // right of the window to the screen bounds. | 116 // right of the window to the screen bounds. |
| 114 // If the bottom of the window would go beyond the screen bounds, aligns the | 117 // If the bottom of the window would go beyond the screen bounds, aligns the |
| 115 // bottom of the window to the cursor top. | 118 // bottom of the window to the cursor top. |
| 116 int x = cursor_bounds.x() - kFollowCursorOffset; | 119 int x = cursor_bounds.x() - kFollowCursorOffset; |
| 117 int y = cursor_bounds.y() + cursor_bounds.height() + kFollowCursorMargin; | 120 int y = cursor_bounds.y() + cursor_bounds.height() + kFollowCursorMargin; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 bounds.set_width(pos.width()); | 194 bounds.set_width(pos.width()); |
| 192 bounds.set_height(pos.height()); | 195 bounds.set_height(pos.height()); |
| 193 native_window_->SetBounds(bounds); | 196 native_window_->SetBounds(bounds); |
| 194 } | 197 } |
| 195 | 198 |
| 196 bool ImeWindow::IsPopupOrPanel(const content::WebContents* source) const { | 199 bool ImeWindow::IsPopupOrPanel(const content::WebContents* source) const { |
| 197 return true; | 200 return true; |
| 198 } | 201 } |
| 199 | 202 |
| 200 } // namespace ui | 203 } // namespace ui |
| OLD | NEW |