Skip to content
Merged
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
17 changes: 13 additions & 4 deletions src/frontend/dbusfrontend/dbusfrontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "fcitx-utils/rect.h"
#include "fcitx/addonfactory.h"
#include "fcitx/addoninstance.h"
#include "fcitx/candidatelist.h"
#include "fcitx/event.h"
#include "fcitx/inputcontext.h"
#include "fcitx/inputmethodentry.h"
Expand Down Expand Up @@ -225,10 +226,18 @@ class DBusInputContext1 : public InputContext,
return;
}

auto preedit = instance->outputFilter(this, inputPanel().preedit());
auto auxUp = instance->outputFilter(this, inputPanel().auxUp());
auto auxDown = instance->outputFilter(this, inputPanel().auxDown());
auto candidateList = inputPanel().candidateList();
Text preedit;
Text auxUp;
Text auxDown;
std::shared_ptr<CandidateList> candidateList;
if (!inputPanel().empty()) {
preedit = instance->outputFilter(this, inputPanel().preedit());
auxUp = instance->outputFilter(this, inputPanel().auxUp());
auxDown = instance->outputFilter(this, inputPanel().auxDown());
candidateList = inputPanel().candidateList();
} else if (!inputPanel().overlayMessage().empty()) {
auxUp = inputPanel().overlayMessage();
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
int cursorIndex = 0;

preeditStrings = buildFormattedTextVector(preedit);
Expand Down
12 changes: 12 additions & 0 deletions src/lib/fcitx/inputpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class InputPanelPrivate {
Text auxUp_;
Text preedit_;
Text clientPreedit_;
Text overlayMessage_;
std::shared_ptr<CandidateList> candidate_;
InputContext *ic_;
CustomInputPanelCallback customCallback_ = nullptr;
Expand Down Expand Up @@ -84,6 +85,16 @@ const Text &InputPanel::preedit() const {
return d->preedit_;
}

const Text &InputPanel::overlayMessage() const {
FCITX_D();
return d->overlayMessage_;
}

void InputPanel::setOverlayMessage(Text text) {
FCITX_D();
d->overlayMessage_ = std::move(text);
}

const CustomInputPanelCallback &InputPanel::customInputPanelCallback() const {
FCITX_D();
return d->customCallback_;
Expand Down Expand Up @@ -115,6 +126,7 @@ void InputPanel::reset() {
d->candidate_.reset();
d->auxUp_.clear();
d->auxDown_.clear();
d->overlayMessage_.clear();
d->customCallback_ = nullptr;
d->customVirtualKeyboardCallback_ = nullptr;
}
Expand Down
38 changes: 38 additions & 0 deletions src/lib/fcitx/inputpanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
#define _FCITX_INPUTPANEL_H_

#include <functional>
#include <memory>
#include <fcitx-utils/macros.h>
#include <fcitx/candidatelist.h>
#include <fcitx/fcitxcore_export.h>
#include <fcitx/text.h>

/// \addtogroup FcitxCore
/// \{
Expand Down Expand Up @@ -67,6 +70,41 @@ class FCITXCORE_EXPORT InputPanel {
std::shared_ptr<CandidateList> candidateList() const;
void setCandidateList(std::unique_ptr<CandidateList> candidate);

/**
* An text message that allows the input method to display a message on top
* of the input panel.
*
* When not empty, it should behave as if it is displayed in aux up.
*
* If you just need a naive implementation with timeout, consider using
* Instance::showCustomInputMethodInformation.
*
* This is intended to be used by a third party to display some message when
* engine/temp mode is controlling the input panel.
*
* This message should still be considered as temporary and
* InputPanel::reset will still clear it when the input panel current owner
* want to reset.
*
* @see Instance::showInputMethodInformation
* @see Instance::showCustomInputMethodInformation
*
* @since 5.1.22
*/
const Text &overlayMessage() const;

/**
* Set an overlay message on the input panel.
*
* It will not be shown if input panel has content, otherwise it will be
* shown as if it is in aux up.
*
Comment thread
coderabbitai[bot] marked this conversation as resolved.
* @param text the message to display.
*
* @since 5.1.22
*/
void setOverlayMessage(Text text);

/**
* Return the current input panel display callback.
*
Expand Down
15 changes: 9 additions & 6 deletions src/lib/fcitx/instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ InputState::InputState(InstancePrivate *d, InputContext *ic)
}

void InputState::showInputMethodInformation(const std::string &name) {
ic_->inputPanel().setAuxUp(Text(name));
ic_->inputPanel().setOverlayMessage(Text(name));
ic_->updateUserInterface(UserInterfaceComponent::InputPanel);
lastInfo_ = name;
imInfoTimer_ = d_ptr->eventLoop_.addTimeEvent(
Expand Down Expand Up @@ -615,11 +615,9 @@ void InputState::hideInputMethodInfo() {
}
imInfoTimer_.reset();
auto &panel = ic_->inputPanel();
if (panel.auxDown().empty() && panel.preedit().empty() &&
panel.clientPreedit().empty() &&
(!panel.candidateList() || panel.candidateList()->empty()) &&
panel.auxUp().size() == 1 && panel.auxUp().stringAt(0) == lastInfo_) {
panel.reset();
if (panel.overlayMessage().size() == 1 &&
panel.overlayMessage().stringAt(0) == lastInfo_) {
panel.setOverlayMessage(Text());
ic_->updateUserInterface(UserInterfaceComponent::InputPanel);
}
}
Expand Down Expand Up @@ -664,6 +662,11 @@ Instance::Instance(int argc, char **argv) {
throw InstanceQuietQuit();
}

// Start logging after quietQuit to avoid spamming the log with version
// information when user just want to see the version.
FCITX_INFO() << "Starting fcitx5 " << Instance::version();
FCITX_LOG_IF(Info, isInFlatpak()) << "Running inside flatpak.";

if (arg.runAsDaemon) {
initAsDaemon();
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "fcitx-utils/log.h"
#include "fcitx-utils/misc.h"
#include "fcitx-utils/misc_p.h"
#include "fcitx-utils/semver.h"
#include "fcitx-utils/standardpath.h"
#include "fcitx-utils/standardpaths.h"
#include "fcitx/addonfactory.h"
Expand Down Expand Up @@ -58,7 +59,6 @@ int main(int argc, char *argv[]) {
bool restart = false;
bool canRestart = false;
try {
FCITX_LOG_IF(Info, isInFlatpak()) << "Running inside flatpak.";
Instance instance(argc, argv);
instance.setBinaryMode();
instance.setSignalPipe(selfPipe[0]);
Expand Down
18 changes: 14 additions & 4 deletions src/ui/classic/inputwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <functional>
#include <initializer_list>
#include <limits>
#include <memory>
#include <string>
#include <tuple>
#include <utility>
Expand Down Expand Up @@ -360,8 +361,18 @@ std::pair<int, int> InputWindow::update(InputContext *inputContext) {
inputContext_ = inputContext->watch();

cursor_ = -1;
auto preedit = instance->outputFilter(inputContext, inputPanel.preedit());
auto auxUp = instance->outputFilter(inputContext, inputPanel.auxUp());
Text preedit;
Text auxUp;
Text auxDown;
std::shared_ptr<CandidateList> candidateList;
if (!inputPanel.empty()) {
preedit = instance->outputFilter(inputContext, inputPanel.preedit());
auxUp = instance->outputFilter(inputContext, inputPanel.auxUp());
auxDown = instance->outputFilter(inputContext, inputPanel.auxDown());
candidateList = inputPanel.candidateList();
} else if (!inputPanel.overlayMessage().empty()) {
auxUp = inputPanel.overlayMessage();
}
pango_layout_set_single_paragraph_mode(upperLayout_.get(), true);
setTextToLayout(inputContext, upperLayout_.get(), nullptr, nullptr,
{auxUp, preedit});
Expand All @@ -370,11 +381,10 @@ std::pair<int, int> InputWindow::update(InputContext *inputContext) {
cursor_ = preedit.cursor() + auxUp.toString().size();
}

auto auxDown = instance->outputFilter(inputContext, inputPanel.auxDown());
setTextToLayout(inputContext, lowerLayout_.get(), nullptr, nullptr,
{auxDown});

if (auto candidateList = inputPanel.candidateList()) {
if (candidateList) {
// Count non-placeholder candidates.
int count = 0;

Expand Down
16 changes: 12 additions & 4 deletions src/ui/kimpanel/kimpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,18 @@ void Kimpanel::updateInputPanel(InputContext *inputContext) {
auto *instance = this->instance();
auto &inputPanel = inputContext->inputPanel();

auto preedit = instance->outputFilter(inputContext, inputPanel.preedit());
auto auxUp = instance->outputFilter(inputContext, inputPanel.auxUp());
Text preedit;
Text auxUp;
Text auxDown;
std::shared_ptr<CandidateList> candidateList;
if (!inputPanel.empty()) {
preedit = instance->outputFilter(inputContext, inputPanel.preedit());
auxUp = instance->outputFilter(inputContext, inputPanel.auxUp());
auxDown = instance->outputFilter(inputContext, inputPanel.auxDown());
candidateList = inputPanel.candidateList();
} else if (!inputPanel.overlayMessage().empty()) {
auxUp = inputPanel.overlayMessage();
}
auto preeditString = preedit.toString();
auto auxUpString = auxUp.toString();
if (!preeditString.empty() || !auxUpString.empty()) {
Expand Down Expand Up @@ -347,9 +357,7 @@ void Kimpanel::updateInputPanel(InputContext *inputContext) {
proxy_->showPreedit(false);
}

auto auxDown = instance->outputFilter(inputContext, inputPanel.auxDown());
auto auxDownString = auxDown.toString();
auto candidateList = inputPanel.candidateList();

auto msg = bus_->createMethodCall("org.kde.impanel", "/org/kde/impanel",
"org.kde.impanel2", "SetLookupTable");
Expand Down
Loading