Skip to content

Commit

Permalink
Try to workaround inconsistency if QWidget focus proxy is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
wengxt committed Nov 23, 2022
1 parent 85c164e commit fbc5f69
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 92 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -79,7 +79,7 @@ if(ENABLE_QT5)
endif()

if(ENABLE_QT6)
find_package(Qt6 ${REQUIRED_QT6_VERSION} CONFIG REQUIRED Core DBus)
find_package(Qt6 ${REQUIRED_QT6_VERSION} CONFIG REQUIRED Core DBus Widgets)
find_package(Qt6Gui ${REQUIRED_QT6_VERSION} REQUIRED Private)
add_subdirectory(qt6)
endif()
Expand Down
1 change: 1 addition & 0 deletions qt5/platforminputcontext/CMakeLists.txt
Expand Up @@ -40,6 +40,7 @@ target_link_libraries(fcitx5platforminputcontextplugin
Qt5::Core
Qt5::Gui
Qt5::DBus
Qt5::Widgets
XCB::XCB
Fcitx5Qt5::DBusAddons
XKBCommon::XKBCommon
Expand Down
10 changes: 5 additions & 5 deletions qt5/platforminputcontext/fcitxcandidatewindow.cpp
Expand Up @@ -83,8 +83,9 @@ class MultilineText {
QRect boundingRect_;
};

FcitxCandidateWindow::FcitxCandidateWindow(QWindow *window, FcitxTheme *theme)
: QWindow(), theme_(theme), parent_(window) {
FcitxCandidateWindow::FcitxCandidateWindow(QWindow *window,
QFcitxPlatformInputContext *context)
: QWindow(), context_(context), theme_(context->theme()), parent_(window) {
setFlags(Qt::ToolTip | Qt::FramelessWindowHint |
Qt::BypassWindowManagerHint | Qt::WindowDoesNotAcceptFocus |
Qt::NoDropShadowWindowHint);
Expand Down Expand Up @@ -356,7 +357,7 @@ void FcitxCandidateWindow::updateClientSideUI(
bool candidatesVisible = !candidates.isEmpty();
bool visible =
preeditVisible || auxUpVisbile || auxDownVisible || candidatesVisible;
auto window = QGuiApplication::focusWindow();
auto window = context_->focusWindowWrapper();
if (!theme_ || !visible || !window || window != parent_) {
hide();
return;
Expand Down Expand Up @@ -413,8 +414,7 @@ void FcitxCandidateWindow::updateClientSideUI(
sizeWithoutShadow.setHeight(0);
}

QRect cursorRect =
QGuiApplication::inputMethod()->cursorRectangle().toRect();
QRect cursorRect = context_->cursorRectangleWrapper();
QRect screenGeometry;
// Try to apply the screen edge detection over the window, because if we
// intent to use this with wayland. It we have no information above screen
Expand Down
6 changes: 4 additions & 2 deletions qt5/platforminputcontext/fcitxcandidatewindow.h
Expand Up @@ -21,14 +21,15 @@

namespace fcitx {

struct FcitxQtICData;
class FcitxTheme;
class MultilineText;
class QFcitxPlatformInputContext;

class FcitxCandidateWindow : public QWindow {
Q_OBJECT
public:
explicit FcitxCandidateWindow(QWindow *window, FcitxTheme *theme);
explicit FcitxCandidateWindow(QWindow *window,
QFcitxPlatformInputContext *context);
~FcitxCandidateWindow();

void render(QPainter *painter);
Expand Down Expand Up @@ -69,6 +70,7 @@ public Q_SLOTS:
const bool isWayland_ =
QGuiApplication::platformName().startsWith("wayland");
QSize actualSize_;
QPointer<QFcitxPlatformInputContext> context_;
QPointer<FcitxTheme> theme_;
QBackingStore *backingStore_;
QTextLayout upperLayout_;
Expand Down

0 comments on commit fbc5f69

Please sign in to comment.