Merge lp:~michael-sheldon/oxide/input-focus-fix into lp:~oxide-developers/oxide/oxide.trunk

Proposed by Michael Sheldon
Status: Merged
Merged at revision: 617
Proposed branch: lp:~michael-sheldon/oxide/input-focus-fix
Merge into: lp:~oxide-developers/oxide/oxide.trunk
Diff against target: 22 lines (+5/-0)
1 file modified
qt/core/browser/oxide_qt_render_widget_host_view.cc (+5/-0)
To merge this branch: bzr merge lp:~michael-sheldon/oxide/input-focus-fix
Reviewer Review Type Date Requested Status
Chris Coulson Approve
Review via email: mp+222507@code.launchpad.net

Commit message

Force Qt focus object changed events when the oxide focused node changes

Description of the change

Works around bug #1323743. After launching the browser via a call to Qt.openExternalUrl() from inside a webapp (e.g. by clicking a link in twitter) and then returning to the webapp, the keyboard stops appearing because the setFocusObject() method is no longer being called on the QInputContext (which is done internally by QGuiApplication). I'm still not clear on why this is the case, but this branch at least provides a work around by explicitly triggering a focus object changed event.

To post a comment you must log in.
Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Just waiting for build with latest changes merged in to finish building to confirm unit tests, then will be ready for review.

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Unit tests passing, ready for review :)

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Need to spend a bit more time testing this on device; saw a crash earlier that may be unrelated (or related to some other changes I was testing) but I want to investigate a bit before this goes any further.

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

Crash was unrelated to this particular change, (it was instead related to resetting the input method at an inappropriate time, a separate change I was testing previously to fix this issue).

To give a bit more detail on what's happening here:

Maliit won't display the keyboard if it doesn't have a valid focus object, if it gets a call to show the keyboard without a focus object it will place it in a "pending" state and wait for the focus object to be set.

The focus object is set via a call to setFocusObject() on the QInputContext interface, which is done internally by QGuiApplication. This all functions correctly within oxide until a call to Qt.openExternalURL() is made by a webapp, after this the setFocusObject() method is never called again and so the keyboard won't display until the webapp is restarted.

This branch works around this by manually triggering the focusObjectChanged signal from the current focusWindow, which then causes QGuiApplication to run setFocusObject on the QInputContext.

Revision history for this message
Olivier Tilloy (osomon) wrote :

If I read the code correctly, QGuiApplicationPrivate::_q_updateFocusObject() is the slot that calls setFocusObject() on the input context, and it is being connected to/called in QGuiApplicationPrivate::processActivatedEvent(). It would be interesting to instrument that code (yes, that means rebuilding Qt…) to understand what’s going on more in depth. It might be a problem in QtUbuntu itself.

Revision history for this message
Chris Coulson (chrisccoulson) wrote :

Ok, let's get this in for now as long as we have a bug tracking the underlying problem. I just have a minor nit - could you please update the comment to point to the actual bug URL (so it's click-able from vim)?

- // Work around for bug lp:1323743
+ // Work around for https://launchpad.net/bugs/1323743

review: Approve
581. By Michael Sheldon

Change commented bug reference to launchpad link

Revision history for this message
Michael Sheldon (michael-sheldon) wrote :

I've now also opened bug: https://bugs.launchpad.net/oxide/+bug/1332505 to track the investigation of the underlying issue.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qt/core/browser/oxide_qt_render_widget_host_view.cc'
2--- qt/core/browser/oxide_qt_render_widget_host_view.cc 2014-06-19 17:41:21 +0000
3+++ qt/core/browser/oxide_qt_render_widget_host_view.cc 2014-06-20 11:36:19 +0000
4@@ -35,6 +35,7 @@
5 #include <QTextCharFormat>
6 #include <QTouchEvent>
7 #include <QWheelEvent>
8+#include <QWindow>
9
10 #include "base/logging.h"
11 #include "base/strings/utf_string_conversions.h"
12@@ -817,6 +818,10 @@
13 if (!HasFocus()) {
14 return;
15 }
16+
17+ // Work around for https://launchpad.net/bugs/1323743
18+ QGuiApplication::focusWindow()->focusObjectChanged(QGuiApplication::focusWindow()->focusObject());
19+
20 delegate_->SetInputMethodEnabled(is_editable_node);
21 if (QGuiApplication::inputMethod()->isVisible() != is_editable_node) {
22 QGuiApplication::inputMethod()->setVisible(is_editable_node);

Subscribers

People subscribed via source and target branches