Bug 464966 - Add NPAPI Plugin support for Mozilla Qt. r=karlt

This commit is contained in:
Oleg Romashin 2010-04-20 21:49:34 +03:00
parent 0df3a5c47c
commit 90532af1b7
9 changed files with 341 additions and 115 deletions

View File

@ -41,12 +41,12 @@
#include "gfxColor.h"
#include "gfxASurface.h"
#include "gfxContext.h"
#include "gfxXlibSurface.h"
class QWidget;
class QRect;
/**
* This class lets us take code that draws into an Qt drawable and lets us
* This class lets us take code that draws into an Xlib surface drawable and lets us
* use it to draw into any Thebes context. The user should subclass this class,
* override NativeDraw, and then call Draw(). The drawing will be subjected
* to all Thebes transformations, clipping etc.
@ -61,7 +61,8 @@ public:
* @param numClipRects the number of rects in the array, or zero if
* no clipping is required
*/
virtual nsresult NativeDraw(QWidget * drawable, short offsetX,
virtual nsresult NativeDraw(gfxXlibSurface *xsurf,
Colormap colormap, short offsetX,
short offsetY, QRect * clipRects, PRUint32 numClipRects) = 0;
enum {

View File

@ -35,102 +35,63 @@
*
* ***** END LICENSE BLOCK ***** */
#include <QWidget>
#include <QX11Info>
#include "gfxQtNativeRenderer.h"
#include "gfxContext.h"
#include "gfxQtPlatform.h"
#include "cairo.h"
typedef struct {
gfxQtNativeRenderer* mRenderer;
nsresult mRV;
} NativeRenderingClosure;
static cairo_bool_t
NativeRendering(void *closure,
QWidget * drawable,
short offset_x, short offset_y,
QRect * rectangles, unsigned int num_rects)
{
NativeRenderingClosure* cl = (NativeRenderingClosure*)closure;
nsresult rv = cl->mRenderer->
NativeDraw(drawable, offset_x, offset_y,
rectangles, num_rects);
cl->mRV = rv;
return NS_SUCCEEDED(rv);
}
#include "gfxXlibSurface.h"
nsresult
gfxQtNativeRenderer::Draw(gfxContext* ctx, int width, int height,
PRUint32 flags, DrawOutput* output)
{
NativeRenderingClosure closure = { this, NS_OK };
Display *dpy = QX11Info().display();
PRBool isOpaque = (flags & DRAW_IS_OPAQUE) ? PR_TRUE : PR_FALSE;
int screen = QX11Info().screen();
int depth = QX11Info().depth();
Visual *visual = static_cast<Visual*>(QX11Info().visual());
Colormap colormap = QX11Info().colormap();
PRBool allocColormap = PR_FALSE;
if (output) {
output->mSurface = NULL;
output->mUniformAlpha = PR_FALSE;
output->mUniformColor = PR_FALSE;
}
if (!isOpaque) {
depth = 32;
XVisualInfo vinfo;
int foundVisual = XMatchVisualInfo(dpy, screen,
depth, TrueColor,
&vinfo);
if (!foundVisual)
return NS_ERROR_FAILURE;
#if 0 // FIXME
cairo_gdk_drawing_result_t result;
// Make sure result.surface is null to start with; we rely on it
// being non-null meaning that a surface actually got allocated.
result.surface = NULL;
int cairoFlags = 0;
if (flags & DRAW_SUPPORTS_OFFSET) {
cairoFlags |= CAIRO_GDK_DRAWING_SUPPORTS_OFFSET;
}
if (flags & DRAW_SUPPORTS_CLIP_RECT) {
cairoFlags |= CAIRO_GDK_DRAWING_SUPPORTS_CLIP_RECT;
}
if (flags & DRAW_SUPPORTS_CLIP_LIST) {
cairoFlags |= CAIRO_GDK_DRAWING_SUPPORTS_CLIP_LIST;
}
if (flags & DRAW_SUPPORTS_ALTERNATE_SCREEN) {
cairoFlags |= CAIRO_GDK_DRAWING_SUPPORTS_ALTERNATE_SCREEN;
}
if (flags & DRAW_SUPPORTS_NONDEFAULT_VISUAL) {
cairoFlags |= CAIRO_GDK_DRAWING_SUPPORTS_NONDEFAULT_VISUAL;
}
cairo_draw_with_gdk(ctx->GetCairo(),
gfxPlatformGtk::GetPlatform()->GetGdkDrawable(ctx->OriginalSurface()),
NativeRendering,
&closure, width, height,
(flags & DRAW_IS_OPAQUE) ? CAIRO_GDK_DRAWING_OPAQUE : CAIRO_GDK_DRAWING_TRANSPARENT,
(cairo_gdk_drawing_support_t)cairoFlags,
output ? &result : NULL);
if (NS_FAILED(closure.mRV)) {
if (result.surface) {
NS_ASSERTION(output, "How did that happen?");
cairo_surface_destroy (result.surface);
if (visual != vinfo.visual) {
allocColormap = PR_TRUE;
visual = vinfo.visual;
colormap = XCreateColormap(dpy,
RootWindow(dpy, screen),
visual, AllocNone);
}
return closure.mRV;
}
if (output) {
if (result.surface) {
output->mSurface = gfxASurface::Wrap(result.surface);
if (!output->mSurface) {
cairo_surface_destroy (result.surface);
return NS_ERROR_OUT_OF_MEMORY;
}
}
nsRefPtr<gfxXlibSurface> xsurf =
new gfxXlibSurface(dpy, visual,
gfxIntSize(width, height),
depth);
output->mUniformAlpha = result.uniform_alpha;
output->mUniformColor = result.uniform_color;
output->mColor = gfxRGBA(result.r, result.g, result.b, result.alpha);
if (!isOpaque) {
nsRefPtr<gfxContext> tempCtx = new gfxContext(xsurf);
tempCtx->SetOperator(gfxContext::OPERATOR_CLEAR);
tempCtx->Paint();
}
#endif
return NS_OK;
nsresult rv = NativeDraw(xsurf.get(), colormap, 0, 0, NULL, 0);
if (!allocColormap)
XFreeColormap(dpy, colormap);
if (NS_FAILED(rv))
return rv;
ctx->SetSource(xsurf);
ctx->Paint();
return rv;
}

View File

@ -46,9 +46,9 @@
/* rendering objects for replaced elements implemented by a plugin */
#ifdef MOZ_X11
#ifdef MOZ_WIDGET_QT
#include <QWidget>
#ifdef MOZ_X11
#include <QX11Info>
#endif
#endif
@ -169,6 +169,7 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
#ifdef MOZ_X11
#include <X11/Xlib.h>
#include <cairo-xlib.h>
/* X headers suck */
enum { XKeyPress = KeyPress };
#ifdef KeyPress
@ -195,10 +196,14 @@ enum { XKeyPress = KeyPress };
#ifdef MOZ_WIDGET_GTK2
#include "gfxGdkNativeRenderer.h"
#define DISPLAY GDK_DISPLAY
#endif
#ifdef MOZ_WIDGET_QT
#include "gfxQtNativeRenderer.h"
#ifdef MOZ_X11
#define DISPLAY QX11Info::display
#endif
#endif
#ifdef XP_WIN
@ -508,8 +513,9 @@ private:
: mWindow(aWindow), mInstance(aInstance),
mPluginSize(aPluginSize), mDirtyRect(aDirtyRect)
{}
virtual nsresult NativeDraw(QWidget * drawable, short offsetX,
short offsetY, QRect * clipRects, PRUint32 numClipRects);
virtual nsresult NativeDraw(gfxXlibSurface* xsurface, Colormap colormap,
short offsetX, short offsetY,
QRect * clipRects, PRUint32 numClipRects);
private:
NPWindow* mWindow;
nsIPluginInstance* mInstance;
@ -2900,8 +2906,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetNetscapeWindow(void *value)
return NS_ERROR_FAILURE;
#ifdef MOZ_X11
*static_cast<Window*>(value) = widget->handle();
#endif
return NS_OK;
#endif
return NS_ERROR_FAILURE;
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
@ -4066,10 +4073,13 @@ static void find_dest_id(XID top, XID *root, XID *dest, int target_x, int target
XID parent;
XID *children;
unsigned int nchildren;
Display *display = DISPLAY();
while (1) {
loop:
//printf("searching %x\n", target_id);
if (!XQueryTree(GDK_DISPLAY(), target_id, root, &parent, &children, &nchildren) ||
if (!XQueryTree(display, target_id, root, &parent, &children, &nchildren) ||
!nchildren)
break;
for (unsigned int i=0; i<nchildren; i++) {
@ -4077,7 +4087,7 @@ loop:
int x, y;
unsigned int width, height;
unsigned int border_width, depth;
XGetGeometry(GDK_DISPLAY(), children[i], &root, &x, &y,
XGetGeometry(display, children[i], &root, &x, &y,
&width, &height, &border_width,
&depth);
//printf("target: %d %d\n", target_x, target_y);
@ -4142,8 +4152,10 @@ nsEventStatus nsPluginInstanceOwner::ProcessEventX11Composited(const nsGUIEvent&
rootPoint = anEvent.refPoint + widget->WidgetToScreenOffset();
#ifdef MOZ_WIDGET_GTK2
Window root = GDK_ROOT_WINDOW();
#elif defined(MOZ_WIDGET_QT)
Window root = QX11Info::appRootWindow();
#else
Window root = None; // Could XQueryTree, but this is not important.
Window root = None;
#endif
switch (anEvent.message)
@ -4231,10 +4243,10 @@ nsEventStatus nsPluginInstanceOwner::ProcessEventX11Composited(const nsGUIEvent&
//printf("xbutton: %d %d %d\n", anEvent.message, be.xbutton.x, be.xbutton.y);
XID w = (XID)mPluginWindow->window;
XGetGeometry(GDK_DISPLAY(), w, &root, &wx, &wy, &width, &height, &border_width, &depth);
XGetGeometry(DISPLAY(), w, &root, &wx, &wy, &width, &height, &border_width, &depth);
find_dest_id(w, &root, &target, pluginPoint.x + wx, pluginPoint.y + wy);
be.xbutton.window = target;
XSendEvent (GDK_DISPLAY(), target,
XSendEvent (DISPLAY(), target,
FALSE, event.type == ButtonPress ? ButtonPressMask : ButtonReleaseMask, &be);
}
@ -4289,10 +4301,10 @@ nsEventStatus nsPluginInstanceOwner::ProcessEventX11Composited(const nsGUIEvent&
//printf("xkey: %d %d %d\n", anEvent.message, be.xkey.keycode, be.xkey.state);
XID w = (XID)mPluginWindow->window;
XGetGeometry(GDK_DISPLAY(), w, &root, &wx, &wy, &width, &height, &border_width, &depth);
XGetGeometry(DISPLAY(), w, &root, &wx, &wy, &width, &height, &border_width, &depth);
find_dest_id(w, &root, &target, mLastPoint.x + wx, mLastPoint.y + wy);
be.xkey.window = target;
XSendEvent (GDK_DISPLAY(), target,
XSendEvent (DISPLAY(), target,
FALSE, event.type == XKeyPress ? KeyPressMask : KeyReleaseMask, &be);
@ -4654,6 +4666,8 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const nsGUIEvent& anEvent)
rootPoint = anEvent.refPoint + widget->WidgetToScreenOffset();
#ifdef MOZ_WIDGET_GTK2
Window root = GDK_ROOT_WINDOW();
#elif defined(MOZ_WIDGET_QT)
Window root = QX11Info::appRootWindow();
#else
Window root = None; // Could XQueryTree, but this is not important.
#endif
@ -5395,16 +5409,15 @@ nsPluginInstanceOwner::Renderer::NativeDraw(GdkDrawable * drawable,
#endif
#elif defined(MOZ_WIDGET_QT)
nsresult
nsPluginInstanceOwner::Renderer::NativeDraw(QWidget * drawable,
nsPluginInstanceOwner::Renderer::NativeDraw(gfxXlibSurface * xsurface,
Colormap colormap,
short offsetX, short offsetY,
QRect * clipRects,
PRUint32 numClipRects)
{
#ifdef MOZ_X11
QX11Info xinfo = drawable->x11Info();
Visual * visual = (Visual*) xinfo.visual();
Colormap colormap = xinfo.colormap();
Screen * screen = (Screen*) xinfo.screen();
Visual * visual = cairo_xlib_surface_get_visual(xsurface->CairoSurface());
Screen *screen = cairo_xlib_surface_get_screen(xsurface->CairoSurface());
#endif
#endif
// See if the plugin must be notified of new window parameters.
@ -5506,7 +5519,7 @@ nsPluginInstanceOwner::Renderer::NativeDraw(QWidget * drawable,
#if defined(MOZ_WIDGET_GTK2)
GDK_DRAWABLE_XID(drawable);
#elif defined(MOZ_WIDGET_QT)
drawable->x11PictureHandle();
xsurface->XDrawable();
#endif
exposeEvent.x = dirtyRect.x;
exposeEvent.y = dirtyRect.y;
@ -5752,11 +5765,9 @@ NS_IMETHODIMP nsPluginInstanceOwner::CreateWidget(void)
ws_info->display =
static_cast<Display*>(win->GetNativeData(NS_NATIVE_DISPLAY));
}
#ifdef MOZ_WIDGET_GTK2
else {
ws_info->display = GDK_DISPLAY();
ws_info->display = DISPLAY();
}
#endif
#endif
} else if (mWidget) {
mWidget->Resize(mPluginWindow->width, mPluginWindow->height,

View File

@ -84,17 +84,20 @@ ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
CPPSRCS += nsPluginsDirDarwin.cpp
CPPSRCS += nsPluginNativeWindow.cpp
else
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
CPPSRCS += nsPluginsDirUnix.cpp
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
CPPSRCS += nsPluginNativeWindowGtk2.cpp
else
CPPSRCS += nsPluginsDirUnix.cpp
ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
CPPSRCS += nsPluginNativeWindowQt.cpp
else
CPPSRCS += nsPluginNativeWindow.cpp
endif
endif
endif
endif
endif
endif
ifneq (,$(filter WINNT Darwin,$(OS_ARCH)))
EXTRA_DSO_LIBS += gkgfx

View File

@ -36,6 +36,10 @@
*
* ***** END LICENSE BLOCK ***** */
#ifdef MOZ_WIDGET_QT
#include <QX11Info>
#endif
#ifdef MOZ_IPC
#include "base/basictypes.h"
#endif
@ -1839,7 +1843,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
switch(variable) {
#if defined(XP_UNIX) && !defined(XP_MACOSX)
case NPNVxDisplay : {
#ifdef MOZ_WIDGET_GTK2
#if defined(MOZ_WIDGET_GTK2) || defined(MOZ_WIDGET_QT)
if (npp) {
nsNPAPIPluginInstance *inst = (nsNPAPIPluginInstance *) npp->ndata;
PRBool windowless = PR_FALSE;
@ -1857,6 +1861,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
return NPERR_NO_ERROR;
}
}
#ifdef MOZ_WIDGET_GTK2
// adobe nppdf calls XtGetApplicationNameAndClass(display,
// &instance, &class) we have to init Xt toolkit before get
// XtDisplay just call gtk_xtbin_new(w,0) once
@ -1868,6 +1873,7 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
}
(*(Display **)result) = GTK_XTBIN(gtkXtBinHolder)->xtdisplay;
return NPERR_NO_ERROR;
#endif
#endif
return NPERR_GENERIC_ERROR;
}
@ -1876,7 +1882,8 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
return NPERR_GENERIC_ERROR;
#endif
#if defined(XP_WIN) || defined(XP_OS2) || defined(MOZ_WIDGET_GTK2)
#if defined(XP_WIN) || defined(XP_OS2) || defined(MOZ_WIDGET_GTK2) \
|| defined(MOZ_WIDGET_QT)
case NPNVnetscapeWindow: {
if (!npp || !npp->ndata)
return NPERR_INVALID_INSTANCE_ERROR;
@ -1928,6 +1935,10 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
*((NPNToolkitType*)result) = NPNVGtk2;
#endif
#ifdef MOZ_WIDGET_QT
/* Fake toolkit so flash plugin works */
*((NPNToolkitType*)result) = NPNVGtk2;
#endif
if (*(NPNToolkitType*)result)
return NPERR_NO_ERROR;
@ -1956,7 +1967,8 @@ _getvalue(NPP npp, NPNVariable variable, void *result)
}
case NPNVSupportsWindowless: {
#if defined(XP_WIN) || defined(XP_MACOSX) || (defined(MOZ_X11) && defined(MOZ_WIDGET_GTK2))
#if defined(XP_WIN) || defined(XP_MACOSX) || \
(defined(MOZ_X11) && (defined(MOZ_WIDGET_GTK2) || defined(MOZ_WIDGET_QT)))
*(NPBool*)result = PR_TRUE;
#else
*(NPBool*)result = PR_FALSE;

View File

@ -0,0 +1,121 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Sun Microsystems, Inc.
* Portions created by the Initial Developer are Copyright (C) 2003
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Robin Lu <robin.lu@sun.com>
* Miika Jarvinen <mjarvin@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* This file is the Qt implementation of plugin native window.
*/
#include "nsDebug.h"
#include "nsPluginNativeWindow.h"
#include "npapi.h"
/**
* Qt implementation of plugin window
*/
class nsPluginNativeWindowQt : public nsPluginNativeWindow
{
public:
nsPluginNativeWindowQt();
virtual ~nsPluginNativeWindowQt();
virtual nsresult CallSetWindow(nsCOMPtr<nsIPluginInstance> &aPluginInstance);
private:
NPSetWindowCallbackStruct mWsInfo;
};
nsPluginNativeWindowQt::nsPluginNativeWindowQt() : nsPluginNativeWindow()
{
//Initialize member variables
#ifdef DEBUG
fprintf(stderr,"\n\n\nCreating plugin native window %p\n\n\n", (void *) this);
#endif
window = nsnull;
x = 0;
y = 0;
width = 0;
height = 0;
memset(&clipRect, 0, sizeof(clipRect));
ws_info = &mWsInfo;
type = NPWindowTypeWindow;
mWsInfo.type = 0;
mWsInfo.display = nsnull;
mWsInfo.visual = nsnull;
mWsInfo.colormap = 0;
mWsInfo.depth = 0;
}
nsPluginNativeWindowQt::~nsPluginNativeWindowQt()
{
#ifdef DEBUG
fprintf(stderr,"\n\n\nDestoying plugin native window %p\n\n\n", (void *) this);
#endif
}
nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow **aPluginNativeWindow)
{
NS_ENSURE_ARG_POINTER(aPluginNativeWindow);
*aPluginNativeWindow = new nsPluginNativeWindowQt();
return *aPluginNativeWindow ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}
nsresult PLUG_DeletePluginNativeWindow(nsPluginNativeWindow * aPluginNativeWindow)
{
NS_ENSURE_ARG_POINTER(aPluginNativeWindow);
nsPluginNativeWindowQt *p = (nsPluginNativeWindowQt *)aPluginNativeWindow;
delete p;
return NS_OK;
}
nsresult nsPluginNativeWindowQt::CallSetWindow(nsCOMPtr<nsIPluginInstance> &aPluginInstance)
{
if (aPluginInstance) {
if (type == NPWindowTypeWindow) {
return NS_ERROR_FAILURE;
} // NPWindowTypeWindow
aPluginInstance->SetWindow(this);
}
else if (mPluginInstance)
mPluginInstance->SetWindow(nsnull);
SetPluginInstance(aPluginInstance);
return NS_OK;
}

View File

@ -72,6 +72,13 @@ endif
ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
CPPSRCS += nptest_qt.cpp
include $(topsrcdir)/config/config.mk
CXXFLAGS += $(MOZ_QT_CFLAGS)
CFLAGS += $(MOZ_QT_CFLAGS)
EXTRA_DSO_LDOPTS = \
$(MOZ_QT_LIBS) \
$(XLDFLAGS) \
$(XLIBS)
endif
ifeq ($(MOZ_WIDGET_TOOLKIT),windows)

View File

@ -30,9 +30,19 @@
* Josh Aas <josh@mozilla.com>
*
* ***** END LICENSE BLOCK ***** */
#include <QWidget>
#include <QPainter>
#include "nptest_platform.h"
#include "npapi.h"
struct _PlatformData {
#ifdef MOZ_X11
Display* display;
Visual* visual;
Colormap colormap;
#endif
};
using namespace std;
bool
@ -50,12 +60,31 @@ pluginSupportsWindowlessMode()
NPError
pluginInstanceInit(InstanceData* instanceData)
{
#ifdef MOZ_X11
instanceData->platformData = static_cast<PlatformData*>
(NPN_MemAlloc(sizeof(PlatformData)));
if (!instanceData->platformData){
//printf("NPERR_OUT_OF_MEMORY_ERROR\n");
return NPERR_OUT_OF_MEMORY_ERROR;
}
instanceData->platformData->display = NULL;
instanceData->platformData->visual = NULL;
instanceData->platformData->colormap = None;
return NPERR_NO_ERROR;
#else
printf("NPERR_INCOMPATIBLE_VERSION_ERROR\n");
return NPERR_INCOMPATIBLE_VERSION_ERROR;
#endif
return NPERR_NO_ERROR;
}
void
pluginInstanceShutdown(InstanceData* instanceData)
{
NPN_MemFree(instanceData->platformData);
instanceData->platformData = 0;
}
void
@ -67,11 +96,96 @@ pluginDoSetWindow(InstanceData* instanceData, NPWindow* newWindow)
void
pluginWidgetInit(InstanceData* instanceData, void* oldWindow)
{
// XXX nothing here yet since we don't support windowed plugins
}
static void
pluginDrawWindow(InstanceData* instanceData, void* event)
{
NPWindow& window = instanceData->window;
// When we have a widget, window.x/y are meaningless since our
// widget is always positioned correctly and we just draw into it at 0,0
int x = instanceData->hasWidget ? 0 : window.x;
int y = instanceData->hasWidget ? 0 : window.y;
int width = window.width;
int height = window.height;
XEvent* nsEvent = (XEvent*)event;
const XGraphicsExposeEvent& expose = nsEvent->xgraphicsexpose;
QColor drawColor((QColor)instanceData->scriptableObject->drawColor);//QRgb qRgba ( int r, int g, int b, int a )
QPixmap pixmap = QPixmap::fromX11Pixmap(expose.drawable, QPixmap::ExplicitlyShared);
QRect exposeRect(expose.x, expose.y, expose.width, expose.height);
if (instanceData->scriptableObject->drawMode == DM_SOLID_COLOR) {
//printf("Drawing Solid\n");
// drawing a solid color for reftests
QPainter painter(&pixmap);
painter.fillRect(exposeRect, drawColor);
notifyDidPaint(instanceData);
return;
}
NPP npp = instanceData->npp;
if (!npp)
return;
QString text (NPN_UserAgent(npp));
if (text.isEmpty())
return;
//printf("Drawing Default\n");
// drawing a solid color for reftests
QColor color;
QPainter painter(&pixmap);
QRect theRect(x, y, width, height);
QRect clipRect(QPoint(window.clipRect.left, window.clipRect.top),
QPoint(window.clipRect.right, window.clipRect.bottom));
painter.setClipRect(clipRect);
painter.fillRect(theRect, QColor(128,128,128,255));
painter.drawRect(theRect);
painter.drawText(QRect(theRect), Qt::AlignCenter, text);
notifyDidPaint(instanceData);
return;
}
int16_t
pluginHandleEvent(InstanceData* instanceData, void* event)
{
#ifdef MOZ_X11
XEvent* nsEvent = (XEvent*)event;
//printf("\nEvent Type %d\n", nsEvent->type);
switch (nsEvent->type) {
case GraphicsExpose: {
//printf("GraphicsExpose\n");
pluginDrawWindow(instanceData, event);
break;
}
case MotionNotify: {
//printf("MotionNotify\n");
XMotionEvent* motion = &nsEvent->xmotion;
instanceData->lastMouseX = motion->x;
instanceData->lastMouseY = motion->y;
break;
}
case ButtonPress:{
////printf("ButtonPress\n");
break;
}
case ButtonRelease: {
//printf("ButtonRelease\n");
XButtonEvent* button = &nsEvent->xbutton;
instanceData->lastMouseX = button->x;
instanceData->lastMouseY = button->y;
break;
}
default:
break;
}
#endif
return 0;
}

View File

@ -1904,11 +1904,7 @@ nsWindow::GetToplevelWidget(MozQWidget **aWidget)
void *
nsWindow::SetupPluginPort(void)
{
if (!mWidget)
return nsnull;
qDebug("FIXME:>>>>>>Func:%s::%d\n", __PRETTY_FUNCTION__, __LINE__);
NS_WARNING("Not implemented");
return nsnull;
}