46 | 46 |
namespace mac{
|
47 | 47 |
|
48 | 48 |
namespace {
|
49 | |
const int kHideWindowDelay = 500; // msec
|
50 | |
const int kMarginAbovePreedit = 10; // pixel
|
|
49 |
const int kHideWindowDelay = 500; // msec
|
|
50 |
const int kWindowMargin = 10; // pixel
|
51 | 51 |
|
52 | 52 |
// In Cocoa's coordinate system the origin point is left-bottom and the Y-axis
|
53 | 53 |
// points up. But in Mozc's coordinate system the Y-axis points down. So we use
|
|
220 | 220 |
mozc::Point(command_.preedit_rectangle().left(),
|
221 | 221 |
command_.preedit_rectangle().top() - GetBaseScreenHeight()),
|
222 | 222 |
preedit_size);
|
223 | |
// Currently preedit_rect doesn't care about the text height -- it
|
224 | |
// just means the line under the preedit. So here we fix the height.
|
225 | |
// TODO(mukai): replace this hack by calculating actual text height.
|
226 | |
preedit_rect.origin.y -= kMarginAbovePreedit;
|
227 | |
preedit_rect.size.height += kMarginAbovePreedit;
|
|
223 |
|
|
224 |
// This is a hacky way to check vertical writing.
|
|
225 |
// TODO(komatsu): We should use the return value of attributesForCharacterIndex
|
|
226 |
// in GoogleJapaneseInputController.mm as a proper way.
|
|
227 |
const bool is_vertical = (preedit_size.height < preedit_size.width);
|
|
228 |
|
|
229 |
// Expand the rect size to make a margin to the candidate window.
|
|
230 |
if (is_vertical) {
|
|
231 |
// Adjust the margin to the candidate window in the right side.
|
|
232 |
preedit_rect.DeflateRect(0, 0, -kWindowMargin, 0); // (dx, dy, dw, dh)
|
|
233 |
} else {
|
|
234 |
// Adjust the margin to the candidate window in the upper side.
|
|
235 |
preedit_rect.DeflateRect(0, -kWindowMargin, 0, 0); // (dx, dy, dw, dh)
|
|
236 |
}
|
228 | 237 |
|
229 | 238 |
// Find out the nearest display.
|
230 | 239 |
const mozc::Rect display_rect = GetNearestDisplayRect(preedit_rect);
|
|
237 | 246 |
const mozc::Point candidate_zero_point(
|
238 | 247 |
candidate_layout->GetColumnRect(COLUMN_CANDIDATE).Left(), 0);
|
239 | 248 |
|
|
249 |
const mozc::Point target_point(preedit_rect.Left(), preedit_rect.Bottom());
|
240 | 250 |
const mozc::Rect candidate_rect =
|
241 | |
WindowUtil::GetWindowRectForMainWindowFromPreeditRect(
|
242 | |
preedit_rect, candidate_window_->GetWindowSize(),
|
243 | |
candidate_zero_point, display_rect);
|
|
251 |
WindowUtil::GetWindowRectForMainWindowFromTargetPointAndPreedit(
|
|
252 |
target_point, preedit_rect,
|
|
253 |
candidate_window_->GetWindowSize(), candidate_zero_point,
|
|
254 |
display_rect, is_vertical);
|
244 | 255 |
candidate_window_->MoveWindow(OriginPointInCocoaCoord(candidate_rect));
|
245 | 256 |
|
246 | 257 |
// Align infolist window
|