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