Bugzilla Bug 84568 xlib port does not support netscape plugins

patch work by timecop@network.email.ne.jp and Roland.Mainz@informatik.med.uni-giessen.de
r=timeless, sr=beard
This commit is contained in:
timeless%mac.com 2001-12-10 01:22:29 +00:00
Родитель 0e3eb87c82
Коммит 54e199871d
6 изменённых файлов: 174 добавлений и 21 удалений

Просмотреть файл

@ -57,7 +57,7 @@ REQUIRES = xpcom \
windowwatcher \
$(NULL)
# for xlib port
REQUIRES += xlibrgb
REQUIRES += xlibxtbin xlibrgb
CPPSRCS = \
ns4xPlugin.cpp \
@ -105,6 +105,17 @@ CFLAGS += $(MOZ_GTK_CFLAGS)
EXTRA_DSO_LDOPTS += -lgtkxtbin -lgtksuperwin $(XLDFLAGS) -lXt $(MOZ_GTK_LDFLAGS)
endif #MOZ_ENABLE_GTK
ifdef MOZ_ENABLE_XLIB
EXTRA_DSO_LDOPTS += -lxlibxtbin -lxlibrgb -L/usr/X11R6/lib -lXt
ifndef MOZ_MONOLITHIC_TOOLKIT
CXXFLAGS += $(MOZ_XLIB_CFLAGS)
CFLAGS += $(MOZ_XLIB_CFLAGS)
else
CXXFLAGS += $(TK_CFLAGS)
CFLAGS += $(TK_CFLAGS)
endif #MOZ_MONOLITHIC_TOOLKIT
endif #MOZ_ENABLE_XLIB
ifdef MOZ_ENABLE_QT
EXTRA_DSO_LDOPTS += $(MOZ_QT_LDFLAGS)
CXXFLAGS += $(MOZ_QT_CFLAGS)

Просмотреть файл

