582行目: 582行目:
     output.write('"},\n')
     output.write('"},\n')
  output.write('};\n')
  output.write('};\n')
</syntaxhighlight>
<br>
===== Mozcのウインドウレンダリングのソースコードの変更 =====
vi src/renderer/qt/qt_window_manager.cc
<br>
<syntaxhighlight lang="c++">
# src/renderer/qt/qt_window_manager.ccファイル
# 35行目あたり
# 編集前
#include "absl/strings/str_cat.h"
#include "base/logging.h"
#include "protocol/candidates.pb.h"
#include "renderer/renderer_style_handler.h"
#include "renderer/window_util.h"
# 編集後
#include "absl/strings/str_cat.h"
#include "base/logging.h"
#include "protocol/candidates.pb.h"
#include "renderer/renderer_style_handler.h"
#include "renderer/window_util.h"
</syntaxhighlight>
<br>
<syntaxhighlight lang="c++">
# src/renderer/qt/qt_window_manager.ccファイル
# 344行目あたり
# 追加
struct VirtualRect {
    const QScreen* screen;
    const Rect rect;
    VirtualRect(const QScreen* screen, const Rect rect): screen(screen), rect(rect) {}
};
Rect TranslateToVirtualRectWithScreen(const QScreen *screen, const Rect& native_rect) {
    const double device_pixel_ratio = screen->devicePixelRatio();
    // screen_left, screen_top have the save value in both virtual and native coordinate
    const int screen_left = screen->geometry().x();
    const int screen_top = screen->geometry().y();
    const int vx = (native_rect.Left() - screen_left) / device_pixel_ratio + screen_left;
    const int vy = (native_rect.Top() - screen_top) / device_pixel_ratio + screen_top;
    return Rect(vx, vy, native_rect.Width() / device_pixel_ratio, native_rect.Height() / device_pixel_ratio);
}
VirtualRect TranslateToVirtualRect(const Rect& native_rect) {
    for (const QScreen *screen: QGuiApplication::screens()) {
      Rect rect = TranslateToVirtualRectWithScreen(screen, native_rect);
      const QRect screen_rect = screen->geometry();
      // Use (top left) to locate a screen
      if (screen_rect.contains(rect.Left(), rect.Top())) {
          return VirtualRect(screen, rect);
      }
    }
    // fall back to primary screen
    const QScreen *screen = QGuiApplication::primaryScreen();
    Rect point = TranslateToVirtualRectWithScreen(screen, native_rect);
    return VirtualRect(screen, point);
}
</syntaxhighlight>
<br>
<syntaxhighlight lang="c++">
# src/renderer/qt/qt_window_manager.ccファイル
# 379行目あたり
# 編集前
Point QtWindowManager::GetWindowPosition(
    const commands::RendererCommand &command, const Size &win_size) {
    const Rect preedit_rect = GetRect(command.preedit_rectangle());
    const Point win_pos = Point(preedit_rect.Left(), preedit_rect.Bottom());
    const Rect monitor_rect = GetMonitorRect(win_pos.x, win_pos.y);
    const Point offset_to_column1(kColumn0Width, 0);
    const Rect adjusted_win_geometry =
      WindowUtil::GetWindowRectForMainWindowFromTargetPointAndPreedit(
          win_pos, preedit_rect, win_size, offset_to_column1, monitor_rect,
          /* vertical */ false);  // Only support horizontal window yet.
    return adjusted_win_geometry.origin;
}
# 編集後
Point QtWindowManager::GetWindowPosition(
    const commands::RendererCommand &command, const Size &win_size) {
    const Rect native_preedit_rect = GetRect(command.preedit_rectangle());
    const VirtualRect preedit_rect = TranslateToVirtualRect(native_preedit_rect);
    const Point win_pos = Point(preedit_rect.rect.Left(), preedit_rect.rect.Bottom());
    const Rect monitor_rect = GetRect(preedit_rect.screen->geometry());
    const Point offset_to_column1(kColumn0Width, 0);
    const Rect adjusted_win_geometry =
      WindowUtil::GetWindowRectForMainWindowFromTargetPointAndPreedit(
          win_pos, preedit_rect.rect, win_size, offset_to_column1, monitor_rect,
          /* vertical */ false);  // Only support horizontal window yet.
    return adjusted_win_geometry.origin;
}
  </syntaxhighlight>
  </syntaxhighlight>
<br>
<br>