Issue #3132 - Add GTK2 NPAPI build toggle

This commit is contained in:
Basilisk-Dev committed 2026-06-26 13:09:49 -04:00
1 parent 27c579652a
commit 3f5b7ed020
9 files changed
+85 -24

No files matched your search

+1
View File
@@ -164,6 +164,7 @@ def old_configure_options(*options):
'--enable-negotiateauth',
'--enable-nfc',
'--enable-npapi',
'--enable-npapi-gtk2',
'--enable-nspr-build',
'--enable-official-branding',
'--enable-official-vendor',
+37 -14
View File
@@ -55,7 +55,12 @@ using namespace std;
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include <gdk/gdk.h>
#if (GTK_MAJOR_VERSION == 3)
#include <gtk/gtkx.h>
#endif
#ifdef MOZ_ENABLE_NPAPI_GTK2
#include "gtk2xtbin.h"
#endif
#elif defined(OS_WIN)
@@ -208,7 +213,9 @@ PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface,
memset(&mWsInfo, 0, sizeof(mWsInfo));
#ifdef MOZ_WIDGET_GTK
mWsInfo.display = nullptr;
#ifdef MOZ_ENABLE_NPAPI_GTK2
mXtClient.top_widget = nullptr;
#endif
#else
mWsInfo.display = DefaultXDisplay();
#endif
@@ -620,15 +627,17 @@ PluginInstanceChild::NPN_SetValue(NPPVariable aVar, void* aValue)
NPWindowType newWindowType = windowed ? NPWindowTypeWindow : NPWindowTypeDrawable;
#ifdef MOZ_WIDGET_GTK
if (mWindow.type != newWindowType && mWsInfo.display) {
// plugin type has been changed but we already have a valid display
// so update it for the recent plugin mode
if (mXEmbed || !windowed) {
// Use default GTK display for XEmbed and windowless plugins
mWsInfo.display = DefaultXDisplay();
}
else {
mWsInfo.display = xt_client_get_display();
}
// plugin type has been changed but we already have a valid display
// so update it for the recent plugin mode
#ifdef MOZ_ENABLE_NPAPI_GTK2
if (!mXEmbed && windowed) {
mWsInfo.display = xt_client_get_display();
} else
#endif
{
// Use default GTK display for XEmbed and windowless plugins.
mWsInfo.display = DefaultXDisplay();
}
}
#endif
mWindow.type = newWindowType;
@@ -1214,12 +1223,18 @@ bool PluginInstanceChild::CreateWindow(const NPRemoteWindow& aWindow)
if (mXEmbed) {
mWindow.window = reinterpret_cast<void*>(aWindow.window);
}
#ifdef MOZ_ENABLE_NPAPI_GTK2
else {
Window browserSocket = (Window)(aWindow.window);
xt_client_init(&mXtClient, mWsInfo.visual, mWsInfo.colormap, mWsInfo.depth);
xt_client_create(&mXtClient, browserSocket, mWindow.width, mWindow.height);
mWindow.window = (void *)XtWindow(mXtClient.child_widget);
}
}
#else
else {
mWindow.window = reinterpret_cast<void*>(aWindow.window);
}
#endif
#else
mWindow.window = reinterpret_cast<void*>(aWindow.window);
#endif
@@ -1239,7 +1254,7 @@ void PluginInstanceChild::DeleteWindow()
if (!mWindow.window)
return;
#ifdef MOZ_WIDGET_GTK
#ifdef MOZ_ENABLE_NPAPI_GTK2
if (mXtClient.top_widget) {
xt_client_unrealize(&mXtClient);
xt_client_destroy(&mXtClient);
@@ -1321,7 +1336,7 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow)
CreateWindow(aWindow);
}
#ifdef MOZ_WIDGET_GTK
#ifdef MOZ_ENABLE_NPAPI_GTK2
if (mXEmbed && gtk_check_version(2,18,7) != nullptr) { // older
if (aWindow.type == NPWindowTypeWindow) {
GdkWindow* socket_window = gdk_window_lookup(static_cast<GdkNativeWindow>(aWindow.window));
@@ -1456,19 +1471,27 @@ PluginInstanceChild::Initialize()
if (mWindow.type == NPWindowTypeWindow) {
AnswerNPP_GetValue_NPPVpluginNeedsXEmbed(&mXEmbed, &rv);
#ifdef MOZ_ENABLE_NPAPI_GTK2
// Set up Xt loop for windowed plugins without XEmbed support
if (!mXEmbed) {
xt_client_xloop_create();
}
#endif
}
// Use default GTK display for XEmbed and windowless plugins
// Use default GTK display for XEmbed and windowless plugins.
if (mXEmbed || mWindow.type != NPWindowTypeWindow) {
mWsInfo.display = DefaultXDisplay();
}
#ifdef MOZ_ENABLE_NPAPI_GTK2
else {
mWsInfo.display = xt_client_get_display();
}
#else
else {
mWsInfo.display = DefaultXDisplay();
}
#endif
#endif
return true;
@@ -4656,7 +4679,7 @@ PluginInstanceChild::Destroy()
mPendingAsyncCalls.Clear();
#ifdef MOZ_WIDGET_GTK
#ifdef MOZ_ENABLE_NPAPI_GTK2
if (mWindow.type == NPWindowTypeWindow && !mXEmbed) {
xt_client_xloop_destroy();
}
+3 -1
View File
@@ -36,7 +36,7 @@
#include <map>
#ifdef MOZ_WIDGET_GTK
#ifdef MOZ_ENABLE_NPAPI_GTK2
#include "gtk2xtbin.h"
#endif
@@ -462,6 +462,8 @@ private:
NPSetWindowCallbackStruct mWsInfo;
#ifdef MOZ_WIDGET_GTK
bool mXEmbed;
#endif
#ifdef MOZ_ENABLE_NPAPI_GTK2
XtClient mXtClient;
#endif
#elif defined(OS_WIN)
+7
View File
@@ -12,6 +12,9 @@
#ifdef MOZ_WIDGET_GTK
#include <gtk/gtk.h>
#if (GTK_MAJOR_VERSION == 3)
#include <gtk/gtkx.h>
#endif
#endif
#include "nsIFile.h"
@@ -1101,7 +1104,11 @@ _getvalue(NPP aNPP,
return InstCast(aNPP)->NPN_GetValue(aVariable, aValue);
}
else {
#ifdef MOZ_ENABLE_NPAPI_GTK2
*(void **)aValue = xt_client_get_display();
#else
*(void **)aValue = DefaultXDisplay();
#endif
}
return NPERR_NO_ERROR;
}
+5 -3
View File
@@ -143,11 +143,13 @@ LOCAL_INCLUDES += [
DEFINES['FORCE_PR_LOG'] = True
if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'gtk3':
CXXFLAGS += CONFIG['TK_CFLAGS']
else:
if (CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3' and
CONFIG['MOZ_ENABLE_NPAPI'] and
CONFIG['MOZ_ENABLE_NPAPI_GTK2']):
# Force build against gtk+2 for struct offsets and such.
CXXFLAGS += CONFIG['MOZ_GTK2_CFLAGS']
else:
CXXFLAGS += CONFIG['TK_CFLAGS']
CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
+22 -3
View File
@@ -2146,12 +2146,26 @@ MOZ_ARG_DISABLE_BOOL(npapi,
MOZ_ENABLE_NPAPI=,
MOZ_ENABLE_NPAPI=1)
MOZ_ENABLE_NPAPI_GTK2=1
MOZ_ARG_DISABLE_BOOL(npapi-gtk2,
[ --disable-npapi-gtk2 Disable GTK2 support for NPAPI plugins ],
MOZ_ENABLE_NPAPI_GTK2=
MOZ_DISABLE_NPAPI_GTK2=1,
MOZ_ENABLE_NPAPI_GTK2=1)
if test "$MOZ_ENABLE_NPAPI"
then
AC_DEFINE(MOZ_ENABLE_NPAPI)
fi
if test "$MOZ_ENABLE_NPAPI" -a "$MOZ_ENABLE_NPAPI_GTK2"
then
AC_DEFINE(MOZ_ENABLE_NPAPI_GTK2)
fi
AC_SUBST(MOZ_ENABLE_NPAPI)
AC_SUBST(MOZ_ENABLE_NPAPI_GTK2)
dnl ========================================================
dnl =
@@ -2200,6 +2214,10 @@ gtk*)
;;
esac
if test "$MOZ_WIDGET_TOOLKIT" = gtk2 -a "$MOZ_DISABLE_NPAPI_GTK2"; then
AC_MSG_ERROR([--disable-npapi-gtk2 cannot be used with GTK2 browser builds.])
fi
if test "$COMPILE_ENVIRONMENT"; then
if test "$MOZ_WIDGET_TOOLKIT" = gtk3; then
PKG_CHECK_MODULES(MOZ_GTK3, gtk+-3.0 >= $GTK3_VERSION gtk+-unix-print-3.0 glib-2.0 gobject-2.0 $GDK_PACKAGES)
@@ -2210,8 +2228,9 @@ if test "$COMPILE_ENVIRONMENT"; then
dnl are suppressed by widget/gtk/compat-gtk3/gdk/gdkversionmacros.h.
AC_DEFINE_UNQUOTED(GDK_VERSION_MAX_ALLOWED,$GDK_VERSION_MAX_ALLOWED)
GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_32
dnl We want to check GTK2 packages if NPAPI is enabled, even if building with GTK3.
if test "$MOZ_ENABLE_NPAPI"; then
dnl GTK2 NPAPI plugin support needs GTK2 packages, even when the browser
dnl itself is built against GTK3.
if test "$MOZ_ENABLE_NPAPI" -a "$MOZ_ENABLE_NPAPI_GTK2"; then
MOZ_CHECK_GTK2=1
fi
fi
@@ -2229,7 +2248,7 @@ if test "$COMPILE_ENVIRONMENT"; then
if test "$MOZ_CHECK_GTK2"; then
PKG_CHECK_MODULES(MOZ_GTK2, gtk+-2.0 >= $GTK2_VERSION gtk+-unix-print-2.0 glib-2.0 >= $GLIB_VERSION gobject-2.0 $GDK_PACKAGES, ,
[AC_MSG_ERROR([ * * * Could not find gtk+-2.0. Required for NPAPI plugins. To build without NPAPI, add --disable-npapi to your .mozconfig and clobber.])])
[AC_MSG_ERROR([ * * * Could not find gtk+-2.0. Required for GTK2 browser builds and GTK2 NPAPI plugin support. To build a GTK3 browser with NPAPI but without GTK2 NPAPI plugin support, add --disable-npapi-gtk2 to your .mozconfig and clobber.])])
MOZ_GTK2_CFLAGS="-I${_topsrcdir}/widget/gtk/compat $MOZ_GTK2_CFLAGS"
fi
fi
+4 -1
View File
@@ -3,4 +3,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
DIRS += ['stub', 'gtk2', 'gtk3']
DIRS += ['stub', 'gtk3']
if CONFIG['MOZ_ENABLE_NPAPI_GTK2']:
DIRS += ['gtk2']
+4 -1
View File
@@ -7,9 +7,12 @@ SOURCES += [
'../mozgtk.c',
]
for var in ('COMMON_SYMBOLS', 'GTK2_SYMBOLS', 'GTK3_SYMBOLS'):
for var in ('COMMON_SYMBOLS', 'GTK3_SYMBOLS'):
DEFINES[var] = True
if CONFIG['MOZ_ENABLE_NPAPI_GTK2']:
DEFINES['GTK2_SYMBOLS'] = True
SharedLibrary('mozgtk_stub')
SONAME = 'mozgtk'
+2 -1
View File
@@ -52,7 +52,8 @@ if toolkit in ('cocoa', 'gtk2', 'gtk3'):
if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
DIRS += ['gtk']
if CONFIG['MOZ_X11'] and CONFIG['MOZ_ENABLE_NPAPI']:
if (CONFIG['MOZ_X11'] and CONFIG['MOZ_ENABLE_NPAPI'] and
CONFIG['MOZ_ENABLE_NPAPI_GTK2']):
DIRS += ['gtkxtbin']
XPIDL_SOURCES += [