@ -20,6 +20,8 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Tim Copperfield <timecop@network.email.ne.jp>
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
* 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
@ -39,6 +41,7 @@
#include "prmem.h"
#include "nscore.h"
#include "ns4xPluginInstance.h"
#include "ns4xPluginStreamListener.h"
#include "nsPluginHostImpl.h"
@ -50,6 +53,9 @@
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include "gtkxtbin.h"
#elif defined(MOZ_WIDGET_XLIB)
#include "xlibxtbin.h"
#include "xlibrgb.h"
#endif
@ -667,6 +673,10 @@ ns4xPluginInstance :: ~ns4xPluginInstance(void)
#if defined(MOZ_WIDGET_GTK)
if (mXtBin)
gtk_widget_destroy(mXtBin);
#elif defined(MOZ_WIDGET_XLIB)
if (mXlibXtBin) {
delete mXlibXtBin;
}
#endif
// clean the stream list if any
@ -693,6 +703,8 @@ NS_IMETHODIMP ns4xPluginInstance::Initialize(nsIPluginInstancePeer* peer)
#ifdef MOZ_WIDGET_GTK
mXtBin = nsnull;
#elif defined(MOZ_WIDGET_XLIB)
mXlibXtBin = nsnull;
#endif
return InitializePlugin(peer);
}
@ -711,6 +723,21 @@ NS_IMETHODIMP ns4xPluginInstance::Start(void)
{
PLUGIN_LOG(PLUGIN_LOG_NORMAL, ("ns4xPluginInstance::Start this=%p\n",this));
#ifdef MOZ_WIDGET_XLIB
if (mXlibXtBin == nsnull)
mXlibXtBin = new xtbin();
if (mXlibXtBin == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
if (!mXlibXtBin->xtbin_initialized())
mXlibXtBin->xtbin_init();
#ifdef NS_DEBUG
printf("Made new XtBin: %p, %d\n", mXlibXtBin, mXlibXtBin->xtbin_initialized());
#endif
#endif
if(mStarted)
return NS_OK;
else
@ -725,9 +752,12 @@ NS_IMETHODIMP ns4xPluginInstance::Stop(void)
NPError error;
#ifdef MOZ_WIDGET_GTK
#if defined(MOZ_WIDGET_GTK)
if (mXtBin)
gtk_widget_destroy(mXtBin);
#elif defined(MOZ_WIDGET_XLIB)
if (mXlibXtBin)
mXlibXtBin->xtbin_destroy();
#endif
if(!mStarted)
@ -755,6 +785,7 @@ NS_IMETHODIMP ns4xPluginInstance::Stop(void)
("NPP Destroy called: this=%p, npp=%p, return=%d\n", this, &fNPP, error));
mStarted = PR_FALSE;
if(error != NPERR_NO_ERROR)
return NS_ERROR_FAILURE;
else
@ -834,7 +865,7 @@ NS_IMETHODIMP ns4xPluginInstance::Destroy(void)
////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP ns4xPluginInstance::SetWindow(nsPluginWindow* window)
{
#ifdef MOZ_WIDGET_GTK
#if defined(MOZ_WIDGET_GTK) || defined(MOZ_WIDGET_XLIB)
NPSetWindowCallbackStruct *ws;
#endif
@ -922,7 +953,72 @@ NS_IMETHODIMP ns4xPluginInstance::SetWindow(nsPluginWindow* window)
// And now point the NPWindow structures window
// to the actual X window
window->window = (nsPluginPort *)GTK_XTBIN(mXtBin)->xtwindow;
#endif // MOZ_WIDGET_GTK
#elif defined(MOZ_WIDGET_XLIB)
// Allocate and fill out the ws_info data
if (!window->ws_info) {
#ifdef NS_DEBUG
printf("About to create new ws_info...\n");
#endif
// allocate a new NPSetWindowCallbackStruct structure at ws_info
window->ws_info = (NPSetWindowCallbackStruct *)PR_MALLOC(sizeof(NPSetWindowCallbackStruct));
if (!window->ws_info)
return NS_ERROR_OUT_OF_MEMORY;
ws = (NPSetWindowCallbackStruct *)window->ws_info;
#if 1
/* See comment above in GTK+ port ... */
if (mXlibXtBin) {
delete mXlibXtBin;
mXlibXtBin = nsnull;
}
#endif
if (!mXlibXtBin) {
mXlibXtBin = new xtbin();
// Check to see if creating mXlibXtBin failed for some reason.
// if it did, we can't go any further.
if (!mXlibXtBin)
return NS_ERROR_FAILURE;
}
if (window->window) {
#ifdef NS_DEBUG
printf("About to create new xtbin of %i X %i from %08x...\n",
window->width, window->height, window->window);
#endif
mXlibXtBin->xtbin_new((Window)window->window);
mXlibXtBin->xtbin_resize(0, 0, window->width, window->height);
#ifdef NS_DEBUG
printf("About to show xtbin(%p)...\n", mXlibXtBin); fflush(NULL);
#endif
mXlibXtBin->xtbin_realize();
}
/* Set window attributes */
XlibRgbHandle *xlibRgbHandle = xxlib_find_handle(XXLIBRGB_DEFAULT_HANDLE);
Display *xdisplay = xxlib_rgb_get_display(xlibRgbHandle);
/* Fill in window info structure */
ws->type = 0;
ws->depth = xxlib_rgb_get_depth(xlibRgbHandle);
ws->display = xdisplay;
ws->visual = xxlib_rgb_get_visual(xlibRgbHandle);
ws->colormap = xxlib_rgb_get_cmap(xlibRgbHandle);
XFlush(ws->display);
} // !window->ws_info
// And now point the NPWindow structures window
// to the actual X window
window->window = (nsPluginPort *)mXlibXtBin->xtbin_xtwindow();
#endif // MOZ_WIDGET
if (fCallbacks->setwindow) {
// XXX Turns out that NPPluginWindow and NPWindow are structurally

Просмотреть файл

@ -20,6 +20,8 @@
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Tim Copperfield <timecop@network.email.ne.jp>
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
* 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
@ -54,6 +56,8 @@
#ifdef MOZ_WIDGET_GTK
#include <gtk/gtk.h>
#elif MOZ_WIDGET_XLIB
#include "xlibxtbin.h"
#endif
////////////////////////////////////////////////////////////////////////
@ -165,6 +169,8 @@ protected:
* within a Gtk Application
*/
GtkWidget *mXtBin;
#elif MOZ_WIDGET_XLIB
xtbin *mXlibXtBin;
#endif
/**

Просмотреть файл

@ -147,6 +147,8 @@
#include <gdk/gdkx.h> // for GDK_DISPLAY()
#elif defined(MOZ_WIDGET_QT)
#include <qwindowdefs.h> // for qt_xdisplay()
#elif defined(MOZ_WIDGET_XLIB)
#include "xlibrgb.h" // for xlib_rgb_get_display()
#endif
#endif
@ -2511,6 +2513,8 @@ NS_IMETHODIMP nsPluginHostImpl::GetValue(nsPluginManagerVariable aVariable, void
*value = GDK_DISPLAY();
#elif defined(MOZ_WIDGET_QT)
*value = qt_xdisplay();
#elif defined(MOZ_WIDGET_XLIB)
*value = xxlib_rgb_get_display(xxlib_find_handle(XXLIBRGB_DEFAULT_HANDLE));
#endif
if (!(*value)) {
return NS_ERROR_FAILURE;

Просмотреть файл

@ -1,4 +1,5 @@
/* widget -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:ts=2:et:sw=2
* XlibXtBin Implementation
* Peter Hartshorn
* Based on GtkXtBin by Rusty Lynch - 02/27/2000
@ -33,19 +34,20 @@
#include <X11/StringDefs.h>
xtbin::xtbin() {
initialized = 0;
xtwindow = 0;
initialized = False;
xtwindow = None;
}
xtbin::~xtbin() {
}
void xtbin::xtbin_init() {
initialized = 1;
xtdisplay = xxlib_rgb_get_display(xxlib_find_handle(XXLIBRGB_DEFAULT_HANDLE));
mXlibRgbHandle = xxlib_find_handle(XXLIBRGB_DEFAULT_HANDLE);
xtdisplay = xxlib_rgb_get_display(mXlibRgbHandle);
if (!xtdisplay)
abort();
app_context = XtDisplayToApplicationContext(xtdisplay);
initialized = True;
}
void xtbin::xtbin_realize() {
@ -57,7 +59,8 @@ void xtbin::xtbin_realize() {
unsigned long mask;
attr.bit_gravity = NorthWestGravity;
attr.event_mask = ButtonMotionMask |
attr.event_mask =
ButtonMotionMask |
ButtonPressMask |
ButtonReleaseMask |
EnterWindowMask |
@ -70,13 +73,27 @@ void xtbin::xtbin_realize() {
VisibilityChangeMask |
FocusChangeMask;
mask = CWBitGravity | CWEventMask;
attr.colormap = xxlib_rgb_get_cmap(mXlibRgbHandle);
attr.background_pixel = xxlib_rgb_xpixel_from_rgb(mXlibRgbHandle, 0xFFC0C0C0);
attr.border_pixel = xxlib_rgb_xpixel_from_rgb(mXlibRgbHandle, 0xFF646464);
#ifdef DEBUG
printf("attr.background_pixel = %lx, attr.border_pixel = %lx, parent_window = %x\n",
(long)attr.background_pixel,
(long)attr.border_pixel, (int)parent_window);
#endif /* DEBUG */
mask = CWBitGravity | CWEventMask | CWBorderPixel | CWBackPixel;
if (attr.colormap)
mask |= CWColormap;
window = XCreateWindow(xtdisplay, parent_window,
x, y, width, height, 0, CopyFromParent,
CopyFromParent, CopyFromParent,
x, y, width, height, 0,
xxlib_rgb_get_depth(mXlibRgbHandle),
InputOutput, xxlib_rgb_get_visual(mXlibRgbHandle),
mask, &attr);
XSetWindowBackgroundPixmap(xtdisplay, window, None);
XSelectInput(xtdisplay, window, ExposureMask);
XMapWindow(xtdisplay, window);
@ -90,14 +107,14 @@ void xtbin::xtbin_realize() {
n = 0;
XtSetArg(args[n], XtNheight, height); n++;
XtSetArg(args[n], XtNwidth, width); n++;
XtSetArg(args[n], XtNwidth, width); n++;
XtSetValues(top_widget, args, n);
embeded = XtVaCreateWidget("form", compositeWidgetClass, top_widget, NULL);
n = 0;
XtSetArg(args[n], XtNheight, height); n++;
XtSetArg(args[n], XtNwidth, width); n++;
XtSetArg(args[n], XtNwidth, width); n++;
XtSetValues(embeded, args, n);
oldwindow = top_widget->core.window;
@ -109,22 +126,36 @@ void xtbin::xtbin_realize() {
XtRealizeWidget(top_widget);
XtManageChild(embeded);
/* Now fill out the xtbin info */
xtwindow = XtWindow(embeded);
/* Suppress background refresh flashing */
XSetWindowBackgroundPixmap(xtdisplay, XtWindow(top_widget), None);
XSetWindowBackgroundPixmap(xtdisplay, XtWindow(embeded), None);
/* Listen to all Xt events */
XSelectInput(xtdisplay, XtWindow(top_widget), 0x0fffff);
XSelectInput(xtdisplay, XtWindow(embeded), 0x0fffff);
XFlush(xtdisplay);
XSelectInput(xtdisplay, XtWindow(embeded), 0x0fffff);
sync();
}
void xtbin::xtbin_new(Window aParent) {
parent_window = aParent;
}
void xtbin::sync() {
/* is this really all ? */
XSync(xtdisplay, False);
}
void xtbin::xtbin_destroy() {
XtDestroyWidget(xtwidget);
initialized = 0;
sync();
XtUnregisterDrawable(xtdisplay, xtwindow);
sync();
xtwidget->core.window = oldwindow;
XtUnrealizeWidget(xtwidget);
initialized = False;
}
void xtbin::xtbin_resize(int aX, int aY, int aWidth, int aHeight) {
@ -137,3 +168,4 @@ void xtbin::xtbin_resize(int aX, int aY, int aWidth, int aHeight) {
int xtbin::xtbin_initialized() {
return initialized;
}

Просмотреть файл

@ -19,6 +19,8 @@
#ifndef __XLIB_XTBIN_H__
#define __XLIB_XTBIN_H__
#include "xlibrgb.h"
#include <X11/Intrinsic.h>
#include <X11/Xutil.h>
#include <X11/Xlib.h>
@ -86,9 +88,11 @@ public:
void xtbin_resize(int aX, int aY, int aWidth, int aHeight);
Window xtbin_xtwindow() { return xtwindow; }
int xtbin_initialized();
void sync();
private:
private:
int initialized;
XlibRgbHandle *mXlibRgbHandle;
Display *xtdisplay;
Window xtwindow;
XtAppContext app_context;