PDA

View Full Version : Dead-keys not working on flash player with QtWebkit



Rafaelfsilva
26th May 2014, 22:56
Hi! Good afternoon!

I'm trying to write a client for an online flash game as we don't have any clients for linux. (We can just play by using the browser. Maybe someone wrote any for personal use only, I don't know.)

So, everything works so far but I can't type any characters that use accents like "é" or any other dead-keys. When I press "´" first and then "e", nothing happens.
Note: These characters works normally on normal HTML inputs.

I've tested the code on an flash demo online that contains text input and it also does not work with Qt Webkit, but works on Chromium.

I'm using Linux amd64 with KDE and the problem happens with Qt 5.2.1 and Qt 5.3, both amd64, if I remember correctly it works with Qt 4.8 without problems, but the game goes somewhat slow in Qt 4.8. With Qt 5.3 it's faster than Chromium.

Here's a minimal sample code for reproducing the problem:

#include <QApplication>
#include <QWebView>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QWebView web;
web.settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
web.settings()->setAttribute(QWebSettings::PluginsEnabled, true);
web.load(QUrl("http://www.flex-component.com/demo/kctextarea/"));
web.show();

return a.exec();
}

Solutions I've tried:
- Install an event filter on QApplication.
Result: The dead-keys only gets KeyRelease events and no KeyPress events.

- Send these keys using QApplication::postEvent.
Result: Nothing changes, same problem.

- Generate the KeyPress events for these keys and call QWebPage::event.
Result: Works for every other key, but not for dead-keys. Same problem.

- Enumerate X11 windows and send the keystrokes directly using Xlib or xcb (I've tried both).
Result: The code still gets inside Qt event loop and nothing happens, same problem.
Extra info: I think I've got only the QWebPage or QWebView X handle.

- Explicitly setting QLocale to Brazilian Portuguese. (I'm Brazilian but I prefer to use English language on my system)
Result: Nothing changes, same problem.

My next option would be loading the flash plugin without Qt WebKit at all but it's a lot of work and I'm not sure if it'll be good as the webkit implementation which just works fine. I'm afraid of getting more problems and losing too much time and resolving just one problem. Anyway, I'll try this later.

Also: "ç" just works fine, maybe because it's an existing key on my keyboard layout, so I'll guess this isn't a problem with the keyboard layout being different for flash player only. (It does get KeyPress and KeyRelease as every key.)

Is there any way or any workaround to make these keys works? Or any function/flags I could try to fix this problem?