Skip to content

Commit

Permalink
Issue #1638 - Part 2: Disable GTK2 when building with GTK3 and withou…
Browse files Browse the repository at this point in the history
…t NPAPI.

The original purpose of this issue.

Ref: BZ 1377445
  • Loading branch information
athenian200 committed Jan 10, 2024
1 parent b787af5 commit ff713f1
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 22 deletions.
2 changes: 2 additions & 0 deletions config/recurse.mk
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ endif
# Interdependencies that moz.build world don't know about yet for compilation.
# Note some others are hardcoded or "guessed" in recursivemake.py and emitter.py
ifeq ($(MOZ_WIDGET_TOOLKIT),gtk3)
ifdef MOZ_ENABLE_NPAPI
toolkit/library/target: widget/gtk/mozgtk/gtk3/target
endif
endif
ifdef MOZ_LDAP_XPCOM
ldap/target: security/target mozglue/build/target
toolkit/library/target: ldap/target
Expand Down
19 changes: 19 additions & 0 deletions mozglue/build/gtk.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */

#include "mozilla/Types.h"

// Only define the following workaround when using GTK3, which we detect
// by checking if GTK3 stubs are not provided.
#include <X11/Xlib.h>
// Bug 1271100
// We need to trick system Cairo into not using the XShm extension due to
// a race condition in it that results in frequent BadAccess errors. Cairo
// relies upon XShmQueryExtension to initially detect if XShm is available.
// So we define our own stub that always indicates XShm not being present.
// mozgtk loads before libXext/libcairo and so this stub will take priority.
// Our tree usage goes through xcb and remains unaffected by this.
MFBT_API Bool XShmQueryExtension(Display* aDisplay) { return False; }
3 changes: 3 additions & 0 deletions mozglue/build/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ SDK_LIBRARY = True
if CONFIG['MOZ_ASAN']:
SOURCES += ['AsanOptions.cpp']

if not CONFIG['MOZ_ENABLE_NPAPI'] and CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3':
SOURCES += ['gtk.c']

if CONFIG['OS_TARGET'] == 'WINNT':
DEFFILE = 'mozglue.def'
# We'll break the DLL blocklist if we immediately load user32.dll
Expand Down
47 changes: 28 additions & 19 deletions old-configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -2122,6 +2122,24 @@ if test -z "$XULRUNNER_STUB_NAME"; then
fi
AC_SUBST(XULRUNNER_STUB_NAME)

dnl ========================================================
dnl = NPAPI support
dnl ========================================================

MOZ_ENABLE_NPAPI=1

MOZ_ARG_DISABLE_BOOL(npapi,
[ --disable-npapi Disable NPAPI support ],
MOZ_ENABLE_NPAPI=,
MOZ_ENABLE_NPAPI=1)

if test "$MOZ_ENABLE_NPAPI"
then
AC_DEFINE(MOZ_ENABLE_NPAPI)
fi

AC_SUBST(MOZ_ENABLE_NPAPI)

dnl ========================================================
dnl =
dnl = Toolkit Options
Expand Down Expand Up @@ -2189,9 +2207,15 @@ 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
MOZ_CHECK_GTK2=1
fi
fi
if test "$MOZ_WIDGET_TOOLKIT" = gtk2; then
GLIB_VERSION_MAX_ALLOWED=$GLIB_VERSION_MIN_REQUIRED
dnl Check GTK2 packages if we're building against GTK2, whether NPAPI is disabled or not.
MOZ_CHECK_GTK2=1
fi
if test "$MOZ_ENABLE_GTK"; then
if test "$MOZ_X11"; then
Expand All @@ -2200,8 +2224,11 @@ if test "$COMPILE_ENVIRONMENT"; then
AC_DEFINE_UNQUOTED(GLIB_VERSION_MIN_REQUIRED,$GLIB_VERSION_MIN_REQUIRED)
AC_DEFINE_UNQUOTED(GLIB_VERSION_MAX_ALLOWED,$GLIB_VERSION_MAX_ALLOWED)

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)
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.])])
MOZ_GTK2_CFLAGS="-I${_topsrcdir}/widget/gtk/compat $MOZ_GTK2_CFLAGS"
fi
fi
if test "$MOZ_WIDGET_TOOLKIT" = gtk2; then
TK_CFLAGS=$MOZ_GTK2_CFLAGS
Expand Down Expand Up @@ -2491,24 +2518,6 @@ then
fi
AC_SUBST(MOZ_ENABLE_DBUS)

dnl ========================================================
dnl = NPAPI support
dnl ========================================================

MOZ_ENABLE_NPAPI=1

MOZ_ARG_DISABLE_BOOL(npapi,
[ --disable-npapi Disable NPAPI support ],
MOZ_ENABLE_NPAPI=,
MOZ_ENABLE_NPAPI=1)

if test "$MOZ_ENABLE_NPAPI"
then
AC_DEFINE(MOZ_ENABLE_NPAPI)
fi

AC_SUBST(MOZ_ENABLE_NPAPI)

dnl =========================================================
dnl = Whether to exclude hyphenations files in the build
dnl =========================================================
Expand Down
5 changes: 4 additions & 1 deletion toolkit/library/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,14 @@ if CONFIG['USE_ICU']:
'icu',
]

if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3':
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3' and CONFIG['MOZ_ENABLE_NPAPI']:
USE_LIBS += [
'mozgtk_stub',
]

if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3' and not CONFIG['MOZ_ENABLE_NPAPI']:
OS_LIBS += CONFIG['MOZ_GTK3_LIBS']

if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
CXXFLAGS += CONFIG['TK_CFLAGS']

Expand Down
2 changes: 1 addition & 1 deletion widget/gtk/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +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/.

if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3':
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gtk3' and CONFIG['MOZ_ENABLE_NPAPI']:
DIRS += ['mozgtk']

EXPORTS += [
Expand Down
2 changes: 1 addition & 1 deletion widget/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ if toolkit in ('cocoa', 'gtk2', 'gtk3'):
if 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
DIRS += ['gtk']

if CONFIG['MOZ_X11']:
if CONFIG['MOZ_X11'] and CONFIG['MOZ_ENABLE_NPAPI']:
DIRS += ['gtkxtbin']

XPIDL_SOURCES += [
Expand Down

0 comments on commit ff713f1

Please sign in to comment.