maliit / framework

Core libraries of Maliit and server.
Other
52 stars 49 forks source link

Issues with DBUS and Maliit-Keyboard #76

Closed Langstonius closed 2 years ago

Langstonius commented 2 years ago

Hello, i am attempting to add the Maliit keyboard to a device, but im encountering some issues when trying to communicate via dbus. While I can find the address and connect to the server, when I attempt to connect to the keyboard, it tells me the connection is valid, but attempting to call any methods via dbus specific to the keyboard (such as setting language) produces this error: "No such object path '/com/meego/inputmethod/inputcontext'

Thanks for any insight you can provide.

dobey commented 2 years ago

What keyboard are you trying to use, exactly?

Langstonius commented 2 years ago

I am attempting to use the Maliit-2 keyboard via DBUS.

jpetersen commented 2 years ago

I do not really understand what you really want to achieve, there might be a better way.

DBus is used to communicate between Maliit keyboard and the application input context. For the specific error message, the input context need to register such an object on the DBus. See

https://github.com/maliit/framework/blob/master/connection/dbusserverconnection.cpp#L93

dobey commented 2 years ago

I am attempting to use the Maliit-2 keyboard via DBUS.

https://github.com/maliit/keyboard ?

Can you be more specific about how you are running things. Are you using a Qt application as the client? Gtk3? What?

The DBus interface works very well, and is used in Ubuntu Touch.

Langstonius commented 2 years ago

1) Really appreciate you working with me here.

Back on topic. I have an application that runs on a tablet. i wish to replace the existing keyboard with the maliit-2 keyboard. It was decided that we would utilize dbus to control the keyboard, specifically to adjust its position and to set the current language. One of the reasons it was chosen was because of its language support.

The application is a Qt application, qml to be specific. I am currently attempting to get everything working before I move to the tablet device for additional dev.

Currently, I have a class that opens the dbus connection, gets the address and connects to maliit-server. I am able to do things like setpreedit text for example. However, when I attempt make calls to the keyboard for example to set the current language, i get the aforementioned error message.

I will take a look at that code snippet now, thank you for that JPeterson.

-Langston Ball

Langstonius commented 2 years ago

Unfortunately it seems im a bit dense and am still struggling with this.

 QSharedPointer<Maliit::InputContext::DBus::Address> address;
    QByteArray maliitServerAddress = qgetenv("MALIIT_SERVER_ADDRESS");
    if (!maliitServerAddress.isEmpty()) {
        address.reset(new Maliit::InputContext::DBus::FixedAddress(maliitServerAddress.constData()));
    } else {
        address.reset(new Maliit::InputContext::DBus::DynamicAddress);
    }
    connect(address.data(), SIGNAL(addressReceived(QString)), this, SLOT(setupKeyboard(QString)));
    m_dbusServerConn = new DBusServerConnection(address);

The above code works to allow me to communicate with the server from inside my application. This snippet from the 'setupKeyboard' function is what I thought I would use to connect to the keyboard instance itself

  QDBusConnection lcl = QDBusConnection::connectToPeer(addr, "Maliit::IMServerConnection");
    m_keyboardInterface = new MaliitKeyboardInterface(
                QString(),
                "/com/meego/inputmethod/inputcontext",
                lcl  );

Unfortunately, the following seems to not connect to the keyboard which i am trying to do for 2 main reasons:

Thanks for any insights you can provide. -Langston Ball

dobey commented 2 years ago
  • allow the user to change language

I don't think this can be done via DBus with the new keyboard. Instead it should be done by setting the active language key in GSettings. There is also another key there to be set for which languages are enabled, and there is a menu in the keyboard which shows this list, as well as a Settings… entry, which normally would take one to the settings panel in the system settings of Plasma Mobile or Lomiri (there is no generic settings UI, and other environments aren't really supported so well yet).

  • be able to know when they keyboard is shown and its geometry so that i can adjust my application to make space for the keyboard.

Given your app is QML, you can simply use Qt.inputMethod.keyboardRectangle values to adjust your app's size/anchors: https://doc.qt.io/qt-5/qml-qtqml-qt.html#inputMethod-prop https://doc.qt.io/qt-5/qinputmethod.html#keyboardRectangle-prop

Langstonius commented 2 years ago

Thanks, that's what I searching for!