• Viktor Engelmann's avatar
    Handle ViewHostMsg_Focus message from chromium · b0324c5e
    Viktor Engelmann authored
    
    Calling the method window.focus() in javascript causes chromium to send
    a ViewHostMsg_Focus message, which is received by RenderViewHost,
    which then calls RenderViewHost::OnFocus.
    This calls WebContentsDelegate::ActivateContents, which does
    nothing in the default implementation. We now override this method in
    WebContentsDelegateQt::ActivateContents and call Focus() on
    the WebContents object IF the new WebEngineSettings value
    AllowWindowActivationFromJavaScript is true (by default, it is false).
    This in turn calls QWebEnginePagePrivate::focusContainer.
    The WebEnginePage now calls QWidget::activateWindow() in addition
    to QWidget::setFocus, to make sure the window is also activated (which
    it might not be, if multiple windows are open).
    For the QML side, a new boolean Property
    allowWindowActivationFromJavaScript was added.
    
    Task-number: QTBUG-58800
    Change-Id: Iabf5d4d15236c77838a3886de81e9dafcaf49f5d
    Reviewed-by: default avatarJüri Valdmann <juri.valdmann@qt.io>
    Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@qt.io>
    b0324c5e
examples.pro 260 bytes
TEMPLATE=subdirs
qtHaveModule(webengine) {
    SUBDIRS += webengine/quicknanobrowser
qtHaveModule(webenginewidgets) {
    SUBDIRS += \
        webenginewidgets/demobrowser \
        webenginewidgets/fancybrowser \
        webenginewidgets/markdowneditor