Refactor some duplicated stuff out...

svn path=/trunk/KDE/kdebase/apps/; revision=748198
This commit is contained in:
Maks Orlovich 2007-12-13 20:44:08 +00:00
parent 25d7450efc
commit 6b1ed28114
5 changed files with 65 additions and 53 deletions

View file

@ -3,7 +3,8 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. )
########### next target ###############
set(nspluginviewer_SRCS nsplugin.cpp viewer.cpp xtevents.cpp pluginhost_xembed.cpp pluginhost_xt.cpp)
set(nspluginviewer_SRCS nsplugin.cpp viewer.cpp xtevents.cpp
pluginhost_xembed.cpp pluginhost_xt.cpp pluginhost.cpp)
qt4_add_dbus_adaptor( nspluginviewer_SRCS org.kde.nsplugins.class.xml nsplugin.h NSPluginClass )
qt4_add_dbus_adaptor( nspluginviewer_SRCS org.kde.nsplugins.instance.xml nsplugin.h NSPluginInstance )

View file

@ -0,0 +1,59 @@
/*
Common stuff for all plugin hosts
Copyright (c) 2000 Matthias Hoelzer-Kluepfel <hoelzer@kde.org>
Stefan Schimanski <1Stein@gmx.de>
2003-2005 George Staikos <staikos@kde.org>
2007 Maksim orlovich <maksim@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "pluginhost.h"
#include <QX11Info>
void PluginHost::setupPluginWindow(NSPluginInstance* plugin, void* winID, int width, int height)
{
NPWindow win;
win.x = 0;
win.y = 0;
win.width = width;
win.height = height;
win.type = NPWindowTypeWindow;
// Well, the docu says sometimes, this is only used on the
// MAC, but sometimes it says it's always. Who knows...
win.clipRect.top = 0;
win.clipRect.left = 0;
win.clipRect.bottom = height;
win.clipRect.right = width;
win.window = winID;
QX11Info x11info;
NPSetWindowCallbackStruct win_info;
win_info.display = QX11Info::display();
win_info.visual = (Visual*) x11info.visual();
win_info.colormap = x11info.colormap();
win_info.depth = x11info.depth();
win.ws_info = &win_info;
NPError error = plugin->NPSetWindow( &win );
kDebug(1431) << "error = " << error;
}
// kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;

View file

@ -32,6 +32,8 @@ public:
virtual void setupWindow (int width, int height) = 0;
virtual void resizePlugin(int width, int height) = 0;
virtual ~PluginHost() {};
void setupPluginWindow(NSPluginInstance* instance, void* winID, int width, int height);
};

View file

@ -70,32 +70,7 @@ void PluginHostXEmbed::setupWindow(int width, int height)
kDebug() << _outside->geometry() << _container->geometry() <<
_outside->isVisible() << _container->isVisible();
NPWindow win;
win.x = 0;
win.y = 0;
win.width = width;
win.height = height;
win.type = NPWindowTypeWindow;
// Well, the docu says sometimes, this is only used on the
// MAC, but sometimes it says it's always. Who knows...
win.clipRect.top = 0;
win.clipRect.left = 0;
win.clipRect.bottom = height;
win.clipRect.right = width;
win.window = (void*)_container->winId();
QX11Info x11info;
NPSetWindowCallbackStruct win_info;
win_info.display = QX11Info::display();
win_info.visual = (Visual*) x11info.visual();
win_info.colormap = x11info.colormap();
win_info.depth = x11info.depth();
win.ws_info = &win_info;
NPError error = _plugin->NPSetWindow( &win );
kDebug(1431) << "error = " << error;
setupPluginWindow(_plugin, (void*)_container->winId(), width, height);
}
// kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;

View file

@ -139,32 +139,7 @@ void PluginHostXt::setupWindow(int width, int height)
// Embed the Xt widget into the Qt widget
XReparentWindow(QX11Info::display(), XtWindow(_toplevel), _outside->winId(), 0, 0);
XtMapWidget(_toplevel);
NPWindow win;
win.x = 0;
win.y = 0;
win.width = width;
win.height = height;
win.type = NPWindowTypeWindow;
// Well, the docu says sometimes, this is only used on the
// MAC, but sometimes it says it's always. Who knows...
win.clipRect.top = 0;
win.clipRect.left = 0;
win.clipRect.bottom = height;
win.clipRect.right = width;
win.window = (void*) XtWindow(_form);
QX11Info x11info;
NPSetWindowCallbackStruct win_info;
win_info.display = QX11Info::display();
win_info.visual = (Visual*) x11info.visual();
win_info.colormap = x11info.colormap();
win_info.depth = x11info.depth();
win.ws_info = &win_info;
NPError error = _plugin->NPSetWindow( &win );
kDebug(1431) << "error = " << error;
setupPluginWindow(_plugin, (void*) XtWindow(_form), width, height);
}
// kate: indent-width 4; replace-tabs on; tab-width 4; space-indent on;