Created
December 19, 2011 13:37
-
-
Save Smith1123/1497265 to your computer and use it in GitHub Desktop.
plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/Source/WebCore/plugins/PluginView.cpp b/Source/WebCore/plugins/PluginView.cpp | |
index 81bbcc2..a247377 100644 | |
--- a/Source/WebCore/plugins/PluginView.cpp | |
+++ b/Source/WebCore/plugins/PluginView.cpp | |
@@ -833,7 +833,7 @@ PluginView::PluginView(Frame* parentFrame, const IntSize& size, PluginPackage* p | |
#if defined(XP_MACOSX) | |
, m_isWindowed(false) | |
#else | |
- , m_isWindowed(true) | |
+ , m_isWindowed(false) | |
#endif | |
, m_isTransparent(false) | |
, m_haveInitialized(false) | |
diff --git a/Source/WebCore/plugins/PluginView.h b/Source/WebCore/plugins/PluginView.h | |
index 453acbd..8a79ba9 100644 | |
--- a/Source/WebCore/plugins/PluginView.h | |
+++ b/Source/WebCore/plugins/PluginView.h | |
@@ -248,6 +248,7 @@ namespace WebCore { | |
#if ENABLE(NETSCAPE_PLUGIN_API) | |
static void keepAlive(NPP); | |
+ static Display* x11HostDisplay(); | |
#endif | |
void keepAlive(); | |
diff --git a/Source/WebCore/plugins/qt/PluginContainerQt.cpp b/Source/WebCore/plugins/qt/PluginContainerQt.cpp | |
index 8486180..aa643ec 100644 | |
--- a/Source/WebCore/plugins/qt/PluginContainerQt.cpp | |
+++ b/Source/WebCore/plugins/qt/PluginContainerQt.cpp | |
@@ -1,150 +1,150 @@ | |
-/* | |
- 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 "PlatformKeyboardEvent.h" | |
-#include "PlatformWheelEvent.h" | |
-#include "PluginView.h" | |
-#include <QApplication> | |
-#include <QX11Info> | |
- | |
-using namespace WebCore; | |
- | |
-PluginClientWrapper::PluginClientWrapper(QWidget* parent, WId client) | |
- : QWidget(0, Qt::Popup) | |
-{ | |
- // create a QWidget that adopts the plugin window id, do not give it | |
- // a parent so that we don't end up handling events supposed to be | |
- // handled by the QX11EmbedContainer. | |
- | |
- // without the parent this will be considered a toplevel widget, | |
- // and thus make Qt not quit the event loop after the last window | |
- // has been closed. In order to work around this, we set the window | |
- // type to Qt::Popup. | |
- | |
- create(client, false, true); | |
- m_parent = parent; | |
-} | |
- | |
-PluginClientWrapper::~PluginClientWrapper() | |
-{ | |
- destroy(false, false); | |
-} | |
- | |
-bool PluginClientWrapper::x11Event(XEvent* event) | |
-{ | |
- // modify the event window id and insert it into the Qt event system. | |
- event->xany.window = m_parent->effectiveWinId(); | |
- static_cast<QApplication*>(QApplication::instance())->x11ProcessEvent(event); | |
- return true; | |
-} | |
- | |
-PluginContainerQt::PluginContainerQt(PluginView* view, QWidget* parent) | |
- : QX11EmbedContainer(parent) | |
- , m_pluginView(view) | |
- , m_clientWrapper(0) | |
-{ | |
- connect(this, SIGNAL(clientClosed()), this, SLOT(on_clientClosed())); | |
- connect(this, SIGNAL(clientIsEmbedded()), this, SLOT(on_clientIsEmbedded())); | |
-} | |
- | |
-PluginContainerQt::~PluginContainerQt() | |
-{ | |
- delete m_clientWrapper; | |
- m_pluginView->setPlatformPluginWidget(0); | |
-} | |
- | |
-void PluginContainerQt::on_clientClosed() | |
-{ | |
- delete m_clientWrapper; | |
- m_clientWrapper = 0; | |
-} | |
- | |
-void PluginContainerQt::on_clientIsEmbedded() | |
-{ | |
- delete m_clientWrapper; | |
- m_clientWrapper = 0; | |
- | |
- // Only create a QWidget wrapper for the plugin in the case it isn't in the | |
- // Qt window mapper, and thus receiving events from the Qt event system. | |
- // This way the PluginClientWrapper receives the scroll events and passes | |
- // them to the parent. NOTICE: Native Qt based plugins running in process, | |
- // will already be in the window mapper, and thus creating a wrapper, stops | |
- // them from getting events from Qt, as they are redirected to the wrapper. | |
- if (!QWidget::find(clientWinId())) | |
- m_clientWrapper = new PluginClientWrapper(this, clientWinId()); | |
-} | |
- | |
-void PluginContainerQt::redirectWheelEventsToParent(bool enable) | |
-{ | |
- // steal wheel events from the plugin as we want to handle it. When doing this | |
- // all button 4, 5, 6, and 7, ButtonPress and ButtonRelease events are passed | |
- // to the x11Event handler of the PluginClientWrapper, which then changes the | |
- // window id of the event to the parent of PluginContainer and puts the event | |
- // back into the Qt event loop, so that we will actually scroll the parent | |
- // frame. | |
- for (int buttonNo = 4; buttonNo < 8; buttonNo++) { | |
- if (enable) | |
- XGrabButton(x11Info().display(), buttonNo, AnyModifier, clientWinId(), | |
- false, ButtonPressMask, GrabModeAsync, GrabModeAsync, 0L, 0L); | |
- else | |
- XUngrabButton(x11Info().display(), buttonNo, AnyModifier, clientWinId()); | |
- } | |
-} | |
- | |
-bool PluginContainerQt::x11Event(XEvent* event) | |
-{ | |
- switch (event->type) { | |
- case EnterNotify: | |
- // if the plugin window doesn't have focus we do not want to send wheel | |
- // events to it, but to the parent frame, so let's redirect here. | |
- redirectWheelEventsToParent(!hasFocus()); | |
- break; | |
- case LeaveNotify: | |
- // it is always safe to ungrab wheel events when the mouse leaves the | |
- // plugin window. | |
- redirectWheelEventsToParent(false); | |
- break; | |
- } | |
- | |
- return QX11EmbedContainer::x11Event(event); | |
-} | |
- | |
-void PluginContainerQt::focusInEvent(QFocusEvent* event) | |
-{ | |
- // we got focus, stop redirecting the wheel events | |
- redirectWheelEventsToParent(false); | |
- | |
- 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. | |
+// */ | |
+// | |
+// #include "config.h" | |
+// #include "PluginContainerQt.h" | |
+// | |
+// #include "FocusController.h" | |
+// #include "Frame.h" | |
+// #include "FrameView.h" | |
+// #include "Page.h" | |
+// #include "PlatformKeyboardEvent.h" | |
+// #include "PlatformWheelEvent.h" | |
+// #include "PluginView.h" | |
+// #include <QApplication> | |
+// // #include <QX11Info> | |
+// | |
+// using namespace WebCore; | |
+// | |
+// PluginClientWrapper::PluginClientWrapper(QWidget* parent, WId client) | |
+// : QWidget(0, Qt::Popup) | |
+// { | |
+// // create a QWidget that adopts the plugin window id, do not give it | |
+// // a parent so that we don't end up handling events supposed to be | |
+// // handled by the QX11EmbedContainer. | |
+// | |
+// // without the parent this will be considered a toplevel widget, | |
+// // and thus make Qt not quit the event loop after the last window | |
+// // has been closed. In order to work around this, we set the window | |
+// // type to Qt::Popup. | |
+// | |
+// create(client, false, true); | |
+// m_parent = parent; | |
+// } | |
+// | |
+// PluginClientWrapper::~PluginClientWrapper() | |
+// { | |
+// destroy(false, false); | |
+// } | |
+// | |
+// bool PluginClientWrapper::x11Event(XEvent* event) | |
+// { | |
+// // modify the event window id and insert it into the Qt event system. | |
+// event->xany.window = m_parent->effectiveWinId(); | |
+// static_cast<QApplication*>(QApplication::instance())->x11ProcessEvent(event); | |
+// return true; | |
+// } | |
+// | |
+// PluginContainerQt::PluginContainerQt(PluginView* view, QWidget* parent) | |
+// : QX11EmbedContainer(parent) | |
+// , m_pluginView(view) | |
+// , m_clientWrapper(0) | |
+// { | |
+// connect(this, SIGNAL(clientClosed()), this, SLOT(on_clientClosed())); | |
+// connect(this, SIGNAL(clientIsEmbedded()), this, SLOT(on_clientIsEmbedded())); | |
+// } | |
+// | |
+// PluginContainerQt::~PluginContainerQt() | |
+// { | |
+// delete m_clientWrapper; | |
+// m_pluginView->setPlatformPluginWidget(0); | |
+// } | |
+// | |
+// void PluginContainerQt::on_clientClosed() | |
+// { | |
+// delete m_clientWrapper; | |
+// m_clientWrapper = 0; | |
+// } | |
+// | |
+// void PluginContainerQt::on_clientIsEmbedded() | |
+// { | |
+// delete m_clientWrapper; | |
+// m_clientWrapper = 0; | |
+// | |
+// // Only create a QWidget wrapper for the plugin in the case it isn't in the | |
+// // Qt window mapper, and thus receiving events from the Qt event system. | |
+// // This way the PluginClientWrapper receives the scroll events and passes | |
+// // them to the parent. NOTICE: Native Qt based plugins running in process, | |
+// // will already be in the window mapper, and thus creating a wrapper, stops | |
+// // them from getting events from Qt, as they are redirected to the wrapper. | |
+// if (!QWidget::find(clientWinId())) | |
+// m_clientWrapper = new PluginClientWrapper(this, clientWinId()); | |
+// } | |
+// | |
+// void PluginContainerQt::redirectWheelEventsToParent(bool enable) | |
+// { | |
+// // steal wheel events from the plugin as we want to handle it. When doing this | |
+// // all button 4, 5, 6, and 7, ButtonPress and ButtonRelease events are passed | |
+// // to the x11Event handler of the PluginClientWrapper, which then changes the | |
+// // window id of the event to the parent of PluginContainer and puts the event | |
+// // back into the Qt event loop, so that we will actually scroll the parent | |
+// // frame. | |
+// for (int buttonNo = 4; buttonNo < 8; buttonNo++) { | |
+// if (enable) | |
+// XGrabButton(x11Info().display(), buttonNo, AnyModifier, clientWinId(), | |
+// false, ButtonPressMask, GrabModeAsync, GrabModeAsync, 0L, 0L); | |
+// else | |
+// XUngrabButton(x11Info().display(), buttonNo, AnyModifier, clientWinId()); | |
+// } | |
+// } | |
+// | |
+// bool PluginContainerQt::x11Event(XEvent* event) | |
+// { | |
+// switch (event->type) { | |
+// case EnterNotify: | |
+// // if the plugin window doesn't have focus we do not want to send wheel | |
+// // events to it, but to the parent frame, so let's redirect here. | |
+// redirectWheelEventsToParent(!hasFocus()); | |
+// break; | |
+// case LeaveNotify: | |
+// // it is always safe to ungrab wheel events when the mouse leaves the | |
+// // plugin window. | |
+// redirectWheelEventsToParent(false); | |
+// break; | |
+// } | |
+// | |
+// return QX11EmbedContainer::x11Event(event); | |
+// } | |
+// | |
+// void PluginContainerQt::focusInEvent(QFocusEvent* event) | |
+// { | |
+// // we got focus, stop redirecting the wheel events | |
+// redirectWheelEventsToParent(false); | |
+// | |
+// 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); | |
+// } | |
diff --git a/Source/WebCore/plugins/qt/PluginContainerQt.h b/Source/WebCore/plugins/qt/PluginContainerQt.h | |
index 3a2896d..3122aad 100644 | |
--- a/Source/WebCore/plugins/qt/PluginContainerQt.h | |
+++ b/Source/WebCore/plugins/qt/PluginContainerQt.h | |
@@ -1,63 +1,63 @@ | |
-/* | |
- 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); | |
- ~PluginContainerQt(); | |
- | |
- void redirectWheelEventsToParent(bool enable = true); | |
- | |
- protected: | |
- virtual bool x11Event(XEvent*); | |
- virtual void focusInEvent(QFocusEvent*); | |
- virtual void focusOutEvent(QFocusEvent*); | |
- | |
- public slots: | |
- void on_clientClosed(); | |
- void on_clientIsEmbedded(); | |
- | |
- private: | |
- PluginView* m_pluginView; | |
- QWidget* m_clientWrapper; | |
- }; | |
- | |
- class PluginClientWrapper : public QWidget | |
- { | |
- public: | |
- PluginClientWrapper(QWidget* parent, WId client); | |
- ~PluginClientWrapper(); | |
- bool x11Event(XEvent*); | |
- | |
- private: | |
- QWidget* m_parent; | |
- }; | |
-} | |
- | |
-#endif // PluginContainerQt_h | |
+// /* | |
+// 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); | |
+// ~PluginContainerQt(); | |
+// | |
+// void redirectWheelEventsToParent(bool enable = true); | |
+// | |
+// protected: | |
+// virtual bool x11Event(XEvent*); | |
+// virtual void focusInEvent(QFocusEvent*); | |
+// virtual void focusOutEvent(QFocusEvent*); | |
+// | |
+// public slots: | |
+// void on_clientClosed(); | |
+// void on_clientIsEmbedded(); | |
+// | |
+// private: | |
+// PluginView* m_pluginView; | |
+// QWidget* m_clientWrapper; | |
+// }; | |
+// | |
+// class PluginClientWrapper : public QWidget | |
+// { | |
+// public: | |
+// PluginClientWrapper(QWidget* parent, WId client); | |
+// ~PluginClientWrapper(); | |
+// bool x11Event(XEvent*); | |
+// | |
+// private: | |
+// QWidget* m_parent; | |
+// }; | |
+// } | |
+// | |
+// #endif // PluginContainerQt_h | |
diff --git a/Source/WebCore/plugins/qt/PluginViewQt.cpp b/Source/WebCore/plugins/qt/PluginViewQt.cpp | |
index 0829ac6..7d6c379 100644 | |
--- a/Source/WebCore/plugins/qt/PluginViewQt.cpp | |
+++ b/Source/WebCore/plugins/qt/PluginViewQt.cpp | |
@@ -58,10 +58,11 @@ | |
#include "Page.h" | |
#include "PlatformMouseEvent.h" | |
#include "PlatformKeyboardEvent.h" | |
-#include "PluginContainerQt.h" | |
+// #include "PluginContainerQt.h" | |
#include "PluginDebug.h" | |
#include "PluginPackage.h" | |
#include "PluginMainThreadScheduler.h" | |
+#include "QtX11ImageConversion.h" | |
#include "QWebPageClient.h" | |
#include "RenderLayer.h" | |
#include "Settings.h" | |
@@ -78,7 +79,7 @@ | |
#include <QPainter> | |
#include <QStyleOptionGraphicsItem> | |
#include <QWidget> | |
-#include <QX11Info> | |
+// #include <QX11Info> | |
#include <X11/X.h> | |
#ifndef QT_NO_XRENDER | |
#define Bool int | |
@@ -121,6 +122,21 @@ private: | |
PluginView* m_view; | |
}; | |
+static inline int x11Screen() | |
+{ | |
+ return XDefaultScreen(PluginView::x11HostDisplay()); | |
+} | |
+ | |
+static inline int displayDepth() | |
+{ | |
+ return XDefaultDepth(PluginView::x11HostDisplay(), x11Screen()); | |
+} | |
+ | |
+static inline unsigned long rootWindowID() | |
+{ | |
+ return XDefaultRootWindow(PluginView::x11HostDisplay()); | |
+} | |
+ | |
bool PluginView::shouldUseAcceleratedCompositing() const | |
{ | |
return m_parentFrame->page()->chrome()->client()->allowsAcceleratedCompositing() | |
@@ -153,9 +169,9 @@ void PluginView::updatePluginWidget() | |
if (!m_isWindowed && m_windowRect.size() != oldWindowRect.size()) { | |
if (m_drawable) | |
- XFreePixmap(QX11Info::display(), m_drawable); | |
+ XFreePixmap(x11HostDisplay(), m_drawable); | |
- m_drawable = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), m_windowRect.width(), m_windowRect.height(), | |
+ m_drawable = XCreatePixmap(x11HostDisplay(), rootWindowID(), m_windowRect.width(), m_windowRect.height(), | |
((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth); | |
QApplication::syncX(); // make sure that the server knows about the Drawable | |
} | |
@@ -208,53 +224,56 @@ void PluginView::hide() | |
void PluginView::paintUsingXPixmap(QPainter* painter, const QRect &exposedRect) | |
{ | |
- QPixmap qtDrawable = QPixmap::fromX11Pixmap(m_drawable, QPixmap::ExplicitlyShared); | |
+// QPixmap qtDrawable = QPixmap::fromX11Pixmap(m_drawable, QPixmap::ExplicitlyShared); | |
+ XImage* xImage = XGetImage(x11HostDisplay(), m_drawable, exposedRect.x(), exposedRect.y(), | |
+ exposedRect.width(), exposedRect.height(), ULONG_MAX, ZPixmap); | |
const int drawableDepth = ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth; | |
- ASSERT(drawableDepth == qtDrawable.depth()); | |
- const bool syncX = m_pluginDisplay && m_pluginDisplay != QX11Info::display(); | |
+ ASSERT(drawableDepth == xImage->depth); | |
+ const bool syncX = m_pluginDisplay && m_pluginDisplay != x11HostDisplay(); | |
// When printing, Qt uses a QPicture to capture the output in preview mode. The | |
// QPicture holds a reference to the X Pixmap. As a result, the print preview would | |
// update itself when the X Pixmap changes. To prevent this, we create a copy. | |
- if (m_element->document()->printing()) | |
- qtDrawable = qtDrawable.copy(); | |
+// if (m_element->document()->printing()) | |
+// qtDrawable = qtDrawable.copy(); | |
if (m_isTransparent && drawableDepth != 32) { | |
// Attempt content propagation for drawable with no alpha by copying over from the backing store | |
- QPoint offset; | |
- QPaintDevice* backingStoreDevice = QPainter::redirected(painter->device(), &offset); | |
- offset = -offset; // negating the offset gives us the offset of the view within the backing store pixmap | |
- | |
- const bool hasValidBackingStore = backingStoreDevice && backingStoreDevice->devType() == QInternal::Pixmap; | |
- QPixmap* backingStorePixmap = static_cast<QPixmap*>(backingStoreDevice); | |
- | |
- // We cannot grab contents from the backing store when painting on QGraphicsView items | |
- // (because backing store contents are already transformed). What we really mean to do | |
- // here is to check if we are painting on QWebView, but let's be a little permissive :) | |
- QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); | |
- const bool backingStoreHasUntransformedContents = client && qobject_cast<QWidget*>(client->pluginParent()); | |
- | |
- if (hasValidBackingStore && backingStorePixmap->depth() == drawableDepth | |
- && backingStoreHasUntransformedContents) { | |
- GC gc = XDefaultGC(QX11Info::display(), QX11Info::appScreen()); | |
- XCopyArea(QX11Info::display(), backingStorePixmap->handle(), m_drawable, gc, | |
- offset.x() + m_windowRect.x() + exposedRect.x(), offset.y() + m_windowRect.y() + exposedRect.y(), | |
- exposedRect.width(), exposedRect.height(), exposedRect.x(), exposedRect.y()); | |
- } else { // no backing store, clean the pixmap because the plugin thinks its transparent | |
- QPainter painter(&qtDrawable); | |
- painter.fillRect(exposedRect, Qt::white); | |
- } | |
- | |
- if (syncX) | |
- QApplication::syncX(); | |
+// QPoint offset; | |
+// QPaintDevice* backingStoreDevice = QPainter::redirected(painter->device(), &offset); | |
+// offset = -offset; // negating the offset gives us the offset of the view within the backing store pixmap | |
+// | |
+// const bool hasValidBackingStore = backingStoreDevice && backingStoreDevice->devType() == QInternal::Pixmap; | |
+// QPixmap* backingStorePixmap = static_cast<QPixmap*>(backingStoreDevice); | |
+// | |
+// // We cannot grab contents from the backing store when painting on QGraphicsView items | |
+// // (because backing store contents are already transformed). What we really mean to do | |
+// // here is to check if we are painting on QWebView, but let's be a little permissive :) | |
+// QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); | |
+// const bool backingStoreHasUntransformedContents = client && qobject_cast<QWidget*>(client->pluginParent()); | |
+// | |
+// if (hasValidBackingStore && backingStorePixmap->depth() == drawableDepth | |
+// && backingStoreHasUntransformedContents) { | |
+// GC gc = XDefaultGC(x11HostDisplay(), x11Screen()); /////////////////////// | |
+// XCopyArea(x11HostDisplay(), backingStorePixmap, m_drawable, gc, | |
+// offset.x() + m_windowRect.x() + exposedRect.x(), offset.y() + m_windowRect.y() + exposedRect.y(), | |
+// exposedRect.width(), exposedRect.height(), exposedRect.x(), exposedRect.y());} | |
+// } else { // no backing store, clean the pixmap because the plugin thinks its transparent | |
+// QImage image = qimageFromXImage(xImage); | |
+// QPainter painter(&image); /////////////???/////////////////// | |
+// painter.fillRect(exposedRect, Qt::white); | |
+// } | |
+// | |
+// if (syncX) | |
+// QApplication::syncX(); | |
} | |
XEvent xevent; | |
memset(&xevent, 0, sizeof(XEvent)); | |
XGraphicsExposeEvent& exposeEvent = xevent.xgraphicsexpose; | |
exposeEvent.type = GraphicsExpose; | |
- exposeEvent.display = QX11Info::display(); | |
- exposeEvent.drawable = qtDrawable.handle(); | |
+ exposeEvent.display = x11HostDisplay(); | |
+ exposeEvent.drawable = m_drawable; | |
exposeEvent.x = exposedRect.x(); | |
exposeEvent.y = exposedRect.y(); | |
exposeEvent.width = exposedRect.x() + exposedRect.width(); // flash bug? it thinks width is the right in transparent mode | |
@@ -265,7 +284,10 @@ void PluginView::paintUsingXPixmap(QPainter* painter, const QRect &exposedRect) | |
if (syncX) | |
XSync(m_pluginDisplay, false); // sync changes by plugin | |
- painter->drawPixmap(QPoint(exposedRect.x(), exposedRect.y()), qtDrawable, exposedRect); | |
+// painter->drawPixmap(QPoint(exposedRect.x(), exposedRect.y()), qtDrawable, exposedRect); | |
+ painter->drawImage(QPoint(exposedRect.x(), exposedRect.y()), qimageFromXImage(xImage), exposedRect); | |
+ | |
+ XDestroyImage(xImage); | |
} | |
void PluginView::paint(GraphicsContext* context, const IntRect& rect) | |
@@ -334,11 +356,12 @@ void setSharedXEventFields(XEvent* xEvent, QWidget* ownerWidget) | |
{ | |
xEvent->xany.serial = 0; // we are unaware of the last request processed by X Server | |
xEvent->xany.send_event = false; | |
- xEvent->xany.display = QX11Info::display(); | |
+ xEvent->xany.display = PluginView::x11HostDisplay(); | |
// NOTE: event->xany.window doesn't always respond to the .window property of other XEvent's | |
// but does in the case of KeyPress, KeyRelease, ButtonPress, ButtonRelease, and MotionNotify | |
// events; thus, this is right: | |
- xEvent->xany.window = ownerWidget ? ownerWidget->window()->handle() : 0; | |
+// xEvent->xany.window = ownerWidget ? ownerWidget->window()->windowHandle() : 0; | |
+ xEvent->xany.window = ownerWidget ? x11Screen() : 0; | |
} | |
void PluginView::initXEvent(XEvent* xEvent) | |
@@ -355,7 +378,7 @@ void setXKeyEventSpecificFields(XEvent* xEvent, KeyboardEvent* event) | |
const PlatformKeyboardEvent* keyEvent = event->keyEvent(); | |
xEvent->type = (event->type() == eventNames().keydownEvent) ? 2 : 3; // ints as Qt unsets KeyPress and KeyRelease | |
- xEvent->xkey.root = QX11Info::appRootWindow(); | |
+ xEvent->xkey.root = rootWindowID(); /////////////////////////// | |
xEvent->xkey.subwindow = 0; // we have no child window | |
xEvent->xkey.time = event->timeStamp(); | |
xEvent->xkey.state = keyEvent->nativeModifiers(); | |
@@ -369,7 +392,7 @@ void setXKeyEventSpecificFields(XEvent* xEvent, KeyboardEvent* event) | |
QKeyEvent* qKeyEvent = keyEvent->qtEvent(); | |
ASSERT(qKeyEvent); | |
QString keyText = qKeyEvent->text().left(1); | |
- xEvent->xkey.keycode = XKeysymToKeycode(QX11Info::display(), XStringToKeysym(keyText.toUtf8().constData())); | |
+ xEvent->xkey.keycode = XKeysymToKeycode(PluginView::x11HostDisplay(), XStringToKeysym(keyText.toUtf8().constData())); | |
} | |
xEvent->xkey.same_screen = true; | |
@@ -400,6 +423,16 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event) | |
event->setDefaultHandled(); | |
} | |
+Display* PluginView::x11HostDisplay() | |
+{ | |
+ static Display* dedicatedDisplay = 0; | |
+ if (!dedicatedDisplay) | |
+ dedicatedDisplay = XOpenDisplay(0); | |
+ | |
+ ASSERT(dedicatedDisplay); | |
+ return dedicatedDisplay; | |
+} | |
+ | |
static unsigned int inputEventState(MouseEvent* event) | |
{ | |
unsigned int state = 0; | |
@@ -418,7 +451,7 @@ static void setXButtonEventSpecificFields(XEvent* xEvent, MouseEvent* event, con | |
{ | |
XButtonEvent& xbutton = xEvent->xbutton; | |
xbutton.type = event->type() == eventNames().mousedownEvent ? ButtonPress : ButtonRelease; | |
- xbutton.root = QX11Info::appRootWindow(); | |
+ xbutton.root = rootWindowID(); /////////////////////////// | |
xbutton.subwindow = 0; | |
xbutton.time = event->timeStamp(); | |
xbutton.x = postZoomPos.x(); | |
@@ -445,7 +478,7 @@ static void setXMotionEventSpecificFields(XEvent* xEvent, MouseEvent* event, con | |
{ | |
XMotionEvent& xmotion = xEvent->xmotion; | |
xmotion.type = MotionNotify; | |
- xmotion.root = QX11Info::appRootWindow(); | |
+ xmotion.root = rootWindowID(); ///////////////////////////// | |
xmotion.subwindow = 0; | |
xmotion.time = event->timeStamp(); | |
xmotion.x = postZoomPos.x(); | |
@@ -461,7 +494,7 @@ static void setXCrossingEventSpecificFields(XEvent* xEvent, MouseEvent* event, c | |
{ | |
XCrossingEvent& xcrossing = xEvent->xcrossing; | |
xcrossing.type = event->type() == eventNames().mouseoverEvent ? EnterNotify : LeaveNotify; | |
- xcrossing.root = QX11Info::appRootWindow(); | |
+ xcrossing.root = rootWindowID(); | |
xcrossing.subwindow = 0; | |
xcrossing.time = event->timeStamp(); | |
xcrossing.x = postZoomPos.y(); | |
@@ -699,7 +732,7 @@ bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* re | |
{ | |
switch (variable) { | |
case NPNVxDisplay: | |
- *(void **)value = QX11Info::display(); | |
+ *(void **)value = x11HostDisplay(); | |
*result = NPERR_NO_ERROR; | |
return true; | |
@@ -771,7 +804,7 @@ void PluginView::forceRedraw() | |
invalidate(); | |
} | |
-static Display *getPluginDisplay() | |
+static Display* getPluginDisplay() | |
{ | |
// The plugin toolkit might run using a different X connection. At the moment, we only | |
// support gdk based plugins (like flash) that use a different X connection. | |
@@ -816,31 +849,31 @@ static void getVisualAndColormap(int depth, Visual **visual, Colormap *colormap) | |
int nvi; | |
XVisualInfo templ; | |
- templ.screen = QX11Info::appScreen(); | |
+ templ.screen = x11Screen(); /////////////////////////// | |
templ.depth = depth; | |
templ.c_class = TrueColor; | |
- XVisualInfo* xvi = XGetVisualInfo(QX11Info::display(), VisualScreenMask | VisualDepthMask | VisualClassMask, &templ, &nvi); | |
+ XVisualInfo* xvi = XGetVisualInfo(PluginView::x11HostDisplay(), VisualScreenMask | VisualDepthMask | VisualClassMask, &templ, &nvi); | |
if (!xvi) | |
return; | |
#ifndef QT_NO_XRENDER | |
- if (depth == 32) { | |
- for (int idx = 0; idx < nvi; ++idx) { | |
- XRenderPictFormat* format = XRenderFindVisualFormat(QX11Info::display(), xvi[idx].visual); | |
- if (format->type == PictTypeDirect && format->direct.alphaMask) { | |
- *visual = xvi[idx].visual; | |
- break; | |
- } | |
- } | |
- } else | |
+// if (depth == 32) { | |
+// for (int idx = 0; idx < nvi; ++idx) { | |
+// XRenderPictFormat* format = XRenderFindVisualFormat(PluginView::x11HostDisplay(), xvi[idx].visual); | |
+// if (format->type == PictTypeDirect && format->direct.alphaMask) { | |
+// *visual = xvi[idx].visual; | |
+// break; | |
+// } | |
+// } | |
+// } else | |
#endif // QT_NO_XRENDER | |
*visual = xvi[0].visual; | |
XFree(xvi); | |
if (*visual) | |
- *colormap = XCreateColormap(QX11Info::display(), QX11Info::appRootWindow(), *visual, AllocNone); | |
+ *colormap = XCreateColormap(PluginView::x11HostDisplay(), rootWindowID(), *visual, AllocNone); | |
} | |
bool PluginView::platformStart() | |
@@ -859,18 +892,18 @@ bool PluginView::platformStart() | |
PluginView::setCurrentPluginView(0); | |
} | |
- if (m_isWindowed) { | |
- QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); | |
- if (m_needsXEmbed && client) { | |
- setPlatformWidget(new PluginContainerQt(this, client->ownerWidget())); | |
- // sync our XEmbed container window creation before sending the xid to plugins. | |
- QApplication::syncX(); | |
- } else { | |
- notImplemented(); | |
- m_status = PluginStatusCanNotLoadPlugin; | |
- return false; | |
- } | |
- } else { | |
+// if (m_isWindowed) { | |
+// QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient(); | |
+// if (m_needsXEmbed && client) { | |
+// setPlatformWidget(new PluginContainerQt(this, client->ownerWidget())); | |
+// // sync our XEmbed container window creation before sending the xid to plugins. | |
+// QApplication::syncX(); | |
+// } else { | |
+// notImplemented(); | |
+// m_status = PluginStatusCanNotLoadPlugin; | |
+// return false; | |
+// } | |
+// } else { | |
setPlatformWidget(0); | |
m_pluginDisplay = getPluginDisplay(); | |
@@ -881,7 +914,7 @@ bool PluginView::platformStart() | |
m_element->setNeedsStyleRecalc(SyntheticStyleChange); | |
} | |
#endif | |
- } | |
+// } | |
// If the width and the height are not zero we show the PluginView. | |
if (!frameRect().isEmpty()) | |
@@ -890,32 +923,32 @@ bool PluginView::platformStart() | |
NPSetWindowCallbackStruct* wsi = new NPSetWindowCallbackStruct(); | |
wsi->type = 0; | |
- if (m_isWindowed) { | |
- const QX11Info* x11Info = &platformPluginWidget()->x11Info(); | |
- | |
- wsi->display = x11Info->display(); | |
- wsi->visual = (Visual*)x11Info->visual(); | |
- wsi->depth = x11Info->depth(); | |
- wsi->colormap = x11Info->colormap(); | |
- | |
- m_npWindow.type = NPWindowTypeWindow; | |
- m_npWindow.window = (void*)platformPluginWidget()->winId(); | |
- m_npWindow.width = -1; | |
- m_npWindow.height = -1; | |
- } else { | |
- const QX11Info* x11Info = &QApplication::desktop()->x11Info(); | |
- | |
- if (x11Info->depth() == 32 || !m_plugin->quirks().contains(PluginQuirkRequiresDefaultScreenDepth)) { | |
+// if (m_isWindowed) { | |
+// const QX11Info* x11Info = &platformPluginWidget()->x11Info(); | |
+// | |
+// wsi->display = x11Info->display(); | |
+// wsi->visual = (Visual*)x11Info->visual(); | |
+// wsi->depth = x11Info->depth(); | |
+// wsi->colormap = x11Info->colormap(); | |
+// | |
+// m_npWindow.type = NPWindowTypeWindow; | |
+// m_npWindow.window = (void*)platformPluginWidget()->winId(); | |
+// m_npWindow.width = -1; | |
+// m_npWindow.height = -1; | |
+// } else { | |
+// const QX11Info* x11Info = &QApplication::desktop()->x11Info(); /////////////////////////////////// | |
+ | |
+ if (displayDepth() == 32 || !m_plugin->quirks().contains(PluginQuirkRequiresDefaultScreenDepth)) { | |
getVisualAndColormap(32, &m_visual, &m_colormap); | |
wsi->depth = 32; | |
} | |
if (!m_visual) { | |
- getVisualAndColormap(x11Info->depth(), &m_visual, &m_colormap); | |
- wsi->depth = x11Info->depth(); | |
+ getVisualAndColormap(displayDepth(), &m_visual, &m_colormap); | |
+ wsi->depth = displayDepth(); | |
} | |
- wsi->display = x11Info->display(); | |
+ wsi->display = x11HostDisplay(); | |
wsi->visual = m_visual; | |
wsi->colormap = m_colormap; | |
@@ -925,7 +958,7 @@ bool PluginView::platformStart() | |
m_npWindow.y = 0; | |
m_npWindow.width = -1; | |
m_npWindow.height = -1; | |
- } | |
+// } | |
m_npWindow.ws_info = wsi; | |
@@ -943,10 +976,10 @@ void PluginView::platformDestroy() | |
delete platformPluginWidget(); | |
if (m_drawable) | |
- XFreePixmap(QX11Info::display(), m_drawable); | |
+ XFreePixmap(x11HostDisplay(), m_drawable); | |
if (m_colormap) | |
- XFreeColormap(QX11Info::display(), m_colormap); | |
+ XFreeColormap(x11HostDisplay(), m_colormap); | |
} | |
#if USE(ACCELERATED_COMPOSITING) | |
diff --git a/Source/WebKit/qt/Api/qwebsettings.cpp b/Source/WebKit/qt/Api/qwebsettings.cpp | |
index 89e9821..76d0c86 100644 | |
--- a/Source/WebKit/qt/Api/qwebsettings.cpp | |
+++ b/Source/WebKit/qt/Api/qwebsettings.cpp | |
@@ -1167,9 +1167,11 @@ void QWebSettings::enablePersistentStorage(const QString& path) | |
#if ENABLE(NETSCAPE_PLUGIN_METADATA_CACHE) | |
// All applications can share the common QtWebkit cache file(s). | |
// Path is not configurable and uses QDesktopServices::CacheLocation by default. | |
- QString cachePath = QDesktopServices::storageLocation(QDesktopServices::CacheLocation); | |
+// QString cachePath = QDesktopServices::storageLocation(QDesktopServices::CacheLocation); | |
+// WebCore::makeAllDirectories(cachePath); | |
+// | |
+ QString cachePath = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); | |
WebCore::makeAllDirectories(cachePath); | |
- | |
QFileInfo info(cachePath); | |
if (info.isDir() && info.isWritable()) { | |
WebCore::PluginDatabase::setPersistentMetadataCacheEnabled(true); | |
diff --git a/Tools/qmake/mkspecs/features/features.prf b/Tools/qmake/mkspecs/features/features.prf | |
index 6b6c08d..7ec192d 100644 | |
--- a/Tools/qmake/mkspecs/features/features.prf | |
+++ b/Tools/qmake/mkspecs/features/features.prf | |
@@ -90,9 +90,13 @@ isEmpty(HAVE_QRAWFONT) { | |
# Tiled Backing Store support | |
!contains(DEFINES, WTF_USE_TILED_BACKING_STORE=.): DEFINES += WTF_USE_TILED_BACKING_STORE=1 | |
-# Nescape plugins support (NPAPI) | |
+# Netscape plugins support (NPAPI) | |
!contains(DEFINES, ENABLE_NETSCAPE_PLUGIN_API=.) { | |
- unix:haveQt(4)|win32-*:!embedded:!wince*: { | |
+# unix|win32-*:!embedded:!wince*: { | |
+ contains(QT_CONFIG, xcb-xlib) { | |
+ CONFIG += plugin_backend_xlib | |
+ CONFIG *= link_pkgconfig | |
+ PKGCONFIG += x11 | |
DEFINES += ENABLE_NETSCAPE_PLUGIN_API=1 | |
} else { | |
DEFINES += ENABLE_NETSCAPE_PLUGIN_API=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment