Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: chrome/browser/ui/ime/ime_window.cc

Issue 2333923005: Finds the nearest display to show the follow-cursor IME window, instead of using the primary one. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 94
94 void ImeWindow::SetBounds(const gfx::Rect& bounds) { 95 void ImeWindow::SetBounds(const gfx::Rect& bounds) {
95 native_window_->SetBounds(bounds); 96 native_window_->SetBounds(bounds);
96 } 97 }
97 98
98 void ImeWindow::FollowCursor(const gfx::Rect& cursor_bounds) { 99 void ImeWindow::FollowCursor(const gfx::Rect& cursor_bounds) {
99 if (mode_ != FOLLOW_CURSOR) 100 if (mode_ != FOLLOW_CURSOR)
100 return; 101 return;
101 102
102 gfx::Rect screen_bounds = 103 gfx::Rect screen_bounds =
103 display::Screen::GetScreen()->GetPrimaryDisplay().bounds(); 104 display::FindDisplayNearestPoint(
105 display::Screen::GetScreen()->GetAllDisplays(),
106 gfx::Point(cursor_bounds.x(), cursor_bounds.y()))->bounds();
104 gfx::Rect window_bounds = native_window_->GetBounds(); 107 gfx::Rect window_bounds = native_window_->GetBounds();
105 int screen_width = screen_bounds.width(); 108 int screen_width = screen_bounds.x() + screen_bounds.width();
106 int screen_height = screen_bounds.height(); 109 int screen_height = screen_bounds.y() + screen_bounds.height();
107 int width = window_bounds.width(); 110 int width = window_bounds.width();
108 int height = window_bounds.height(); 111 int height = window_bounds.height();
109 // By default, aligns the left of the window client area to the left of the 112 // By default, aligns the left of the window client area to the left of the
110 // cursor, and aligns the top of the window to the bottom of the cursor. 113 // cursor, and aligns the top of the window to the bottom of the cursor.
111 // If the right of the window would go beyond the screen bounds, aligns the 114 // If the right of the window would go beyond the screen bounds, aligns the
112 // right of the window to the screen bounds. 115 // right of the window to the screen bounds.
113 // If the bottom of the window would go beyond the screen bounds, aligns the 116 // If the bottom of the window would go beyond the screen bounds, aligns the
114 // bottom of the window to the cursor top. 117 // bottom of the window to the cursor top.
115 int x = cursor_bounds.x() - kFollowCursorOffset; 118 int x = cursor_bounds.x() - kFollowCursorOffset;
116 int y = cursor_bounds.y() + cursor_bounds.height() + kFollowCursorMargin; 119 int y = cursor_bounds.y() + cursor_bounds.height() + kFollowCursorMargin;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 bounds.set_width(pos.width()); 193 bounds.set_width(pos.width());
191 bounds.set_height(pos.height()); 194 bounds.set_height(pos.height());
192 native_window_->SetBounds(bounds); 195 native_window_->SetBounds(bounds);
193 } 196 }
194 197
195 bool ImeWindow::IsPopupOrPanel(const content::WebContents* source) const { 198 bool ImeWindow::IsPopupOrPanel(const content::WebContents* source) const {
196 return true; 199 return true;
197 } 200 }
198 201
199 } // namespace ui 202 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698