task-opendreambox-enigma2: split into .inc and .bb
[opendreambox.git] / meta-opendreambox / recipes-qt / qt4 / qt4-embedded-4.8.1 / 0001-Qt-build-NPAPI-without-X11.patch
1 From cca9f103aeb0f88fd56c347b843b445f636e7691 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/2] Qt: build NPAPI without X11
5
6 ---
7  src/3rdparty/webkit/Source/WebCore/WebCore.pro     |    9 ++-
8  src/3rdparty/webkit/Source/WebCore/bridge/npapi.h  |    8 +-
9  .../Source/WebCore/bridge/npruntime_internal.h     |    2 +-
10  src/3rdparty/webkit/Source/WebCore/features.pri    |    1 +
11  .../webkit/Source/WebCore/plugins/PluginView.cpp   |    4 +-
12  .../webkit/Source/WebCore/plugins/PluginView.h     |    4 +-
13  .../Source/WebCore/plugins/qt/PluginViewQt.cpp     |   62 ++++++++++++++++++++
14  7 files changed, 78 insertions(+), 12 deletions(-)
15
16 diff --git a/src/3rdparty/webkit/Source/WebCore/WebCore.pro b/src/3rdparty/webkit/Source/WebCore/WebCore.pro
17 index ceceee8..ef4c7f9 100644
18 --- a/src/3rdparty/webkit/Source/WebCore/WebCore.pro
19 +++ b/src/3rdparty/webkit/Source/WebCore/WebCore.pro
20 @@ -2587,11 +2587,14 @@ contains(DEFINES, ENABLE_NETSCAPE_PLUGIN_API=1) {
21                  plugins/mac/PluginViewMac.mm
22          } else {
23              SOURCES += \
24 -                plugins/qt/PluginContainerQt.cpp \
25                  plugins/qt/PluginPackageQt.cpp \
26                  plugins/qt/PluginViewQt.cpp
27 -            HEADERS += \
28 -                plugins/qt/PluginContainerQt.h
29 +            !embedded {
30 +                SOURCES += \
31 +                    plugins/qt/PluginContainerQt.cpp
32 +                HEADERS += \
33 +                    plugins/qt/PluginContainerQt.h
34 +            }
35          }
36      }
37  
38 diff --git a/src/3rdparty/webkit/Source/WebCore/bridge/npapi.h b/src/3rdparty/webkit/Source/WebCore/bridge/npapi.h
39 index c217718..54fc0aa 100644
40 --- a/src/3rdparty/webkit/Source/WebCore/bridge/npapi.h
41 +++ b/src/3rdparty/webkit/Source/WebCore/bridge/npapi.h
42 @@ -89,7 +89,7 @@
43  #endif
44  #endif
45  
46 -#if defined(XP_UNIX)
47 +#if defined(XP_UNIX) && defined(Q_WS_X11)
48  #include <X11/Xlib.h>
49  #include <X11/Xutil.h>
50  #include <stdio.h>
51 @@ -248,7 +248,7 @@ typedef enum {
52  /* Exact meaning must be spec'd in event model. */
53  #define kNPEventStartIME 2
54  
55 -#if defined(XP_UNIX)
56 +#if defined(XP_UNIX) && defined(Q_WS_X11)
57  /*
58   * Unix specific structures and definitions
59   */
60 @@ -537,7 +537,7 @@ typedef struct _NPEvent
61    uint32_t wParam;
62    uint32_t lParam;
63  } NPEvent;
64 -#elif defined(XP_UNIX)
65 +#elif defined(XP_UNIX) && defined(Q_WS_X11)
66  typedef XEvent NPEvent;
67  #else
68  typedef void*  NPEvent;
69 @@ -551,7 +551,7 @@ typedef RgnHandle NPQDRegion;
70  typedef CGPathRef NPCGRegion;
71  #elif defined(XP_WIN)
72  typedef HRGN NPRegion;
73 -#elif defined(XP_UNIX)
74 +#elif defined(XP_UNIX) && defined(Q_WS_X11)
75  typedef Region NPRegion;
76  #elif defined(XP_SYMBIAN)
77  typedef QRegion* NPRegion;
78 diff --git a/src/3rdparty/webkit/Source/WebCore/bridge/npruntime_internal.h b/src/3rdparty/webkit/Source/WebCore/bridge/npruntime_internal.h
79 index 2d7dc06..ec84b6c 100644
80 --- a/src/3rdparty/webkit/Source/WebCore/bridge/npruntime_internal.h
81 +++ b/src/3rdparty/webkit/Source/WebCore/bridge/npruntime_internal.h
82 @@ -29,7 +29,7 @@
83  #include "npfunctions.h"
84  #include "npruntime.h"
85  
86 -#ifdef XP_UNIX
87 +#if defined(XP_UNIX) && defined(Q_WS_X11)
88      #include <X11/Xresource.h>
89  
90      #undef None
91 diff --git a/src/3rdparty/webkit/Source/WebCore/features.pri b/src/3rdparty/webkit/Source/WebCore/features.pri
92 index f04d0b4..48b2eb2 100644
93 --- a/src/3rdparty/webkit/Source/WebCore/features.pri
94 +++ b/src/3rdparty/webkit/Source/WebCore/features.pri
95 @@ -97,6 +97,7 @@ contains(DEFINES, ENABLE_SINGLE_THREADED=1) {
96  !contains(DEFINES, ENABLE_TILED_BACKING_STORE=.): DEFINES += ENABLE_TILED_BACKING_STORE=1
97  
98  # Nescape plugins support (NPAPI)
99 +DEFINES += ENABLE_NETSCAPE_PLUGIN_API=1
100  !contains(DEFINES, ENABLE_NETSCAPE_PLUGIN_API=.) {
101      unix|win32-*:!embedded:!wince*: {
102          DEFINES += ENABLE_NETSCAPE_PLUGIN_API=1
103 diff --git a/src/3rdparty/webkit/Source/WebCore/plugins/PluginView.cpp b/src/3rdparty/webkit/Source/WebCore/plugins/PluginView.cpp
104 index b020946..62ebc41 100644
105 --- a/src/3rdparty/webkit/Source/WebCore/plugins/PluginView.cpp
106 +++ b/src/3rdparty/webkit/Source/WebCore/plugins/PluginView.cpp
107 @@ -369,7 +369,7 @@ void PluginView::stop()
108          PluginView::setCurrentPluginView(0);
109      }
110  
111 -#ifdef XP_UNIX
112 +#if defined(XP_UNIX) && defined(Q_WS_X11)
113      if (m_isWindowed && m_npWindow.ws_info)
114             delete (NPSetWindowCallbackStruct *)m_npWindow.ws_info;
115      m_npWindow.ws_info = 0;
116 @@ -867,7 +867,7 @@ PluginView::PluginView(Frame* parentFrame, const IntSize& size, PluginPackage* p
117      , m_contextRef(0)
118      , m_fakeWindow(0)
119  #endif
120 -#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
121 +#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API) && defined(Q_WS_X11)
122      , m_hasPendingGeometryChange(true)
123      , m_drawable(0)
124      , m_visual(0)
125 diff --git a/src/3rdparty/webkit/Source/WebCore/plugins/PluginView.h b/src/3rdparty/webkit/Source/WebCore/plugins/PluginView.h
126 index f528754..a49db47 100644
127 --- a/src/3rdparty/webkit/Source/WebCore/plugins/PluginView.h
128 +++ b/src/3rdparty/webkit/Source/WebCore/plugins/PluginView.h
129 @@ -416,7 +416,7 @@ private:
130          Point mousePosForPlugin(MouseEvent* event = 0) const;
131  #endif
132  
133 -#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
134 +#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API) && defined(Q_WS_X11)
135          bool m_hasPendingGeometryChange;
136          Pixmap m_drawable;
137          Visual* m_visual;
138 @@ -432,7 +432,7 @@ private:
139          bool m_renderToImage;
140          void paintUsingImageSurfaceExtension(QPainter* painter, const IntRect& exposedRect);
141  #endif
142 -#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API)
143 +#if defined(XP_UNIX) && ENABLE(NETSCAPE_PLUGIN_API) && defined(Q_WS_X11)
144          void paintUsingXPixmap(QPainter* painter, const QRect &exposedRect);
145  #endif
146  #if USE(ACCELERATED_COMPOSITING_PLUGIN_LAYER)
147 diff --git a/src/3rdparty/webkit/Source/WebCore/plugins/qt/PluginViewQt.cpp b/src/3rdparty/webkit/Source/WebCore/plugins/qt/PluginViewQt.cpp
148 index 2fe69d1..bb27eb8 100644
149 --- a/src/3rdparty/webkit/Source/WebCore/plugins/qt/PluginViewQt.cpp
150 +++ b/src/3rdparty/webkit/Source/WebCore/plugins/qt/PluginViewQt.cpp
151 @@ -58,7 +58,9 @@
152  #include "Page.h"
153  #include "PlatformMouseEvent.h"
154  #include "PlatformKeyboardEvent.h"
155 +#if defined(Q_WS_X11)
156  #include "PluginContainerQt.h"
157 +#endif
158  #include "PluginDebug.h"
159  #include "PluginPackage.h"
160  #include "PluginMainThreadScheduler.h"
161 @@ -78,6 +80,7 @@
162  #include <QPainter>
163  #include <QStyleOptionGraphicsItem>
164  #include <QWidget>
165 +#if defined(Q_WS_X11)
166  #include <QX11Info>
167  #include <X11/X.h>
168  #ifndef QT_NO_XRENDER
169 @@ -85,6 +88,7 @@
170  #define Status int
171  #include <X11/extensions/Xrender.h>
172  #endif
173 +#endif
174  #include <runtime/JSLock.h>
175  #include <runtime/JSValue.h>
176  
177 @@ -111,11 +115,13 @@ public:
178      PluginGraphicsLayerQt(PluginView* view) : m_view(view) { }
179      ~PluginGraphicsLayerQt() { }
180  
181 +#if defined(Q_WS_X11)
182      void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0)
183      {
184          Q_UNUSED(widget);
185          m_view->paintUsingXPixmap(painter, option->exposedRect.toRect());
186      }
187 +#endif
188  
189  private:
190      PluginView* m_view;
191 @@ -123,9 +129,13 @@ private:
192  
193  bool PluginView::shouldUseAcceleratedCompositing() const
194  {
195 +#if defined(Q_WS_X11)
196      return m_parentFrame->page()->chrome()->client()->allowsAcceleratedCompositing()
197             && m_parentFrame->page()->settings()
198             && m_parentFrame->page()->settings()->acceleratedCompositingEnabled();
199 +#else
200 +    return false;
201 +#endif
202  }
203  #endif
204  
205 @@ -151,6 +161,7 @@ void PluginView::updatePluginWidget()
206      if (oldWindowRect.isEmpty())
207          show();
208  
209 +#if defined(Q_WS_X11)
210      if (!m_isWindowed && m_windowRect.size() != oldWindowRect.size()) {
211  #if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5)
212          // On Maemo5, Flash always renders to 16-bit buffer
213 @@ -170,6 +181,7 @@ void PluginView::updatePluginWidget()
214  
215      // do not call setNPWindowIfNeeded immediately, will be called on paint()
216      m_hasPendingGeometryChange = true;
217 +#endif
218  
219      // (i) in order to move/resize the plugin window at the same time as the
220      // rest of frame during e.g. scrolling, we set the window geometry
221 @@ -279,6 +291,7 @@ void PluginView::paintUsingImageSurfaceExtension(QPainter* painter, const IntRec
222  }
223  #endif
224  
225 +#if defined(Q_WS_X11)
226  void PluginView::paintUsingXPixmap(QPainter* painter, const QRect &exposedRect)
227  {
228      QPixmap qtDrawable = QPixmap::fromX11Pixmap(m_drawable, QPixmap::ExplicitlyShared);
229 @@ -340,6 +353,7 @@ void PluginView::paintUsingXPixmap(QPainter* painter, const QRect &exposedRect)
230  
231      painter->drawPixmap(QPoint(exposedRect.x(), exposedRect.y()), qtDrawable, exposedRect);
232  }
233 +#endif
234  
235  void PluginView::paint(GraphicsContext* context, const IntRect& rect)
236  {
237 @@ -361,12 +375,14 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
238          return;
239  #endif
240  
241 +#if defined(Q_WS_X11)
242      if (!m_drawable
243  #if defined(MOZ_PLATFORM_MAEMO) && (MOZ_PLATFORM_MAEMO >= 5)
244          && m_image.isNull()
245  #endif
246         )
247          return;
248 +#endif
249  
250      QPainter* painter = context->platformContext();
251      IntRect exposedRect(rect);
252 @@ -380,9 +396,11 @@ void PluginView::paint(GraphicsContext* context, const IntRect& rect)
253      }
254  #endif
255  
256 +#if defined(Q_WS_X11)
257      painter->translate(frameRect().x(), frameRect().y());
258      paintUsingXPixmap(painter, exposedRect);
259      painter->translate(-frameRect().x(), -frameRect().y());
260 +#endif
261  }
262  
263  // TODO: Unify across ports.
264 @@ -403,6 +421,7 @@ bool PluginView::dispatchNPEvent(NPEvent& event)
265      return accepted;
266  }
267  
268 +#if defined(Q_WS_X11)
269  void setSharedXEventFields(XEvent* xEvent, QWidget* ownerWidget)
270  {
271      xEvent->xany.serial = 0; // we are unaware of the last request processed by X Server
272 @@ -456,6 +475,7 @@ void setXKeyEventSpecificFields(XEvent* xEvent, KeyboardEvent* event)
273      xEvent->xkey.x_root = 0;
274      xEvent->xkey.y_root = 0;
275  }
276 +#endif
277  
278  void PluginView::handleKeyboardEvent(KeyboardEvent* event)
279  {
280 @@ -465,14 +485,21 @@ void PluginView::handleKeyboardEvent(KeyboardEvent* event)
281      if (event->type() != eventNames().keydownEvent && event->type() != eventNames().keyupEvent)
282          return;
283  
284 +#if defined(Q_WS_X11)
285      XEvent npEvent;
286      initXEvent(&npEvent);
287      setXKeyEventSpecificFields(&npEvent, event);
288  
289      if (!dispatchNPEvent(npEvent))
290          event->setDefaultHandled();
291 +#endif
292 +
293 +#if defined(Q_WS_QWS)
294 +    event->setDefaultHandled();
295 +#endif
296  }
297  
298 +#if defined(Q_WS_X11)
299  static unsigned int inputEventState(MouseEvent* event)
300  {
301      unsigned int state = 0;
302 @@ -547,6 +574,7 @@ static void setXCrossingEventSpecificFields(XEvent* xEvent, MouseEvent* event, c
303      xcrossing.same_screen = true;
304      xcrossing.focus = false;
305  }
306 +#endif
307  
308  void PluginView::handleMouseEvent(MouseEvent* event)
309  {
310 @@ -564,6 +592,7 @@ void PluginView::handleMouseEvent(MouseEvent* event)
311          focusPluginElement();
312      }
313  
314 +#if defined(Q_WS_X11)
315      XEvent npEvent;
316      initXEvent(&npEvent);
317  
318 @@ -580,10 +609,16 @@ void PluginView::handleMouseEvent(MouseEvent* event)
319  
320      if (!dispatchNPEvent(npEvent))
321          event->setDefaultHandled();
322 +#endif
323 +
324 +#if defined(Q_WS_QWS)
325 +    event->setDefaultHandled();
326 +#endif
327  }
328  
329  void PluginView::handleFocusInEvent()
330  {
331 +#if defined(Q_WS_X11)
332      XEvent npEvent;
333      initXEvent(&npEvent);
334  
335 @@ -593,10 +628,12 @@ void PluginView::handleFocusInEvent()
336      event.detail = NotifyDetailNone;
337  
338      dispatchNPEvent(npEvent);
339 +#endif
340  }
341  
342  void PluginView::handleFocusOutEvent()
343  {
344 +#if defined(Q_WS_X11)
345      XEvent npEvent;
346      initXEvent(&npEvent);
347  
348 @@ -606,6 +643,7 @@ void PluginView::handleFocusOutEvent()
349      event.detail = NotifyDetailNone;
350  
351      dispatchNPEvent(npEvent);
352 +#endif
353  }
354  
355  void PluginView::setParent(ScrollView* parent)
356 @@ -639,9 +677,11 @@ void PluginView::setNPWindowIfNeeded()
357      if (m_isWindowed && !platformPluginWidget())
358          return;
359  
360 +#if defined(Q_WS_X11)
361      if (!m_hasPendingGeometryChange)
362          return;
363      m_hasPendingGeometryChange = false;
364 +#endif
365  
366      if (m_isWindowed) {
367          platformPluginWidget()->setGeometry(m_windowRect);
368 @@ -779,7 +819,12 @@ bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* re
369  {
370      switch (variable) {
371      case NPNVxDisplay:
372 +#if defined(Q_WS_QWS)
373 +        *reinterpret_cast<void**>(value) = 0;
374 +#endif
375 +#if defined(Q_WS_X11)
376          *(void **)value = QX11Info::display();
377 +#endif
378          *result = NPERR_NO_ERROR;
379          return true;
380  
381 @@ -788,9 +833,14 @@ bool PluginView::platformGetValue(NPNVariable variable, void* value, NPError* re
382          return true;
383  
384      case NPNVnetscapeWindow: {
385 +#if defined(Q_WS_QWS)
386 +        *reinterpret_cast<void**>(value) = 0;
387 +#endif
388 +#if defined(Q_WS_X11)
389          void* w = reinterpret_cast<void*>(value);
390          QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
391          *((XID *)w) = client ? client->ownerWidget()->window()->winId() : 0;
392 +#endif
393          *result = NPERR_NO_ERROR;
394          return true;
395      }
396 @@ -851,6 +901,7 @@ void PluginView::forceRedraw()
397      invalidate();
398  }
399  
400 +#if defined(Q_WS_X11)
401  static Display *getPluginDisplay()
402  {
403      // The plugin toolkit might run using a different X connection. At the moment, we only
404 @@ -916,6 +967,7 @@ static void getVisualAndColormap(int depth, Visual **visual, Colormap *colormap)
405      if (*visual)
406          *colormap = XCreateColormap(QX11Info::display(), QX11Info::appRootWindow(), *visual, AllocNone);
407  }
408 +#endif
409  
410  bool PluginView::platformStart()
411  {
412 @@ -934,19 +986,25 @@ bool PluginView::platformStart()
413      }
414  
415      if (m_isWindowed) {
416 +#if defined(Q_WS_X11)
417          QWebPageClient* client = m_parentFrame->view()->hostWindow()->platformPageClient();
418          if (m_needsXEmbed && client) {
419              setPlatformWidget(new PluginContainerQt(this, client->ownerWidget()));
420              // sync our XEmbed container window creation before sending the xid to plugins.
421              QApplication::syncX();
422          } else {
423 +#endif
424              notImplemented();
425              m_status = PluginStatusCanNotLoadPlugin;
426              return false;
427 +#if defined(Q_WS_X11)
428          }
429 +#endif
430      } else {
431          setPlatformWidget(0);
432 +#if defined(Q_WS_X11)
433          m_pluginDisplay = getPluginDisplay();
434 +#endif
435  
436  #if USE(ACCELERATED_COMPOSITING) && !USE(TEXTURE_MAPPER)
437          if (shouldUseAcceleratedCompositing()) {
438 @@ -961,6 +1019,7 @@ bool PluginView::platformStart()
439      if (!frameRect().isEmpty())
440          show();
441  
442 +#if defined(Q_WS_X11)
443      NPSetWindowCallbackStruct* wsi = new NPSetWindowCallbackStruct();
444      wsi->type = 0;
445  
446 @@ -1002,6 +1061,7 @@ bool PluginView::platformStart()
447      }
448  
449      m_npWindow.ws_info = wsi;
450 +#endif
451  
452      if (!(m_plugin->quirks().contains(PluginQuirkDeferFirstSetWindowCall))) {
453          updatePluginWidget();
454 @@ -1016,11 +1076,13 @@ void PluginView::platformDestroy()
455      if (platformPluginWidget())
456          delete platformPluginWidget();
457  
458 +#if defined(Q_WS_X11)
459      if (m_drawable)
460          XFreePixmap(QX11Info::display(), m_drawable);
461  
462      if (m_colormap)
463          XFreeColormap(QX11Info::display(), m_colormap);
464 +#endif
465  }
466  
467  void PluginView::halt()
468 -- 
469 1.7.5.4
470