Commit 1e07dedb authored by hausmann@webkit.org's avatar hausmann@webkit.org

2009-04-22 Simon Hausmann <simon.hausmann@nokia.com>

        Reviewed by Ariya Hidayat.

        Fix various bugs in the X11 Qt plugin focus handling.

        Notify the focus controller on activation/deactivation of the plugin and
        set focus on the plugin's element when it receives the window system
        focus.

git-svn-id: svn://svn.chromium.org/blink/trunk@42748 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent d6976e2b
2009-04-22 Simon Hausmann <simon.hausmann@nokia.com>
Reviewed by Ariya Hidayat.
Fix various bugs in the X11 Qt plugin focus handling.
Notify the focus controller on activation/deactivation of the plugin and
set focus on the plugin's element when it receives the window system
focus.
* WebCore.pro: Added PluginContainerQt to the Qt build.
* plugins/PluginView.cpp:
(WebCore::PluginView::focusPluginElement): New helper function, moved from PluginViewWin.
* plugins/PluginView.h:
(WebCore::PluginView::parentFrame): Added parent frame accessor.
* plugins/qt/PluginContainerQt.cpp: Added.
(PluginContainerQt::PluginContainerQt):
(PluginContainerQt::focusInEvent): Set the focus controller active on focus in events.
(PluginContainerQt::focusOutEvent): Deactivate the focus controller when loosing the focus.
* plugins/qt/PluginContainerQt.h: Added.
* plugins/qt/PluginViewQt.cpp:
(WebCore::PluginView::init): Allocate a PluginContainerQt instead of QX11EmbedContainer.
* plugins/win/PluginViewWin.cpp:
(WebCore::PluginView::handleMouseEvent): Moved the code to set focus on the plugin element
to PluginView::focusPluginElement.
2009-04-22 Tamas Szirbucz <szirbucz.tamas@stud.u-szeged.hu> 2009-04-22 Tamas Szirbucz <szirbucz.tamas@stud.u-szeged.hu>
Reviewed by Ariya Hidayat. Reviewed by Ariya Hidayat.
...@@ -1250,8 +1250,11 @@ contains(DEFINES, ENABLE_NETSCAPE_PLUGIN_API=1) { ...@@ -1250,8 +1250,11 @@ contains(DEFINES, ENABLE_NETSCAPE_PLUGIN_API=1) {
} else { } else {
!embedded: CONFIG += x11 !embedded: CONFIG += x11
SOURCES += \ SOURCES += \
plugins/qt/PluginContainerQt.cpp \
plugins/qt/PluginPackageQt.cpp \ plugins/qt/PluginPackageQt.cpp \
plugins/qt/PluginViewQt.cpp plugins/qt/PluginViewQt.cpp
HEADERS += \
plugins/qt/PluginContainerQt.h
DEFINES += XP_UNIX DEFINES += XP_UNIX
} }
} }
......
...@@ -593,6 +593,14 @@ PluginView::PluginView(Frame* parentFrame, const IntSize& size, PluginPackage* p ...@@ -593,6 +593,14 @@ PluginView::PluginView(Frame* parentFrame, const IntSize& size, PluginPackage* p
resize(size); resize(size);
} }
void PluginView::focusPluginElement()
{
// Focus the plugin
if (Page* page = m_parentFrame->page())
page->focusController()->setFocusedFrame(m_parentFrame);
m_parentFrame->document()->setFocusedNode(m_element);
}
void PluginView::didReceiveResponse(const ResourceResponse& response) void PluginView::didReceiveResponse(const ResourceResponse& response)
{ {
if (m_status != PluginStatusLoadedSuccessfully) if (m_status != PluginStatusLoadedSuccessfully)
......
...@@ -173,6 +173,10 @@ namespace WebCore { ...@@ -173,6 +173,10 @@ namespace WebCore {
virtual bool isPluginView() const { return true; } virtual bool isPluginView() const { return true; }
Frame* parentFrame() const { return m_parentFrame; }
void focusPluginElement();
#if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API) #if PLATFORM(WIN_OS) && !PLATFORM(WX) && ENABLE(NETSCAPE_PLUGIN_API)
static LRESULT CALLBACK PluginViewWndProc(HWND, UINT, WPARAM, LPARAM); static LRESULT CALLBACK PluginViewWndProc(HWND, UINT, WPARAM, LPARAM);
LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
......
/*
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include "PluginContainerQt.h"
#include "FocusController.h"
#include "Frame.h"
#include "FrameView.h"
#include "Page.h"
#include "PluginView.h"
using namespace WebCore;
PluginContainerQt::PluginContainerQt(PluginView* view, QWidget* parent)
: QX11EmbedContainer(parent), m_pluginView(view)
{
}
void PluginContainerQt::focusInEvent(QFocusEvent* event)
{
if (Page* page = m_pluginView->parentFrame()->page())
page->focusController()->setActive(true);
m_pluginView->focusPluginElement();
}
void PluginContainerQt::focusOutEvent(QFocusEvent*)
{
if (Page* page = m_pluginView->parentFrame()->page())
page->focusController()->setActive(false);
}
/*
Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef PluginContainerQt_H
#define PluginContainerQt_H
#include <QX11EmbedContainer>
namespace WebCore {
class PluginView;
class PluginContainerQt : public QX11EmbedContainer
{
Q_OBJECT
public:
PluginContainerQt(PluginView*, QWidget* parent);
protected:
virtual void focusInEvent(QFocusEvent*);
virtual void focusOutEvent(QFocusEvent*);
private:
PluginView* m_pluginView;
};
}
#endif // PluginContainerQt_H
...@@ -27,39 +27,37 @@ ...@@ -27,39 +27,37 @@
#include "config.h" #include "config.h"
#include "PluginView.h" #include "PluginView.h"
#include <QWidget>
#include <QX11EmbedContainer>
#include <QX11Info>
#include "NotImplemented.h"
#include "PluginDebug.h"
#include "PluginPackage.h"
#include "npruntime_impl.h"
#include "runtime.h"
#include "runtime_root.h"
#include <runtime/JSLock.h>
#include <runtime/JSValue.h>
#include "JSDOMBinding.h"
#include "ScriptController.h"
#include "Document.h" #include "Document.h"
#include "DocumentLoader.h" #include "DocumentLoader.h"
#include "Element.h" #include "Element.h"
#include "FrameLoader.h" #include "Frame.h"
#include "FrameLoadRequest.h" #include "FrameLoadRequest.h"
#include "FrameLoader.h"
#include "FrameTree.h" #include "FrameTree.h"
#include "Frame.h"
#include "FrameView.h" #include "FrameView.h"
#include "GraphicsContext.h" #include "GraphicsContext.h"
#include "Image.h"
#include "HTMLNames.h" #include "HTMLNames.h"
#include "HTMLPlugInElement.h" #include "HTMLPlugInElement.h"
#include "Image.h"
#include "JSDOMBinding.h"
#include "KeyboardEvent.h" #include "KeyboardEvent.h"
#include "MouseEvent.h" #include "MouseEvent.h"
#include "NotImplemented.h"
#include "Page.h" #include "Page.h"
#include "PlatformMouseEvent.h" #include "PlatformMouseEvent.h"
#include "PluginContainerQt.h"
#include "PluginDebug.h"
#include "PluginPackage.h"
#include "RenderLayer.h" #include "RenderLayer.h"
#include "ScriptController.h"
#include "Settings.h" #include "Settings.h"
#include "npruntime_impl.h"
#include "runtime.h"
#include "runtime_root.h"
#include <QWidget>
#include <QX11Info>
#include <runtime/JSLock.h>
#include <runtime/JSValue.h>
using JSC::ExecState; using JSC::ExecState;
using JSC::Interpreter; using JSC::Interpreter;
...@@ -458,7 +456,7 @@ void PluginView::init() ...@@ -458,7 +456,7 @@ void PluginView::init()
} }
if (m_needsXEmbed) { if (m_needsXEmbed) {
setPlatformWidget(new QX11EmbedContainer(m_parentFrame->view()->hostWindow()->platformWindow())); setPlatformWidget(new PluginContainerQt(this, m_parentFrame->view()->hostWindow()->platformWindow()));
} else { } else {
notImplemented(); notImplemented();
m_status = PluginStatusCanNotLoadPlugin; m_status = PluginStatusCanNotLoadPlugin;
......
...@@ -551,10 +551,7 @@ void PluginView::handleMouseEvent(MouseEvent* event) ...@@ -551,10 +551,7 @@ void PluginView::handleMouseEvent(MouseEvent* event)
} }
} }
else if (event->type() == eventNames().mousedownEvent) { else if (event->type() == eventNames().mousedownEvent) {
// Focus the plugin focusPluginElement();
if (Page* page = m_parentFrame->page())
page->focusController()->setFocusedFrame(m_parentFrame);
m_parentFrame->document()->setFocusedNode(m_element);
switch (event->button()) { switch (event->button()) {
case 0: case 0:
npEvent.event = WM_LBUTTONDOWN; npEvent.event = WM_LBUTTONDOWN;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment