「インストール - Fcitx」の版間の差分

ナビゲーションに移動 検索に移動
196行目: 196行目:
  </syntaxhighlight>
  </syntaxhighlight>
<br>
<br>
===== Mozcのウインドウレンダリングの変更 =====
vi src/renderer/qt/qt_window_manager.cc
<br>
<syntaxhighlight lang="c++">
// src/renderer/qt/qt_window_manager.ccファイル
// 35行目あたり
// 編集前
#include "base/logging.h"
#include "protocol/candidates.pb.h"
#include "absl/strings/str_cat.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>
<br>
===== IBus-Mozcの設定 =====
vi src/unix/ibus/gen_mozc_xml.py
<br>
<syntaxhighlight lang="python">
# src/unix/ibus/gen_mozc_xml.pyファイル
# 261行目あたり
# 編集前
}, {
    'name': 'mozc-off',
    'longname': product_name + ':A_',
    'layout': 'default',
    'layout_variant': '',
    'layout_option': '',
    'rank': 99,
    'symbol': 'A',
    'composition_mode': 'DIRECT',
}]
# 編集後
}, {
    'name': 'mozc-off',
    'longname': product_name + ':A_',
    'layout': 'default',
    'layout_variant': '',
    'layout_option': '',
    'rank': 99,
    'symbol': 'A',
    'composition_mode': 'DIRECT',
}, {
    'name': 'mozc-jp-jp',
    'longname': product_name + " - JP layout",
    'layout': 'jp',
    'layout_variant': '',
    'layout_option': '',
    'rank': 0,
}, {
    'name': 'mozc-us',
    'longname': product_name + " - US layout",
    'layout': 'us',
    'layout_variant': '',
    'layout_option': '',
    'rank': 0,
}, {
    'name': 'mozc-dv',
    'longname': product_name + " - US Dvorak layout",
    'layout': 'us',
    'layout_variant': 'dvorak',
    'layout_option': '',
    'rank': 0,
}]
</syntaxhighlight>
<br>
==== Mozcのビルド ====
==== Mozcのビルド ====
Fcitx-Mozc、Mozcサーバ、Mozcツールをビルドおよびインストールする。<br>
Fcitx-Mozc、Mozcサーバ、Mozcツールをビルドおよびインストールする。<br>

案内メニュー