meta-opendreambox: drop gstreamer 0.10
[opendreambox.git] / meta-opendreambox / recipes-qt / qt4 / qt4 / 0001-Qt-remove-x11-from-npapi-while-keeping-some-basic-fu.patch
1 From 409ea9d5567b191a31ad379d5b354e86f831f570 Mon Sep 17 00:00:00 2001
2 From: Andreas Oberritter <obi@opendreambox.org>
3 Date: Wed, 21 Dec 2011 17:24:36 +0100
4 Subject: [PATCH 1/7] Qt: remove x11 from npapi while keeping some basic
5  functionality (calling SetWindow with proper position and size)
6
7 ---
8  src/3rdparty/webkit/Source/WebCore/WebCore.pro     |   9 +-
9  src/3rdparty/webkit/Source/WebCore/bridge/npapi.h  |   8 +-
10  .../Source/WebCore/bridge/npruntime_internal.h     |   2 +-
11  src/3rdparty/webkit/Source/WebCore/features.pri    |   1 +
12  .../webkit/Source/WebCore/plugins/PluginView.cpp   |   8 +-
13  .../webkit/Source/WebCore/plugins/PluginView.h     |   4 +-
14  .../Source/WebCore/plugins/qt/PluginViewQt.cpp     | 578 ++-------------------
15  7 files changed, 50 insertions(+), 560 deletions(-)
16
17 diff --git a/src/3rdparty/webkit/Source/WebCore/WebCore.pro b/src/3rdparty/webkit/Source/WebCore/WebCore.pro
18 index ceceee8..ef4c7f9 100644
19 --- a/src/3rdparty/webkit/Source/WebCore/WebCore.pro
20 +++ b/src/3rdparty/webkit/Source/WebCore/WebCore.pro
21 @@ -2587,11 +2587,14 @@ contains(DEFINES, ENABLE_NETSCAPE_PLUGIN_API=1) {
22                  plugins/mac/PluginViewMac.mm
23          } else {
24              SOURCES += \
25 -                plugins/qt/PluginContainerQt.cpp \
26                  plugins/qt/PluginPackageQt.cpp \
27                  plugins/qt/PluginViewQt.cpp
28 -            HEADERS += \
29 -                plugins/qt/PluginContainerQt.h
30 +            !embedded {
31 +                SOURCES += \
32 +                    plugins/qt/PluginContainerQt.cpp
33 +                HEADERS += \
34 +                    plugins/qt/PluginContainerQt.h
35 +            }
36          }
37      }
38  
39 diff --git a/src/3rdparty/webkit/Source/WebCore/bridge/npapi.h b/src/3rdparty/webkit/Source/WebCore/bridge/npapi.h
40 index c217718..54fc0aa 100644
41 --- a/src/3rdparty/webkit/Source/WebCore/bridge/npapi.h
42 +++ b/src/3rdparty/webkit/Source/WebCore/bridge/npapi.h
43 @@ -89,7 +89,7 @@
44  #endif
45  #endif
46  
47 -#if defined(XP_UNIX)
48 +#if defined(XP_UNIX) && defined(Q_WS_X11)
49  #include <X11/Xlib.h>
50  #include <X11/Xutil.h>
51  #include <stdio.h>
52 @@ -248,7 +248,7 @@ typedef enum {
53  /* Exact meaning must be spec'd in event model. */
54  #define kNPEventStartIME 2
55  
56 -#if defined(XP_UNIX)
57 +#if defined(XP_UNIX) && defined(Q_WS_X11)
58  /*
59   * Unix specific structures and definitions
60   */
61 @@ -537,7 +537,7 @@ typedef struct _NPEvent
62    uint32_t wParam;
63    uint32_t lParam;
64  } NPEvent;
65 -#elif defined(XP_UNIX)
66 +#elif defined(XP_UNIX) && defined(Q_WS_X11)
67  typedef XEvent NPEvent;
68  #else
69  typedef void*  NPEvent;
70 @@ -551,7 +551,7 @@ typedef RgnHandle NPQDRegion;
71  typedef CGPathRef NPCGRegion;
72  #elif defined(XP_WIN)
73  typedef HRGN NPRegion;
74 -#elif defined(XP_UNIX)
75 +#elif defined(XP_UNIX) && defined(Q_WS_X11)
76  typedef Region NPRegion;
77  #elif defined(XP_SYMBIAN)
78  typedef QRegion* NPRegion;
79 diff --git a/src/3rdparty/webkit/Source/WebCore/bridge/npruntime_internal.h b/src/3rdparty/webkit/Source/WebCore/bridge/npruntime_internal.h
80 index 2d7dc06..ec84b6c 100644
81 --- a/src/3rdparty/webkit/Source/WebCore/bridge/npruntime_internal.h
82 +++ b/src/3rdparty/webkit/Source/WebCore/bridge/npruntime_internal.h
83 @@ -29,7 +29,7 @@
84  #include "npfunctions.h"
85  #include "npruntime.h"
86  
87 -#ifdef XP_UNIX
88 +#if defined(XP_UNIX) && defined(Q_WS_X11)
89      #include <X11/Xresource.h>
90  
91      #undef None
92 diff --git a/src/3rdparty/webkit/Source/WebCore/features.pri b/src/3rdparty/webkit/Source/WebCore/features.pri
93 index f04d0b4..48b2eb2 100644
94 --- a/src/3rdparty/webkit/Source/WebCore/features.pri
95 +++ b/src/3rdparty/webkit/Source/WebCore/features.pri
96 @@ -97,6 +97,7 @@ contains(DEFINES, ENABLE_SINGLE_THREADED=1) {
97  !contains(DEFINES, ENABLE_TILED_BACKING_STORE=.): DEFINES += ENABLE_TILED_BACKING_STORE=1
98  
99  # Nescape plugins support (NPAPI)
100 +DEFINES += ENABLE_NETSCAPE_PLUGIN_API=1
101  !contains(DEFINES, ENABLE_NETSCAPE_PLUGIN_API=.) {
102      unix|win32-*:!embedded:!wince*: {
103          DEFINES += ENABLE_NETSCAPE_PLUGIN_API=1
104 diff --git a/src/3rdparty/webkit/Source/WebCore/plugins/PluginView.cpp b/src/3rdparty/webkit/Source/WebCore/plugins/PluginView.cpp
105 index b020946..983ad8c 100644
106 --- a/src/3rdparty/webkit/Source/WebCore/plugins/PluginView.cpp
107 +++ b/src/3rdparty/webkit/Source/WebCore/plugins/PluginView.cpp
108 @@ -369,7 +369,7 @@ void PluginView::stop()
109          PluginView::setCurrentPluginView(0);
110      }
111  
112 -#ifdef XP_UNIX
113 +#if defined(XP_UNIX) && defined(Q_WS_X11)
114      if (m_isWindowed && m_npWindow.ws_info)
115             delete (NPSetWindowCallbackStruct *)m_npWindow.ws_info;
116      m_npWindow.ws_info = 0;
117 @@ -630,7 +630,11 @@ NPError PluginView::setValue(NPPVariable variable, void* value)
118  
119      switch (variable) {
120      case NPPVpluginWindowBool:
121 +#if defined(Q_WS_X11)
122          m_isWindowed = value;
123 +#else
124 +        m_isWindowed = true;
125 +#endif
126          return NPERR_NO_ERROR;
127      case NPPVpluginTransparentBool:
128          m_isTransparent = value;
129 @@ -867,7 +871,7 @@ PluginView::PluginView(Frame* parentFrame, const IntSize& size, PluginPackage* p
130      , m_contextRef(0)
131      , m_fakeWindow(0)
132  #endif
133 -#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
134 +#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API) && defined(Q_WS_X11)
135      , m_hasPendingGeometryChange(true)
136      , m_drawable(0)
137      , m_visual(0)
138 diff --git a/src/3rdparty/webkit/Source/WebCore/plugins/PluginView.h b/src/3rdparty/webkit/Source/WebCore/plugins/PluginView.h
139 index f528754..a49db47 100644
140 --- a/src/3rdparty/webkit/Source/WebCore/plugins/PluginView.h
141 +++ b/src/3rdparty/webkit/Source/WebCore/plugins/PluginView.h
142 @@ -416,7 +416,7 @@ private:
143          Point mousePosForPlugin(MouseEvent* event = 0) const;
144  #endif
145  
146 -#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
147 +#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API) && defined(Q_WS_X11)
148          bool m_hasPendingGeometryChange;
149          Pixmap m_drawable;
150          Visual* m_visual;
151 @@ -432,7 +432,7 @@ private:
152          bool m_renderToImage;
153          void paintUsingImageSurfaceExtension(QPainter* painter, const IntRect& exposedRect);
154  #endif
155 -#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
156 +#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API) && defined(Q_WS_X11)
157          void paintUsingXPixmap(QPainter* painter, const QRect &exposedRect);
158  #endif
159  #if USE(ACCELERATED_COMPOSITING_PLUGIN_LAYER)
160 diff --git a/src/3rdparty/webkit/Source/WebCore/plugins/qt/PluginViewQt.cpp b/src/3rdparty/webkit/Source/WebCore/plugins/qt/PluginViewQt.cpp
161 index 2fe69d1..795cb9a 100644
162 --- a/src/3rdparty/webkit/Source/WebCore/plugins/qt/PluginViewQt.cpp
163 +++ b/src/3rdparty/webkit/Source/WebCore/plugins/qt/PluginViewQt.cpp
164 @@ -58,7 +58,6 @@
165  #include "Page.h"
166  #include "PlatformMouseEvent.h"
167  #include "PlatformKeyboardEvent.h"
168 -#include "PluginContainerQt.h"
169  #include "PluginDebug.h"
170  #include "PluginPackage.h"
171  #include "PluginMainThreadScheduler.h"
172 @@ -78,13 +77,6 @@
173  #include <QPainter>
174  #include <QStyleOptionGraphicsItem>
175  #include <QWidget>
176 -#include <QX11Info>
177 -#include <X11/X.h>
178 -#ifndef QT_NO_XRENDER
179 -#define Bool int
180 -#define Status int
181 -#include <X11/extensions/Xrender.h>
182 -#endif
183  #include <runtime/JSLock.h>
184  #include <runtime/JSValue.h>
185  
186 @@ -111,21 +103,13 @@ public:
187      PluginGraphicsLayerQt(PluginView* view) : m_view(view) { }
188      ~PluginGraphicsLayerQt() { }
189  
190 -    void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0)
191 -    {
192 -        Q_UNUSED(widget);
193 -        m_view->paintUsingXPixmap(painter, option->exposedRect.toRect());
194 -    }
195 -
196  private:
197      PluginView* m_view;
198  };
199  
200  bool PluginView::shouldUseAcceleratedCompositing() const
201  {
202 -    return m_parentFrame->page()->chrome()->client()->allowsAcceleratedCompositing()
203 -           && m_parentFrame->page()->settings()
204 -           && m_parentFrame->page()->settings()->acceleratedCompositingEnabled();
205 +    return false;
206  }
207  #endif
208  
209 @@ -151,25 +135,6 @@ void PluginView::updatePluginWidget()
210      if (oldWindowRect.isEmpty())
211          show();
212  
213 -    if (!m_isWindowed && m_windowRect.size() != oldWindowRect.size()) {
214 -#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5)
215 -        // On Maemo5, Flash always renders to 16-bit buffer
216 -        if (m_renderToImage)
217 -            m_image = QImage(m_windowRect.width(), m_windowRect.height(), QImage::Format_RGB16);
218 -        else
219 -#endif
220 -        {
221 -            if (m_drawable)
222 -                XFreePixmap(QX11Info::display(), m_drawable);
223 -
224 -            m_drawable = XCreatePixmap(QX11Info::display(), QX11Info::appRootWindow(), m_windowRect.width(), m_windowRect.height(), 
225 -                                       ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth);
226 -            QApplication::syncX(); // make sure that the server knows about the Drawable
227 -        }
228 -    }
229 -
230 -    // do not call setNPWindowIfNeeded immediately, will be called on paint()
231 -    m_hasPendingGeometryChange = true;
232  
233      // (i) in order to move/resize the plugin window at the same time as the
234      // rest of frame during e.g. scrolling, we set the window geometry
235 @@ -178,9 +143,8 @@ void PluginView::updatePluginWidget()
236      // scroll, we need to move/resize immediately.
237      // (ii) if we are running layout tests from DRT, paint() won't ever get called
238      // so we need to call setNPWindowIfNeeded() if window geometry has changed
239 -    if (!m_windowRect.intersects(frameView->frameRect())
240 -        || (QWebPagePrivate::drtRun && platformPluginWidget() && (m_windowRect != oldWindowRect || m_clipRect != oldClipRect)))
241 -        setNPWindowIfNeeded();
242 +    setNPWindowIfNeeded();
243 +
244  
245      if (!m_platformLayer) {
246          // Make sure we get repainted afterwards. This is necessary for downward
247 @@ -214,133 +178,6 @@ void PluginView::hide()
248      Widget::hide();
249  }
250  
251 -#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5)
252 -void PluginView::paintUsingImageSurfaceExtension(QPainter* painter, const IntRect& exposedRect)
253 -{
254 -    NPImageExpose imageExpose;
255 -    QPoint offset;
256 -    QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
257 -    const bool surfaceHasUntransformedContents = client && qobject_cast<QWidget*>(client->pluginParent());
258 -
259 -    QPaintDevice* surface =  QPainter::redirected(painter->device(), &offset);
260 -
261 -    // If the surface is a QImage, we can render directly into it
262 -    if (surfaceHasUntransformedContents && surface && surface->devType() == QInternal::Image) {
263 -        QImage* image = static_cast<QImage*>(surface);
264 -        offset = -offset; // negating the offset gives us the offset of the view within the surface
265 -        imageExpose.data = reinterpret_cast<char*>(image->bits());
266 -        imageExpose.dataSize.width = image->width();
267 -        imageExpose.dataSize.height = image->height();
268 -        imageExpose.stride = image->bytesPerLine();
269 -        imageExpose.depth = image->depth(); // this is guaranteed to be 16 on Maemo5
270 -        imageExpose.translateX = offset.x() + m_windowRect.x();
271 -        imageExpose.translateY = offset.y() + m_windowRect.y();
272 -        imageExpose.scaleX = 1;
273 -        imageExpose.scaleY = 1;
274 -    } else {
275 -        if (m_isTransparent) {
276 -            // On Maemo5, Flash expects the buffer to contain the contents that are below it.
277 -            // We don't support transparency for non-raster graphicssystem, so clean the image 
278 -            // before giving to Flash.
279 -            QPainter imagePainter(&m_image);
280 -            imagePainter.fillRect(exposedRect, Qt::white);
281 -        }
282 -
283 -        imageExpose.data = reinterpret_cast<char*>(m_image.bits());
284 -        imageExpose.dataSize.width = m_image.width();
285 -        imageExpose.dataSize.height = m_image.height();
286 -        imageExpose.stride = m_image.bytesPerLine();
287 -        imageExpose.depth = m_image.depth();
288 -        imageExpose.translateX = 0;
289 -        imageExpose.translateY = 0;
290 -        imageExpose.scaleX = 1;
291 -        imageExpose.scaleY = 1;
292 -    }
293 -    imageExpose.x = exposedRect.x();
294 -    imageExpose.y = exposedRect.y();
295 -    imageExpose.width = exposedRect.width();
296 -    imageExpose.height = exposedRect.height();
297 -
298 -    XEvent xevent;
299 -    memset(&xevent, 0, sizeof(XEvent));
300 -    XGraphicsExposeEvent& exposeEvent = xevent.xgraphicsexpose;
301 -    exposeEvent.type = GraphicsExpose;
302 -    exposeEvent.display = 0;
303 -    exposeEvent.drawable = reinterpret_cast<XID>(&imageExpose);
304 -    exposeEvent.x = exposedRect.x();
305 -    exposeEvent.y = exposedRect.y();
306 -    exposeEvent.width = exposedRect.width();
307 -    exposeEvent.height = exposedRect.height();
308 -
309 -    dispatchNPEvent(xevent);
310 -
311 -    if (!surfaceHasUntransformedContents || !surface || surface->devType() != QInternal::Image)
312 -        painter->drawImage(QPoint(frameRect().x() + exposedRect.x(), frameRect().y() + exposedRect.y()), m_image, exposedRect);
313 -}
314 -#endif
315 -
316 -void PluginView::paintUsingXPixmap(QPainter* painter, const QRect &exposedRect)
317 -{
318 -    QPixmap qtDrawable = QPixmap::fromX11Pixmap(m_drawable, QPixmap::ExplicitlyShared);
319 -    const int drawableDepth = ((NPSetWindowCallbackStruct*)m_npWindow.ws_info)->depth;
320 -    ASSERT(drawableDepth == qtDrawable.depth());
321 -    const bool syncX = m_pluginDisplay && m_pluginDisplay != QX11Info::display();
322 -
323 -    // When printing, Qt uses a QPicture to capture the output in preview mode. The
324 -    // QPicture holds a reference to the X Pixmap. As a result, the print preview would
325 -    // update itself when the X Pixmap changes. To prevent this, we create a copy.
326 -    if (m_element->document()->printing())
327 -        qtDrawable = qtDrawable.copy();
328 -
329 -    if (m_isTransparent && drawableDepth != 32) {
330 -        // Attempt content propagation for drawable with no alpha by copying over from the backing store
331 -        QPoint offset;
332 -        QPaintDevice* backingStoreDevice =  QPainter::redirected(painter->device(), &offset);
333 -        offset = -offset; // negating the offset gives us the offset of the view within the backing store pixmap
334 -
335 -        const bool hasValidBackingStore = backingStoreDevice && backingStoreDevice->devType() == QInternal::Pixmap;
336 -        QPixmap* backingStorePixmap = static_cast<QPixmap*>(backingStoreDevice);
337 -
338 -        // We cannot grab contents from the backing store when painting on QGraphicsView items
339 -        // (because backing store contents are already transformed). What we really mean to do 
340 -        // here is to check if we are painting on QWebView, but let's be a little permissive :)
341 -        QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
342 -        const bool backingStoreHasUntransformedContents = client && qobject_cast<QWidget*>(client->pluginParent());
343 -
344 -        if (hasValidBackingStore && backingStorePixmap->depth() == drawableDepth 
345 -            && backingStoreHasUntransformedContents) {
346 -            GC gc = XDefaultGC(QX11Info::display(), QX11Info::appScreen());
347 -            XCopyArea(QX11Info::display(), backingStorePixmap->handle(), m_drawable, gc,
348 -                offset.x() + m_windowRect.x() + exposedRect.x(), offset.y() + m_windowRect.y() + exposedRect.y(),
349 -                exposedRect.width(), exposedRect.height(), exposedRect.x(), exposedRect.y());
350 -        } else { // no backing store, clean the pixmap because the plugin thinks its transparent
351 -            QPainter painter(&qtDrawable);
352 -            painter.fillRect(exposedRect, Qt::white);
353 -        }
354 -
355 -        if (syncX)
356 -            QApplication::syncX();
357 -    }
358 -
359 -    XEvent xevent;
360 -    memset(&xevent, 0, sizeof(XEvent));
361 -    XGraphicsExposeEvent& exposeEvent = xevent.xgraphicsexpose;
362 -    exposeEvent.type = GraphicsExpose;
363 -    exposeEvent.display = QX11Info::display();
364 -    exposeEvent.drawable = qtDrawable.handle();
365 -    exposeEvent.x = exposedRect.x();
366 -    exposeEvent.y = exposedRect.y();
367 -    exposeEvent.width = exposedRect.x() + exposedRect.width(); // flash bug? it thinks width is the right in transparent mode
368 -    exposeEvent.height = exposedRect.y() + exposedRect.height(); // flash bug? it thinks height is the bottom in transparent mode
369 -
370 -    dispatchNPEvent(xevent);
371 -
372 -    if (syncX)
373 -        XSync(m_pluginDisplay, false); // sync changes by plugin
374 -
375 -    painter->drawPixmap(QPoint(exposedRect.x(), exposedRect.y()), qtDrawable, exposedRect);
376 -}
377 -
378  void PluginView::paint(GraphicsContext* context, const IntRect& rect)
379  {
380      if (!m_isStarted) {
381 @@ -351,38 +188,23 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
382      if (context->paintingDisabled())
383          return;
384  
385 +    updatePluginWidget();
386      setNPWindowIfNeeded();
387  
388 -    if (m_isWindowed)
389 -        return;
390 -
391  #if USE(ACCELERATED_COMPOSITING)
392      if (m_platformLayer)
393          return;
394  #endif
395  
396 -    if (!m_drawable
397 -#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5)
398 -        && m_image.isNull()
399 -#endif
400 -       )
401 -        return;
402 -
403      QPainter* painter = context->platformContext();
404      IntRect exposedRect(rect);
405      exposedRect.intersect(frameRect());
406      exposedRect.move(-frameRect().x(), -frameRect().y());
407  
408 -#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5)
409 -    if (!m_image.isNull()) {
410 -        paintUsingImageSurfaceExtension(painter, exposedRect);
411 -        return;
412 -    }
413 -#endif
414 -
415 -    painter->translate(frameRect().x(), frameRect().y());
416 -    paintUsingXPixmap(painter, exposedRect);
417 -    painter->translate(-frameRect().x(), -frameRect().y());
418 +    QPainter::CompositionMode oldMode = painter->compositionMode();
419 +    painter->setCompositionMode(QPainter::CompositionMode_Source);
420 +    painter->eraseRect(m_windowRect);
421 +    painter->setCompositionMode(oldMode);
422  }
423  
424  // TODO: Unify across ports.
425 @@ -403,60 +225,6 @@ bool PluginView::dispatchNPEvent(NPEvent& event)
426      return accepted;
427  }
428  
429 -void setSharedXEventFields(XEvent* xEvent, QWidget* ownerWidget)
430 -{
431 -    xEvent->xany.serial = 0; // we are unaware of the last request processed by X Server
432 -    xEvent->xany.send_event = false;
433 -    xEvent->xany.display = QX11Info::display();
434 -    // NOTE: event->xany.window doesn't always respond to the .window property of other XEvent's
435 -    // but does in the case of KeyPress, KeyRelease, ButtonPress, ButtonRelease, and MotionNotify
436 -    // events; thus, this is right:
437 -    xEvent->xany.window = ownerWidget ? ownerWidget->window()->handle() : 0;
438 -}
439 -
440 -void PluginView::initXEvent(XEvent* xEvent)
441 -{
442 -    memset(xEvent, 0, sizeof(XEvent));
443 -
444 -    QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
445 -    QWidget* ownerWidget = client ? client->ownerWidget() : 0;
446 -    setSharedXEventFields(xEvent, ownerWidget);
447 -}
448 -
449 -void setXKeyEventSpecificFields(XEvent* xEvent, KeyboardEvent* event)
450 -{
451 -    const PlatformKeyboardEvent* keyEvent = event->keyEvent();
452 -
453 -    xEvent->type = (event->type() == eventNames().keydownEvent) ? 2 : 3; // ints as Qt unsets KeyPress and KeyRelease
454 -    xEvent->xkey.root = QX11Info::appRootWindow();
455 -    xEvent->xkey.subwindow = 0; // we have no child window
456 -    xEvent->xkey.time = event->timeStamp();
457 -    xEvent->xkey.state = keyEvent->nativeModifiers();
458 -    xEvent->xkey.keycode = keyEvent->nativeScanCode();
459 -
460 -    // We may not have a nativeScanCode() if the key event is from DRT's eventsender. In that
461 -    // case fetch the XEvent's keycode from the event's text. The only
462 -    // place this keycode will be used is in webkit_test_plugin_handle_event().
463 -    // FIXME: Create Qt API so that we can set the appropriate keycode in DRT EventSender instead.
464 -    if (QWebPagePrivate::drtRun && !xEvent->xkey.keycode) {
465 -        QKeyEvent* qKeyEvent = keyEvent->qtEvent();
466 -        ASSERT(qKeyEvent);
467 -        QString keyText = qKeyEvent->text().left(1);
468 -        xEvent->xkey.keycode = XKeysymToKeycode(QX11Info::display(), XStringToKeysym(keyText.toUtf8().constData()));
469 -    }
470 -
471 -    xEvent->xkey.same_screen = true;
472 -
473 -    // NOTE: As the XEvents sent to the plug-in are synthesized and there is not a native window
474 -    // corresponding to the plug-in rectangle, some of the members of the XEvent structures are not
475 -    // set to their normal Xserver values. e.g. Key events don't have a position.
476 -    // source: https://developer.mozilla.org/en/NPEvent
477 -    xEvent->xkey.x = 0;
478 -    xEvent->xkey.y = 0;
479 -    xEvent->xkey.x_root = 0;
480 -    xEvent->xkey.y_root = 0;
481 -}
482 -
483  void PluginView::handleKeyboardEvent(KeyboardEvent* event)
484  {
485      if (m_isWindowed)
486 @@ -465,87 +233,9 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event)
487      if (event->type() != eventNames().keydownEvent && event->type() != eventNames().keyupEvent)
488          return;
489  
490 -    XEvent npEvent;
491 -    initXEvent(&npEvent);
492 -    setXKeyEventSpecificFields(&npEvent, event);
493 -
494 -    if (!dispatchNPEvent(npEvent))
495 -        event->setDefaultHandled();
496 -}
497 -
498 -static unsigned int inputEventState(MouseEvent* event)
499 -{
500 -    unsigned int state = 0;
501 -    if (event->ctrlKey())
502 -        state |= ControlMask;
503 -    if (event->shiftKey())
504 -        state |= ShiftMask;
505 -    if (event->altKey())
506 -        state |= Mod1Mask;
507 -    if (event->metaKey())
508 -        state |= Mod4Mask;
509 -    return state;
510 -}
511 -
512 -static void setXButtonEventSpecificFields(XEvent* xEvent, MouseEvent* event, const IntPoint& postZoomPos)
513 -{
514 -    XButtonEvent& xbutton = xEvent->xbutton;
515 -    xbutton.type = event->type() == eventNames().mousedownEvent ? ButtonPress : ButtonRelease;
516 -    xbutton.root = QX11Info::appRootWindow();
517 -    xbutton.subwindow = 0;
518 -    xbutton.time = event->timeStamp();
519 -    xbutton.x = postZoomPos.x();
520 -    xbutton.y = postZoomPos.y();
521 -    xbutton.x_root = event->screenX();
522 -    xbutton.y_root = event->screenY();
523 -    xbutton.state = inputEventState(event);
524 -    switch (event->button()) {
525 -    case MiddleButton:
526 -        xbutton.button = Button2;
527 -        break;
528 -    case RightButton:
529 -        xbutton.button = Button3;
530 -        break;
531 -    case LeftButton:
532 -    default:
533 -        xbutton.button = Button1;
534 -        break;
535 -    }
536 -    xbutton.same_screen = true;
537 -}
538 -
539 -static void setXMotionEventSpecificFields(XEvent* xEvent, MouseEvent* event, const IntPoint& postZoomPos)
540 -{
541 -    XMotionEvent& xmotion = xEvent->xmotion;
542 -    xmotion.type = MotionNotify;
543 -    xmotion.root = QX11Info::appRootWindow();
544 -    xmotion.subwindow = 0;
545 -    xmotion.time = event->timeStamp();
546 -    xmotion.x = postZoomPos.x();
547 -    xmotion.y = postZoomPos.y();
548 -    xmotion.x_root = event->screenX();
549 -    xmotion.y_root = event->screenY();
550 -    xmotion.state = inputEventState(event);
551 -    xmotion.is_hint = NotifyNormal;
552 -    xmotion.same_screen = true;
553 -}
554 -
555 -static void setXCrossingEventSpecificFields(XEvent* xEvent, MouseEvent* event, const IntPoint& postZoomPos)
556 -{
557 -    XCrossingEvent& xcrossing = xEvent->xcrossing;
558 -    xcrossing.type = event->type() == eventNames().mouseoverEvent ? EnterNotify : LeaveNotify;
559 -    xcrossing.root = QX11Info::appRootWindow();
560 -    xcrossing.subwindow = 0;
561 -    xcrossing.time = event->timeStamp();
562 -    xcrossing.x = postZoomPos.y();
563 -    xcrossing.y = postZoomPos.x();
564 -    xcrossing.x_root = event->screenX();
565 -    xcrossing.y_root = event->screenY();
566 -    xcrossing.state = inputEventState(event);
567 -    xcrossing.mode = NotifyNormal;
568 -    xcrossing.detail = NotifyDetailNone;
569 -    xcrossing.same_screen = true;
570 -    xcrossing.focus = false;
571 +#if defined(Q_WS_QWS)
572 +    event->setDefaultHandled();
573 +#endif
574  }
575  
576  void PluginView::handleMouseEvent(MouseEvent* event)
577 @@ -564,49 +254,14 @@ void PluginView::handleMouseEvent(MouseEvent* event)
578          focusPluginElement();
579      }
580  
581 -    XEvent npEvent;
582 -    initXEvent(&npEvent);
583 -
584 -    IntPoint postZoomPos = roundedIntPoint(m_element->renderer()->absoluteToLocal(event->absoluteLocation()));
585 -
586 -    if (event->type() == eventNames().mousedownEvent || event->type() == eventNames().mouseupEvent)
587 -        setXButtonEventSpecificFields(&npEvent, event, postZoomPos);
588 -    else if (event->type() == eventNames().mousemoveEvent)
589 -        setXMotionEventSpecificFields(&npEvent, event, postZoomPos);
590 -    else if (event->type() == eventNames().mouseoutEvent || event->type() == eventNames().mouseoverEvent)
591 -        setXCrossingEventSpecificFields(&npEvent, event, postZoomPos);
592 -    else
593 -        return;
594 -
595 -    if (!dispatchNPEvent(npEvent))
596 -        event->setDefaultHandled();
597 -}
598 -
599 -void PluginView::handleFocusInEvent()
600 -{
601 -    XEvent npEvent;
602 -    initXEvent(&npEvent);
603 -
604 -    XFocusChangeEvent& event = npEvent.xfocus;
605 -    event.type = 9; /* int as Qt unsets FocusIn */
606 -    event.mode = NotifyNormal;
607 -    event.detail = NotifyDetailNone;
608 -
609 -    dispatchNPEvent(npEvent);
610 +#if defined(Q_WS_QWS)
611 +    event->setDefaultHandled();
612 +#endif
613  }
614  
615 -void PluginView::handleFocusOutEvent()
616 -{
617 -    XEvent npEvent;
618 -    initXEvent(&npEvent);
619 -
620 -    XFocusChangeEvent& event = npEvent.xfocus;
621 -    event.type = 10; /* int as Qt unsets FocusOut */
622 -    event.mode = NotifyNormal;
623 -    event.detail = NotifyDetailNone;
624 +void PluginView::handleFocusInEvent(){}
625  
626 -    dispatchNPEvent(npEvent);
627 -}
628 +void PluginView::handleFocusOutEvent(){}
629  
630  void PluginView::setParent(ScrollView* parent)
631  {
632 @@ -618,53 +273,16 @@ void PluginView::setParent(ScrollView* parent)
633  
634  void PluginView::setNPWindowRect(const IntRect&)
635  {
636 -    if (!m_isWindowed)
637 -        setNPWindowIfNeeded();
638 +    setNPWindowIfNeeded();
639  }
640  
641  void PluginView::setNPWindowIfNeeded()
642  {
643 -    if (!m_isStarted || !parent() || !m_plugin->pluginFuncs()->setwindow)
644 +     if (!m_isStarted || !parent() || !m_plugin->pluginFuncs()->setwindow)
645          return;
646  
647 -    // If the plugin didn't load sucessfully, no point in calling setwindow
648 -    if (m_status != PluginStatusLoadedSuccessfully)
649 -        return;
650 -
651 -    // On Unix, only call plugin if it's full-page or windowed
652 -    if (m_mode != NP_FULL && m_mode != NP_EMBED)
653 -        return;
654 -
655 -    // Check if the platformPluginWidget still exists
656 -    if (m_isWindowed && !platformPluginWidget())
657 -        return;
658 -
659 -    if (!m_hasPendingGeometryChange)
660 -        return;
661 -    m_hasPendingGeometryChange = false;
662 -
663 -    if (m_isWindowed) {
664 -        platformPluginWidget()->setGeometry(m_windowRect);
665 -
666 -        // Cut out areas of the plugin occluded by iframe shims
667 -        Vector<IntRect> cutOutRects;
668 -        QRegion clipRegion = QRegion(m_clipRect);
669 -        getPluginOcclusions(m_element, this->parent(), frameRect(), cutOutRects);
670 -        for (size_t i = 0; i < cutOutRects.size(); i++) {
671 -            cutOutRects[i].move(-frameRect().x(), -frameRect().y());
672 -            clipRegion = clipRegion.subtracted(QRegion(cutOutRects[i]));
673 -        }
674 -        // if setMask is set with an empty QRegion, no clipping will
675 -        // be performed, so in that case we hide the plugin view
676 -        platformPluginWidget()->setVisible(!clipRegion.isEmpty());
677 -        platformPluginWidget()->setMask(clipRegion);
678 -
679 -        m_npWindow.x = m_windowRect.x();
680 -        m_npWindow.y = m_windowRect.y();
681 -    } else {
682 -        m_npWindow.x = 0;
683 -        m_npWindow.y = 0;
684 -    }
685 +    m_npWindow.x = m_windowRect.x();
686 +    m_npWindow.y = m_windowRect.y();
687  
688      // If the width or height are null, set the clipRect to null, indicating that
689      // the plugin is not visible/scrolled out.
690 @@ -674,24 +292,15 @@ void PluginView::setNPWindowIfNeeded()
691          m_npWindow.clipRect.top = 0;
692          m_npWindow.clipRect.bottom = 0;
693      } else {
694 -        // Clipping rectangle of the plug-in; the origin is the top left corner of the drawable or window. 
695 +        // Clipping rectangle of the plug-in; the origin is the top left corner of the drawable or window.
696          m_npWindow.clipRect.left = m_npWindow.x + m_clipRect.x();
697          m_npWindow.clipRect.top = m_npWindow.y + m_clipRect.y();
698          m_npWindow.clipRect.right = m_npWindow.x + m_clipRect.x() + m_clipRect.width();
699          m_npWindow.clipRect.bottom = m_npWindow.y + m_clipRect.y() + m_clipRect.height();
700      }
701 +    m_npWindow.width = m_windowRect.width();
702 +    m_npWindow.height = m_windowRect.height();
703  
704 -    if (m_plugin->quirks().contains(PluginQuirkDontCallSetWindowMoreThanOnce)) {
705 -        // FLASH WORKAROUND: Only set initially. Multiple calls to
706 -        // setNPWindow() cause the plugin to crash in windowed mode.
707 -        if (!m_isWindowed || m_npWindow.width == -1 || m_npWindow.height == -1) {
708 -            m_npWindow.width = m_windowRect.width();
709 -            m_npWindow.height = m_windowRect.height();
710 -        }
711 -    } else {
712 -        m_npWindow.width = m_windowRect.width();
713 -        m_npWindow.height = m_windowRect.height();
714 -    }
715  
716      PluginView::setCurrentPluginView(this);
717  #if USE(JSC)
718 @@ -700,7 +309,6 @@ void PluginView::setNPWindowIfNeeded()
719      setCallingPlugin(true);
720      m_plugin->pluginFuncs()->setwindow(m_instance, &m_npWindow);
721      setCallingPlugin(false);
722 -    PluginView::setCurrentPluginView(0);
723  }
724  
725  void PluginView::setParentVisible(bool visible)
726 @@ -763,13 +371,6 @@ bool PluginView::platformGetValueStatic(NPNVariable variable, void* value, NPErr
727          *result = NPERR_NO_ERROR;
728          return true;
729  
730 -#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5)
731 -    case NPNVSupportsWindowlessLocal:
732 -        *static_cast<NPBool*>(value) = true;
733 -        *result = NPERR_NO_ERROR;
734 -        return true;
735 -#endif
736 -
737      default:
738          return false;
739      }
740 @@ -779,7 +380,10 @@ bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* re
741  {
742      switch (variable) {
743      case NPNVxDisplay:
744 -        *(void **)value = QX11Info::display();
745 +#if defined(Q_WS_QWS)
746 +        *reinterpret_cast<void**>(value) = 0;
747 +#endif
748 +
749          *result = NPERR_NO_ERROR;
750          return true;
751  
752 @@ -788,9 +392,9 @@ bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* re
753          return true;
754  
755      case NPNVnetscapeWindow: {
756 -        void* w = reinterpret_cast<void*>(value);
757 -        QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
758 -        *((XID *)w) = client ? client->ownerWidget()->window()->winId() : 0;
759 +#if defined(Q_WS_QWS)
760 +        *reinterpret_cast<void**>(value) = 0;
761 +#endif
762          *result = NPERR_NO_ERROR;
763          return true;
764      }
765 @@ -851,72 +455,6 @@ void PluginView::forceRedraw()
766      invalidate();
767  }
768  
769 -static Display *getPluginDisplay()
770 -{
771 -    // The plugin toolkit might run using a different X connection. At the moment, we only
772 -    // support gdk based plugins (like flash) that use a different X connection.
773 -    // The code below has the same effect as this one:
774 -    // Display *gdkDisplay = gdk_x11_display_get_xdisplay(gdk_display_get_default());
775 -    QLibrary library(QLatin1String("libgdk-x11-2.0"), 0);
776 -    if (!library.load())
777 -        return 0;
778 -
779 -    typedef void *(*gdk_display_get_default_ptr)();
780 -    gdk_display_get_default_ptr gdk_display_get_default = (gdk_display_get_default_ptr)library.resolve("gdk_display_get_default");
781 -    if (!gdk_display_get_default)
782 -        return 0;
783 -
784 -    typedef void *(*gdk_x11_display_get_xdisplay_ptr)(void *);
785 -    gdk_x11_display_get_xdisplay_ptr gdk_x11_display_get_xdisplay = (gdk_x11_display_get_xdisplay_ptr)library.resolve("gdk_x11_display_get_xdisplay");
786 -    if (!gdk_x11_display_get_xdisplay)
787 -        return 0;
788 -
789 -    return (Display*)gdk_x11_display_get_xdisplay(gdk_display_get_default());
790 -}
791 -
792 -static void getVisualAndColormap(int depth, Visual **visual, Colormap *colormap)
793 -{
794 -    *visual = 0;
795 -    *colormap = 0;
796 -
797 -#ifndef QT_NO_XRENDER
798 -    static const bool useXRender = qgetenv("QT_X11_NO_XRENDER").isNull(); // Should also check for XRender >= 0.5
799 -#else
800 -    static const bool useXRender = false;
801 -#endif
802 -
803 -    if (!useXRender && depth == 32)
804 -        return;
805 -
806 -    int nvi;
807 -    XVisualInfo templ;
808 -    templ.screen  = QX11Info::appScreen();
809 -    templ.depth   = depth;
810 -    templ.c_class = TrueColor;
811 -    XVisualInfo* xvi = XGetVisualInfo(QX11Info::display(), VisualScreenMask | VisualDepthMask | VisualClassMask, &templ, &nvi);
812 -
813 -    if (!xvi)
814 -        return;
815 -
816 -#ifndef QT_NO_XRENDER
817 -    if (depth == 32) {
818 -        for (int idx = 0; idx < nvi; ++idx) {
819 -            XRenderPictFormat* format = XRenderFindVisualFormat(QX11Info::display(), xvi[idx].visual);
820 -            if (format->type == PictTypeDirect && format->direct.alphaMask) {
821 -                 *visual = xvi[idx].visual;
822 -                 break;
823 -            }
824 -         }
825 -    } else
826 -#endif // QT_NO_XRENDER
827 -        *visual = xvi[0].visual;
828 -
829 -    XFree(xvi);
830 -
831 -    if (*visual)
832 -        *colormap = XCreateColormap(QX11Info::display(), QX11Info::appRootWindow(), *visual, AllocNone);
833 -}
834 -
835  bool PluginView::platformStart()
836  {
837      ASSERT(m_isStarted);
838 @@ -934,19 +472,11 @@ bool PluginView::platformStart()
839      }
840  
841      if (m_isWindowed) {
842 -        QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
843 -        if (m_needsXEmbed && client) {
844 -            setPlatformWidget(new PluginContainerQt(this, client->ownerWidget()));
845 -            // sync our XEmbed container window creation before sending the xid to plugins.
846 -            QApplication::syncX();
847 -        } else {
848              notImplemented();
849              m_status = PluginStatusCanNotLoadPlugin;
850              return false;
851 -        }
852      } else {
853          setPlatformWidget(0);
854 -        m_pluginDisplay = getPluginDisplay();
855  
856  #if USE(ACCELERATED_COMPOSITING) && !USE(TEXTURE_MAPPER)
857          if (shouldUseAcceleratedCompositing()) {
858 @@ -961,48 +491,6 @@ bool PluginView::platformStart()
859      if (!frameRect().isEmpty())
860          show();
861  
862 -    NPSetWindowCallbackStruct* wsi = new NPSetWindowCallbackStruct();
863 -    wsi->type = 0;
864 -
865 -    if (m_isWindowed) {
866 -        const QX11Info* x11Info = &platformPluginWidget()->x11Info();
867 -
868 -        wsi->display = x11Info->display();
869 -        wsi->visual = (Visual*)x11Info->visual();
870 -        wsi->depth = x11Info->depth();
871 -        wsi->colormap = x11Info->colormap();
872 -
873 -        m_npWindow.type = NPWindowTypeWindow;
874 -        m_npWindow.window = (void*)platformPluginWidget()->winId();
875 -        m_npWindow.width = -1;
876 -        m_npWindow.height = -1;
877 -    } else {
878 -        const QX11Info* x11Info = &QApplication::desktop()->x11Info();
879 -
880 -        if (x11Info->depth() == 32 || !m_plugin->quirks().contains(PluginQuirkRequiresDefaultScreenDepth)) {
881 -            getVisualAndColormap(32, &m_visual, &m_colormap);
882 -            wsi->depth = 32;
883 -        }
884 -
885 -        if (!m_visual) {
886 -            getVisualAndColormap(x11Info->depth(), &m_visual, &m_colormap);
887 -            wsi->depth = x11Info->depth();
888 -        }
889 -
890 -        wsi->display = x11Info->display();
891 -        wsi->visual = m_visual;
892 -        wsi->colormap = m_colormap;
893 -
894 -        m_npWindow.type = NPWindowTypeDrawable;
895 -        m_npWindow.window = 0; // Not used?
896 -        m_npWindow.x = 0;
897 -        m_npWindow.y = 0;
898 -        m_npWindow.width = -1;
899 -        m_npWindow.height = -1;
900 -    }
901 -
902 -    m_npWindow.ws_info = wsi;
903 -
904      if (!(m_plugin->quirks().contains(PluginQuirkDeferFirstSetWindowCall))) {
905          updatePluginWidget();
906          setNPWindowIfNeeded();
907 @@ -1015,12 +503,6 @@ void PluginView::platformDestroy()
908  {
909      if (platformPluginWidget())
910          delete platformPluginWidget();
911 -
912 -    if (m_drawable)
913 -        XFreePixmap(QX11Info::display(), m_drawable);
914 -
915 -    if (m_colormap)
916 -        XFreeColormap(QX11Info::display(), m_colormap);
917  }
918  
919  void PluginView::halt()
920 -- 
921 1.9.1
922