17 #include "NpapiTypes.h"
18 #include "PluginCore.h"
19 #include "X11/PluginWindowX11.h"
20 #include "FactoryBase.h"
22 #include "X11/NpapiPluginX11.h"
23 #include "NpapiPluginFactory.h"
24 #include <boost/make_shared.hpp>
26 FB::Npapi::NpapiPluginPtr FB::Npapi::createNpapiPlugin(
const FB::Npapi::NpapiBrowserHostPtr& host,
const std::string& mimetype)
28 return boost::make_shared<NpapiPluginX11>(host, mimetype);
31 using namespace FB::Npapi;
33 inline GdkNativeWindow getGdkWindow(
void *in)
37 return (
char*)in - (
char*)0;
42 std::string getPluginPath()
45 if (::dladdr((
void*)::NP_Initialize, &dlinfo) != 0) {
46 return dlinfo.dli_fname;
53 NpapiPluginX11::NpapiPluginX11(
const FB::Npapi::NpapiBrowserHostPtr& host,
const std::string& mimetype)
54 : NpapiPlugin(host, mimetype), pluginWin(NULL)
60 static const std::string pluginPath = getPluginPath();
61 setFSPath(pluginPath);
64 NpapiPluginX11::~NpapiPluginX11()
70 NPError NpapiPluginX11::GetValue(NPPVariable variable,
void *value)
74 case NPPVpluginNeedsXEmbed:
75 *((
bool *)value) =
true;
76 return NPERR_NO_ERROR;
78 return NpapiPlugin::GetValue(variable, value);
82 NPError NpapiPluginX11::SetWindow(NPWindow* window)
84 #if FB_GUI_DISABLED != 1
85 if (window != NULL && window->window != NULL) {
89 int xembedSupported = 0;
91 m_npHost->GetValue(NPNVSupportsXEmbedBool, &xembedSupported);
94 FBLOG_ERROR(
"FB.NpapiPluginX11",
"XEmbed not supported! Cannot create pluginwindow!");
95 return NPERR_GENERIC_ERROR;
98 if (pluginWin != NULL && pluginWin->getTopLevelWindow() != getGdkWindow(window->window)) {
99 pluginMain->ClearWindow();
104 if (pluginWin == NULL) {
105 GdkNativeWindow browserWindow;
106 m_npHost->GetValue(NPNVnetscapeWindow, (
void*)&browserWindow);
108 pluginWin = getFactoryInstance()->createPluginWindowX11(WindowContextX11(getGdkWindow(window->window)));
109 pluginWin->setBrowserWindow(browserWindow);
110 pluginWin->setWindowPosition(window->x, window->y, window->width, window->height);
111 pluginWin->setWindowClipping(window->clipRect.top, window->clipRect.left,
112 window->clipRect.bottom, window->clipRect.right);
113 pluginMain->SetWindow(pluginWin);
115 pluginWin->setWindowPosition(window->x, window->y, window->width, window->height);
116 pluginWin->setWindowClipping(window->clipRect.top, window->clipRect.left,
117 window->clipRect.bottom, window->clipRect.right);
120 }
else if (pluginWin != NULL) {
122 pluginMain->ClearWindow();
123 delete pluginWin; pluginWin = NULL;
126 return NPERR_NO_ERROR;
static void setPlatform(const std::string &os, const std::string &browser)
Called by the browser when the Operating System and Browser are known.