Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 63dda1c7 authored by Leon Scroggins's avatar Leon Scroggins
Browse files

Make webkit's cursor draw at the correct times.

This change is dependent on another change to external/webkit.  Tell the WebViewCore to change its FocusController's "active" status depending upon whether the WebView has focus.  This fixes a bug where we were showing the blinking cursor when the WebView was not in focus.
parent 3071177a
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -3430,6 +3430,7 @@ public class WebView extends AbsoluteLayout
                if (mNativeClass != 0) {
                    nativeRecordButtons(true, false, true);
                }
                setFocusControllerActive(true);
            } else {
                // If our window gained focus, but we do not have it, do not
                // draw the focus ring.
@@ -3455,11 +3456,22 @@ public class WebView extends AbsoluteLayout
            if (mNativeClass != 0) {
                nativeRecordButtons(false, false, true);
            }
            setFocusControllerActive(false);
        }
        invalidate();
        super.onWindowFocusChanged(hasWindowFocus);
    }

    /*
     * Pass a message to WebCore Thread, determining whether the WebCore::Page's
     * FocusController is "active" so that it will draw the blinking cursor.
     */
    private void setFocusControllerActive(boolean active) {
        if (mWebViewCore != null) {
            mWebViewCore.sendMessage(EventHub.SET_ACTIVE, active ? 1 : 0, 0);
        }
    }

    @Override
    protected void onFocusChanged(boolean focused, int direction,
            Rect previouslyFocusedRect) {
@@ -3478,6 +3490,10 @@ public class WebView extends AbsoluteLayout
                if (mNativeClass != 0) {
                    nativeRecordButtons(true, false, true);
                }
                // FIXME: This is unnecessary if we are gaining focus from the
                // TextDialog.  How can we tell if it was the last thing in
                // focus?
                setFocusControllerActive(true);
            //} else {
                // The WebView has gained focus while we do not have
                // windowfocus.  When our window lost focus, we should have
@@ -3491,6 +3507,7 @@ public class WebView extends AbsoluteLayout
                if (mNativeClass != 0) {
                    nativeRecordButtons(false, false, true);
                }
                setFocusControllerActive(false);
            }
            mGotKeyDown = false;
        }
+11 −1
Original line number Diff line number Diff line
@@ -330,6 +330,8 @@ final class WebViewCore {
            String currentText, int keyCode, int keyValue, boolean down,
            boolean cap, boolean fn, boolean sym);

    private native void nativeSetFocusControllerActive(boolean active);

    private native void nativeSaveDocumentState(int frame);

    private native void nativeSetFinalFocus(int framePtr, int nodePtr, int x,
@@ -596,6 +598,10 @@ final class WebViewCore {
        // message used to pass UI touch events to WebCore
        static final int TOUCH_EVENT = 141;

        // Used to tell the focus controller whether to draw the blinking cursor
        // or not, based on whether the WebView has focus.
        static final int SET_ACTIVE = 142;

        // Network-based messaging
        static final int CLEAR_SSL_PREF_TABLE = 150;

@@ -644,7 +650,7 @@ final class WebViewCore {
                public void handleMessage(Message msg) {
                    if (LOGV_ENABLED) {
                        Log.v(LOGTAG, msg.what < LOAD_URL || msg.what 
                                > TOUCH_EVENT ? Integer.toString(msg.what)
                                > SET_ACTIVE ? Integer.toString(msg.what)
                                : HandlerDebugString[msg.what - LOAD_URL]);
                    }
                    switch (msg.what) {
@@ -866,6 +872,10 @@ final class WebViewCore {
                            break;
                        }

                        case SET_ACTIVE:
                            nativeSetFocusControllerActive(msg.arg1 == 1);
                            break;

                        case ADD_JS_INTERFACE:
                            HashMap map = (HashMap) msg.obj;
                            Object obj = map.get("object");