📢 Webサイト閉鎖と移転のお知らせ
このWebサイトは2026年9月に閉鎖いたします。
新しい記事は移転先で追加しております。(旧サイトでは記事を追加しておりません)

 
(同じ利用者による、間の6版が非表示)
35行目: 35行目:
<br><br>
<br><br>


==== Fcitxのインストール (リポジトリを追加してインストール) ====
== Fcitxのインストール (リポジトリを追加してインストール) ==
SUSEの公式リポジトリからM17Nリポジトリを追加する。<br>
SUSEの公式リポジトリからM17Nリポジトリを追加する。<br>
  # SLE / openSUSE Leap
  # SLE / openSUSE Leap
58行目: 58行目:
<br><br>
<br><br>


== Mozcのインストール ==
== Mozcのインストール (ソースコードからインストール) ==
==== ソースコードのダウンロード ====
==== ソースコードのダウンロード ====
SLE 15において、現在、パッケージ管理システムにFcitx-mozcが存在しない。<br>
SLE 15において、現在、パッケージ管理システムにFcitx-mozcが存在しない。<br>
91行目: 91行目:
* src/WORKSPACE.bazel
* src/WORKSPACE.bazel
*: ビルドの依存関係。
*: ビルドの依存関係。
<br>
==== インストールディレクトリの設定 ====
必要ならば、srcディレクトリにあるconfig.bzlファイルを編集して、インストールディレクトリを変更する。<br>
vi mozc/src/config.bzl
<br>
# mozc/src/config.bzlファイル
LINUX_MOZC_BROWSER_COMMAND = "/usr/bin/xdg-open"
LINUX_MOZC_ICONS_DIR = "/<Mozcのインストールディクトリ>/share/icons/mozc"
LINUX_MOZC_SERVER_DIR = "/<Mozcのインストールディクトリ>/lib/mozc"
LINUX_MOZC_DOCUMENT_DIR = LINUX_MOZC_SERVER_DIR + "/documents"
IBUS_COMPONENT_DIR = "/<Mozcのインストールディクトリ>/share/ibus/component"
IBUS_MOZC_INSTALL_DIR = "/<Mozcのインストールディクトリ>/share/ibus-mozc"
IBUS_MOZC_ICON_PATH = IBUS_MOZC_INSTALL_DIR + "/product_icon.png"
IBUS_MOZC_PATH = "/<Mozcのインストールディクトリ>/lib/ibus-mozc/ibus-engine-mozc"
EMACS_MOZC_CLIENT_DIR = "/<Mozcのインストールディクトリ>/share/emacs/site-lisp/emacs-mozc"
EMACS_MOZC_HELPER_DIR = "/<Mozcのインストールディクトリ>/bin"
<br>
==== Bazelの設定ファイルの作成と変更 ====
===== WORKSPACEの編集 =====
src/WORKSPACE.bazelファイルを編集して、以下に示す設定を追記する。<br>
vi src/WORKSPACE.bazel
<br>
* パッケージ管理システムからFcitxをインストールしている場合
# src/WORKSPACE.bazelファイル
## 138行目あたり
# Fcitx
# pkg_config_repository does not work because pkgconfig --cflags-only-I fcitx returns nothing
new_local_repository(
  name = "fcitx",
  # This path should be updated per the environment.
  path = "/usr",  # For Debian
  build_file = "BUILD.fcitx.bazel",
)
<br>
* ソースコードからFcitxをインストールしている場合
# src/WORKSPACE.bazelファイル
## 138行目あたり
# Fcitx
new_local_repository(
  name = "fcitx",
  path = "/<Fcitxのインストールディレクトリ>",
  build_file = "BUILD.fcitx.bazel",
)
<br>
src/BUILD.fcitx.bazelファイルを作成する。<br>
vi src/BUILD.fcitx.bazel
<br>
# src/BUILD.fcitx.bazelファイル
package(
    default_visibility = ["//visibility:public"],
)
cc_library(
    name = "fcitx",
    hdrs = glob([
        "include/fcitx/**",
        "include/fcitx-config/**",
        "include/fcitx-utils/**",
    ]),
    copts = ["-pthread"],
    includes = [
        "include",
    ],
    linkopts = [
        "-lfcitx-core",
        "-lfcitx-config",
        "-lfcitx-utils",
    ],
)
<br>
===== Python 3.6を使用している場合 =====
vi src/base/gen_config_file_stream_data.py
<br>
<syntaxhighlight lang="python">
# src/base/gen_config_file_stream_data.pyファイル
# 68行目あたり
## 編集前
output.write('constexpr FileData kFileData[] = {\n')
for path in path_list:
    output.write('  {"%s", "' % os.path.basename(path))
    with open(path, 'rb') as stream:
      while (byte := stream.read(1)):
          output.write(r'\x' + byte.hex())
    output.write('"},\n')
output.write('};\n')
## 編集後
output.write('constexpr FileData kFileData[] = {\n')
for path in path_list:
    output.write('  {"%s", "' % os.path.basename(path))
    with open(path, 'rb') as stream:
      byte = stream.read(1)
      while (byte):
          output.write(r'\x' + byte.hex())
          byte = stream.read(1)
    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 "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>
<br>


140行目: 398行目:
<u>必要であれば、src/scripts/install_fcitx_bazelファイルおよびsrc/scripts/install_server_bazelファイルの内容を参照する。</u><br>
<u>必要であれば、src/scripts/install_fcitx_bazelファイルおよびsrc/scripts/install_server_bazelファイルの内容を参照する。</u><br>
<br>
<br>
==== Mozcの設定ファイルの作成 ====
==== Mozcの設定ファイルの作成 ====
Mozcのアドオン設定ファイル、および、インプットメソッド設定ファイルを作成する。<br>
Mozcのアドオン設定ファイル、および、インプットメソッド設定ファイルを作成する。<br>
147行目: 406行目:
<br>
<br>
  <syntaxhighlight lang="ini">
  <syntaxhighlight lang="ini">
  # /<Mozcのインストールディレクトリ>/share/fcitx5/addon/mozc.conf
  # /<Mozcのインストールディレクトリ>/share/fcitx/addon/fcitx-mozc.conf
  # または
  # または
  # /usr/share/fcitx/addon/fcitx-mozc.confファイル
  # /usr/share/fcitx/addon/fcitx-mozc.confファイル
354行目: 613行目:
再ログインまたはPCを再起動する。<br>
再ログインまたはPCを再起動する。<br>
<br><br>
<br><br>
{{#seo:
|title={{PAGENAME}} : Exploring Electronics and SUSE Linux | MochiuWiki
|keywords=MochiuWiki,Mochiu,Wiki,Mochiu Wiki,Electric Circuit,Electric,pcb,Mathematics,AVR,TI,STMicro,AVR,ATmega,MSP430,STM,Arduino,Xilinx,FPGA,Verilog,HDL,PinePhone,Pine Phone,Raspberry,Raspberry Pi,C,C++,C#,Qt,Qml,MFC,Shell,Bash,Zsh,Fish,SUSE,SLE,Suse Enterprise,Suse Linux,openSUSE,open SUSE,Leap,Linux,uCLnux,Podman,電気回路,電子回路,基板,プリント基板
|description={{PAGENAME}} - 電子回路とSUSE Linuxに関する情報 | This page is {{PAGENAME}} in our wiki about electronic circuits and SUSE Linux
|image=/resources/assets/MochiuLogo_Single_Blue.png
}}


__FORCETOC__
__FORCETOC__
[[カテゴリ:RHEL]][[カテゴリ:SUSE]]
[[カテゴリ:RHEL]][[カテゴリ:SUSE]]