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
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(-)
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
26 - plugins/qt/PluginContainerQt.cpp \
27 plugins/qt/PluginPackageQt.cpp \
28 plugins/qt/PluginViewQt.cpp
30 - plugins/qt/PluginContainerQt.h
33 + plugins/qt/PluginContainerQt.cpp
35 + plugins/qt/PluginContainerQt.h
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
49 +#if defined(XP_UNIX) && defined(Q_WS_X11)
51 #include <X11/Xutil.h>
53 @@ -248,7 +248,7 @@ typedef enum {
54 /* Exact meaning must be spec'd in event model. */
55 #define kNPEventStartIME 2
58 +#if defined(XP_UNIX) && defined(Q_WS_X11)
60 * Unix specific structures and definitions
62 @@ -537,7 +537,7 @@ typedef struct _NPEvent
66 -#elif defined(XP_UNIX)
67 +#elif defined(XP_UNIX) && defined(Q_WS_X11)
68 typedef XEvent NPEvent;
70 typedef void* NPEvent;
71 @@ -551,7 +551,7 @@ typedef RgnHandle NPQDRegion;
72 typedef CGPathRef NPCGRegion;
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
85 #include "npfunctions.h"
86 #include "npruntime.h"
89 +#if defined(XP_UNIX) && defined(Q_WS_X11)
90 #include <X11/Xresource.h>
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
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);
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)
121 case NPPVpluginWindowBool:
122 +#if defined(Q_WS_X11)
123 m_isWindowed = value;
125 + m_isWindowed = true;
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
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)
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;
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;
152 @@ -432,7 +432,7 @@ private:
153 bool m_renderToImage;
154 void paintUsingImageSurfaceExtension(QPainter* painter, const IntRect& exposedRect);
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);
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
167 #include "PlatformMouseEvent.h"
168 #include "PlatformKeyboardEvent.h"
169 -#include "PluginContainerQt.h"
170 #include "PluginDebug.h"
171 #include "PluginPackage.h"
172 #include "PluginMainThreadScheduler.h"
175 #include <QStyleOptionGraphicsItem>
179 -#ifndef QT_NO_XRENDER
182 -#include <X11/extensions/Xrender.h>
184 #include <runtime/JSLock.h>
185 #include <runtime/JSValue.h>
187 @@ -111,21 +103,13 @@ public:
188 PluginGraphicsLayerQt(PluginView* view) : m_view(view) { }
189 ~PluginGraphicsLayerQt() { }
191 - void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0)
194 - m_view->paintUsingXPixmap(painter, option->exposedRect.toRect());
201 bool PluginView::shouldUseAcceleratedCompositing() const
203 - return m_parentFrame->page()->chrome()->client()->allowsAcceleratedCompositing()
204 - && m_parentFrame->page()->settings()
205 - && m_parentFrame->page()->settings()->acceleratedCompositingEnabled();
210 @@ -151,25 +135,6 @@ void PluginView::updatePluginWidget()
211 if (oldWindowRect.isEmpty())
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);
223 - XFreePixmap(QX11Info::display(), m_drawable);
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
231 - // do not call setNPWindowIfNeeded immediately, will be called on paint()
232 - m_hasPendingGeometryChange = true;
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();
246 if (!m_platformLayer) {
247 // Make sure we get repainted afterwards. This is necessary for downward
248 @@ -214,133 +178,6 @@ void PluginView::hide()
252 -#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5)
253 -void PluginView::paintUsingImageSurfaceExtension(QPainter* painter, const IntRect& exposedRect)
255 - NPImageExpose imageExpose;
257 - QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
258 - const bool surfaceHasUntransformedContents = client && qobject_cast<QWidget*>(client->pluginParent());
260 - QPaintDevice* surface = QPainter::redirected(painter->device(), &offset);
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;
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);
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;
294 - imageExpose.x = exposedRect.x();
295 - imageExpose.y = exposedRect.y();
296 - imageExpose.width = exposedRect.width();
297 - imageExpose.height = exposedRect.height();
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();
310 - dispatchNPEvent(xevent);
312 - if (!surfaceHasUntransformedContents || !surface || surface->devType() != QInternal::Image)
313 - painter->drawImage(QPoint(frameRect().x() + exposedRect.x(), frameRect().y() + exposedRect.y()), m_image, exposedRect);
317 -void PluginView::paintUsingXPixmap(QPainter* painter, const QRect &exposedRect)
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();
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();
330 - if (m_isTransparent && drawableDepth != 32) {
331 - // Attempt content propagation for drawable with no alpha by copying over from the backing store
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
336 - const bool hasValidBackingStore = backingStoreDevice && backingStoreDevice->devType() == QInternal::Pixmap;
337 - QPixmap* backingStorePixmap = static_cast<QPixmap*>(backingStoreDevice);
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());
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);
357 - QApplication::syncX();
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
371 - dispatchNPEvent(xevent);
374 - XSync(m_pluginDisplay, false); // sync changes by plugin
376 - painter->drawPixmap(QPoint(exposedRect.x(), exposedRect.y()), qtDrawable, exposedRect);
379 void PluginView::paint(GraphicsContext* context, const IntRect& rect)
382 @@ -351,38 +188,23 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
383 if (context->paintingDisabled())
386 + updatePluginWidget();
387 setNPWindowIfNeeded();
392 #if USE(ACCELERATED_COMPOSITING)
398 -#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5)
399 - && m_image.isNull()
404 QPainter* painter = context->platformContext();
405 IntRect exposedRect(rect);
406 exposedRect.intersect(frameRect());
407 exposedRect.move(-frameRect().x(), -frameRect().y());
409 -#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5)
410 - if (!m_image.isNull()) {
411 - paintUsingImageSurfaceExtension(painter, exposedRect);
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);
425 // TODO: Unify across ports.
426 @@ -403,60 +225,6 @@ bool PluginView::dispatchNPEvent(NPEvent& event)
430 -void setSharedXEventFields(XEvent* xEvent, QWidget* ownerWidget)
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;
441 -void PluginView::initXEvent(XEvent* xEvent)
443 - memset(xEvent, 0, sizeof(XEvent));
445 - QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
446 - QWidget* ownerWidget = client ? client->ownerWidget() : 0;
447 - setSharedXEventFields(xEvent, ownerWidget);
450 -void setXKeyEventSpecificFields(XEvent* xEvent, KeyboardEvent* event)
452 - const PlatformKeyboardEvent* keyEvent = event->keyEvent();
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();
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();
468 - QString keyText = qKeyEvent->text().left(1);
469 - xEvent->xkey.keycode = XKeysymToKeycode(QX11Info::display(), XStringToKeysym(keyText.toUtf8().constData()));
472 - xEvent->xkey.same_screen = true;
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;
484 void PluginView::handleKeyboardEvent(KeyboardEvent* event)
487 @@ -465,87 +233,9 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event)
488 if (event->type() != eventNames().keydownEvent && event->type() != eventNames().keyupEvent)
492 - initXEvent(&npEvent);
493 - setXKeyEventSpecificFields(&npEvent, event);
495 - if (!dispatchNPEvent(npEvent))
496 - event->setDefaultHandled();
499 -static unsigned int inputEventState(MouseEvent* event)
501 - unsigned int state = 0;
502 - if (event->ctrlKey())
503 - state |= ControlMask;
504 - if (event->shiftKey())
505 - state |= ShiftMask;
506 - if (event->altKey())
508 - if (event->metaKey())
513 -static void setXButtonEventSpecificFields(XEvent* xEvent, MouseEvent* event, const IntPoint& postZoomPos)
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()) {
527 - xbutton.button = Button2;
530 - xbutton.button = Button3;
534 - xbutton.button = Button1;
537 - xbutton.same_screen = true;
540 -static void setXMotionEventSpecificFields(XEvent* xEvent, MouseEvent* event, const IntPoint& postZoomPos)
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;
556 -static void setXCrossingEventSpecificFields(XEvent* xEvent, MouseEvent* event, const IntPoint& postZoomPos)
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();
577 void PluginView::handleMouseEvent(MouseEvent* event)
578 @@ -564,49 +254,14 @@ void PluginView::handleMouseEvent(MouseEvent* event)
579 focusPluginElement();
583 - initXEvent(&npEvent);
585 - IntPoint postZoomPos = roundedIntPoint(m_element->renderer()->absoluteToLocal(event->absoluteLocation()));
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);
596 - if (!dispatchNPEvent(npEvent))
597 - event->setDefaultHandled();
600 -void PluginView::handleFocusInEvent()
603 - initXEvent(&npEvent);
605 - XFocusChangeEvent& event = npEvent.xfocus;
606 - event.type = 9; /* int as Qt unsets FocusIn */
607 - event.mode = NotifyNormal;
608 - event.detail = NotifyDetailNone;
610 - dispatchNPEvent(npEvent);
611 +#if defined(Q_WS_QWS)
612 + event->setDefaultHandled();
616 -void PluginView::handleFocusOutEvent()
619 - initXEvent(&npEvent);
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(){}
627 - dispatchNPEvent(npEvent);
629 +void PluginView::handleFocusOutEvent(){}
631 void PluginView::setParent(ScrollView* parent)
633 @@ -618,53 +273,16 @@ void PluginView::setParent(ScrollView* parent)
635 void PluginView::setNPWindowRect(const IntRect&)
638 - setNPWindowIfNeeded();
639 + setNPWindowIfNeeded();
642 void PluginView::setNPWindowIfNeeded()
644 - if (!m_isStarted || !parent() || !m_plugin->pluginFuncs()->setwindow)
645 + if (!m_isStarted || !parent() || !m_plugin->pluginFuncs()->setwindow)
648 - // If the plugin didn't load sucessfully, no point in calling setwindow
649 - if (m_status != PluginStatusLoadedSuccessfully)
652 - // On Unix, only call plugin if it's full-page or windowed
653 - if (m_mode != NP_FULL && m_mode != NP_EMBED)
656 - // Check if the platformPluginWidget still exists
657 - if (m_isWindowed && !platformPluginWidget())
660 - if (!m_hasPendingGeometryChange)
662 - m_hasPendingGeometryChange = false;
664 - if (m_isWindowed) {
665 - platformPluginWidget()->setGeometry(m_windowRect);
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]));
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);
680 - m_npWindow.x = m_windowRect.x();
681 - m_npWindow.y = m_windowRect.y();
686 + m_npWindow.x = m_windowRect.x();
687 + m_npWindow.y = m_windowRect.y();
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;
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();
702 + m_npWindow.width = m_windowRect.width();
703 + m_npWindow.height = m_windowRect.height();
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();
713 - m_npWindow.width = m_windowRect.width();
714 - m_npWindow.height = m_windowRect.height();
717 PluginView::setCurrentPluginView(this);
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);
726 void PluginView::setParentVisible(bool visible)
727 @@ -763,13 +371,6 @@ bool PluginView::platformGetValueStatic(NPNVariable variable, void* value, NPErr
728 *result = NPERR_NO_ERROR;
731 -#if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5)
732 - case NPNVSupportsWindowlessLocal:
733 - *static_cast<NPBool*>(value) = true;
734 - *result = NPERR_NO_ERROR;
741 @@ -779,7 +380,10 @@ bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* re
745 - *(void **)value = QX11Info::display();
746 +#if defined(Q_WS_QWS)
747 + *reinterpret_cast<void**>(value) = 0;
750 *result = NPERR_NO_ERROR;
753 @@ -788,9 +392,9 @@ bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* re
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;
763 *result = NPERR_NO_ERROR;
766 @@ -851,72 +455,6 @@ void PluginView::forceRedraw()
770 -static Display *getPluginDisplay()
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())
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)
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)
790 - return (Display*)gdk_x11_display_get_xdisplay(gdk_display_get_default());
793 -static void getVisualAndColormap(int depth, Visual **visual, Colormap *colormap)
798 -#ifndef QT_NO_XRENDER
799 - static const bool useXRender = qgetenv("QT_X11_NO_XRENDER").isNull(); // Should also check for XRender >= 0.5
801 - static const bool useXRender = false;
804 - if (!useXRender && depth == 32)
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);
817 -#ifndef QT_NO_XRENDER
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;
827 -#endif // QT_NO_XRENDER
828 - *visual = xvi[0].visual;
833 - *colormap = XCreateColormap(QX11Info::display(), QX11Info::appRootWindow(), *visual, AllocNone);
836 bool PluginView::platformStart()
839 @@ -934,19 +472,11 @@ bool PluginView::platformStart()
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();
850 m_status = PluginStatusCanNotLoadPlugin;
854 setPlatformWidget(0);
855 - m_pluginDisplay = getPluginDisplay();
857 #if USE(ACCELERATED_COMPOSITING) && !USE(TEXTURE_MAPPER)
858 if (shouldUseAcceleratedCompositing()) {
859 @@ -961,48 +491,6 @@ bool PluginView::platformStart()
860 if (!frameRect().isEmpty())
863 - NPSetWindowCallbackStruct* wsi = new NPSetWindowCallbackStruct();
866 - if (m_isWindowed) {
867 - const QX11Info* x11Info = &platformPluginWidget()->x11Info();
869 - wsi->display = x11Info->display();
870 - wsi->visual = (Visual*)x11Info->visual();
871 - wsi->depth = x11Info->depth();
872 - wsi->colormap = x11Info->colormap();
874 - m_npWindow.type = NPWindowTypeWindow;
875 - m_npWindow.window = (void*)platformPluginWidget()->winId();
876 - m_npWindow.width = -1;
877 - m_npWindow.height = -1;
879 - const QX11Info* x11Info = &QApplication::desktop()->x11Info();
881 - if (x11Info->depth() == 32 || !m_plugin->quirks().contains(PluginQuirkRequiresDefaultScreenDepth)) {
882 - getVisualAndColormap(32, &m_visual, &m_colormap);
887 - getVisualAndColormap(x11Info->depth(), &m_visual, &m_colormap);
888 - wsi->depth = x11Info->depth();
891 - wsi->display = x11Info->display();
892 - wsi->visual = m_visual;
893 - wsi->colormap = m_colormap;
895 - m_npWindow.type = NPWindowTypeDrawable;
896 - m_npWindow.window = 0; // Not used?
899 - m_npWindow.width = -1;
900 - m_npWindow.height = -1;
903 - m_npWindow.ws_info = wsi;
905 if (!(m_plugin->quirks().contains(PluginQuirkDeferFirstSetWindowCall))) {
906 updatePluginWidget();
907 setNPWindowIfNeeded();
908 @@ -1015,12 +503,6 @@ void PluginView::platformDestroy()
910 if (platformPluginWidget())
911 delete platformPluginWidget();
914 - XFreePixmap(QX11Info::display(), m_drawable);
917 - XFreeColormap(QX11Info::display(), m_colormap);
920 void PluginView::halt()