Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/unix/ibus/ibus_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ static_assert(std::is_same<guint, uint>::value, "guint must be uint.");
static_assert(std::is_same<gchar, char>::value, "gchar must be char.");
static_assert(std::is_same<gboolean, int>::value, "gboolean must be int.");

#if !IBUS_CHECK_VERSION(1, 5, 4)
#error "ibus-mozc requires IBus>=1.5.4"
#endif // libibus (<1.5.4)
#if !IBUS_CHECK_VERSION(1, 5, 33)
#error "ibus-mozc requires IBus>=1.5.33"
#endif // libibus (<1.5.33)

#endif // MOZC_UNIX_IBUS_IBUS_HEADER_H_
6 changes: 3 additions & 3 deletions src/unix/ibus/ibus_wrapper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ static_assert(std::is_same<gchar, char>::value, "gchar must be char.");
static_assert(std::is_same<gboolean, int>::value, "gboolean must be int.");
static_assert(std::is_same<gpointer, void*>::value, "gpointer must be void*.");

#if !IBUS_CHECK_VERSION(1, 5, 4)
#error "ibus-mozc requires IBus>=1.5.4"
#endif // libibus (<1.5.4)
#if !IBUS_CHECK_VERSION(1, 5, 33)
#error "ibus-mozc requires IBus>=1.5.33"
#endif // libibus (<1.5.33)

namespace mozc {
namespace ibus {
Expand Down
25 changes: 5 additions & 20 deletions src/unix/ibus/preedit_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,35 +55,20 @@ IbusTextWrapper ComposePreeditText(const commands::Preedit& preedit) {
IBusAttrUnderline attr = IBUS_ATTR_UNDERLINE_ERROR;
switch (segment.annotation()) {
case commands::Preedit::Segment::NONE:
attr = IBUS_ATTR_UNDERLINE_NONE;
// No decoration
break;
case commands::Preedit::Segment::UNDERLINE:
attr = IBUS_ATTR_UNDERLINE_SINGLE;
text.AppendAttribute(IBUS_ATTR_TYPE_HINT, IBUS_ATTR_PREEDIT_WHOLE,
start, end);
break;
case commands::Preedit::Segment::HIGHLIGHT:
attr = IBUS_ATTR_UNDERLINE_DOUBLE;
text.AppendAttribute(IBUS_ATTR_TYPE_HINT, IBUS_ATTR_PREEDIT_SELECTION,
start, end);
break;
default:
LOG(ERROR) << "unknown annotation:" << segment.annotation();
break;
}
end += segment.value_length();
text.AppendAttribute(IBUS_ATTR_TYPE_UNDERLINE, attr, start, end);

// Many applications show a single underline regardless of using
// IBUS_ATTR_UNDERLINE_SINGLE or IBUS_ATTR_UNDERLINE_DOUBLE for some
// reasons. Here we add a background color for the highlighted candidate
// to make it easiliy distinguishable.
if (segment.annotation() == commands::Preedit::Segment::HIGHLIGHT) {
constexpr uint kBackgroundColor = 0xD1EAFF;
text.AppendAttribute(IBUS_ATTR_TYPE_BACKGROUND, kBackgroundColor, start,
end);
// IBUS_ATTR_TYPE_FOREGROUND is necessary to highlight the segment on
// Firefox.
constexpr uint kForegroundColor = 0x000000;
text.AppendAttribute(IBUS_ATTR_TYPE_FOREGROUND, kForegroundColor, start,
end);
}
start = end;
}

Expand Down