зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1288686 - Avoid X11's |#define None 0L| intruding on other parts of the code. r=jrmuizel
MozReview-Commit-ID: 9rD0KLTLg7l --HG-- extra : rebase_source : a537ba1913b6959e74fc4fcaf58f51f759cc5882 extra : source : 9278e13a7d664e787f763a7c21a32833700899e1
This commit is contained in:
Родитель
3e21f8275b
Коммит
2af3f87bb6
|
@ -46,6 +46,7 @@
|
|||
#if defined(MOZ_X11)
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "X11UndefineNone.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2610,7 +2610,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
|||
#ifdef MOZ_WIDGET_GTK
|
||||
Window root = GDK_ROOT_WINDOW();
|
||||
#else
|
||||
Window root = None; // Could XQueryTree, but this is not important.
|
||||
Window root = X11None; // Could XQueryTree, but this is not important.
|
||||
#endif
|
||||
|
||||
switch (anEvent.mMessage) {
|
||||
|
@ -2628,7 +2628,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
|||
event.y_root = rootPoint.y;
|
||||
event.state = XInputEventState(mouseEvent);
|
||||
// information lost
|
||||
event.subwindow = None;
|
||||
event.subwindow = X11None;
|
||||
event.mode = -1;
|
||||
event.detail = NotifyDetailNone;
|
||||
event.same_screen = True;
|
||||
|
@ -2647,7 +2647,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
|||
event.y_root = rootPoint.y;
|
||||
event.state = XInputEventState(mouseEvent);
|
||||
// information lost
|
||||
event.subwindow = None;
|
||||
event.subwindow = X11None;
|
||||
event.is_hint = NotifyNormal;
|
||||
event.same_screen = True;
|
||||
}
|
||||
|
@ -2678,7 +2678,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
|||
break;
|
||||
}
|
||||
// information lost:
|
||||
event.subwindow = None;
|
||||
event.subwindow = X11None;
|
||||
event.same_screen = True;
|
||||
}
|
||||
break;
|
||||
|
@ -2722,7 +2722,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
|||
|
||||
// Information that could be obtained from pluginEvent but we may not
|
||||
// want to promise to provide:
|
||||
event.subwindow = None;
|
||||
event.subwindow = X11None;
|
||||
event.x = 0;
|
||||
event.y = 0;
|
||||
event.x_root = -1;
|
||||
|
@ -2764,7 +2764,7 @@ nsEventStatus nsPluginInstanceOwner::ProcessEvent(const WidgetGUIEvent& anEvent)
|
|||
XAnyEvent& event = pluginEvent.xany;
|
||||
event.display = widget ?
|
||||
static_cast<Display*>(widget->GetNativeData(NS_NATIVE_DISPLAY)) : nullptr;
|
||||
event.window = None; // not a real window
|
||||
event.window = X11None; // not a real window
|
||||
// information lost:
|
||||
event.serial = 0;
|
||||
event.send_event = False;
|
||||
|
|
|
@ -217,7 +217,7 @@ nsresult nsPluginNativeWindowGtk::CreateXEmbedWindow(bool aEnableXtFocus) {
|
|||
GdkVisual* gdkVisual = gdk_drawable_get_visual(gdkWindow);
|
||||
mWsInfo.depth = gdkVisual->depth;
|
||||
#else
|
||||
mWsInfo.colormap = None;
|
||||
mWsInfo.colormap = X11None;
|
||||
GdkVisual* gdkVisual = gdk_window_get_visual(gdkWindow);
|
||||
mWsInfo.depth = gdk_visual_get_depth(gdkVisual);
|
||||
#endif
|
||||
|
|
|
@ -1282,7 +1282,7 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow)
|
|||
}
|
||||
}
|
||||
|
||||
if (aWindow.visualID != None
|
||||
if (aWindow.visualID != X11None
|
||||
&& gtk_check_version(2, 12, 10) != nullptr) { // older
|
||||
// Workaround for a bug in Gtk+ (prior to 2.12.10) where deleting
|
||||
// a foreign GdkColormap will also free the XColormap.
|
||||
|
|
|
@ -81,7 +81,7 @@ pluginInstanceInit(InstanceData* instanceData)
|
|||
|
||||
instanceData->platformData->display = nullptr;
|
||||
instanceData->platformData->visual = nullptr;
|
||||
instanceData->platformData->colormap = None;
|
||||
instanceData->platformData->colormap = X11None;
|
||||
instanceData->platformData->plug = nullptr;
|
||||
|
||||
return NPERR_NO_ERROR;
|
||||
|
@ -97,7 +97,7 @@ pluginInstanceShutdown(InstanceData* instanceData)
|
|||
if (instanceData->hasWidget) {
|
||||
Window window = reinterpret_cast<XID>(instanceData->window.window);
|
||||
|
||||
if (window != None) {
|
||||
if (window != X11None) {
|
||||
// This window XID should still be valid.
|
||||
// See bug 429604 and bug 454756.
|
||||
XWindowAttributes attributes;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#ifdef MOZ_X11
|
||||
#include <X11/extensions/Xrender.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include "X11UndefineNone.h"
|
||||
#endif
|
||||
|
||||
struct _cairo;
|
||||
|
@ -87,7 +88,7 @@ public:
|
|||
BorrowedXlibDrawable()
|
||||
: mDT(nullptr),
|
||||
mDisplay(nullptr),
|
||||
mDrawable(None),
|
||||
mDrawable(X11None),
|
||||
mScreen(nullptr),
|
||||
mVisual(nullptr),
|
||||
mXRenderFormat(nullptr)
|
||||
|
@ -96,7 +97,7 @@ public:
|
|||
explicit BorrowedXlibDrawable(DrawTarget *aDT)
|
||||
: mDT(nullptr),
|
||||
mDisplay(nullptr),
|
||||
mDrawable(None),
|
||||
mDrawable(X11None),
|
||||
mScreen(nullptr),
|
||||
mVisual(nullptr),
|
||||
mXRenderFormat(nullptr)
|
||||
|
|
|
@ -2163,7 +2163,7 @@ DrawTargetCairo::Draw3DTransformedSurface(SourceSurface* aSurface, const Matrix4
|
|||
0, nullptr);
|
||||
|
||||
XRenderComposite(display, PictOpSrc,
|
||||
srcPict, None, dstPict,
|
||||
srcPict, X11None, dstPict,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
xformBounds.width, xformBounds.height);
|
||||
|
||||
|
@ -2313,7 +2313,7 @@ BorrowedXlibDrawable::Init(DrawTarget* aDT)
|
|||
MOZ_ASSERT(aDT, "Caller should check for nullptr");
|
||||
MOZ_ASSERT(!mDT, "Can't initialize twice!");
|
||||
mDT = aDT;
|
||||
mDrawable = None;
|
||||
mDrawable = X11None;
|
||||
|
||||
#ifdef CAIRO_HAS_XLIB_SURFACE
|
||||
if (aDT->GetBackendType() != BackendType::CAIRO ||
|
||||
|
@ -2356,7 +2356,7 @@ BorrowedXlibDrawable::Finish()
|
|||
cairo_surface_t* surf = cairo_get_group_target(cairoDT->mContext);
|
||||
cairo_surface_mark_dirty(surf);
|
||||
if (mDrawable) {
|
||||
mDrawable = None;
|
||||
mDrawable = X11None;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "X11UndefineNone.h"
|
||||
|
||||
#include "mozilla/MathAlgorithms.h"
|
||||
#include "mozilla/StaticPtr.h"
|
||||
|
@ -308,13 +309,13 @@ GLXPixmap
|
|||
GLXLibrary::CreatePixmap(gfxASurface* aSurface)
|
||||
{
|
||||
if (!SupportsTextureFromPixmap(aSurface)) {
|
||||
return None;
|
||||
return X11None;
|
||||
}
|
||||
|
||||
gfxXlibSurface* xs = static_cast<gfxXlibSurface*>(aSurface);
|
||||
const XRenderPictFormat* format = xs->XRenderFormat();
|
||||
if (!format || format->type != PictTypeDirect) {
|
||||
return None;
|
||||
return X11None;
|
||||
}
|
||||
const XRenderDirectFormat& direct = format->direct;
|
||||
int alphaSize = FloorLog2(direct.alphaMask + 1);
|
||||
|
@ -327,7 +328,7 @@ GLXLibrary::CreatePixmap(gfxASurface* aSurface)
|
|||
(alphaSize ? LOCAL_GLX_BIND_TO_TEXTURE_RGBA_EXT
|
||||
: LOCAL_GLX_BIND_TO_TEXTURE_RGB_EXT), True,
|
||||
LOCAL_GLX_RENDER_TYPE, LOCAL_GLX_RGBA_BIT,
|
||||
None };
|
||||
X11None };
|
||||
|
||||
int numConfigs = 0;
|
||||
Display* display = xs->XDisplay();
|
||||
|
@ -351,7 +352,7 @@ GLXLibrary::CreatePixmap(gfxASurface* aSurface)
|
|||
~(redMask | greenMask | blueMask) != -1UL << format->depth;
|
||||
|
||||
for (int i = 0; i < numConfigs; i++) {
|
||||
int id = None;
|
||||
int id = X11None;
|
||||
sGLXLibrary.xGetFBConfigAttrib(display, cfgs[i], LOCAL_GLX_VISUAL_ID, &id);
|
||||
Visual* visual;
|
||||
int depth;
|
||||
|
@ -424,14 +425,14 @@ GLXLibrary::CreatePixmap(gfxASurface* aSurface)
|
|||
// caller should deal with this situation.
|
||||
NS_WARN_IF_FALSE(format->depth == 8,
|
||||
"[GLX] Couldn't find a FBConfig matching Pixmap format");
|
||||
return None;
|
||||
return X11None;
|
||||
}
|
||||
|
||||
int pixmapAttribs[] = { LOCAL_GLX_TEXTURE_TARGET_EXT, LOCAL_GLX_TEXTURE_2D_EXT,
|
||||
LOCAL_GLX_TEXTURE_FORMAT_EXT,
|
||||
(alphaSize ? LOCAL_GLX_TEXTURE_FORMAT_RGBA_EXT
|
||||
: LOCAL_GLX_TEXTURE_FORMAT_RGB_EXT),
|
||||
None};
|
||||
X11None};
|
||||
|
||||
GLXPixmap glxpixmap = xCreatePixmap(display,
|
||||
cfgs[matchIndex],
|
||||
|
@ -900,7 +901,7 @@ GLContextGLX::~GLContextGLX()
|
|||
#ifdef DEBUG
|
||||
bool success =
|
||||
#endif
|
||||
mGLX->xMakeCurrent(mDisplay, None, nullptr);
|
||||
mGLX->xMakeCurrent(mDisplay, X11None, nullptr);
|
||||
MOZ_ASSERT(success,
|
||||
"glXMakeCurrent failed to release GL context before we call "
|
||||
"glXDestroyContext!");
|
||||
|
@ -1242,7 +1243,7 @@ GLContextGLX::FindFBConfigForWindow(Display* display, int screen, Window window,
|
|||
#endif
|
||||
|
||||
for (int i = 0; i < numConfigs; i++) {
|
||||
int visid = None;
|
||||
int visid = X11None;
|
||||
sGLXLibrary.xGetFBConfigAttrib(display, cfgs[i], LOCAL_GLX_VISUAL_ID, &visid);
|
||||
if (!visid) {
|
||||
continue;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <X11/extensions/Xrender.h> // for XRenderPictFormat, etc
|
||||
#include <X11/extensions/render.h> // for PictFormat
|
||||
#include "cairo-xlib.h"
|
||||
#include "X11UndefineNone.h"
|
||||
#include <stdint.h> // for uint32_t
|
||||
#include "GLDefs.h" // for GLenum
|
||||
#include "gfxPlatform.h" // for gfxPlatform
|
||||
|
@ -65,7 +66,7 @@ SurfaceDescriptorX11::SurfaceDescriptorX11(gfxXlibSurface* aSurf,
|
|||
bool aForwardGLX)
|
||||
: mId(aSurf->XDrawable())
|
||||
, mSize(aSurf->GetSize())
|
||||
, mGLXPixmap(None)
|
||||
, mGLXPixmap(X11None)
|
||||
{
|
||||
const XRenderPictFormat *pictFormat = aSurf->XRenderFormat();
|
||||
if (pictFormat) {
|
||||
|
@ -86,7 +87,7 @@ SurfaceDescriptorX11::SurfaceDescriptorX11(Drawable aDrawable, XID aFormatID,
|
|||
: mId(aDrawable)
|
||||
, mFormat(aFormatID)
|
||||
, mSize(aSize)
|
||||
, mGLXPixmap(None)
|
||||
, mGLXPixmap(X11None)
|
||||
{ }
|
||||
|
||||
already_AddRefed<gfxXlibSurface>
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/* -*- 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/. */
|
||||
|
||||
#ifndef MOZILLA_GFX_X11UNDEFINENONE_H_
|
||||
#define MOZILLA_GFX_X11UNDEFINENONE_H_
|
||||
|
||||
// The header <X11/X.h> defines "None" as a macro that expands to "0L".
|
||||
// This is terrible because many enumerations have an enumerator named "None".
|
||||
// To work around this, we undefine the macro "None", and define a replacement
|
||||
// macro named "X11None".
|
||||
// Include this header after including X11 headers, where necessary.
|
||||
#ifdef None
|
||||
# undef None
|
||||
# define X11None 0L
|
||||
// <X11/X.h> also defines "RevertToNone" as a macro that expands to "(int)None".
|
||||
// Since we are undefining "None", that stops working. To keep it working,
|
||||
// we undefine "RevertToNone" and redefine it in terms of "X11None".
|
||||
# ifdef RevertToNone
|
||||
# undef RevertToNone
|
||||
# define RevertToNone (int)X11None
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* MOZILLA_GFX_X11UNDEFINENONE_H_ */
|
|
@ -29,7 +29,7 @@ FindVisualAndDepth(Display* aDisplay, VisualID aVisualID,
|
|||
}
|
||||
}
|
||||
|
||||
NS_ASSERTION(aVisualID == None, "VisualID not on Screen.");
|
||||
NS_ASSERTION(aVisualID == X11None, "VisualID not on Screen.");
|
||||
*aVisual = nullptr;
|
||||
*aDepth = 0;
|
||||
return;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#if defined(MOZ_WIDGET_GTK)
|
||||
# include <gdk/gdk.h>
|
||||
# include <gdk/gdkx.h>
|
||||
# include "X11UndefineNone.h"
|
||||
#else
|
||||
# error Unknown toolkit
|
||||
#endif
|
||||
|
|
|
@ -39,6 +39,7 @@ EXPORTS += [
|
|||
'nsTransform2D.h',
|
||||
'PingPongRegion.h',
|
||||
'RegionBuilder.h',
|
||||
'X11UndefineNone.h'
|
||||
]
|
||||
|
||||
EXPORTS.mozilla += [
|
||||
|
|
|
@ -25,7 +25,7 @@ using namespace mozilla::gfx;
|
|||
gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual)
|
||||
: mPixmapTaken(false), mDisplay(dpy), mDrawable(drawable)
|
||||
#if defined(GL_PROVIDER_GLX)
|
||||
, mGLXPixmap(None)
|
||||
, mGLXPixmap(X11None)
|
||||
#endif
|
||||
{
|
||||
const gfx::IntSize size = DoSizeQuery();
|
||||
|
@ -36,7 +36,7 @@ gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual)
|
|||
gfxXlibSurface::gfxXlibSurface(Display *dpy, Drawable drawable, Visual *visual, const gfx::IntSize& size)
|
||||
: mPixmapTaken(false), mDisplay(dpy), mDrawable(drawable)
|
||||
#if defined(GL_PROVIDER_GLX)
|
||||
, mGLXPixmap(None)
|
||||
, mGLXPixmap(X11None)
|
||||
#endif
|
||||
{
|
||||
NS_ASSERTION(Factory::CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT),
|
||||
|
@ -51,7 +51,7 @@ gfxXlibSurface::gfxXlibSurface(Screen *screen, Drawable drawable, XRenderPictFor
|
|||
: mPixmapTaken(false), mDisplay(DisplayOfScreen(screen)),
|
||||
mDrawable(drawable)
|
||||
#if defined(GL_PROVIDER_GLX)
|
||||
, mGLXPixmap(None)
|
||||
, mGLXPixmap(X11None)
|
||||
#endif
|
||||
{
|
||||
NS_ASSERTION(Factory::CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT),
|
||||
|
@ -67,7 +67,7 @@ gfxXlibSurface::gfxXlibSurface(Screen *screen, Drawable drawable, XRenderPictFor
|
|||
gfxXlibSurface::gfxXlibSurface(cairo_surface_t *csurf)
|
||||
: mPixmapTaken(false)
|
||||
#if defined(GL_PROVIDER_GLX)
|
||||
, mGLXPixmap(None)
|
||||
, mGLXPixmap(X11None)
|
||||
#endif
|
||||
{
|
||||
NS_PRECONDITION(cairo_surface_status(csurf) == 0,
|
||||
|
@ -97,9 +97,9 @@ CreatePixmap(Screen *screen, const gfx::IntSize& size, unsigned int depth,
|
|||
Drawable relatedDrawable)
|
||||
{
|
||||
if (!Factory::CheckSurfaceSize(size, XLIB_IMAGE_SIDE_SIZE_LIMIT))
|
||||
return None;
|
||||
return X11None;
|
||||
|
||||
if (relatedDrawable == None) {
|
||||
if (relatedDrawable == X11None) {
|
||||
relatedDrawable = RootWindowOfScreen(screen);
|
||||
}
|
||||
Display *dpy = DisplayOfScreen(screen);
|
||||
|
@ -274,7 +274,7 @@ gfxXlibSurface::Finish()
|
|||
#if defined(GL_PROVIDER_GLX)
|
||||
if (mPixmapTaken && mGLXPixmap) {
|
||||
gl::sGLXLibrary.DestroyPixmap(mDisplay, mGLXPixmap);
|
||||
mGLXPixmap = None;
|
||||
mGLXPixmap = X11None;
|
||||
}
|
||||
#endif
|
||||
gfxASurface::Finish();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <X11/extensions/Xrender.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include "X11UndefineNone.h"
|
||||
|
||||
#if defined(GL_PROVIDER_GLX)
|
||||
#include "GLXLibrary.h"
|
||||
|
@ -46,13 +47,13 @@ public:
|
|||
// |screen| (if specified).
|
||||
static already_AddRefed<gfxXlibSurface>
|
||||
Create(Screen *screen, Visual *visual, const mozilla::gfx::IntSize& size,
|
||||
Drawable relatedDrawable = None);
|
||||
Drawable relatedDrawable = X11None);
|
||||
static cairo_surface_t *
|
||||
CreateCairoSurface(Screen *screen, Visual *visual, const mozilla::gfx::IntSize& size,
|
||||
Drawable relatedDrawable = None);
|
||||
Drawable relatedDrawable = X11None);
|
||||
static already_AddRefed<gfxXlibSurface>
|
||||
Create(Screen* screen, XRenderPictFormat *format, const mozilla::gfx::IntSize& size,
|
||||
Drawable relatedDrawable = None);
|
||||
Drawable relatedDrawable = X11None);
|
||||
|
||||
virtual ~gfxXlibSurface();
|
||||
|
||||
|
|
|
@ -1030,7 +1030,7 @@ selection_request_filter(GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
|
|||
{
|
||||
XEvent *xevent = static_cast<XEvent*>(gdk_xevent);
|
||||
if (xevent->xany.type == SelectionRequest) {
|
||||
if (xevent->xselectionrequest.requestor == None)
|
||||
if (xevent->xselectionrequest.requestor == X11None)
|
||||
return GDK_FILTER_REMOVE;
|
||||
|
||||
GdkDisplay *display = gdk_x11_lookup_xdisplay(
|
||||
|
|
|
@ -452,7 +452,7 @@ nsWindow::nsWindow()
|
|||
mOldFocusWindow = 0;
|
||||
|
||||
mXDisplay = nullptr;
|
||||
mXWindow = None;
|
||||
mXWindow = X11None;
|
||||
mXVisual = nullptr;
|
||||
mXDepth = 0;
|
||||
#endif /* MOZ_X11 */
|
||||
|
@ -4587,7 +4587,7 @@ nsWindow::ClearTransparencyBitmap()
|
|||
Display* xDisplay = GDK_WINDOW_XDISPLAY(mGdkWindow);
|
||||
Window xWindow = gdk_x11_window_get_xid(mGdkWindow);
|
||||
|
||||
XShapeCombineMask(xDisplay, xWindow, ShapeBounding, 0, 0, None, ShapeSet);
|
||||
XShapeCombineMask(xDisplay, xWindow, ShapeBounding, 0, 0, X11None, ShapeSet);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче