Bye bye gtk1 and xlib (part 2 of 2). b=326152 r+sr=roc

This commit is contained in:
mats.palmgren@bredband.net 2007-05-02 17:10:01 -07:00
parent a9dddfe17f
commit 781088d843
115 changed files with 0 additions and 46897 deletions

View File

@ -1,156 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
#
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = gfx
EXPORTS = nsGCCache.h
LIBRARY_NAME = gfx_xlib
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsGfxXlibModule
GRE_MODULE = 1
LIBXUL_LIBRARY = 1
REQUIRES = xpcom \
string \
xlibrgb \
widget \
js \
necko \
pref \
util \
view \
uconv \
locale \
unicharutil \
imglib2 \
mozcomps \
intl \
$(NULL)
# Sun's Complex Text Layout support
ifdef SUNCTL
REQUIRES += ctl
endif
ifdef MOZ_ENABLE_XPRINT
REQUIRES += xprintutil
endif
# Code shared between GTK+, Xlib and Xprint gfx modules
# (empty for now - but this will be filled soon...)
X11SHARED_LCPPSRCS = \
$(NULL)
CPPSRCS = \
$(X11SHARED_LCPPSRCS) \
nsDeviceContextSpecXlib.cpp \
nsDeviceContextXlib.cpp \
nsDrawingSurfaceXlib.cpp \
nsFontMetricsXlib.cpp \
nsGfxFactoryXlib.cpp \
nsImageXlib.cpp \
nsRegionXlib.cpp \
nsRenderingContextXlib.cpp \
nsPrintOptionsXlib.cpp \
nsGCCache.cpp \
$(NULL)
ifdef HAVE_XIE
CSRCS += XIE.c
endif
GARBAGE += $(X11SHARED_LCPPSRCS) $(wildcard *.$(OBJ_SUFFIX))
EXTRA_DSO_LDOPTS = $(DIST)/lib/$(LIB_PREFIX)gfxshared_s.$(LIB_SUFFIX)
include $(topsrcdir)/config/rules.mk
EXTRA_DSO_LDOPTS += -L$(DIST)/bin -lxlibrgb $(MOZ_XLIB_LDFLAGS)
CXXFLAGS += $(MOZ_XLIB_CFLAGS)
ifdef HAVE_XIE
DEFINES += -DHAVE_XIE
GFX_XIE_LIBS += $(MOZ_XIE_LIBS)
endif
EXTRA_DSO_LDOPTS += \
$(LIBS_DIR) \
-lgkgfx \
$(GFX_XIE_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(MOZ_UNICHARUTIL_LIBS) \
$(NULL)
DEFINES += -DUSE_MOZILLA_TYPES
ifdef MOZ_ENABLE_POSTSCRIPT
DEFINES += -DUSE_POSTSCRIPT
EXTRA_DSO_LDOPTS += -lgfxpsshar
endif
ifdef MOZ_ENABLE_XPRINT
DEFINES += -DUSE_XPRINT
EXTRA_DSO_LDOPTS += \
-lxprintutil \
$(MOZ_XPRINT_LDFLAGS)
endif
LOCAL_INCLUDES += \
-I../.. \
-I$(srcdir)/. \
-I$(srcdir)/.. \
-I$(srcdir)/../shared \
-I$(srcdir)/../x11shared \
$(NULL)
ifdef MOZ_ENABLE_XPRINT
#export:: $(addprefix $(srcdir)/../x11shared/,$(X11SHARED_LCPPSRCS))
# $(INSTALL) $^ .
else
# disabled until X11SHARED_LCPPSRCS becomes non-empty
# export:: $(addprefix $(srcdir)/../x11shared/,$(X11SHARED_LCPPSRCS))
# $(INSTALL) $^ .
endif

View File

@ -1,194 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:ts=2:et:sw=2:
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
* Syd Logan <syd@netscape.com>
* Xlibified by tim copperfield <timecop@japan.co.jp>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "drawers.h"
#ifdef HAVE_XIE
#include <stdio.h>
#include <string.h>
#include "prenv.h"
#include "xlibrgb.h"
#include <X11/extensions/XIElib.h>
/* #define DEBUG_XIE 1 */
static PRBool useXIE = PR_TRUE;
static PRBool inited = PR_FALSE;
static XiePhotospace gPhotospace;
static XiePhotoElement *photoElement;
static void
DoFlo(Display *display,
Drawable aDest,
GC aGC,
Drawable aSrc,
PRInt32 aSrcWidth,
PRInt32 aSrcHeight,
PRInt32 aSX,
PRInt32 aSY,
PRInt32 aSWidth,
PRInt32 aSHeight,
PRInt32 aDX,
PRInt32 aDY,
PRInt32 aDWidth,
PRInt32 aDHeight)
{
XieExtensionInfo *info;
float coeffs[6];
XieConstant constant;
XiePhototag idx = 0, src;
/* create the pretty flo graph */
/* import */
XieFloImportDrawable(&photoElement[idx], aSrc,
aSX, aSY, aSWidth, aSHeight,
0, PR_FALSE);
++idx;
src = idx;
/* do the scaling stuff */
coeffs[0] = (float)aSrcWidth / (float)aDWidth;
coeffs[1] = 0.0;
coeffs[2] = 0.0;
coeffs[3] = (float)aSrcHeight / (float)aDHeight;
coeffs[4] = 0.0;
coeffs[5] = 0.0;
constant[0] = 128.0;
constant[1] = 128.0;
constant[2] = 128.0;
XieFloGeometry(&photoElement[idx], src, aDWidth, aDHeight,
coeffs,
constant,
0x07,
xieValGeomNearestNeighbor,
NULL);
++idx;
/* export */
XieFloExportDrawable(&photoElement[idx], idx, aDest, aGC,
(aDX - aSX),
(aDY - aSY));
#ifdef DEBUG_XIE
printf("export to %d, %d (%dx%d)\n", (aDX - aSX), (aDY - aSY),
aDWidth, aDHeight);
#endif
++idx;
/* do the scale thing baby */
XieExecuteImmediate(display, gPhotospace, 1, PR_FALSE, photoElement, idx);
/*
XieFreePhotofloGraph(photoElement, 3);
*/
}
PRBool
DrawScaledImageXIE(Display *display,
Drawable aDest,
GC aGC,
Drawable aSrc,
PRInt32 aSrcWidth,
PRInt32 aSrcHeight,
PRInt32 aSX,
PRInt32 aSY,
PRInt32 aSWidth,
PRInt32 aSHeight,
PRInt32 aDX,
PRInt32 aDY,
PRInt32 aDWidth,
PRInt32 aDHeight)
{
#ifdef DEBUG_XIE
printf("DrawScaledImageXIE\n");
#endif
if (!useXIE) {
#ifdef DEBUG_XIE
fprintf(stderr, "useXIE is false.\n");
#endif
return PR_FALSE;
}
if (!inited) {
XieExtensionInfo *info;
if (useXIE) {
char *text = PR_GetEnv("MOZ_DISABLE_XIE");
if (text) {
#ifdef DEBUG_XIE
fprintf(stderr, "MOZ_DISABLE_XIE set, disabling use of XIE.\n");
#endif
useXIE = PR_FALSE;
return PR_FALSE;
}
}
if (!XieInitialize(display, &info)) {
useXIE = PR_FALSE;
return PR_FALSE;
}
inited = PR_TRUE;
/* create the photospace (we only need to do this once) */
gPhotospace = XieCreatePhotospace(display);
photoElement = XieAllocatePhotofloGraph(3);
/* XXX we want to destroy this at shutdown
XieDestroyPhotospace(display, photospace);
*/
}
/* run the flo on the image to get a the scaled image */
DoFlo(display, aDest, aGC, aSrc,
aSrcWidth, aSrcHeight,
aSX, aSY, aSWidth, aSHeight,
aDX, aDY, aDWidth, aDHeight);
return PR_TRUE;
}
#endif

View File

@ -1,64 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:ts=2:et:sw=2:
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "prtypes.h"
#include <X11/Xlib.h>
PR_BEGIN_EXTERN_C
#ifdef HAVE_XIE
PRBool
DrawScaledImageXIE(Display *display,
Drawable aDest,
GC aGC,
Drawable aSrc,
PRInt32 aSrcWidth,
PRInt32 aSrcHeight,
PRInt32 aSX,
PRInt32 aSY,
PRInt32 aSWidth,
PRInt32 aSHeight,
PRInt32 aDX,
PRInt32 aDY,
PRInt32 aDWidth,
PRInt32 aDHeight);
#endif
PR_END_EXTERN_C

File diff suppressed because it is too large Load Diff

View File

@ -1,140 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
* Julien Lafon <julien.lafon@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextSpecXlib_h___
#define nsDeviceContextSpecXlib_h___
#include "nsIDeviceContextSpec.h"
#include "nsIPrintSettings.h"
#include "nsIPrintOptions.h"
#include "nsVoidArray.h"
#include "nsCOMPtr.h"
#ifdef USE_POSTSCRIPT
#include "nsIDeviceContextSpecPS.h"
#endif /* USE_POSTSCRIPT */
#ifdef USE_XPRINT
#include "nsIDeviceContextSpecXPrint.h"
#endif /* USE_XPRINT */
#include "nsCRT.h" /* should be <limits.h>? */
#define NS_PORTRAIT 0
#define NS_LANDSCAPE 1
typedef enum
{
pmInvalid = 0,
pmXprint,
pmPostScript
} PrintMethod;
class nsDeviceContextSpecXlib : public nsIDeviceContextSpec
#ifdef USE_POSTSCRIPT
, public nsIDeviceContextSpecPS
#endif /* USE_POSTSCRIPT */
#ifdef USE_XPRINT
, public nsIDeviceContextSpecXp
#endif /* USE_XPRINT */
{
public:
nsDeviceContextSpecXlib();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIWidget *aWidget, nsIPrintSettings* aPS, PRBool aIsPrintPreview);
NS_IMETHOD ClosePrintManager();
NS_IMETHOD GetToPrinter(PRBool &aToPrinter);
NS_IMETHOD GetIsPrintPreview(PRBool &aIsPPreview);
NS_IMETHOD GetPrinterName ( const char **aPrinter );
NS_IMETHOD GetCopies ( int &aCopies );
NS_IMETHOD GetFirstPageFirst(PRBool &aFpf);
NS_IMETHOD GetGrayscale(PRBool &aGrayscale);
NS_IMETHOD GetTopMargin(float &value);
NS_IMETHOD GetBottomMargin(float &value);
NS_IMETHOD GetLeftMargin(float &value);
NS_IMETHOD GetRightMargin(float &value);
NS_IMETHOD GetCommand(const char **aCommand);
NS_IMETHOD GetPath (const char **aPath);
NS_IMETHOD GetLandscape (PRBool &aLandscape);
NS_IMETHOD GetUserCancelled(PRBool &aCancel);
NS_IMETHOD GetPrintMethod(PrintMethod &aMethod);
static nsresult GetPrintMethod(const char *aPrinter, PrintMethod &aMethod);
NS_IMETHOD GetPageSizeInTwips(PRInt32 *aWidth, PRInt32 *aHeight);
NS_IMETHOD GetPaperName(const char **aPaperName);
NS_IMETHOD GetPlexName(const char **aPlexName);
NS_IMETHOD GetResolutionName(const char **aResolutionName);
NS_IMETHOD GetColorspace(const char **aColorspace);
NS_IMETHOD GetDownloadFonts(PRBool &aDownloadFonts);
virtual ~nsDeviceContextSpecXlib();
protected:
nsCOMPtr<nsIPrintSettings> mPrintSettings;
PRPackedBool mToPrinter : 1; /* If PR_TRUE, print to printer */
PRPackedBool mIsPPreview : 1; /* If PR_TRUE, is print preview */
PRPackedBool mFpf : 1; /* If PR_TRUE, first page first */
PRPackedBool mGrayscale : 1; /* If PR_TRUE, print grayscale */
PRPackedBool mDownloadFonts : 1; /* If PR_TRUE, download fonts to printer */
PRPackedBool mCancel : 1; /* If PR_TRUE, user cancelled */
int mOrientation; /* Orientation e.g. Portrait */
char mCommand[PATH_MAX]; /* Print command e.g., lpr */
char mPath[PATH_MAX]; /* If toPrinter = PR_FALSE, dest file */
char mPrinter[256]; /* Printer name */
char mPaperName[256]; /* Printer name */
char mPlexName[256]; /* Plex mode name */
char mResolutionName[256];/* Resolution name */
char mColorspace[256]; /* Colorspace */
int mCopies; /* number of copies */
float mLeft; /* left margin */
float mRight; /* right margin */
float mTop; /* top margin */
float mBottom; /* bottom margin */
};
//-------------------------------------------------------------------------
// Printer Enumerator
//-------------------------------------------------------------------------
class nsPrinterEnumeratorXlib : public nsIPrinterEnumerator
{
public:
nsPrinterEnumeratorXlib();
NS_DECL_ISUPPORTS
NS_DECL_NSIPRINTERENUMERATOR
};
#endif /* !nsDeviceContextSpecXlib_h___ */

View File

@ -1,66 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextX_h__
#define nsDeviceContextX_h__
#include "nsDeviceContext.h"
#include "xlibrgb.h"
class nsFontMetricsXlibContext;
class nsRenderingContextXlibContext;
/* common baseclass for |nsDeviceContextXlib| and |nsDeviceContextXp| */
class nsDeviceContextX : public DeviceContextImpl
{
public:
nsDeviceContextX()
: DeviceContextImpl()
{
}
virtual ~nsDeviceContextX() {}
NS_IMETHOD GetXlibRgbHandle(XlibRgbHandle *&aHandle) = 0;
virtual void GetFontMetricsContext(nsFontMetricsXlibContext *&aContext) = 0;
virtual void GetRCContext(nsRenderingContextXlibContext *&aContext) = 0;
};
#endif /* !nsDeviceContextX_h__ */

View File

@ -1,528 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
* Peter Hartshorn <peter@igelaus.com.au>
* Ken Faulkner <faulkner@igelaus.com.au>
* Tony Tsui <tony@igelaus.com.au>
* Tim Copperfield <timecop@network.email.ne.jp>
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsRenderingContextXlib.h"
#include "nsDrawingSurfaceXlib.h"
#include "nsDeviceContextXlib.h"
#include "nsIPref.h"
#include "nsIServiceManager.h"
#include "nsGfxCIID.h"
#include "nspr.h"
#include "nsFontMetricsXlib.h"
#include "xlibrgb.h"
#include <X11/Xatom.h>
#include "nsDeviceContextSpecXlib.h"
#ifdef USE_POSTSCRIPT
#include "nsGfxPSCID.h"
#include "nsIDeviceContextPS.h"
#endif /* USE_POSTSCRIPT */
#ifdef USE_XPRINT
#include "nsGfxXPrintCID.h"
#include "nsIDeviceContextXPrint.h"
#endif /* USE_XPRINT */
#define XLIB_DEFAULT_FONT1 "-*-helvetica-medium-r-*--*-120-*-*-*-*-iso8859-1"
#define XLIB_DEFAULT_FONT2 "-*-fixed-medium-r-*-*-*-120-*-*-*-*-*-*"
#ifdef PR_LOGGING
static PRLogModuleInfo *DeviceContextXlibLM = PR_NewLogModule("DeviceContextXlib");
#endif /* PR_LOGGING */
/* global default font handle */
static XFontStruct *mDefaultFont = nsnull;
nsDeviceContextXlib::nsDeviceContextXlib()
: nsDeviceContextX()
{
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::nsDeviceContextXlib()\n"));
mTwipsToPixels = 1.0;
mPixelsToTwips = 1.0;
mNumCells = 0;
mSurface = nsnull;
mDisplay = nsnull;
mScreen = nsnull;
mVisual = nsnull;
mDepth = 0;
mWidthFloat = 0.0f;
mHeightFloat = 0.0f;
mWidth = -1;
mHeight = -1;
mXlibRgbHandle = xxlib_find_handle(XXLIBRGB_DEFAULT_HANDLE);
if (!mXlibRgbHandle)
abort();
mContextCounter++;
}
nsDeviceContextXlib::~nsDeviceContextXlib()
{
nsIDrawingSurfaceXlib *surf = NS_STATIC_CAST(nsIDrawingSurfaceXlib *, mSurface);
NS_IF_RELEASE(surf);
mSurface = nsnull;
mContextCounter--;
if (mContextCounter == 0)
{
DeleteRenderingContextXlibContext(mRCContext);
DeleteFontMetricsXlibContext(mFontMetricsContext);
mRCContext = nsnull;
mFontMetricsContext = nsnull;
}
}
nsFontMetricsXlibContext *nsDeviceContextXlib::mFontMetricsContext = nsnull;
nsRenderingContextXlibContext *nsDeviceContextXlib::mRCContext = nsnull;
int nsDeviceContextXlib::mContextCounter = 0;
NS_IMETHODIMP nsDeviceContextXlib::Init(nsNativeWidget aNativeWidget)
{
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::Init()\n"));
mWidget = aNativeWidget;
mDisplay = xxlib_rgb_get_display(mXlibRgbHandle);
mScreen = xxlib_rgb_get_screen(mXlibRgbHandle);
mVisual = xxlib_rgb_get_visual(mXlibRgbHandle);
mDepth = xxlib_rgb_get_depth(mXlibRgbHandle);
if (!mDefaultFont)
mDefaultFont = XLoadQueryFont(mDisplay, XLIB_DEFAULT_FONT1);
if (!mDefaultFont)
mDefaultFont = XLoadQueryFont(mDisplay, XLIB_DEFAULT_FONT2);
#ifdef DEBUG
static PRBool once = PR_TRUE;
if (once)
{
once = PR_FALSE;
printf("nsDeviceContextXlib::Init(dpy=%p screen=%p visual=%p depth=%d)\n",
mDisplay,
mScreen,
mVisual,
mDepth);
}
#endif /* DEBUG */
return CommonInit();
}
nsresult
nsDeviceContextXlib::CommonInit(void)
{
nsresult rv = NS_OK;;
// FIXME: PeterH
// This was set to 100 dpi, then later on in the function is was changed
// to a default of 96dpi IF we had a preference component. We need to
// find a way to get the actual server dpi for a comparison ala GTK.
static nscoord dpi = 96;
static int initialized = 0;
if (!initialized) {
initialized = 1;
nsresult res;
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID, &res));
if (NS_SUCCEEDED(res) && prefs) {
PRInt32 intVal = 96;
res = prefs->GetIntPref("layout.css.dpi", &intVal);
if (NS_SUCCEEDED(res)) {
if (intVal) {
dpi = intVal;
}
else {
// Compute dpi of display
float screenWidth = float(XWidthOfScreen(mScreen));
float screenWidthIn = float(XWidthMMOfScreen(mScreen)) / 25.4f;
dpi = nscoord(screenWidth / screenWidthIn);
}
}
}
}
// Do extra rounding (based on GTK). KenF
mPixelsToTwips = float(NSToIntRound(float(NSIntPointsToTwips(72)) / float(dpi)));
mTwipsToPixels = 1.0f / mPixelsToTwips;
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("GFX: dpi=%d t2p=%g p2t=%g\n", dpi, mTwipsToPixels, mPixelsToTwips));
mWidthFloat = (float) XWidthOfScreen(mScreen);
mHeightFloat = (float) XHeightOfScreen(mScreen);
DeviceContextImpl::CommonInit();
if (!mFontMetricsContext)
{
rv = CreateFontMetricsXlibContext(this, PR_FALSE, &mFontMetricsContext);
if (NS_FAILED(rv))
return rv;
}
if (!mRCContext)
{
rv = CreateRenderingContextXlibContext(this, &mRCContext);
if (NS_FAILED(rv))
return rv;
}
return rv;
}
NS_IMETHODIMP nsDeviceContextXlib::CreateRenderingContext(nsIRenderingContext *&aContext)
{
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::CreateRenderingContext()\n"));
#ifdef NS_PRINT_PREVIEW
/* Defer to Alt when there is one */
if (mAltDC && ((mUseAltDC & kUseAltDCFor_CREATERC_PAINT) || (mUseAltDC & kUseAltDCFor_CREATERC_REFLOW))) {
return mAltDC->CreateRenderingContext(aContext);
}
#endif /* NS_PRINT_PREVIEW */
nsIRenderingContext *context;
nsDrawingSurfaceXlibImpl *surface = nsnull;
nsresult rv;
context = new nsRenderingContextXlib();
if (nsnull != context) {
NS_ADDREF(context);
surface = new nsDrawingSurfaceXlibImpl();
if (nsnull != surface) {
xGC *gc = new xGC(mDisplay, (Drawable)mWidget, 0, nsnull);
rv = surface->Init(mXlibRgbHandle,
(Drawable)mWidget,
gc);
if (NS_SUCCEEDED(rv)) {
rv = context->Init(this, surface);
}
}
else {
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
else {
rv = NS_ERROR_OUT_OF_MEMORY;
}
if (NS_FAILED(rv)) {
NS_IF_RELEASE(context);
}
aContext = context;
return rv;
}
NS_IMETHODIMP nsDeviceContextXlib::CreateRenderingContextInstance(nsIRenderingContext *&aContext)
{
nsCOMPtr<nsIRenderingContext> renderingContext = new nsRenderingContextXlib();
if (!renderingContext)
return NS_ERROR_OUT_OF_MEMORY;
aContext = renderingContext;
NS_ADDREF(aContext);
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextXlib::SupportsNativeWidgets(PRBool &aSupportsWidgets)
{
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::SupportsNativeWidgets()\n"));
aSupportsWidgets = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextXlib::GetSystemFont(nsSystemFontID anID, nsFont *aFont) const
{
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::GetSystemFont()\n"));
switch (anID) {
case eSystemFont_Caption: // css2
case eSystemFont_Icon:
case eSystemFont_Menu:
case eSystemFont_MessageBox:
case eSystemFont_SmallCaption:
case eSystemFont_StatusBar:
case eSystemFont_Window: // css3
case eSystemFont_Document:
case eSystemFont_Workspace:
case eSystemFont_Desktop:
case eSystemFont_Info:
case eSystemFont_Dialog:
case eSystemFont_Button:
case eSystemFont_PullDownMenu:
case eSystemFont_List:
case eSystemFont_Field:
case eSystemFont_Tooltips: // moz
case eSystemFont_Widget:
aFont->style = NS_FONT_STYLE_NORMAL;
aFont->weight = NS_FONT_WEIGHT_NORMAL;
aFont->decorations = NS_FONT_DECORATION_NONE;
if (!mDefaultFont)
return NS_ERROR_FAILURE;
else
{
char *fontName = nsnull;
unsigned long pr = 0;
::XGetFontProperty(mDefaultFont, XA_FULL_NAME, &pr);
if(pr)
{
fontName = XGetAtomName(mDisplay, pr);
aFont->name.AssignWithConversion(fontName);
::XFree(fontName);
}
pr = 0;
::XGetFontProperty(mDefaultFont, XA_WEIGHT, &pr);
if ( pr > 10 )
aFont->weight = NS_FONT_WEIGHT_BOLD;
pr = 0;
Atom pixelSizeAtom = ::XInternAtom(mDisplay, "PIXEL_SIZE", 0);
::XGetFontProperty(mDefaultFont, pixelSizeAtom, &pr);
if( pr )
aFont->size = NSIntPixelsToTwips(pr, mPixelsToTwips);
pr = 0;
::XGetFontProperty(mDefaultFont, XA_ITALIC_ANGLE, &pr );
if( pr )
aFont->style = NS_FONT_STYLE_ITALIC;
pr = 0;
::XGetFontProperty(mDefaultFont, XA_UNDERLINE_THICKNESS, &pr);
if( pr )
aFont->decorations = NS_FONT_DECORATION_UNDERLINE;
}
break;
}
aFont->systemFont = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextXlib::CheckFontExistence(const nsString& aFontName)
{
return nsFontMetricsXlib::FamilyExists(mFontMetricsContext, aFontName);
}
NS_IMETHODIMP nsDeviceContextXlib::GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight)
{
#ifdef NS_PRINT_PREVIEW
/* Defer to Alt when there is one */
if (mAltDC && (mUseAltDC & kUseAltDCFor_SURFACE_DIM)) {
return mAltDC->GetDeviceSurfaceDimensions(aWidth, aHeight);
}
#endif /* NS_PRINT_PREVIEW */
if (mWidth == -1)
mWidth = NSToIntRound(mWidthFloat * mDevUnitsToAppUnits);
if (mHeight == -1)
mHeight = NSToIntRound(mHeightFloat * mDevUnitsToAppUnits);
aWidth = mWidth;
aHeight = mHeight;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextXlib::GetRect(nsRect &aRect)
{
PRInt32 width, height;
nsresult rv;
rv = GetDeviceSurfaceDimensions(width, height);
aRect.x = 0;
aRect.y = 0;
aRect.width = width;
aRect.height = height;
return rv;
}
NS_IMETHODIMP nsDeviceContextXlib::GetClientRect(nsRect &aRect)
{
PRInt32 width, height;
nsresult rv;
rv = GetDeviceSurfaceDimensions(width, height);
aRect.x = 0;
aRect.y = 0;
aRect.width = width;
aRect.height = height;
return rv;
}
NS_IMETHODIMP nsDeviceContextXlib::GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext)
{
nsresult rv;
PrintMethod method;
nsDeviceContextSpecXlib *spec = NS_STATIC_CAST(nsDeviceContextSpecXlib *, aDevice);
rv = spec->GetPrintMethod(method);
if (NS_FAILED(rv))
return rv;
#ifdef USE_XPRINT
if (method == pmXprint) { // XPRINT
static NS_DEFINE_CID(kCDeviceContextXp, NS_DEVICECONTEXTXP_CID);
nsCOMPtr<nsIDeviceContextXp> dcxp(do_CreateInstance(kCDeviceContextXp, &rv));
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create Xp Device context.");
if (NS_FAILED(rv))
return NS_ERROR_GFX_COULD_NOT_LOAD_PRINT_MODULE;
rv = dcxp->SetSpec(aDevice);
if (NS_FAILED(rv))
return rv;
rv = dcxp->InitDeviceContextXP((nsIDeviceContext*)aContext,
(nsIDeviceContext*)this);
if (NS_FAILED(rv))
return rv;
rv = dcxp->QueryInterface(NS_GET_IID(nsIDeviceContext),
(void **)&aContext);
return rv;
}
else
#endif /* USE_XPRINT */
#ifdef USE_POSTSCRIPT
if (method == pmPostScript) { // PostScript
// default/PS
static NS_DEFINE_CID(kCDeviceContextPS, NS_DEVICECONTEXTPS_CID);
// Create a Postscript device context
nsCOMPtr<nsIDeviceContextPS> dcps(do_CreateInstance(kCDeviceContextPS, &rv));
NS_ASSERTION(NS_SUCCEEDED(rv), "Couldn't create PS Device context.");
if (NS_FAILED(rv))
return NS_ERROR_GFX_COULD_NOT_LOAD_PRINT_MODULE;
rv = dcps->SetSpec(aDevice);
if (NS_FAILED(rv))
return rv;
rv = dcps->InitDeviceContextPS((nsIDeviceContext*)aContext,
(nsIDeviceContext*)this);
if (NS_FAILED(rv))
return rv;
rv = dcps->QueryInterface(NS_GET_IID(nsIDeviceContext),
(void **)&aContext);
return rv;
}
#endif /* USE_POSTSCRIPT */
NS_WARNING("no print module created.");
return NS_ERROR_UNEXPECTED;
}
NS_IMETHODIMP nsDeviceContextXlib::BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage)
{
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::BeginDocument()\n"));
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextXlib::EndDocument(void)
{
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::EndDocument()\n"));
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextXlib::AbortDocument(void)
{
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::EndDocument()\n"));
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextXlib::BeginPage(void)
{
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::BeginPage()\n"));
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextXlib::EndPage(void)
{
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::EndPage()\n"));
return NS_OK;
}
class nsFontCacheXlib : public nsFontCache
{
public:
/* override DeviceContextImpl::CreateFontCache() */
virtual nsresult CreateFontMetricsInstance(nsIFontMetrics** aResult);
};
nsresult nsFontCacheXlib::CreateFontMetricsInstance(nsIFontMetrics** aResult)
{
NS_PRECONDITION(aResult, "null out param");
nsIFontMetrics *fm = new nsFontMetricsXlib();
if (!fm)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(fm);
*aResult = fm;
return NS_OK;
}
/* override DeviceContextImpl::CreateFontCache() */
NS_IMETHODIMP nsDeviceContextXlib::CreateFontCache()
{
mFontCache = new nsFontCacheXlib();
if (nsnull == mFontCache) {
return NS_ERROR_OUT_OF_MEMORY;
}
return mFontCache->Init(this);
}

View File

@ -1,115 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* David Smith <david@igelaus.com.au>
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDeviceContextXlib_h__
#define nsDeviceContextXlib_h__
#include "nsDeviceContextX.h"
#include "nsRenderingContextXlib.h"
class nsDeviceContextXlib : public nsDeviceContextX
{
public:
nsDeviceContextXlib();
NS_IMETHOD Init(nsNativeWidget aNativeWidget);
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext);
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext)
{return (DeviceContextImpl::CreateRenderingContext(aView, aContext)); }
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext)
{return (DeviceContextImpl::CreateRenderingContext(aWidget, aContext)); }
NS_IMETHOD CreateRenderingContext(nsIDrawingSurface* aSurface, nsIRenderingContext *&aContext)
{return (DeviceContextImpl::CreateRenderingContext(aSurface, aContext));}
NS_IMETHOD CreateRenderingContextInstance(nsIRenderingContext *&aContext);
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets);
NS_IMETHOD GetSystemFont(nsSystemFontID anID, nsFont *aFont) const;
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
NS_IMETHOD GetRect(nsRect &aRect);
NS_IMETHOD GetClientRect(nsRect &aRect);
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
nsIDeviceContext *&aContext);
NS_IMETHOD BeginDocument(PRUnichar * aTitle, PRUnichar* aPrintToFileName, PRInt32 aStartPage, PRInt32 aEndPage);
NS_IMETHOD EndDocument(void);
NS_IMETHOD AbortDocument(void);
NS_IMETHOD BeginPage(void);
NS_IMETHOD EndPage(void);
NS_IMETHOD CreateFontCache();
NS_IMETHOD GetXlibRgbHandle(XlibRgbHandle *&aHandle)
{ aHandle = mXlibRgbHandle; return NS_OK; }
XlibRgbHandle *GetXlibRgbHandle() { return mXlibRgbHandle; }
NS_IMETHOD GetDepth( PRUint32 &depth ) { depth = (PRUint32)mDepth; return NS_OK; }
virtual void GetFontMetricsContext(nsFontMetricsXlibContext *&aContext) { aContext = mFontMetricsContext; };
virtual void GetRCContext(nsRenderingContextXlibContext *&aContext) { aContext = mRCContext; };
protected:
virtual ~nsDeviceContextXlib();
private:
nsresult CommonInit(void);
PRBool mWriteable;
PRUint32 mNumCells;
nsIDrawingSurface* mSurface;
XlibRgbHandle *mXlibRgbHandle;
Display * mDisplay;
Screen * mScreen;
Visual * mVisual;
int mDepth;
static nsFontMetricsXlibContext *mFontMetricsContext;
static nsRenderingContextXlibContext *mRCContext;
static int mContextCounter;
float mWidthFloat;
float mHeightFloat;
PRInt32 mWidth;
PRInt32 mHeight;
};
#endif /* !nsDeviceContextXlib_h__ */

View File

@ -1,302 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* David Smith <david@igelaus.com.au>
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsDrawingSurfaceXlib.h"
#include "prlog.h"
#include "nsGCCache.h"
#include "xlibrgb.h" // for xxlib_rgb_get_visual_info
#ifdef PR_LOGGING
static PRLogModuleInfo *DrawingSurfaceXlibLM = PR_NewLogModule("DrawingSurfaceXlib");
#endif /* PR_LOGGING */
nsDrawingSurfaceXlibImpl::nsDrawingSurfaceXlibImpl() :
nsIDrawingSurfaceXlib(),
mXlibRgbHandle(nsnull),
mDisplay(nsnull),
mScreen(nsnull),
mVisual(nsnull),
mDepth(0),
mGC(nsnull),
mDrawable(None),
mImage(nsnull),
// set up lock info
mLockX(0),
mLockY(0),
mLockWidth(0),
mLockHeight(0),
mLockFlags(0),
mLocked(PR_FALSE),
// dimensions...
mWidth(0),
mHeight(0),
mIsOffscreen(PR_FALSE)
{
PR_LOG(DrawingSurfaceXlibLM, PR_LOG_DEBUG, ("nsDrawingSurfaceXlibImpl::nsDrawingSurfaceXlibImpl()\n"));
}
nsDrawingSurfaceXlibImpl::~nsDrawingSurfaceXlibImpl()
{
PR_LOG(DrawingSurfaceXlibLM, PR_LOG_DEBUG, ("nsDrawingSurfaceXlibImpl::~nsDrawingSurfaceXlibImpl()\n"));
// if it's been labeled as destroy, it's a pixmap.
if (mDrawable!=None && mIsOffscreen) {
XFreePixmap(mDisplay, mDrawable);
}
if (mImage) {
XDestroyImage(mImage);
}
// We are freeing the GC here now [See nsWidget::CreateGC()]
if(mGC) {
mGC->Release();
mGC = nsnull;
}
}
NS_IMPL_ISUPPORTS1(nsDrawingSurfaceXlibImpl, nsIDrawingSurfaceXlib)
NS_IMETHODIMP
nsDrawingSurfaceXlibImpl::Init(XlibRgbHandle *aXlibRgbHandle,
Drawable aDrawable,
xGC *aGC)
{
PR_LOG(DrawingSurfaceXlibLM, PR_LOG_DEBUG, ("nsDrawingSurfaceXlibImpl::Init()\n"));
mXlibRgbHandle = aXlibRgbHandle;
mDrawable = aDrawable;
CommonInit();
if (mGC)
mGC->Release();
mGC = aGC;
mGC->AddRef();
mIsOffscreen = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsDrawingSurfaceXlibImpl::Init(XlibRgbHandle *aXlibRgbHandle,
xGC * aGC,
PRUint32 aWidth,
PRUint32 aHeight,
PRUint32 aFlags)
{
mXlibRgbHandle = aXlibRgbHandle;
mWidth = aWidth;
mHeight = aHeight;
mLockFlags = aFlags;
CommonInit();
if (mGC)
mGC->Release();
mGC = aGC;
mGC->AddRef();
mIsOffscreen = PR_TRUE;
mDrawable = XCreatePixmap(mDisplay,
XRootWindow(mDisplay, XScreenNumberOfScreen(mScreen)),
mWidth,
mHeight,
mDepth);
return (mDrawable!=None)?(NS_OK):(NS_ERROR_FAILURE);
}
void
nsDrawingSurfaceXlibImpl::CommonInit()
{
mDisplay = xxlib_rgb_get_display(mXlibRgbHandle);
mScreen = xxlib_rgb_get_screen(mXlibRgbHandle);
mVisual = xxlib_rgb_get_visual(mXlibRgbHandle);
mDepth = xxlib_rgb_get_depth(mXlibRgbHandle);
XVisualInfo *x_visual_info = xxlib_rgb_get_visual_info(mXlibRgbHandle);
NS_ASSERTION(nsnull != x_visual_info, "Visual info from xlibrgb is null.");
if (x_visual_info)
{
mPixFormat.mRedMask = x_visual_info->red_mask;
mPixFormat.mGreenMask = x_visual_info->green_mask;;
mPixFormat.mBlueMask = x_visual_info->blue_mask;;
mPixFormat.mAlphaMask = 0;
mPixFormat.mRedCount = ConvertMaskToCount(x_visual_info->red_mask);
mPixFormat.mGreenCount = ConvertMaskToCount(x_visual_info->green_mask);
mPixFormat.mBlueCount = ConvertMaskToCount(x_visual_info->blue_mask);;
mPixFormat.mAlphaCount = 0;
mPixFormat.mRedShift = GetShiftForMask(x_visual_info->red_mask);
mPixFormat.mGreenShift = GetShiftForMask(x_visual_info->green_mask);
mPixFormat.mBlueShift = GetShiftForMask(x_visual_info->blue_mask);
mPixFormat.mAlphaShift = 0;
}
}
NS_IMETHODIMP
nsDrawingSurfaceXlibImpl::Lock(PRInt32 aX, PRInt32 aY,
PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride,
PRInt32 *aWidthBytes, PRUint32 aFlags)
{
PR_LOG(DrawingSurfaceXlibLM, PR_LOG_DEBUG, ("nsDrawingSurfaceXlibImpl::Lock()\n"));
if (mLocked)
{
NS_ASSERTION(0, "nested lock attempt");
return NS_ERROR_FAILURE;
}
if (aWidth == 0 || aHeight == 0)
{
NS_ASSERTION(0, "Width or Height is 0");
return NS_ERROR_FAILURE;
}
mLocked = PR_TRUE;
mLockX = aX;
mLockY = aY;
mLockWidth = aWidth;
mLockHeight = aHeight;
mLockFlags = aFlags;
mImage = XGetImage(mDisplay, mDrawable,
mLockX, mLockY,
mLockWidth, mLockHeight,
0xFFFFFFFF,
ZPixmap);
if (!mImage) {
mLocked = PR_FALSE;
return NS_ERROR_FAILURE;
}
*aBits = mImage->data;
*aWidthBytes = mImage->bytes_per_line;
*aStride = mImage->bytes_per_line;
return NS_OK;
}
NS_IMETHODIMP
nsDrawingSurfaceXlibImpl::Unlock(void)
{
PR_LOG(DrawingSurfaceXlibLM, PR_LOG_DEBUG, ("nsDrawingSurfaceXlibImpl::UnLock()\n"));
if (!mLocked) {
NS_ASSERTION(0, "attempting to unlock an DS that isn't locked");
return NS_ERROR_FAILURE;
}
// If the lock was not read only, put the bits back on the pixmap
if (!(mLockFlags & NS_LOCK_SURFACE_READ_ONLY)) {
XPutImage(mDisplay, mDrawable, *mGC, mImage,
0, 0, mLockX, mLockY,
mLockWidth, mLockHeight);
}
if (mImage) {
XDestroyImage(mImage);
mImage = nsnull;
}
mLocked = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsDrawingSurfaceXlibImpl::GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight)
{
*aWidth = mWidth;
*aHeight = mHeight;
return NS_OK;
}
NS_IMETHODIMP
nsDrawingSurfaceXlibImpl::IsOffscreen(PRBool *aOffScreen)
{
*aOffScreen = mIsOffscreen;
return NS_OK;
}
NS_IMETHODIMP
nsDrawingSurfaceXlibImpl::IsPixelAddressable(PRBool *aAddressable)
{
*aAddressable = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsDrawingSurfaceXlibImpl::GetPixelFormat(nsPixelFormat *aFormat)
{
*aFormat = mPixFormat;
return NS_OK;
}
PRUint8
nsDrawingSurfaceXlibImpl::ConvertMaskToCount(unsigned long val)
{
PRUint8 retval = 0;
PRUint8 cur_bit = 0;
// walk through the number, incrementing the value if
// the bit in question is set.
while (cur_bit < (sizeof(unsigned long) * 8)) {
if ((val >> cur_bit) & 0x1) {
retval++;
}
cur_bit++;
}
return retval;
}
PRUint8
nsDrawingSurfaceXlibImpl::GetShiftForMask(unsigned long val)
{
PRUint8 cur_bit = 0;
// walk through the number, looking for the first 1
while (cur_bit < (sizeof(unsigned long) * 8)) {
if ((val >> cur_bit) & 0x1) {
return cur_bit;
}
cur_bit++;
}
return cur_bit;
}

View File

@ -1,136 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDrawingSurfaceXlib_h__
#define nsDrawingSurfaceXlib_h__
#include "nsIDrawingSurface.h"
#include "nsGCCache.h"
#include "xlibrgb.h"
/* common interface for both nsDrawingSurfaceXlibImpl (drawing surface for
* normal displays) and nsXPrintContext (drawing surface for printers)
*/
class nsIDrawingSurfaceXlib : public nsIDrawingSurface
{
public:
NS_IMETHOD Lock(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
PRUint32 aFlags) = 0;
NS_IMETHOD Unlock(void) = 0;
NS_IMETHOD GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight) = 0;
NS_IMETHOD IsOffscreen(PRBool *aOffScreen) = 0;
NS_IMETHOD IsPixelAddressable(PRBool *aAddressable) = 0;
NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat) = 0;
NS_IMETHOD GetDrawable(Drawable &aDrawable) = 0;
NS_IMETHOD GetXlibRgbHandle(XlibRgbHandle *&aHandle) = 0;
NS_IMETHOD GetGC(xGC *&aXGC) = 0;
virtual Drawable GetDrawable() = 0;
};
class nsDrawingSurfaceXlibImpl : public nsIDrawingSurfaceXlib
{
public:
nsDrawingSurfaceXlibImpl();
virtual ~nsDrawingSurfaceXlibImpl();
NS_DECL_ISUPPORTS
NS_IMETHOD Lock(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
PRUint32 aFlags);
NS_IMETHOD Unlock(void);
NS_IMETHOD GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight);
NS_IMETHOD IsOffscreen(PRBool *aOffScreen);
NS_IMETHOD IsPixelAddressable(PRBool *aAddressable);
NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat);
NS_IMETHOD Init (XlibRgbHandle *aHandle,
Drawable aDrawable,
xGC * aGC);
NS_IMETHOD Init (XlibRgbHandle *aHandle,
xGC * aGC,
PRUint32 aWidth,
PRUint32 aHeight,
PRUint32 aFlags);
NS_IMETHOD GetDrawable(Drawable &aDrawable) { aDrawable = mDrawable; return NS_OK; }
NS_IMETHOD GetXlibRgbHandle(XlibRgbHandle *&aHandle) { aHandle = mXlibRgbHandle; return NS_OK; }
NS_IMETHOD GetGC(xGC *&aXGC) { mGC->AddRef(); aXGC = mGC; return NS_OK; }
virtual Drawable GetDrawable() { return mDrawable; }
private:
void CommonInit();
XlibRgbHandle *mXlibRgbHandle;
Display * mDisplay;
Screen * mScreen;
Visual * mVisual;
int mDepth;
xGC *mGC;
Drawable mDrawable;
XImage * mImage;
nsPixelFormat mPixFormat;
// for locking
PRInt32 mLockX;
PRInt32 mLockY;
PRUint32 mLockWidth;
PRUint32 mLockHeight;
PRUint32 mLockFlags;
PRBool mLocked;
// dimensions
PRUint32 mWidth;
PRUint32 mHeight;
// are we offscreen
PRBool mIsOffscreen;
private:
static PRUint8 ConvertMaskToCount(unsigned long val);
static PRUint8 GetShiftForMask(unsigned long val);
};
#endif /* !nsDrawingSurfaceXlib_h__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,535 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Tony Tsui <tony@igelaus.com.au>
* Tim Copperfield <timecop@network.email.ne.jp>
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsFontMetricsXlib_h__
#define nsFontMetricsXlib_h__
#include "nsIFontMetrics.h"
#include "nsIFontEnumerator.h"
#include "nsIDeviceContext.h"
#include "nsDeviceContextXlib.h"
#include "nsFont.h"
#include "nsString.h"
#include "nsUnitConversion.h"
#include "nsCRT.h"
#include "nsCOMPtr.h"
#include "nsRenderingContextXlib.h"
#include "nsICharRepresentable.h"
#include "nsCompressedCharMap.h"
/* Undefine some CPP symbols which wrap not-yet-implemented code */
#undef MOZ_ENABLE_FREETYPE2
#undef USE_AASB
#undef USE_X11SHARED_CODE
#ifdef USE_X11SHARED_CODE
/* XXX: I wish I would use the code in gfx/src/x11shared/ - unfortunately
* it is full of GDK/GTK+ dependices which makes it impossible to use it
* yet... ;-(
*/
#error not implemented yet
#include "nsXFontNormal.h"
#else
class nsX11FontNormal {
public:
nsX11FontNormal(Display *, XFontStruct *);
~nsX11FontNormal();
void DrawText8(Drawable Drawable, GC GC, PRInt32, PRInt32,
const char *, PRUint32);
void DrawText16(Drawable Drawable, GC GC, PRInt32, PRInt32,
const XChar2b *, PRUint32);
PRBool GetXFontProperty(Atom, unsigned long *);
XFontStruct *GetXFontStruct();
PRBool LoadFont();
void TextExtents8(const char *, PRUint32, PRInt32*, PRInt32*,
PRInt32*, PRInt32*, PRInt32*);
void TextExtents16(const XChar2b *, PRUint32, PRInt32*, PRInt32*,
PRInt32*, PRInt32*, PRInt32*);
PRInt32 TextWidth8(const char *, PRUint32);
PRInt32 TextWidth16(const XChar2b *, PRUint32);
void UnloadFont();
inline PRBool IsSingleByte() { return mIsSingleByte; };
protected:
Display *mDisplay; /* Track |Display *| for this font
* (Xlib gfx supports multiple displays) */
XFontStruct *mXFont;
PRBool mIsSingleByte;
};
/* XXX: Silly class rename hack to avoid issues with StaticBuild code and to
* keep the source clean until we can reuse the classes from gfx/src/x11shared/
*/
#define nsXFont nsX11FontNormal
#define nsXFontNormal nsX11FontNormal
#endif /* USE_X11SHARED_CODE */
class nsFontXlib;
class nsXFont;
class nsRenderingContextXlib;
class nsIDrawingSurfaceXlib;
/* nsFontMetricsXlibContext glue */
class nsFontMetricsXlibContext;
nsresult CreateFontMetricsXlibContext(nsIDeviceContext *aDevice, PRBool printermode, nsFontMetricsXlibContext **aFontMetricsXlibContext);
void DeleteFontMetricsXlibContext(nsFontMetricsXlibContext *aFontMetricsXlibContext);
#undef FONT_HAS_GLYPH
#define FONT_HAS_GLYPH(map, char) IS_REPRESENTABLE(map, char)
#define WEIGHT_INDEX(weight) (((weight) / 100) - 1)
#define NS_FONT_DEBUG_LOAD_FONT 0x01
#define NS_FONT_DEBUG_CALL_TRACE 0x02
#define NS_FONT_DEBUG_FIND_FONT 0x04
#define NS_FONT_DEBUG_SIZE_FONT 0x08
#define NS_FONT_DEBUG_SCALED_FONT 0x10
#define NS_FONT_DEBUG_BANNED_FONT 0x20
#define NS_FONT_DEBUG_FONT_CATALOG 0x100
#define NS_FONT_DEBUG_FONT_SCAN 0x200
#define NS_FONT_DEBUG_FREETYPE_FONT 0x400
#define NS_FONT_DEBUG_FREETYPE_GRAPHICS 0x800
#undef NS_FONT_DEBUG
#define NS_FONT_DEBUG 1
#ifdef NS_FONT_DEBUG
# define DEBUG_PRINTF(x) \
DEBUG_PRINTF_MACRO(x, 0xFFFF)
# define DEBUG_PRINTF_MACRO(x, type) \
PR_BEGIN_MACRO \
if (gFontDebug & (type)) { \
printf x ; \
printf(", %s %d\n", __FILE__, __LINE__); \
} \
PR_END_MACRO
#else
# define DEBUG_PRINTF_MACRO(x, type) \
PR_BEGIN_MACRO \
PR_END_MACRO
#endif
#define FIND_FONT_PRINTF(x) \
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_FIND_FONT)
#define SIZE_FONT_PRINTF(x) \
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_SIZE_FONT)
#define SCALED_FONT_PRINTF(x) \
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_SCALED_FONT)
#define BANNED_FONT_PRINTF(x) \
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_BANNED_FONT)
#define FONT_CATALOG_PRINTF(x) \
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_FONT_CATALOG)
#define FONT_SCAN_PRINTF(x) \
PR_BEGIN_MACRO \
if (gFontDebug & NS_FONT_DEBUG_FONT_SCAN) { \
printf x ; \
fflush(stdout); \
} \
PR_END_MACRO
#define FREETYPE_FONT_PRINTF(x) \
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_FREETYPE_FONT)
typedef struct nsFontCharSetInfoXlib nsFontCharSetInfoXlib;
typedef int (*nsFontCharSetConverterXlib)(nsFontCharSetInfoXlib* aSelf,
XFontStruct* aFont, const PRUnichar* aSrcBuf, PRInt32 aSrcLen,
char* aDestBuf, PRInt32 aDestLen);
struct nsFontCharSetXlib;
struct nsFontFamilyXlib;
struct nsFontNodeXlib;
struct nsFontStretchXlib;
struct nsFontWeightXlib;
class nsFontXlibUserDefined;
class nsFontMetricsXlib;
#ifdef MOZ_ENABLE_FREETYPE2
class nsFreeTypeFace;
#endif /* MOZ_ENABLE_FREETYPE2 */
struct nsFontStretchXlib
{
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
void SortSizes(void);
nsFontXlib **mSizes;
PRUint16 mSizesAlloc;
PRUint16 mSizesCount;
char* mScalable;
PRBool mOutlineScaled;
nsVoidArray mScaledFonts;
#ifdef MOZ_ENABLE_FREETYPE2
nsFreeTypeFace *mFreeTypeFaceID;
#endif /* MOZ_ENABLE_FREETYPE2 */
};
struct nsFontStyleXlib
{
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
void FillWeightHoles(void);
nsFontWeightXlib *mWeights[9];
};
struct nsFontWeightXlib
{
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
void FillStretchHoles(void);
nsFontStretchXlib *mStretches[9];
};
struct nsFontNodeXlib
{
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
void FillStyleHoles(void);
nsCAutoString mName;
nsFontCharSetInfoXlib *mCharSetInfo;
nsFontStyleXlib *mStyles[3];
PRUint8 mHolesFilled;
PRUint8 mDummy;
};
class nsFontNodeArrayXlib : public nsAutoVoidArray
{
public:
nsFontNodeArrayXlib() {};
nsFontNodeXlib *GetElement(PRInt32 aIndex)
{
return (nsFontNodeXlib *) ElementAt(aIndex);
};
};
/*
* Font Language Groups
*
* These Font Language Groups (FLG) indicate other related
* encodings to look at when searching for glyphs
*
*/
typedef struct nsFontLangGroupXlib {
const char *mFontLangGroupName;
nsIAtom* mFontLangGroupAtom;
} nsFontLangGroup;
struct nsFontCharSetMapXlib
{
const char* mName;
nsFontLangGroupXlib* mFontLangGroup;
nsFontCharSetInfoXlib* mInfo;
};
class nsFontXlib
{
public:
nsFontXlib();
nsFontXlib(nsFontXlib *);
virtual ~nsFontXlib();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
nsFontMetricsXlibContext *mFontMetricsContext;
void LoadFont(void);
PRBool IsEmptyFont(XFontStruct*);
inline int SupportsChar(PRUnichar aChar)
{ return mCCMap && CCMAP_HAS_CHAR(mCCMap, aChar); };
virtual XFontStruct *GetXFontStruct(void);
virtual nsXFont *GetXFont(void);
virtual PRBool GetXFontIs10646(void);
#ifdef MOZ_ENABLE_FREETYPE2
virtual PRBool IsFreeTypeFont(void);
#endif /* MOZ_ENABLE_FREETYPE2 */
virtual int GetWidth(const PRUnichar* aString, PRUint32 aLength) = 0;
virtual int DrawString(nsRenderingContextXlib *aContext,
nsIDrawingSurfaceXlib *aSurface, nscoord aX,
nscoord aY, const PRUnichar* aString,
PRUint32 aLength) = 0;
#ifdef MOZ_MATHML
// bounding metrics for a string
// remember returned values are not in app units
// - to emulate GetWidth () above
virtual nsresult
GetBoundingMetrics(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics) = 0;
#endif /* MOZ_MATHML */
PRUint16 *mCCMap;
nsFontCharSetInfoXlib *mCharSetInfo;
char *mName;
nsFontXlibUserDefined *mUserDefinedFont;
PRUint16 mSize;
#ifdef USE_AASB
PRUint16 mAABaseSize;
#endif /* USE_AASB */
PRInt16 mBaselineAdjust;
// these values are not in app units, they need to be scaled with
// nsIDeviceContext::DevUnitsToAppUnits()
PRInt16 mMaxAscent;
PRInt16 mMaxDescent;
protected:
XFontStruct *mFont;
XFontStruct *mFontHolder;
nsXFont *mXFont;
PRPackedBool mAlreadyCalledLoadFont;
};
struct nsFontSwitchXlib {
// Simple wrapper on top of nsFontXlib for the moment
// Could hold other attributes of the font
nsFontXlib *mFontXlib;
};
typedef PRBool (*PR_CALLBACK nsFontSwitchCallbackXlib)
(const nsFontSwitchXlib *aFontSwitch,
const PRUnichar* aSubstring,
PRUint32 aSubstringLength,
void* aData);
class nsFontMetricsXlib : public nsIFontMetrics
{
public:
nsFontMetricsXlib();
virtual ~nsFontMetricsXlib();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
NS_IMETHOD Init(const nsFont& aFont, nsIAtom* aLangGroup,
nsIDeviceContext* aContext);
NS_IMETHOD Destroy();
NS_IMETHOD GetXHeight(nscoord& aResult);
NS_IMETHOD GetSuperscriptOffset(nscoord& aResult);
NS_IMETHOD GetSubscriptOffset(nscoord& aResult);
NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize);
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize);
NS_IMETHOD GetHeight(nscoord &aHeight);
#ifdef FONT_LEADING_APIS_V2
NS_IMETHOD GetInternalLeading(nscoord &aLeading);
NS_IMETHOD GetExternalLeading(nscoord &aLeading);
#else
NS_IMETHOD GetNormalLineHeight(nscoord &aHeight);
NS_IMETHOD GetLeading(nscoord &aLeading);
#endif
NS_IMETHOD GetEmHeight(nscoord &aHeight);
NS_IMETHOD GetEmAscent(nscoord &aAscent);
NS_IMETHOD GetEmDescent(nscoord &aDescent);
NS_IMETHOD GetMaxHeight(nscoord &aHeight);
NS_IMETHOD GetMaxAscent(nscoord &aAscent);
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth);
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
// Xlib probably has string length limits, but I can't be bothered
virtual PRInt32 GetMaxStringLength() { return PR_INT32_MAX; }
NS_IMETHOD GetSpaceWidth(nscoord &aSpaceWidth);
NS_IMETHOD ResolveForwards(const PRUnichar* aString, PRUint32 aLength,
nsFontSwitchCallbackXlib aFunc, void* aData);
nsFontXlib* FindFont(PRUnichar aChar);
nsFontXlib* FindUserDefinedFont(PRUnichar aChar);
nsFontXlib* FindStyleSheetSpecificFont(PRUnichar aChar);
nsFontXlib* FindStyleSheetGenericFont(PRUnichar aChar);
nsFontXlib* FindLangGroupPrefFont(nsIAtom* aLangGroup, PRUnichar aChar);
nsFontXlib* FindLangGroupFont(nsIAtom* aLangGroup, PRUnichar aChar, nsCString* aName);
nsFontXlib* FindAnyFont(PRUnichar aChar);
nsFontXlib* FindSubstituteFont(PRUnichar aChar);
nsFontXlib* SearchNode(nsFontNodeXlib* aNode, PRUnichar aChar);
nsFontXlib* TryAliases(nsCString* aName, PRUnichar aChar);
nsFontXlib* TryFamily(nsCString* aName, PRUnichar aChar);
nsFontXlib* TryNode(nsCString* aName, PRUnichar aChar);
nsFontXlib* TryNodes(nsACString &aFFREName, PRUnichar aChar);
nsFontXlib* TryLangGroup(nsIAtom* aLangGroup, nsCString* aName, PRUnichar aChar);
nsFontXlib* AddToLoadedFontsList(nsFontXlib* aFont);
nsFontXlib* FindNearestSize(nsFontStretchXlib* aStretch, PRUint16 aSize);
#ifdef USE_AASB
nsFontXlib* GetAASBBaseFont(nsFontStretchXlib *aStretch,
nsFontCharSetInfoXlib* aCharSet);
#endif /* USE_AASB */
nsFontXlib* PickASizeAndLoad(nsFontStretchXlib *aStretch,
nsFontCharSetInfoXlib *aCharSet,
PRUnichar aChar,
const char *aName);
static nsresult FamilyExists(nsFontMetricsXlibContext *aFontMetricsContext, const nsString& aName);
//friend struct nsFontXlib;
nsFontXlib **mLoadedFonts;
PRUint16 mLoadedFontsAlloc;
PRUint16 mLoadedFontsCount;
nsFontXlib *mSubstituteFont;
nsCStringArray mFonts;
PRInt32 mFontsIndex;
nsAutoVoidArray mFontIsGeneric;
nsCAutoString mDefaultFont;
nsCString *mGeneric;
nsCOMPtr<nsIAtom> mLangGroup;
nsCAutoString mUserDefined;
PRUint8 mTriedAllGenerics;
PRUint8 mIsUserDefined;
nsFontMetricsXlibContext *mFontMetricsContext;
nsIDeviceContext *mDeviceContext;
protected:
void RealizeFont();
nsFontXlib *LocateFont(PRUint32 aChar, PRInt32 & aCount);
nsFontXlib *mWesternFont;
nscoord mLeading;
nscoord mEmHeight;
nscoord mEmAscent;
nscoord mEmDescent;
nscoord mMaxHeight;
nscoord mMaxAscent;
nscoord mMaxDescent;
nscoord mMaxAdvance;
nscoord mXHeight;
nscoord mSuperscriptOffset;
nscoord mSubscriptOffset;
nscoord mStrikeoutSize;
nscoord mStrikeoutOffset;
nscoord mUnderlineSize;
nscoord mUnderlineOffset;
nscoord mSpaceWidth;
nscoord mAveCharWidth;
PRUint16 mPixelSize;
PRUint8 mStretchIndex;
PRUint8 mStyleIndex;
nsFontCharSetConverterXlib mDocConverterType;
};
class nsFontEnumeratorXlib : public nsIFontEnumerator
{
public:
nsFontEnumeratorXlib();
NS_DECL_ISUPPORTS
NS_DECL_NSIFONTENUMERATOR
};
class nsHashKey;
/* XXX: We can't include gfx/src/x11shared/nsFreeType.h because it relies on
* GDK/GTK+ includes which are not available in Xlib builds (fix is to remove
* the GDK/GTK+ dependicy from the code in gfx/src/x11shared/ ...)
*/
#ifndef MOZ_ENABLE_FREETYPE2
/*
* Defines for the TrueType codepage bits.
* Used as a hint for the languages supported in a TrueType font.
*/
/*
* ulCodePageRange1
*/
#define TT_OS2_CPR1_LATIN1 (0x00000001) /* Latin 1 */
#define TT_OS2_CPR1_LATIN2 (0x00000002) /* Latin 2: Eastern Europe */
#define TT_OS2_CPR1_CYRILLIC (0x00000004) /* Cyrillic */
#define TT_OS2_CPR1_GREEK (0x00000008) /* Greek */
#define TT_OS2_CPR1_TURKISH (0x00000010) /* Turkish */
#define TT_OS2_CPR1_HEBREW (0x00000020) /* Hebrew */
#define TT_OS2_CPR1_ARABIC (0x00000040) /* Arabic */
#define TT_OS2_CPR1_BALTIC (0x00000080) /* Windows Baltic */
#define TT_OS2_CPR1_VIETNAMESE (0x00000100) /* Vietnamese */
/* 9-15 Reserved for Alternate ANSI */
#define TT_OS2_CPR1_THAI (0x00010000) /* Thai */
#define TT_OS2_CPR1_JAPANESE (0x00020000) /* JIS/Japan */
#define TT_OS2_CPR1_CHINESE_SIMP (0x00040000) /* Chinese: Simplified */
#define TT_OS2_CPR1_KO_WANSUNG (0x00080000) /* Korean Wansung */
#define TT_OS2_CPR1_CHINESE_TRAD (0x00100000) /* Chinese: Traditional */
#define TT_OS2_CPR1_KO_JOHAB (0x00200000) /* Korean Johab */
/* 22-28 Reserved for Alternate ANSI&OEM */
#define TT_OS2_CPR1_MAC_ROMAN (0x20000000) /* Mac (US Roman) */
#define TT_OS2_CPR1_OEM (0x40000000) /* OEM Character Set */
#define TT_OS2_CPR1_SYMBOL (0x80000000) /* Symbol Character Set */
/*
* ulCodePageRange2
*/ /* 32-47 Reserved for OEM */
#define TT_OS2_CPR2_GREEK (0x00010000) /* IBM Greek */
#define TT_OS2_CPR2_RUSSIAN (0x00020000) /* MS-DOS Russian */
#define TT_OS2_CPR2_NORDIC (0x00040000) /* MS-DOS Nordic */
#define TT_OS2_CPR2_ARABIC (0x00080000) /* Arabic */
#define TT_OS2_CPR2_CA_FRENCH (0x00100000) /* MS-DOS Canadian French */
#define TT_OS2_CPR2_HEBREW (0x00200000) /* Hebrew */
#define TT_OS2_CPR2_ICELANDIC (0x00400000) /* MS-DOS Icelandic */
#define TT_OS2_CPR2_PORTUGESE (0x00800000) /* MS-DOS Portuguese */
#define TT_OS2_CPR2_TURKISH (0x01000000) /* IBM Turkish */
#define TT_OS2_CPR2_CYRILLIC (0x02000000)/*IBM Cyrillic; primarily Russian*/
#define TT_OS2_CPR2_LATIN2 (0x04000000) /* Latin 2 */
#define TT_OS2_CPR2_BALTIC (0x08000000) /* MS-DOS Baltic */
#define TT_OS2_CPR2_GREEK_437G (0x10000000) /* Greek; former 437 G */
#define TT_OS2_CPR2_ARABIC_708 (0x20000000) /* Arabic; ASMO 708 */
#define TT_OS2_CPR2_WE_LATIN1 (0x40000000) /* WE/Latin 1 */
#define TT_OS2_CPR2_US (0x80000000) /* US */
#endif /* !MOZ_ENABLE_FREETYPE2 */
#endif /* !nsFontMetricsXlib_h__ */

View File

@ -1,249 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
* Mike Shaver <shaver@zeroknowledge.com>
* Tomi Leppikangas <Tomi.Leppikangas@oulu.fi>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <stdio.h>
#include "nsGCCache.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
/* The GC cache is shared among all windows, since it doesn't hog
any scarce resources (like colormap entries.) */
Region nsGCCacheXlib::copyRegion = 0;
nsGCCacheXlib::nsGCCacheXlib()
{
PR_INIT_CLIST(&GCCache);
PR_INIT_CLIST(&GCFreeList);
for (int i = 0; i < GC_CACHE_SIZE; i++) {
GCCacheEntryXlib *entry = new GCCacheEntryXlib();
entry->gc=NULL;
PR_INSERT_LINK(&entry->clist, &GCFreeList);
}
DEBUG_METER(memset(&GCCacheStats, 0, sizeof(GCCacheStats));)
}
void
nsGCCacheXlib::move_cache_entry(PRCList *clist)
{
/* thread on the freelist, at the front */
PR_REMOVE_LINK(clist);
PR_INSERT_LINK(clist, &GCFreeList);
}
void
nsGCCacheXlib::free_cache_entry(PRCList *clist)
{
GCCacheEntryXlib *entry = (GCCacheEntryXlib *)clist;
entry->gc->Release();
if (entry->clipRegion)
::XDestroyRegion(entry->clipRegion);
/* thread on the freelist, at the front */
PR_REMOVE_LINK(clist);
memset(entry, 0, sizeof(*entry));
PR_INSERT_LINK(clist, &GCFreeList);
}
nsGCCacheXlib::~nsGCCacheXlib()
{
PRCList *head;
ReportStats();
while (!PR_CLIST_IS_EMPTY(&GCCache)) {
head = PR_LIST_HEAD(&GCCache);
if (head == &GCCache)
break;
free_cache_entry(head);
}
while (!PR_CLIST_IS_EMPTY(&GCFreeList)) {
head = PR_LIST_HEAD(&GCFreeList);
if (head == &GCFreeList)
break;
PR_REMOVE_LINK(head);
delete (GCCacheEntryXlib *)head;
}
}
void
nsGCCacheXlib::ReportStats() {
DEBUG_METER(
fprintf(stderr, "GC Cache:\n\thits:");
int hits = 0;
for (int i = 0; i < GC_CACHE_SIZE; i++) {
fprintf(stderr, " %4d", GCCacheStats.hits[i]);
hits+=GCCacheStats.hits[i];
}
int total = hits + GCCacheStats.misses;
float percent = float(float(hits) / float(total));
percent *= 100;
fprintf(stderr, "\n\thits: %d, misses: %d, hit percent: %f%%\n",
hits, GCCacheStats.misses, percent);
);
}
void
nsGCCacheXlib::XCopyRegion(Region srca, Region dr_return)
{
if (!copyRegion) copyRegion = ::XCreateRegion();
::XUnionRegion(srca, copyRegion, dr_return);
}
/* Dispose of entries matching the given flags, compressing the GC cache */
void nsGCCacheXlib::Flush(unsigned long flags)
{
while (!PR_CLIST_IS_EMPTY(&GCCache)) {
PRCList *head = PR_LIST_HEAD(&GCCache);
if (head == &GCCache)
break;
GCCacheEntryXlib *entry = (GCCacheEntryXlib *)head;
if (entry->flags & flags)
free_cache_entry(head);
}
}
xGC *nsGCCacheXlib::GetGC(Display *display, Drawable drawable, unsigned long flags, XGCValues *gcv, Region clipRegion)
{
PRCList *iter;
GCCacheEntryXlib *entry;
DEBUG_METER(int i = 0;)
for (iter = PR_LIST_HEAD(&GCCache); iter != &GCCache;
iter = PR_NEXT_LINK(iter)) {
entry = (GCCacheEntryXlib *)iter;
if (flags == entry->flags &&
!memcmp (gcv, &entry->gcv, sizeof (*gcv))) {
/* if there's a clipRegion, we have to match */
if ((clipRegion && entry->clipRegion &&
::XEqualRegion(clipRegion, entry->clipRegion)) ||
/* and if there isn't, we can't have one */
(!clipRegion && !entry->clipRegion)) {
/* move to the front of the list, if needed */
if (iter != PR_LIST_HEAD(&GCCache)) {
PR_REMOVE_LINK(iter);
PR_INSERT_LINK(iter, &GCCache);
}
DEBUG_METER(GCCacheStats.hits[i]++;)
entry->gc->AddRef();
return entry->gc;
}
}
DEBUG_METER(++i;)
}
/* might need to forcibly free the LRU cache entry */
if (PR_CLIST_IS_EMPTY(&GCFreeList)) {
DEBUG_METER(GCCacheStats.reclaim++);
move_cache_entry(PR_LIST_TAIL(&GCCache));
}
DEBUG_METER(GCCacheStats.misses++;)
iter = PR_LIST_HEAD(&GCFreeList);
PR_REMOVE_LINK(iter);
PR_INSERT_LINK(iter, &GCCache);
entry = (GCCacheEntryXlib *)iter;
if (!entry->gc) {
// No old GC, greate new
entry->gc = new xGC(display, drawable, flags, gcv);
entry->gc->AddRef(); // addref the newly created xGC
entry->flags = flags;
entry->gcv = *gcv;
entry->clipRegion = NULL;
//printf("creating new gc=%X\n",entry->gc);
}
else if (entry->gc->mRefCnt > 0) {
// Old GC still in use, create new
entry->gc->Release();
entry->gc = new xGC(display, drawable, flags, gcv);
entry->gc->AddRef(); // addref the newly created xGC
entry->flags = flags;
entry->gcv = *gcv;
if (entry->clipRegion)
XDestroyRegion(entry->clipRegion);
entry->clipRegion = NULL;
//printf("creating new (use)gc=%X\n",entry->gc);
}
else {
ReuseGC(entry, flags, gcv);
}
if (clipRegion) {
entry->clipRegion = ::XCreateRegion();
XCopyRegion(clipRegion, entry->clipRegion);
if (entry->clipRegion)
::XSetRegion(display, entry->gc->mGC, entry->clipRegion);
/* XXX what if it fails? */
}
entry->gc->AddRef();
return entry->gc;
}
void nsGCCacheXlib::ReuseGC(GCCacheEntryXlib *entry, unsigned long flags, XGCValues *gcv)
{
// We have old GC, reuse it and check what
// we have to change
if (entry->clipRegion) {
// set it to none here and then set the clip region with
// gdk_gc_set_clip_region in GetGC()
gcv->clip_mask = None;
flags |= GCClipMask;
::XDestroyRegion(entry->clipRegion);
entry->clipRegion = NULL;
}
if (flags != 0) {
::XChangeGC(entry->gc->mDisplay, entry->gc->mGC,
flags, gcv);
}
entry->flags = flags; entry->gcv = *gcv;
}

View File

@ -1,148 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Mozilla browser.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
* Mike Shaver <shaver@zeroknowledge.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsGCCacheXlib_h___
#define nsGCCacheXlib_h___
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "nscore.h"
#include "nsDebug.h"
#include "prclist.h"
#include <stdlib.h>
#include <string.h>
#define countof(x) ((int)(sizeof(x) / sizeof (*x)))
#define GC_CACHE_SIZE 64
#ifdef DEBUG
#define DEBUG_METER(x) x
#else
#define DEBUG_METER(x)
#endif
class nsGCCacheXlib;
class xGC {
friend class nsGCCacheXlib;
public:
xGC(Display *display, Drawable d, unsigned long valuemask, XGCValues *values)
{
mRefCnt = 0;
mDisplay = display;
mGC = ::XCreateGC(display, d, valuemask, values);
}
virtual ~xGC() {
::XFreeGC(mDisplay, mGC);
}
PRInt32 AddRef(void) {
#ifdef DEBUG
if(mRefCnt>400) abort();
#endif /* DEBUG */
NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");
++mRefCnt;
return mRefCnt;
}
PRInt32 Release(void) {
NS_PRECONDITION(0 != mRefCnt, "dup release");
--mRefCnt;
if (mRefCnt == 0) {
mRefCnt = 1; /* stabilize */
delete this;
return 0;
}
return mRefCnt;
}
//operator GC() { return mGC; }
operator const GC() { return (const GC)mGC; }
private:
PRInt32 mRefCnt;
Display *mDisplay;
GC mGC;
};
struct GCCacheEntryXlib
{
PRCList clist;
unsigned long flags;
XGCValues gcv;
Region clipRegion;
xGC *gc;
};
class nsGCCacheXlib
{
public:
nsGCCacheXlib();
virtual ~nsGCCacheXlib();
void Flush(unsigned long flags);
xGC *GetGC(Display *display, Window window, unsigned long flags, XGCValues *gcv, Region clipRegion);
private:
void ReuseGC(GCCacheEntryXlib *entry, unsigned long flags, XGCValues *gcv);
PRCList GCCache;
PRCList GCFreeList;
void free_cache_entry(PRCList *clist);
void move_cache_entry(PRCList *clist);
static void XCopyRegion(Region src, Region dr_return);
static Region copyRegion;
void ReportStats();
DEBUG_METER(
struct {
int hits[GC_CACHE_SIZE];
int misses;
int reclaim;
} GCCacheStats;
)
};
#endif

View File

@ -1,190 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Hartshorn <peter@igelaus.com.au>
* Tony Tsui <tony@igelaus.com.au>
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIGenericFactory.h"
#include "nsIModule.h"
#include "nsCOMPtr.h"
#include "nsGfxCIID.h"
#include "nsBlender.h"
#include "nsFontMetricsXlib.h"
#include "nsRenderingContextXlib.h"
// aka nsDeviceContextSpecXlib.h
#include "nsDeviceContextSpecXlib.h"
#include "nsScriptableRegion.h"
#include "nsDeviceContextXlib.h"
#include "nsImageXlib.h"
#include "nsFontList.h"
#include "nsPrintOptionsXlib.h"
#include "nsPrintSession.h"
#include "gfxImageFrame.h"
// objects that just require generic constructors
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontMetricsXlib)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextXlib)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRenderingContextXlib)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsImageXlib)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlender)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionXlib)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecXlib)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorXlib)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintOptionsXlib, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrinterEnumeratorXlib)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsPrintSession, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(gfxImageFrame)
// our custom constructors
static nsresult nsScriptableRegionConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
nsresult rv;
nsIScriptableRegion *inst = nsnull;
if ( NULL == aResult )
{
rv = NS_ERROR_NULL_POINTER;
return rv;
}
*aResult = NULL;
if (NULL != aOuter)
{
rv = NS_ERROR_NO_AGGREGATION;
return rv;
}
// create an nsRegionXlib and get the scriptable region from it
nsCOMPtr <nsIRegion> rgn;
NS_NEWXPCOM(rgn, nsRegionXlib);
if (rgn != nsnull)
{
nsCOMPtr<nsIScriptableRegion> scriptableRgn = new nsScriptableRegion(rgn);
inst = scriptableRgn;
}
if (NULL == inst)
{
rv = NS_ERROR_OUT_OF_MEMORY;
return rv;
}
NS_ADDREF(inst);
rv = inst->QueryInterface(aIID, aResult);
NS_RELEASE(inst);
return rv;
}
static const nsModuleComponentInfo components[] =
{
{ "Xlib Font Metrics",
NS_FONT_METRICS_CID,
// "@mozilla.org/gfx/font_metrics/xlib;1",
"@mozilla.org/gfx/fontmetrics;1",
nsFontMetricsXlibConstructor },
{ "Xlib Device Context",
NS_DEVICE_CONTEXT_CID,
// "@mozilla.org/gfx/device_context/xlib;1",
"@mozilla.org/gfx/devicecontext;1",
nsDeviceContextXlibConstructor },
{ "Xlib Rendering Context",
NS_RENDERING_CONTEXT_CID,
// "@mozilla.org/gfx/rendering_context/xlib;1",
"@mozilla.org/gfx/renderingcontext;1",
nsRenderingContextXlibConstructor },
{ "Xlib Image",
NS_IMAGE_CID,
// "@mozilla.org/gfx/image/xlib;1",
"@mozilla.org/gfx/image;1",
nsImageXlibConstructor },
{ "Xlib Region",
NS_REGION_CID,
"@mozilla.org/gfx/region/xlib;1",
nsRegionXlibConstructor },
{ "Scriptable Region",
NS_SCRIPTABLE_REGION_CID,
// "@mozilla.org/gfx/scriptable_region;1",
"@mozilla.org/gfx/region;1",
nsScriptableRegionConstructor },
{ "Blender",
NS_BLENDER_CID,
// "@mozilla.org/gfx/blender;1",
"@mozilla.org/gfx/blender;1",
nsBlenderConstructor },
{ "Xlib Device Context Spec",
NS_DEVICE_CONTEXT_SPEC_CID,
// "@mozilla.org/gfx/device_context_spec/xlib;1",
"@mozilla.org/gfx/devicecontextspec;1",
nsDeviceContextSpecXlibConstructor },
{ "PrintSettings Service",
NS_PRINTSETTINGSSERVICE_CID,
// "@mozilla.org/gfx/printsettings-service;1",
"@mozilla.org/gfx/printsettings-service;1",
nsPrintOptionsXlibConstructor },
{ "Xlib Font Enumerator",
NS_FONT_ENUMERATOR_CID,
// "@mozilla.org/gfx/font_enumerator/xlib;1",
"@mozilla.org/gfx/fontenumerator;1",
nsFontEnumeratorXlibConstructor },
{ "Font List",
NS_FONTLIST_CID,
// "@mozilla.org/gfx/fontlist;1"
NS_FONTLIST_CONTRACTID,
nsFontListConstructor },
{ "Xlib Printer Enumerator",
NS_PRINTER_ENUMERATOR_CID,
// "@mozilla.org/gfx/printer_enumerator/xlib;1",
"@mozilla.org/gfx/printerenumerator;1",
nsPrinterEnumeratorXlibConstructor },
{ "windows image frame",
GFX_IMAGEFRAME_CID,
"@mozilla.org/gfx/image/frame;2",
gfxImageFrameConstructor, },
{ "Print Session",
NS_PRINTSESSION_CID,
"@mozilla.org/gfx/printsession;1",
nsPrintSessionConstructor }
};
PR_STATIC_CALLBACK(void)
nsGfxXlibModuleDtor(nsIModule *self)
{
}
NS_IMPL_NSGETMODULE_WITH_DTOR(nsGfxXlibModule, components, nsGfxXlibModuleDtor)

File diff suppressed because it is too large Load Diff

View File

@ -1,199 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Hartshorn <peter@igelaus.com.au>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsImageXlib_h__
#define nsImageXlib_h__
#include "nsIImage.h"
#include "nsPoint.h"
#include "nsGCCache.h"
#include "nsRegion.h"
#include "xlibrgb.h"
class nsImageXlib : public nsIImage {
public:
nsImageXlib();
virtual ~nsImageXlib();
NS_DECL_ISUPPORTS
virtual PRInt32 GetBytesPix() { return mNumBytesPixel; }
virtual PRInt32 GetHeight();
virtual PRInt32 GetWidth();
virtual PRUint8* GetBits();
virtual void* GetBitInfo();
virtual PRBool GetIsRowOrderTopToBottom() { return PR_TRUE; }
virtual PRInt32 GetLineStride();
virtual nsColorMap* GetColorMap();
NS_IMETHOD Draw(nsIRenderingContext &aContext,
nsIDrawingSurface* aSurface,
PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD Draw(nsIRenderingContext &aContext,
nsIDrawingSurface* aSurface,
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
NS_IMETHOD DrawToImage(nsIImage* aDstImage, nscoord aDX, nscoord aDY,
nscoord aDWidth, nscoord aDHeight);
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
nsIDrawingSurface* aSurface,
PRInt32 aSXOffset, PRInt32 aSYOffset,
PRInt32 aPadX, PRInt32 aPadY,
const nsRect &aTileRect);
void UpdateCachedImage();
virtual void ImageUpdated(nsIDeviceContext *aContext,
PRUint8 aFlags, nsRect *aUpdateRect);
virtual PRBool GetIsImageComplete();
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight,
PRInt32 aDepth,
nsMaskRequirements aMaskRequirements);
virtual nsresult Optimize(nsIDeviceContext* aContext);
virtual PRBool GetHasAlphaMask() { return mAlphaBits != nsnull; }
virtual PRUint8* GetAlphaBits();
virtual PRInt32 GetAlphaLineStride();
/**
* Get the alpha depth for the image mask
* @update - lordpixel 2001/05/16
* @return the alpha mask depth for the image, ie, 0, 1 or 8
*/
virtual PRInt8 GetAlphaDepth() {return(mAlphaDepth);}
NS_IMETHOD LockImagePixels(PRBool aMaskPixels);
NS_IMETHOD UnlockImagePixels(PRBool aMaskPixels);
private:
/**
* Calculate the amount of memory needed for the initialization of the image
*/
void ComputeMetrics() {
mRowBytes = (mWidth * mDepth) >> 5;
if (((PRUint32)mWidth * mDepth) & 0x1F)
mRowBytes++;
mRowBytes <<= 2;
mSizeImage = mRowBytes * mHeight;
};
void ComputePaletteSize(PRIntn nBitCount);
private:
NS_IMETHODIMP DrawScaled(nsIRenderingContext &aContext, nsIDrawingSurface* aSurface,
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
static unsigned scaled6[1<<6];
static unsigned scaled5[1<<5];
void DrawComposited32(PRBool isLSB, PRBool flipBytes,
PRUint8 *imageOrigin, PRUint32 imageStride,
PRUint8 *alphaOrigin, PRUint32 alphaStride,
unsigned width, unsigned height,
XImage *ximage, unsigned char *readData);
void DrawComposited24(PRBool isLSB, PRBool flipBytes,
PRUint8 *imageOrigin, PRUint32 imageStride,
PRUint8 *alphaOrigin, PRUint32 alphaStride,
unsigned width, unsigned height,
XImage *ximage, unsigned char *readData);
void DrawComposited16(PRBool isLSB, PRBool flipBytes,
PRUint8 *imageOrigin, PRUint32 imageStride,
PRUint8 *alphaOrigin, PRUint32 alphaStride,
unsigned width, unsigned height,
XImage *ximage, unsigned char *readData);
void DrawCompositedGeneral(PRBool isLSB, PRBool flipBytes,
PRUint8 *imageOrigin, PRUint32 imageStride,
PRUint8 *alphaOrigin, PRUint32 alphaStride,
unsigned width, unsigned height,
XImage *ximage, unsigned char *readData);
inline void DrawComposited(nsIRenderingContext &aContext,
nsIDrawingSurface* aSurface,
PRInt32 aSX, PRInt32 aSY,
PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY,
PRInt32 aDWidth, PRInt32 aDHeight);
inline void TilePixmap(Pixmap src, Pixmap dest, PRInt32 aSXOffset, PRInt32 aSYOffset,
const nsRect &destRect, const nsRect &clipRect, PRBool useClip);
inline void CreateAlphaBitmap(PRInt32 aWidth, PRInt32 aHeight);
inline void CreateOffscreenPixmap(PRInt32 aWidth, PRInt32 aHeight);
inline void DrawImageOffscreen(PRInt32 aSX, PRInt32 aSY,
PRInt32 aWidth, PRInt32 aHeight);
inline void SetupGCForAlpha(GC aGC, PRInt32 aX, PRInt32 aY);
// image bits
PRUint8 *mImageBits;
PRUint8 *mAlphaBits;
Pixmap mImagePixmap;
Pixmap mAlphaPixmap;
PRInt32 mWidth;
PRInt32 mHeight;
PRInt32 mDepth; // bits per pixel
PRInt32 mRowBytes;
GC mGC;
PRInt32 mSizeImage;
PRInt8 mNumBytesPixel;
PRInt32 mDecodedX1; //Keeps track of what part of image
PRInt32 mDecodedY1; // has been decoded.
PRInt32 mDecodedX2;
PRInt32 mDecodedY2;
nsRegion mUpdateRegion;
static XlibRgbHandle *mXlibRgbHandle;
static Display *mDisplay;
// alpha layer members
PRInt8 mAlphaDepth; // alpha layer depth
PRInt16 mAlphaRowBytes; // alpha bytes per row
PRPackedBool mAlphaValid;
PRPackedBool mIsSpacer;
PRPackedBool mPendingUpdate;
PRUint8 mFlags; // flags set by ImageUpdated
};
#endif /* !nsImageXlib_h__ */

View File

@ -1,57 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Xlib toolkit.
*
* The Initial Developer of the Original Code is
* Roland Mainz.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsPrintOptionsXlib.h"
/** ---------------------------------------------------
* See documentation in nsPrintOptionsWin.h
* @update 6/21/00 dwc
*/
nsPrintOptionsXlib::nsPrintOptionsXlib()
{
}
/** ---------------------------------------------------
* See documentation in nsPrintOptionsImpl.h
* @update 6/21/00 dwc
*/
nsPrintOptionsXlib::~nsPrintOptionsXlib()
{
}

View File

@ -1,57 +0,0 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Xlib toolkit.
*
* The Initial Developer of the Original Code is
* Roland Mainz.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsPrintOptionsXlib_h__
#define nsPrintOptionsXlib_h__
#include "nsPrintOptionsImpl.h"
// *****************************************************************************
// *** nsPrintOptions
// *****************************************************************************
class nsPrintOptionsXlib : public nsPrintOptions
{
public:
nsPrintOptionsXlib();
virtual ~nsPrintOptionsXlib();
};
#endif /* !nsPrintOptionsXlib_h__ */

View File

@ -1,424 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "prmem.h"
#include "nsRegionXlib.h"
#include "xregion.h"
// #define DEBUG_REGIONS 1
#ifdef DEBUG_REGIONS
static int nRegions;
#endif
Region nsRegionXlib::copyRegion = 0;
nsRegionXlib::nsRegionXlib()
{
#ifdef DEBUG_REGIONS
++nRegions;
printf("REGIONS+ = %i\n", nRegions);
#endif
mRegion = nsnull;
}
nsRegionXlib::~nsRegionXlib()
{
#ifdef DEBUG_REGIONS
--nRegions;
printf("REGIONS- = %i\n", nRegions);
#endif
if (mRegion)
::XDestroyRegion(mRegion);
mRegion = nsnull;
}
NS_IMPL_ISUPPORTS1(nsRegionXlib, nsIRegion)
Region
nsRegionXlib::GetCopyRegion()
{
if (!copyRegion)
copyRegion = ::XCreateRegion();
return copyRegion;
}
Region
nsRegionXlib::xlib_region_copy(Region region)
{
Region nRegion;
nRegion = XCreateRegion();
XUnionRegion(region, GetCopyRegion(), nRegion);
return nRegion;
}
Region nsRegionXlib::xlib_region_from_rect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
XRectangle rect;
Region nRegion;
rect.x = aX;
rect.y = aY;
rect.width = aWidth;
rect.height = aHeight;
nRegion = XCreateRegion();
XUnionRectWithRegion(&rect, GetCopyRegion(), nRegion);
return nRegion;
}
nsresult
nsRegionXlib::Init()
{
if (mRegion) {
::XDestroyRegion(mRegion);
mRegion = nsnull;
}
return NS_OK;
}
void
nsRegionXlib::SetTo(const nsIRegion &aRegion)
{
Init();
nsRegionXlib * pRegion = (nsRegionXlib *)&aRegion;
mRegion = xlib_region_copy(pRegion->mRegion);
}
void
nsRegionXlib::SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
Init();
mRegion = xlib_region_from_rect(aX, aY, aWidth, aHeight);
}
void
nsRegionXlib::Intersect(const nsIRegion &aRegion)
{
nsRegionXlib * pRegion = (nsRegionXlib *)&aRegion;
Region nRegion = XCreateRegion();
::XIntersectRegion(mRegion, pRegion->mRegion, nRegion);
::XDestroyRegion(mRegion);
mRegion = nRegion;
}
void
nsRegionXlib::Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
Region tRegion = xlib_region_from_rect(aX, aY, aWidth, aHeight);
Region nRegion = XCreateRegion();
::XIntersectRegion(mRegion, tRegion, nRegion);
::XDestroyRegion(tRegion);
::XDestroyRegion(mRegion);
mRegion = nRegion;
}
void
nsRegionXlib::Union(const nsIRegion &aRegion)
{
nsRegionXlib * pRegion = (nsRegionXlib *)&aRegion;
if (pRegion->mRegion && !::XEmptyRegion(pRegion->mRegion)) {
if (mRegion) {
if (::XEmptyRegion(mRegion)) {
::XDestroyRegion(mRegion);
mRegion = xlib_region_copy(pRegion->mRegion);
} else {
Region nRegion = ::XCreateRegion();
::XUnionRegion(mRegion, pRegion->mRegion, nRegion);
::XDestroyRegion(mRegion);
mRegion = nRegion;
}
} else
mRegion = xlib_region_copy(pRegion->mRegion);
}
}
void
nsRegionXlib::Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
if (mRegion) {
XRectangle rect;
rect.x = aX;
rect.y = aY;
rect.width = aWidth;
rect.height = aHeight;
if (rect.width > 0 && rect.height > 0) {
if (::XEmptyRegion(mRegion)) {
::XDestroyRegion(mRegion);
mRegion = xlib_region_from_rect(aX, aY, aWidth, aHeight);
} else {
Region nRegion = ::XCreateRegion();
::XUnionRectWithRegion(&rect, mRegion, nRegion);
::XDestroyRegion(mRegion);
mRegion = nRegion;
}
}
} else {
mRegion = xlib_region_from_rect(aX, aY, aWidth, aHeight);
}
}
void
nsRegionXlib::Subtract(const nsIRegion &aRegion)
{
#ifdef DEBUG_REGIONS
printf("nsRegionXlib::Subtract ");
#endif
nsRegionXlib * pRegion = (nsRegionXlib *)&aRegion;
if (pRegion->mRegion) {
if (mRegion) {
#ifdef DEBUG_REGIONS
printf("-");
#endif
Region nRegion = ::XCreateRegion();
::XSubtractRegion(mRegion, pRegion->mRegion, nRegion);
::XDestroyRegion(mRegion);
mRegion = nRegion;
} else {
#ifdef DEBUG_REGIONS
printf("+");
#endif
mRegion = ::XCreateRegion();
::XSubtractRegion(GetCopyRegion(), pRegion->mRegion, mRegion);
}
}
#ifdef DEBUG_REGIONS
printf("\n");
#endif
}
void
nsRegionXlib::Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
if (mRegion) {
Region tRegion = xlib_region_from_rect(aX, aY, aWidth, aHeight);
Region nRegion = ::XCreateRegion();
::XSubtractRegion(mRegion, tRegion, nRegion);
::XDestroyRegion(mRegion);
::XDestroyRegion(tRegion);
mRegion = nRegion;
} else {
Region tRegion = xlib_region_from_rect(aX, aY, aWidth, aHeight);
mRegion = XCreateRegion();
::XSubtractRegion(GetCopyRegion(), tRegion, mRegion);
::XDestroyRegion(tRegion);
}
}
PRBool
nsRegionXlib::IsEmpty(void)
{
if (!mRegion)
return PR_TRUE;
return ::XEmptyRegion(mRegion);
}
PRBool
nsRegionXlib::IsEqual(const nsIRegion &aRegion)
{
nsRegionXlib *pRegion = (nsRegionXlib *)&aRegion;
if (mRegion && pRegion->mRegion) {
return ::XEqualRegion(mRegion, pRegion->mRegion);
} else if (!mRegion && !pRegion->mRegion) {
return PR_TRUE;
} else if ((mRegion && !pRegion->mRegion) ||
(!mRegion && pRegion->mRegion)) {
return PR_FALSE;
}
return PR_FALSE;
}
void
nsRegionXlib::GetBoundingBox(PRInt32 *aX, PRInt32 *aY,
PRInt32 *aWidth, PRInt32 *aHeight)
{
if (mRegion) {
XRectangle r;
::XClipBox(mRegion, &r);
*aX = r.x;
*aY = r.y;
*aWidth = r.width;
*aHeight = r.height;
} else {
*aX = 0;
*aY = 0;
*aWidth = 0;
*aHeight = 0;
}
}
void
nsRegionXlib::Offset(PRInt32 aXOffset, PRInt32 aYOffset)
{
if (mRegion) {
::XOffsetRegion(mRegion, aXOffset, aYOffset);
}
}
PRBool
nsRegionXlib::ContainsRect(PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight)
{
return (::XRectInRegion(mRegion, aX, aY, aWidth, aHeight) == RectangleIn) ?
PR_TRUE : PR_FALSE;
}
NS_IMETHODIMP
nsRegionXlib::GetRects(nsRegionRectSet **aRects)
{
*aRects = nsnull;
if (!mRegion)
return NS_OK;
nsRegionRectSet *rects;
int nbox;
BOX *pbox;
nsRegionRect *rect;
NS_ASSERTION(!(nsnull == aRects), "bad ptr");
//code lifted from old xfe. MMP
pbox = mRegion->rects;
nbox = mRegion->numRects;
rects = *aRects;
if ((nsnull == rects) || (rects->mRectsLen < (PRUint32)nbox)) {
void *buf = PR_Realloc(rects, sizeof(nsRegionRectSet) +
(sizeof(nsRegionRect) * (nbox - 1)));
if (nsnull == buf) {
if (nsnull != rects)
rects->mNumRects = 0;
return NS_OK;
}
rects = (nsRegionRectSet *)buf;
rects->mRectsLen = nbox;
}
rects->mNumRects = nbox;
rects->mArea = 0;
rect = &rects->mRects[0];
while (nbox--) {
rect->x = pbox->x1;
rect->width = (pbox->x2 - pbox->x1);
rect->y = pbox->y1;
rect->height = (pbox->y2 - pbox->y1);
rects->mArea += rect->width * rect->height;
pbox++;
rect++;
}
*aRects = rects;
return NS_OK;
}
NS_IMETHODIMP
nsRegionXlib::FreeRects(nsRegionRectSet *aRects)
{
if (nsnull != aRects)
PR_Free((void *)aRects);
return NS_OK;
}
NS_IMETHODIMP
nsRegionXlib::GetNativeRegion(void *&aRegion) const
{
aRegion = (void *)mRegion;
return NS_OK;
}
NS_IMETHODIMP
nsRegionXlib::GetRegionComplexity(nsRegionComplexity &aComplexity) const
{
// cast to avoid const-ness problems on some compilers
if (((nsRegionXlib*)this)->IsEmpty())
aComplexity = eRegionComplexity_empty;
else
aComplexity = eRegionComplexity_rect;
return NS_OK;
}
void nsRegionXlib::SetRegionEmpty()
{
if (!IsEmpty()) {
::XDestroyRegion(mRegion);
}
}
NS_IMETHODIMP
nsRegionXlib::GetNumRects(PRUint32 *aRects) const
{
if (!mRegion)
*aRects = 0;
*aRects = mRegion->numRects;
return NS_OK;
}

View File

@ -1,88 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsRegionXlib_h___
#define nsRegionXlib_h___
#include "nsIRegion.h"
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
class nsRegionXlib : public nsIRegion
{
public:
nsRegionXlib();
virtual ~nsRegionXlib();
NS_DECL_ISUPPORTS
nsresult Init();
void SetTo(const nsIRegion &aRegion);
void SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
void Intersect(const nsIRegion &aRegion);
void Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
void Union(const nsIRegion &aRegion);
void Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
void Subtract(const nsIRegion &aRegion);
void Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
PRBool IsEmpty(void);
PRBool IsEqual(const nsIRegion &aRegion);
void GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight);
void Offset(PRInt32 aXOffset, PRInt32 aYOffset);
PRBool ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD GetRects(nsRegionRectSet **aRects);
NS_IMETHOD FreeRects(nsRegionRectSet *aRects);
NS_IMETHOD GetNativeRegion(void *&aRegion) const;
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const;
NS_IMETHOD GetNumRects(PRUint32 *aRects) const;
protected:
Region xlib_region_copy(Region region);
Region xlib_region_from_rect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
private:
Region mRegion;
static Region copyRegion;
inline Region GetCopyRegion();
inline void SetRegionEmpty();
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,280 +0,0 @@
/* -*- Mode: C++; tab-width: 1; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Hartshorn <peter@igelaus.com.au>
* Tim Copperfield <timecop@network.email.ne.jp>
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsRenderingContextXlib_h___
#define nsRenderingContextXlib_h___
#include "nsIDeviceContext.h"
#include "nsIWidget.h"
#include "nsRenderingContextImpl.h"
#include "nsUnitConversion.h"
#include "nsFont.h"
#include "nsFontMetricsXlib.h"
#include "nsPoint.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsTransform2D.h"
#include "nsRect.h"
#include "nsVoidArray.h"
#include "nsGfxCIID.h"
#include "nsDrawingSurfaceXlib.h"
#include "nsRegionXlib.h"
class nsFontXlib;
class nsRenderingContextXlibContext
{
public:
nsGCCacheXlib mGcCache;
};
/* Note |nsRenderingContextXp| may override some of these methods here */
class nsRenderingContextXlib : public nsRenderingContextImpl
{
public:
nsRenderingContextXlib();
virtual ~nsRenderingContextXlib();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIDrawingSurface* aSurface);
NS_IMETHOD Reset(void);
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext);
NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
PRUint32 aFlags);
NS_IMETHOD UnlockDrawingSurface(void);
NS_IMETHOD SelectOffScreenDrawingSurface(nsIDrawingSurface* aSurface);
NS_IMETHOD GetDrawingSurface(nsIDrawingSurface* *aSurface);
NS_IMETHOD GetHints(PRUint32& aResult);
NS_IMETHOD PushState(void);
NS_IMETHOD PopState(void);
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aVisible);
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine);
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipValid);
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine);
NS_IMETHOD CopyClipRegion(nsIRegion &aRegion);
NS_IMETHOD GetClipRegion(nsIRegion **aRegion);
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle);
NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle);
NS_IMETHOD SetColor(nscolor aColor);
NS_IMETHOD GetColor(nscolor &aColor) const;
NS_IMETHOD SetFont(const nsFont& aFont, nsIAtom* aLangGroup);
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics);
NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics);
NS_IMETHOD Translate(nscoord aX, nscoord aY);
NS_IMETHOD Scale(float aSx, float aSy);
NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform);
NS_IMETHOD CreateDrawingSurface(const nsRect& aBounds, PRUint32 aSurfFlags, nsIDrawingSurface* &aSurface);
NS_IMETHOD DestroyDrawingSurface(nsIDrawingSurface* aDS);
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
NS_IMETHOD DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawRect(const nsRect& aRect);
NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillRect(const nsRect& aRect);
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD InvertRect(const nsRect& aRect);
NS_IMETHOD InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawEllipse(const nsRect& aRect);
NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillEllipse(const nsRect& aRect);
NS_IMETHOD FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
NS_IMETHOD DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD GetWidth(char aC, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const char *aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const char *aString, PRUint32 aLength, nscoord &aWidth);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
PRInt32 aFontID,
const nscoord* aSpacing);
NS_IMETHOD GetTextDimensions(const char* aString, PRUint32 aLength,
nsTextDimensions& aDimensions);
NS_IMETHOD GetTextDimensions(const PRUnichar *aString, PRUint32 aLength,
nsTextDimensions& aDimensions, PRInt32 *aFontID);
NS_IMETHOD GetTextDimensions(const char* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID = nsnull);
NS_IMETHOD GetTextDimensions(const PRUnichar* aString,
PRInt32 aLength,
PRInt32 aAvailWidth,
PRInt32* aBreaks,
PRInt32 aNumBreaks,
nsTextDimensions& aDimensions,
PRInt32& aNumCharsFit,
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID = nsnull);
NS_IMETHOD CopyOffScreenBits(nsIDrawingSurface* aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect & aSrcRect, const nsRect & aDestRect);
#ifdef MOZ_MATHML
/**
* Returns metrics (in app units) of an 8-bit character string
*/
NS_IMETHOD GetBoundingMetrics(const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics);
/**
* Returns metrics (in app units) of a Unicode character string
*/
NS_IMETHOD GetBoundingMetrics(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics,
PRInt32* aFontID = nsnull);
#endif /* MOZ_MATHML */
void SetClipRectInPixels(const nsRect& aRect, nsClipCombine aCombine);
xGC *GetGC() { mGC->AddRef(); return mGC; }
void UpdateGC();
/* Use UpdateGC() to update GC-cache !! */
void SetCurrentFont(nsFontXlib *cf) { mCurrentFont = cf; };
nsFontXlib *GetCurrentFont() { return mCurrentFont; };
protected:
/* This is a common init function for all of the |Init()| functions.*/
nsresult CommonInit(void);
nsCOMPtr<nsIDeviceContext> mContext;
nsCOMPtr<nsIDrawingSurfaceXlib> mOffscreenSurface;
nsCOMPtr<nsIDrawingSurfaceXlib> mSurface;
nsCOMPtr<nsIFontMetrics> mFontMetrics;
nsCOMPtr<nsIRegion> mClipRegion;
float mP2T;
// graphic state stack (GraphicsState)
nsAutoVoidArray mStateCache;
xGC *mGC;
int mFunction;
int mLineStyle;
char *mDashList;
int mDashes;
nscolor mCurrentColor;
XlibRgbHandle *mXlibRgbHandle;
Display *mDisplay;
nsFontXlib *mCurrentFont;
nsLineStyle mCurrentLineStyle;
// ConditionRect is used to fix coordinate overflow problems for
// rectangles after they are transformed to screen coordinates
void ConditionRect(nscoord &x, nscoord &y, nscoord &w, nscoord &h) {
if ( y < -32766 ) {
y = -32766;
}
if ( y + h > 32766 ) {
h = 32766 - y;
}
if ( x < -32766 ) {
x = -32766;
}
if ( x + w > 32766 ) {
w = 32766 - x;
}
}
};
/* Prototypes */
nsresult CreateRenderingContextXlibContext(nsIDeviceContext *aDevice, nsRenderingContextXlibContext **aContext);
void DeleteRenderingContextXlibContext(nsRenderingContextXlibContext *aContext);
#endif /* !nsRenderingContextXlib_h___ */

View File

@ -1,6 +0,0 @@
[gecko]
#if SHARED_LIBRARY
dist/bin/components/@SHARED_LIBRARY@
#else
!staticcomp @LIBRARY@ @MODULE_NAME@
#endif

View File

@ -1,177 +0,0 @@
/* $XConsortium: region.h,v 11.13 91/09/10 08:21:49 rws Exp $ */
/************************************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
All Rights Reserved
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital or MIT not be
used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
************************************************************************/
#ifndef _XREGION_H
#define _XREGION_H
typedef struct {
short x1, x2, y1, y2;
} Box, BOX, BoxRec, *BoxPtr;
typedef struct {
short x, y, width, height;
}RECTANGLE, RectangleRec, *RectanglePtr;
#ifdef TRUE
#undef TRUE
#endif
#define TRUE 1
#ifndef FALSE
#define FALSE 0
#endif
#ifndef MAXSHORT
#define MAXSHORT 32767
#endif
#ifndef MINSHORT
#define MINSHORT -MAXSHORT
#endif
#ifndef MAX
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#endif
/*
* clip region
*/
typedef struct _XRegion {
long size;
long numRects;
BOX *rects;
BOX extents;
} REGION;
/* Xutil.h contains the declaration:
* typedef struct _XRegion *Region;
*/
/* 1 if two BOXs overlap.
* 0 if two BOXs do not overlap.
* Remember, x2 and y2 are not in the region
*/
#define EXTENTCHECK(r1, r2) \
((r1)->x2 > (r2)->x1 && \
(r1)->x1 < (r2)->x2 && \
(r1)->y2 > (r2)->y1 && \
(r1)->y1 < (r2)->y2)
/*
* update region extents
*/
#define EXTENTS(r,idRect){\
if((r)->x1 < (idRect)->extents.x1)\
(idRect)->extents.x1 = (r)->x1;\
if((r)->y1 < (idRect)->extents.y1)\
(idRect)->extents.y1 = (r)->y1;\
if((r)->x2 > (idRect)->extents.x2)\
(idRect)->extents.x2 = (r)->x2;\
if((r)->y2 > (idRect)->extents.y2)\
(idRect)->extents.y2 = (r)->y2;\
}
/*
* Check to see if there is enough memory in the present region.
*/
#define MEMCHECK(reg, rect, firstrect){\
if ((reg)->numRects >= ((reg)->size - 1)){\
(firstrect) = (BOX *) Xrealloc \
((char *)(firstrect), (unsigned) (2 * (sizeof(BOX)) * ((reg)->size)));\
if ((firstrect) == 0)\
return(0);\
(reg)->size *= 2;\
(rect) = &(firstrect)[(reg)->numRects];\
}\
}
/* this routine checks to see if the previous rectangle is the same
* or subsumes the new rectangle to add.
*/
#define CHECK_PREVIOUS(Reg, R, Rx1, Ry1, Rx2, Ry2)\
(!(((Reg)->numRects > 0)&&\
((R-1)->y1 == (Ry1)) &&\
((R-1)->y2 == (Ry2)) &&\
((R-1)->x1 <= (Rx1)) &&\
((R-1)->x2 >= (Rx2))))
/* add a rectangle to the given Region */
#define ADDRECT(reg, r, rx1, ry1, rx2, ry2){\
if (((rx1) < (rx2)) && ((ry1) < (ry2)) &&\
CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
(r)->x1 = (rx1);\
(r)->y1 = (ry1);\
(r)->x2 = (rx2);\
(r)->y2 = (ry2);\
EXTENTS((r), (reg));\
(reg)->numRects++;\
(r)++;\
}\
}
/* add a rectangle to the given Region */
#define ADDRECTNOX(reg, r, rx1, ry1, rx2, ry2){\
if ((rx1 < rx2) && (ry1 < ry2) &&\
CHECK_PREVIOUS((reg), (r), (rx1), (ry1), (rx2), (ry2))){\
(r)->x1 = (rx1);\
(r)->y1 = (ry1);\
(r)->x2 = (rx2);\
(r)->y2 = (ry2);\
(reg)->numRects++;\
(r)++;\
}\
}
#define EMPTY_REGION(pReg) pReg->numRects = 0
#define REGION_NOT_EMPTY(pReg) pReg->numRects
#define INBOX(r, x, y) \
( ( ((r).x2 > x)) && \
( ((r).x1 <= x)) && \
( ((r).y2 > y)) && \
( ((r).y1 <= y)) )
/*
* number of points to buffer before sending them off
* to scanlines() : Must be an even number
*/
#define NUMPTSTOBUFFER 200
/*
* used to allocate buffers for points and link
* the buffers together
*/
typedef struct _POINTBLOCK {
XPoint pts[NUMPTSTOBUFFER];
struct _POINTBLOCK *next;
} POINTBLOCK;
#endif

View File

@ -1,60 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard <blizzard@mozilla.org>.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Peter Hartshorn <peter@igelaus.com.au>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsIDragSessionXLIB_h_
#define nsIDragSessionXLIB_h_
#include "nsISupports.h"
#include "nsIWidget.h"
#define NS_IDRAGSESSIONXLIB_IID \
{ 0xa6b49c42, 0x1dd1, 0x11b2, { 0xb2, 0xdf, 0xc1, 0xd6, 0x1d, 0x67, 0x45, 0xcf } };
class nsIDragSessionXlib : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IDRAGSESSIONXLIB_IID)
NS_IMETHOD IsDragging(PRBool *result) = 0;
NS_IMETHOD UpdatePosition(PRInt32 x, PRInt32 y) = 0;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIDragSessionXlib, NS_IDRAGSESSIONXLIB_IID)
#endif /* nsIDragSessionXLIB_h_ */

View File

@ -1,160 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org Code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = widget
LIBRARY_NAME = widget_gtk
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsWidgetGTKModule
GRE_MODULE = 1
LIBXUL_LIBRARY = 1
PACKAGE_FILE = widget_gtk.pkg
NATIVE_THEME_SUPPORT = 1
REQUIRES = xpcom \
string \
appshell \
gfx \
pref \
dom \
uconv \
necko \
view \
util \
unicharutil \
content \
layout \
locale \
$(NULL)
ifdef NS_TRACE_MALLOC
REQUIRES += tracemalloc
endif
CSRCS = \
keysym2ucs.c
CPPSRCS = \
nsAppShell.cpp \
nsBidiKeyboard.cpp \
nsClipboard.cpp \
nsDragService.cpp \
nsGtkEventHandler.cpp \
nsGtkUtils.cpp \
nsKeyboardUtils.cpp \
nsLookAndFeel.cpp \
nsSound.cpp \
nsToolkit.cpp \
nsWidget.cpp \
nsWidgetFactory.cpp \
nsWindow.cpp \
nsGtkIMEHelper.cpp \
nsScreenGtk.cpp \
nsScreenManagerGtk.cpp \
$(NULL)
SHARED_LIBRARY_LIBS = $(DIST)/lib/libxpwidgets_s.a
EXTRA_DSO_LIBS = gkgfx
ifdef NS_TRACE_MALLOC
EXTRA_DSO_LIBS += tracemalloc
endif
EXTRA_DSO_LDOPTS = \
$(LIBS_DIR) \
$(EXTRA_DSO_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(MOZ_JS_LIBS) \
$(NULL)
EXTRA_DSO_LDOPTS += -L$(DIST)/lib -lgtksuperwin $(MOZ_GTK_LDFLAGS)
ifdef NATIVE_THEME_SUPPORT
CSRCS += gtkdrawing.c
CPPSRCS += nsNativeThemeGTK.cpp
DEFINES += -DNATIVE_THEME_SUPPORT
endif
include $(topsrcdir)/config/rules.mk
CXXFLAGS += $(MOZ_GTK_CFLAGS)
CFLAGS += $(MOZ_GTK_CFLAGS)
DEFINES += -D_IMPL_NS_WIDGET -DUSE_XIM
ifeq ($(OS_ARCH), SunOS)
ifndef GNU_CC
# When using Sun's WorkShop compiler, including
# /wherever/workshop-5.0/SC5.0/include/CC/std/time.h
# causes most of these compiles to fail with:
# line 29: Error: Multiple declaration for std::tm.
# So, this gets around the problem.
DEFINES += -D_TIME_H=1
endif
endif
ifeq ($(OS_ARCH), OpenVMS)
DEFINES += -DGENERIC_MOTIF_REDEFINES
endif
LOCAL_INCLUDES = \
-I$(srcdir)/../xpwidgets \
-I$(srcdir) \
-I$(topsrcdir)/gfx/src/gtk \
$(NULL)
ICON_FILES = \
$(srcdir)/mozicon50.xpm \
$(srcdir)/mozicon16.xpm \
$(NULL)
libs::
$(INSTALL) $(ICON_FILES) $(DIST)/bin/icons
install::
$(SYSINSTALL) $(IFLAGS1) $(ICON_FILES) $(DESTDIR)$(mozappdir)/icons

File diff suppressed because it is too large Load Diff

View File

@ -1,293 +0,0 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Brian Ryner <bryner@brianryner.com> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/**
* gtkdrawing.h: GTK widget rendering utilities
*
* gtkdrawing provides an API for rendering GTK widgets in the
* current theme to a pixmap or window, without requiring an actual
* widget instantiation, similar to the Macintosh Appearance Manager
* or Windows XP's DrawThemeBackground() API.
*/
#ifndef _GTK_DRAWING_H_
#define _GTK_DRAWING_H_
#include <gdk/gdk.h>
#include <gtk/gtkstyle.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/*** type definitions ***/
typedef struct {
guint8 active;
guint8 focused;
guint8 inHover;
guint8 disabled;
guint8 isDefault;
guint8 canDefault;
gint32 curpos; /* curpos and maxpos are used for scrollbars */
gint32 maxpos;
} GtkWidgetState;
typedef struct {
gint slider_width;
gint trough_border;
gint stepper_size;
gint stepper_spacing;
gint min_slider_size;
} MozGtkScrollbarMetrics;
/** flags for tab state **/
typedef enum {
/* the first tab in the group */
MOZ_GTK_TAB_FIRST = 1 << 0,
/* the tab just before the selected tab */
MOZ_GTK_TAB_BEFORE_SELECTED = 1 << 1,
/* the selected tab */
MOZ_GTK_TAB_SELECTED = 1 << 2
} GtkTabFlags;
/* function type for moz_gtk_enable_style_props */
typedef gint (*style_prop_t)(GtkStyle*, const gchar*, gint);
/*** result/error codes ***/
#define MOZ_GTK_SUCCESS 0
#define MOZ_GTK_UNKNOWN_WIDGET -1
#define MOZ_GTK_UNSAFE_THEME -2
/*** widget type constants ***/
typedef enum {
/* Paints a GtkButton. flags is a GtkReliefStyle. */
MOZ_GTK_BUTTON,
/* Paints a GtkCheckButton. flags is a boolean, 1=checked, 0=not checked. */
MOZ_GTK_CHECKBUTTON,
/* Paints a GtkRadioButton. flags is a boolean, 1=checked, 0=not checked. */
MOZ_GTK_RADIOBUTTON,
/**
* Paints the button of a GtkScrollbar. flags is a GtkArrowType giving
* the arrow direction.
*/
MOZ_GTK_SCROLLBAR_BUTTON,
/* Paints the trough (track) of a GtkScrollbar. */
MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL,
MOZ_GTK_SCROLLBAR_TRACK_VERTICAL,
/* Paints the slider (thumb) of a GtkScrollbar. */
MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL,
MOZ_GTK_SCROLLBAR_THUMB_VERTICAL,
/* Paints a GtkScale. */
MOZ_GTK_SCALE_HORIZONTAL,
MOZ_GTK_SCALE_VERTICAL,
/* Paints a GtkScale thumb. */
MOZ_GTK_SCALE_THUMB_HORIZONTAL,
MOZ_GTK_SCALE_THUMB_VERTICAL,
/* Paints a GtkSpinButton */
MOZ_GTK_SPINBUTTON_UP,
MOZ_GTK_SPINBUTTON_DOWN,
/* Paints the gripper of a GtkHandleBox. */
MOZ_GTK_GRIPPER,
/* Paints a GtkEntry. */
MOZ_GTK_ENTRY,
/* Paints a GtkOptionMenu. */
MOZ_GTK_DROPDOWN,
/* Paints a dropdown arrow (a GtkButton containing a down GtkArrow). */
MOZ_GTK_DROPDOWN_ARROW,
/* Paints the container part of a GtkCheckButton. */
MOZ_GTK_CHECKBUTTON_CONTAINER,
/* Paints the container part of a GtkRadioButton. */
MOZ_GTK_RADIOBUTTON_CONTAINER,
/* Paints the label of a GtkCheckButton (focus outline) */
MOZ_GTK_CHECKBUTTON_LABEL,
/* Paints the label of a GtkRadioButton (focus outline) */
MOZ_GTK_RADIOBUTTON_LABEL,
/* Paints the background of a GtkHandleBox. */
MOZ_GTK_TOOLBAR,
/* Paints a GtkToolTip */
MOZ_GTK_TOOLTIP,
/* Paints a GtkFrame (e.g. a status bar panel). */
MOZ_GTK_FRAME,
/* Paints a GtkProgressBar. */
MOZ_GTK_PROGRESSBAR,
/* Paints a progress chunk of a GtkProgressBar. */
MOZ_GTK_PROGRESS_CHUNK,
/* Paints a tab of a GtkNotebook. flags is a GtkTabFlags, defined above. */
MOZ_GTK_TAB,
/* Paints the background and border of a GtkNotebook. */
MOZ_GTK_TABPANELS,
/* Paints the background of the menu bar. */
MOZ_GTK_MENUBAR,
/* Paints the background of menus, context menus. */
MOZ_GTK_MENUPOPUP,
/* Paints items of menubar and popups. */
MOZ_GTK_MENUITEM,
MOZ_GTK_CHECKMENUITEM,
MOZ_GTK_RADIOMENUITEM,
/* Paints the background of a window, dialog or page. */
MOZ_GTK_WINDOW
} GtkThemeWidgetType;
/*** General library functions ***/
/**
* Initializes the drawing library. You must call this function
* prior to using any other functionality.
* returns: MOZ_GTK_SUCCESS if there were no errors
* MOZ_GTK_UNSAFE_THEME if the current theme engine is known
* to crash with gtkdrawing.
*/
gint moz_gtk_init();
/**
* Enable GTK+ 1.2.9+ theme enhancements. You must provide a pointer
* to the GTK+ 1.2.9+ function "gtk_style_get_prop_experimental".
* styleGetProp: pointer to gtk_style_get_prop_experimental
*
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
*/
gint moz_gtk_enable_style_props(style_prop_t styleGetProp);
/**
* Perform cleanup of the drawing library. You should call this function
* when your program exits, or you no longer need the library.
*
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
*/
gint moz_gtk_shutdown();
/*** Widget drawing ***/
/**
* Paint a widget in the current theme.
* widget: a constant giving the widget to paint
* rect: the bounding rectangle for the widget
* cliprect: a clipprect rectangle for this painting operation
* state: the state of the widget. ignored for some widgets.
* flags: widget-dependant flags; see the GtkThemeWidgetType definition.
*/
gint
moz_gtk_widget_paint(GtkThemeWidgetType widget, GdkDrawable* drawable,
GdkRectangle* rect, GdkRectangle* cliprect,
GtkWidgetState* state, gint flags);
/*** Widget metrics ***/
/**
* Get the border size of a widget
* xthickness: [OUT] the widget's left/right border
* ythickness: [OUT] the widget's top/bottom border
*
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
*/
gint moz_gtk_get_widget_border(GtkThemeWidgetType widget, gint* xthickness,
gint* ythickness);
/**
* Get the desired size of a GtkCheckButton
* indicator_size: [OUT] the indicator size
* indicator_spacing: [OUT] the spacing between the indicator and its
* container
*
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
*/
gint
moz_gtk_checkbox_get_metrics(gint* indicator_size, gint* indicator_spacing);
/**
* Get the desired size of a GtkRadioButton
* indicator_size: [OUT] the indicator size
* indicator_spacing: [OUT] the spacing between the indicator and its
* container
*
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
*/
gint
moz_gtk_radio_get_metrics(gint* indicator_size, gint* indicator_spacing);
/** Get the focus metrics for a button, checkbox, or radio button.
* interior_focus: [OUT] whether the focus is drawn around the
* label (TRUE) or around the whole container (FALSE)
* focus_width: [OUT] the width of the focus line
* focus_pad: [OUT] the padding between the focus line and children
*
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
*/
gint
moz_gtk_button_get_focus(gboolean* interior_focus,
gint* focus_width, gint* focus_pad);
gint
moz_gtk_checkbox_get_focus(gboolean* interior_focus,
gint* focus_width, gint* focus_pad);
gint
moz_gtk_radio_get_focus(gboolean* interior_focus,
gint* focus_width, gint* focus_pad);
/**
* Get the desired size of a GtkScale thumb
* orient: [IN] the scale orientation
* thumb_length: [OUT] the length of the thumb
* thumb_height: [OUT] the height of the thumb
*
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
*/
gint
moz_gtk_get_scalethumb_metrics(GtkOrientation orient, gint* thumb_length, gint* thumb_height);
/**
* Get the desired metrics for a GtkScrollbar
* metrics: [IN] struct which will contain the metrics
*
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
*/
gint
moz_gtk_get_scrollbar_metrics(MozGtkScrollbarMetrics* metrics);
/**
* Get the desired size of a dropdown arrow button
* width: [OUT] the desired width
* height: [OUT] the desired height
*
* returns: MOZ_GTK_SUCCESS if there was no error, an error code otherwise
*/
gint moz_gtk_get_dropdown_arrow_size(gint* width, gint* height);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif

View File

@ -1,894 +0,0 @@
/*
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is from xterm-122 source XFree86: xc/programs/xterm/keysym2ucs.c,v 1.3 1999/07/11 08:49:37 dawes Exp.
*
* The Initial Developer of the Original Code is
* Markus G. Kuhn <mkuhn@acm.org> and Richard Verhoeven <river@win.tue.nl>.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Frank Tang <ftang@netscape.com> adopt into mozilla
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* This module converts keysym values into the corresponding ISO 10646-1
* (UCS, Unicode) values.
*
* The array keysymtab[] contains pairs of X11 keysym values for graphical
* characters and the corresponding Unicode value. The function
* keysym2ucs() maps a keysym onto a Unicode value using a binary search,
* therefore keysymtab[] must remain SORTED by keysym value.
*
* The keysym -> UTF-8 conversion will hopefully one day be provided
* by Xlib via XmbLookupString() and should ideally not have to be
* done in X applications. But we are not there yet.
*
* We allow to represent any UCS character in the range U+00000000 to
* U+00FFFFFF by a keysym value in the range 0x01000000 to 0x01ffffff.
* This admittedly does not cover the entire 31-bit space of UCS, but
* it does cover all of the characters up to U+10FFFF, which can be
* represented by UTF-16, and more, and it is very unlikely that higher
* UCS codes will ever be assigned by ISO. So to get Unicode character
* U+ABCD you can directly use keysym 0x1000abcd.
*
* NOTE: The comments in the table below contain the actual character
* encoded in UTF-8, so for viewing and editing best use an editor in
* UTF-8 mode.
*
* Author: Markus G. Kuhn <mkuhn@acm.org>, University of Cambridge, June 1999
*
* Special thanks to Richard Verhoeven <river@win.tue.nl> for preparing
* an initial draft of the mapping table.
*
* This software is in the public domain. Share and enjoy!
*/
#include "keysym2ucs.h"
struct codepair {
unsigned short keysym;
unsigned short ucs;
} keysymtab[] = {
{ 0x01a1, 0x0104 }, /* Aogonek Ą LATIN CAPITAL LETTER A WITH OGONEK */
{ 0x01a2, 0x02d8 }, /* breve ˘ BREVE */
{ 0x01a3, 0x0141 }, /* Lstroke Ł LATIN CAPITAL LETTER L WITH STROKE */
{ 0x01a5, 0x013d }, /* Lcaron Ľ LATIN CAPITAL LETTER L WITH CARON */
{ 0x01a6, 0x015a }, /* Sacute Ś LATIN CAPITAL LETTER S WITH ACUTE */
{ 0x01a9, 0x0160 }, /* Scaron Š LATIN CAPITAL LETTER S WITH CARON */
{ 0x01aa, 0x015e }, /* Scedilla Ş LATIN CAPITAL LETTER S WITH CEDILLA */
{ 0x01ab, 0x0164 }, /* Tcaron Ť LATIN CAPITAL LETTER T WITH CARON */
{ 0x01ac, 0x0179 }, /* Zacute Ź LATIN CAPITAL LETTER Z WITH ACUTE */
{ 0x01ae, 0x017d }, /* Zcaron Ž LATIN CAPITAL LETTER Z WITH CARON */
{ 0x01af, 0x017b }, /* Zabovedot Ż LATIN CAPITAL LETTER Z WITH DOT ABOVE */
{ 0x01b1, 0x0105 }, /* aogonek ą LATIN SMALL LETTER A WITH OGONEK */
{ 0x01b2, 0x02db }, /* ogonek ˛ OGONEK */
{ 0x01b3, 0x0142 }, /* lstroke ł LATIN SMALL LETTER L WITH STROKE */
{ 0x01b5, 0x013e }, /* lcaron ľ LATIN SMALL LETTER L WITH CARON */
{ 0x01b6, 0x015b }, /* sacute ś LATIN SMALL LETTER S WITH ACUTE */
{ 0x01b7, 0x02c7 }, /* caron ˇ CARON */
{ 0x01b9, 0x0161 }, /* scaron š LATIN SMALL LETTER S WITH CARON */
{ 0x01ba, 0x015f }, /* scedilla ş LATIN SMALL LETTER S WITH CEDILLA */
{ 0x01bb, 0x0165 }, /* tcaron ť LATIN SMALL LETTER T WITH CARON */
{ 0x01bc, 0x017a }, /* zacute ź LATIN SMALL LETTER Z WITH ACUTE */
{ 0x01bd, 0x02dd }, /* doubleacute ˝ DOUBLE ACUTE ACCENT */
{ 0x01be, 0x017e }, /* zcaron ž LATIN SMALL LETTER Z WITH CARON */
{ 0x01bf, 0x017c }, /* zabovedot ż LATIN SMALL LETTER Z WITH DOT ABOVE */
{ 0x01c0, 0x0154 }, /* Racute Ŕ LATIN CAPITAL LETTER R WITH ACUTE */
{ 0x01c3, 0x0102 }, /* Abreve Ă LATIN CAPITAL LETTER A WITH BREVE */
{ 0x01c5, 0x0139 }, /* Lacute Ĺ LATIN CAPITAL LETTER L WITH ACUTE */
{ 0x01c6, 0x0106 }, /* Cacute Ć LATIN CAPITAL LETTER C WITH ACUTE */
{ 0x01c8, 0x010c }, /* Ccaron Č LATIN CAPITAL LETTER C WITH CARON */
{ 0x01ca, 0x0118 }, /* Eogonek Ę LATIN CAPITAL LETTER E WITH OGONEK */
{ 0x01cc, 0x011a }, /* Ecaron Ě LATIN CAPITAL LETTER E WITH CARON */
{ 0x01cf, 0x010e }, /* Dcaron Ď LATIN CAPITAL LETTER D WITH CARON */
{ 0x01d0, 0x0110 }, /* Dstroke Đ LATIN CAPITAL LETTER D WITH STROKE */
{ 0x01d1, 0x0143 }, /* Nacute Ń LATIN CAPITAL LETTER N WITH ACUTE */
{ 0x01d2, 0x0147 }, /* Ncaron Ň LATIN CAPITAL LETTER N WITH CARON */
{ 0x01d5, 0x0150 }, /* Odoubleacute Ő LATIN CAPITAL LETTER O WITH DOUBLE ACUTE */
{ 0x01d8, 0x0158 }, /* Rcaron Ř LATIN CAPITAL LETTER R WITH CARON */
{ 0x01d9, 0x016e }, /* Uring Ů LATIN CAPITAL LETTER U WITH RING ABOVE */
{ 0x01db, 0x0170 }, /* Udoubleacute Ű LATIN CAPITAL LETTER U WITH DOUBLE ACUTE */
{ 0x01de, 0x0162 }, /* Tcedilla Ţ LATIN CAPITAL LETTER T WITH CEDILLA */
{ 0x01e0, 0x0155 }, /* racute ŕ LATIN SMALL LETTER R WITH ACUTE */
{ 0x01e3, 0x0103 }, /* abreve ă LATIN SMALL LETTER A WITH BREVE */
{ 0x01e5, 0x013a }, /* lacute ĺ LATIN SMALL LETTER L WITH ACUTE */
{ 0x01e6, 0x0107 }, /* cacute ć LATIN SMALL LETTER C WITH ACUTE */
{ 0x01e8, 0x010d }, /* ccaron č LATIN SMALL LETTER C WITH CARON */
{ 0x01ea, 0x0119 }, /* eogonek ę LATIN SMALL LETTER E WITH OGONEK */
{ 0x01ec, 0x011b }, /* ecaron ě LATIN SMALL LETTER E WITH CARON */
{ 0x01ef, 0x010f }, /* dcaron ď LATIN SMALL LETTER D WITH CARON */
{ 0x01f0, 0x0111 }, /* dstroke đ LATIN SMALL LETTER D WITH STROKE */
{ 0x01f1, 0x0144 }, /* nacute ń LATIN SMALL LETTER N WITH ACUTE */
{ 0x01f2, 0x0148 }, /* ncaron ň LATIN SMALL LETTER N WITH CARON */
{ 0x01f5, 0x0151 }, /* odoubleacute ő LATIN SMALL LETTER O WITH DOUBLE ACUTE */
{ 0x01f8, 0x0159 }, /* rcaron ř LATIN SMALL LETTER R WITH CARON */
{ 0x01f9, 0x016f }, /* uring ů LATIN SMALL LETTER U WITH RING ABOVE */
{ 0x01fb, 0x0171 }, /* udoubleacute ű LATIN SMALL LETTER U WITH DOUBLE ACUTE */
{ 0x01fe, 0x0163 }, /* tcedilla ţ LATIN SMALL LETTER T WITH CEDILLA */
{ 0x01ff, 0x02d9 }, /* abovedot ˙ DOT ABOVE */
{ 0x02a1, 0x0126 }, /* Hstroke Ħ LATIN CAPITAL LETTER H WITH STROKE */
{ 0x02a6, 0x0124 }, /* Hcircumflex Ĥ LATIN CAPITAL LETTER H WITH CIRCUMFLEX */
{ 0x02a9, 0x0130 }, /* Iabovedot İ LATIN CAPITAL LETTER I WITH DOT ABOVE */
{ 0x02ab, 0x011e }, /* Gbreve Ğ LATIN CAPITAL LETTER G WITH BREVE */
{ 0x02ac, 0x0134 }, /* Jcircumflex Ĵ LATIN CAPITAL LETTER J WITH CIRCUMFLEX */
{ 0x02b1, 0x0127 }, /* hstroke ħ LATIN SMALL LETTER H WITH STROKE */
{ 0x02b6, 0x0125 }, /* hcircumflex ĥ LATIN SMALL LETTER H WITH CIRCUMFLEX */
{ 0x02b9, 0x0131 }, /* idotless ı LATIN SMALL LETTER DOTLESS I */
{ 0x02bb, 0x011f }, /* gbreve ğ LATIN SMALL LETTER G WITH BREVE */
{ 0x02bc, 0x0135 }, /* jcircumflex ĵ LATIN SMALL LETTER J WITH CIRCUMFLEX */
{ 0x02c5, 0x010a }, /* Cabovedot Ċ LATIN CAPITAL LETTER C WITH DOT ABOVE */
{ 0x02c6, 0x0108 }, /* Ccircumflex Ĉ LATIN CAPITAL LETTER C WITH CIRCUMFLEX */
{ 0x02d5, 0x0120 }, /* Gabovedot Ġ LATIN CAPITAL LETTER G WITH DOT ABOVE */
{ 0x02d8, 0x011c }, /* Gcircumflex Ĝ LATIN CAPITAL LETTER G WITH CIRCUMFLEX */
{ 0x02dd, 0x016c }, /* Ubreve Ŭ LATIN CAPITAL LETTER U WITH BREVE */
{ 0x02de, 0x015c }, /* Scircumflex Ŝ LATIN CAPITAL LETTER S WITH CIRCUMFLEX */
{ 0x02e5, 0x010b }, /* cabovedot ċ LATIN SMALL LETTER C WITH DOT ABOVE */
{ 0x02e6, 0x0109 }, /* ccircumflex ĉ LATIN SMALL LETTER C WITH CIRCUMFLEX */
{ 0x02f5, 0x0121 }, /* gabovedot ġ LATIN SMALL LETTER G WITH DOT ABOVE */
{ 0x02f8, 0x011d }, /* gcircumflex ĝ LATIN SMALL LETTER G WITH CIRCUMFLEX */
{ 0x02fd, 0x016d }, /* ubreve ŭ LATIN SMALL LETTER U WITH BREVE */
{ 0x02fe, 0x015d }, /* scircumflex ŝ LATIN SMALL LETTER S WITH CIRCUMFLEX */
{ 0x03a2, 0x0138 }, /* kra ĸ LATIN SMALL LETTER KRA */
{ 0x03a3, 0x0156 }, /* Rcedilla Ŗ LATIN CAPITAL LETTER R WITH CEDILLA */
{ 0x03a5, 0x0128 }, /* Itilde Ĩ LATIN CAPITAL LETTER I WITH TILDE */
{ 0x03a6, 0x013b }, /* Lcedilla Ļ LATIN CAPITAL LETTER L WITH CEDILLA */
{ 0x03aa, 0x0112 }, /* Emacron Ē LATIN CAPITAL LETTER E WITH MACRON */
{ 0x03ab, 0x0122 }, /* Gcedilla Ģ LATIN CAPITAL LETTER G WITH CEDILLA */
{ 0x03ac, 0x0166 }, /* Tslash Ŧ LATIN CAPITAL LETTER T WITH STROKE */
{ 0x03b3, 0x0157 }, /* rcedilla ŗ LATIN SMALL LETTER R WITH CEDILLA */
{ 0x03b5, 0x0129 }, /* itilde ĩ LATIN SMALL LETTER I WITH TILDE */
{ 0x03b6, 0x013c }, /* lcedilla ļ LATIN SMALL LETTER L WITH CEDILLA */
{ 0x03ba, 0x0113 }, /* emacron ē LATIN SMALL LETTER E WITH MACRON */
{ 0x03bb, 0x0123 }, /* gcedilla ģ LATIN SMALL LETTER G WITH CEDILLA */
{ 0x03bc, 0x0167 }, /* tslash ŧ LATIN SMALL LETTER T WITH STROKE */
{ 0x03bd, 0x014a }, /* ENG Ŋ LATIN CAPITAL LETTER ENG */
{ 0x03bf, 0x014b }, /* eng ŋ LATIN SMALL LETTER ENG */
{ 0x03c0, 0x0100 }, /* Amacron Ā LATIN CAPITAL LETTER A WITH MACRON */
{ 0x03c7, 0x012e }, /* Iogonek Į LATIN CAPITAL LETTER I WITH OGONEK */
{ 0x03cc, 0x0116 }, /* Eabovedot Ė LATIN CAPITAL LETTER E WITH DOT ABOVE */
{ 0x03cf, 0x012a }, /* Imacron Ī LATIN CAPITAL LETTER I WITH MACRON */
{ 0x03d1, 0x0145 }, /* Ncedilla Ņ LATIN CAPITAL LETTER N WITH CEDILLA */
{ 0x03d2, 0x014c }, /* Omacron Ō LATIN CAPITAL LETTER O WITH MACRON */
{ 0x03d3, 0x0136 }, /* Kcedilla Ķ LATIN CAPITAL LETTER K WITH CEDILLA */
{ 0x03d9, 0x0172 }, /* Uogonek Ų LATIN CAPITAL LETTER U WITH OGONEK */
{ 0x03dd, 0x0168 }, /* Utilde Ũ LATIN CAPITAL LETTER U WITH TILDE */
{ 0x03de, 0x016a }, /* Umacron Ū LATIN CAPITAL LETTER U WITH MACRON */
{ 0x03e0, 0x0101 }, /* amacron ā LATIN SMALL LETTER A WITH MACRON */
{ 0x03e7, 0x012f }, /* iogonek į LATIN SMALL LETTER I WITH OGONEK */
{ 0x03ec, 0x0117 }, /* eabovedot ė LATIN SMALL LETTER E WITH DOT ABOVE */
{ 0x03ef, 0x012b }, /* imacron ī LATIN SMALL LETTER I WITH MACRON */
{ 0x03f1, 0x0146 }, /* ncedilla ņ LATIN SMALL LETTER N WITH CEDILLA */
{ 0x03f2, 0x014d }, /* omacron ō LATIN SMALL LETTER O WITH MACRON */
{ 0x03f3, 0x0137 }, /* kcedilla ķ LATIN SMALL LETTER K WITH CEDILLA */
{ 0x03f9, 0x0173 }, /* uogonek ų LATIN SMALL LETTER U WITH OGONEK */
{ 0x03fd, 0x0169 }, /* utilde ũ LATIN SMALL LETTER U WITH TILDE */
{ 0x03fe, 0x016b }, /* umacron ū LATIN SMALL LETTER U WITH MACRON */
{ 0x047e, 0x203e }, /* overline ‾ OVERLINE */
{ 0x04a1, 0x3002 }, /* kana_fullstop 。 IDEOGRAPHIC FULL STOP */
{ 0x04a2, 0x300c }, /* kana_openingbracket 「 LEFT CORNER BRACKET */
{ 0x04a3, 0x300d }, /* kana_closingbracket 」 RIGHT CORNER BRACKET */
{ 0x04a4, 0x3001 }, /* kana_comma 、 IDEOGRAPHIC COMMA */
{ 0x04a5, 0x30fb }, /* kana_conjunctive ・ KATAKANA MIDDLE DOT */
{ 0x04a6, 0x30f2 }, /* kana_WO ヲ KATAKANA LETTER WO */
{ 0x04a7, 0x30a1 }, /* kana_a ァ KATAKANA LETTER SMALL A */
{ 0x04a8, 0x30a3 }, /* kana_i ィ KATAKANA LETTER SMALL I */
{ 0x04a9, 0x30a5 }, /* kana_u ゥ KATAKANA LETTER SMALL U */
{ 0x04aa, 0x30a7 }, /* kana_e ェ KATAKANA LETTER SMALL E */
{ 0x04ab, 0x30a9 }, /* kana_o ォ KATAKANA LETTER SMALL O */
{ 0x04ac, 0x30e3 }, /* kana_ya ャ KATAKANA LETTER SMALL YA */
{ 0x04ad, 0x30e5 }, /* kana_yu ュ KATAKANA LETTER SMALL YU */
{ 0x04ae, 0x30e7 }, /* kana_yo ョ KATAKANA LETTER SMALL YO */
{ 0x04af, 0x30c3 }, /* kana_tsu ッ KATAKANA LETTER SMALL TU */
{ 0x04b0, 0x30fc }, /* prolongedsound ー KATAKANA-HIRAGANA PROLONGED SOUND MARK */
{ 0x04b1, 0x30a2 }, /* kana_A ア KATAKANA LETTER A */
{ 0x04b2, 0x30a4 }, /* kana_I イ KATAKANA LETTER I */
{ 0x04b3, 0x30a6 }, /* kana_U ウ KATAKANA LETTER U */
{ 0x04b4, 0x30a8 }, /* kana_E エ KATAKANA LETTER E */
{ 0x04b5, 0x30aa }, /* kana_O オ KATAKANA LETTER O */
{ 0x04b6, 0x30ab }, /* kana_KA カ KATAKANA LETTER KA */
{ 0x04b7, 0x30ad }, /* kana_KI キ KATAKANA LETTER KI */
{ 0x04b8, 0x30af }, /* kana_KU ク KATAKANA LETTER KU */
{ 0x04b9, 0x30b1 }, /* kana_KE ケ KATAKANA LETTER KE */
{ 0x04ba, 0x30b3 }, /* kana_KO コ KATAKANA LETTER KO */
{ 0x04bb, 0x30b5 }, /* kana_SA サ KATAKANA LETTER SA */
{ 0x04bc, 0x30b7 }, /* kana_SHI シ KATAKANA LETTER SI */
{ 0x04bd, 0x30b9 }, /* kana_SU ス KATAKANA LETTER SU */
{ 0x04be, 0x30bb }, /* kana_SE セ KATAKANA LETTER SE */
{ 0x04bf, 0x30bd }, /* kana_SO ソ KATAKANA LETTER SO */
{ 0x04c0, 0x30bf }, /* kana_TA タ KATAKANA LETTER TA */
{ 0x04c1, 0x30c1 }, /* kana_CHI チ KATAKANA LETTER TI */
{ 0x04c2, 0x30c4 }, /* kana_TSU ツ KATAKANA LETTER TU */
{ 0x04c3, 0x30c6 }, /* kana_TE テ KATAKANA LETTER TE */
{ 0x04c4, 0x30c8 }, /* kana_TO ト KATAKANA LETTER TO */
{ 0x04c5, 0x30ca }, /* kana_NA ナ KATAKANA LETTER NA */
{ 0x04c6, 0x30cb }, /* kana_NI ニ KATAKANA LETTER NI */
{ 0x04c7, 0x30cc }, /* kana_NU ヌ KATAKANA LETTER NU */
{ 0x04c8, 0x30cd }, /* kana_NE ネ KATAKANA LETTER NE */
{ 0x04c9, 0x30ce }, /* kana_NO KATAKANA LETTER NO */
{ 0x04ca, 0x30cf }, /* kana_HA ハ KATAKANA LETTER HA */
{ 0x04cb, 0x30d2 }, /* kana_HI ヒ KATAKANA LETTER HI */
{ 0x04cc, 0x30d5 }, /* kana_FU フ KATAKANA LETTER HU */
{ 0x04cd, 0x30d8 }, /* kana_HE ヘ KATAKANA LETTER HE */
{ 0x04ce, 0x30db }, /* kana_HO ホ KATAKANA LETTER HO */
{ 0x04cf, 0x30de }, /* kana_MA マ KATAKANA LETTER MA */
{ 0x04d0, 0x30df }, /* kana_MI ミ KATAKANA LETTER MI */
{ 0x04d1, 0x30e0 }, /* kana_MU ム KATAKANA LETTER MU */
{ 0x04d2, 0x30e1 }, /* kana_ME メ KATAKANA LETTER ME */
{ 0x04d3, 0x30e2 }, /* kana_MO モ KATAKANA LETTER MO */
{ 0x04d4, 0x30e4 }, /* kana_YA ヤ KATAKANA LETTER YA */
{ 0x04d5, 0x30e6 }, /* kana_YU ユ KATAKANA LETTER YU */
{ 0x04d6, 0x30e8 }, /* kana_YO ヨ KATAKANA LETTER YO */
{ 0x04d7, 0x30e9 }, /* kana_RA ラ KATAKANA LETTER RA */
{ 0x04d8, 0x30ea }, /* kana_RI リ KATAKANA LETTER RI */
{ 0x04d9, 0x30eb }, /* kana_RU ル KATAKANA LETTER RU */
{ 0x04da, 0x30ec }, /* kana_RE レ KATAKANA LETTER RE */
{ 0x04db, 0x30ed }, /* kana_RO ロ KATAKANA LETTER RO */
{ 0x04dc, 0x30ef }, /* kana_WA ワ KATAKANA LETTER WA */
{ 0x04dd, 0x30f3 }, /* kana_N ン KATAKANA LETTER N */
{ 0x04de, 0x309b }, /* voicedsound ゛ KATAKANA-HIRAGANA VOICED SOUND MARK */
{ 0x04df, 0x309c }, /* semivoicedsound ゜ KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK */
{ 0x05ac, 0x060c }, /* Arabic_comma ، ARABIC COMMA */
{ 0x05bb, 0x061b }, /* Arabic_semicolon ؛ ARABIC SEMICOLON */
{ 0x05bf, 0x061f }, /* Arabic_question_mark ؟ ARABIC QUESTION MARK */
{ 0x05c1, 0x0621 }, /* Arabic_hamza ء ARABIC LETTER HAMZA */
{ 0x05c2, 0x0622 }, /* Arabic_maddaonalef آ ARABIC LETTER ALEF WITH MADDA ABOVE */
{ 0x05c3, 0x0623 }, /* Arabic_hamzaonalef أ ARABIC LETTER ALEF WITH HAMZA ABOVE */
{ 0x05c4, 0x0624 }, /* Arabic_hamzaonwaw ؤ ARABIC LETTER WAW WITH HAMZA ABOVE */
{ 0x05c5, 0x0625 }, /* Arabic_hamzaunderalef إ ARABIC LETTER ALEF WITH HAMZA BELOW */
{ 0x05c6, 0x0626 }, /* Arabic_hamzaonyeh ئ ARABIC LETTER YEH WITH HAMZA ABOVE */
{ 0x05c7, 0x0627 }, /* Arabic_alef ا ARABIC LETTER ALEF */
{ 0x05c8, 0x0628 }, /* Arabic_beh ب ARABIC LETTER BEH */
{ 0x05c9, 0x0629 }, /* Arabic_tehmarbuta ة ARABIC LETTER TEH MARBUTA */
{ 0x05ca, 0x062a }, /* Arabic_teh ت ARABIC LETTER TEH */
{ 0x05cb, 0x062b }, /* Arabic_theh ث ARABIC LETTER THEH */
{ 0x05cc, 0x062c }, /* Arabic_jeem ج ARABIC LETTER JEEM */
{ 0x05cd, 0x062d }, /* Arabic_hah ح ARABIC LETTER HAH */
{ 0x05ce, 0x062e }, /* Arabic_khah خ ARABIC LETTER KHAH */
{ 0x05cf, 0x062f }, /* Arabic_dal د ARABIC LETTER DAL */
{ 0x05d0, 0x0630 }, /* Arabic_thal ذ ARABIC LETTER THAL */
{ 0x05d1, 0x0631 }, /* Arabic_ra ر ARABIC LETTER REH */
{ 0x05d2, 0x0632 }, /* Arabic_zain ز ARABIC LETTER ZAIN */
{ 0x05d3, 0x0633 }, /* Arabic_seen س ARABIC LETTER SEEN */
{ 0x05d4, 0x0634 }, /* Arabic_sheen ش ARABIC LETTER SHEEN */
{ 0x05d5, 0x0635 }, /* Arabic_sad ص ARABIC LETTER SAD */
{ 0x05d6, 0x0636 }, /* Arabic_dad ض ARABIC LETTER DAD */
{ 0x05d7, 0x0637 }, /* Arabic_tah ط ARABIC LETTER TAH */
{ 0x05d8, 0x0638 }, /* Arabic_zah ظ ARABIC LETTER ZAH */
{ 0x05d9, 0x0639 }, /* Arabic_ain ع ARABIC LETTER AIN */
{ 0x05da, 0x063a }, /* Arabic_ghain غ ARABIC LETTER GHAIN */
{ 0x05e0, 0x0640 }, /* Arabic_tatweel ـ ARABIC TATWEEL */
{ 0x05e1, 0x0641 }, /* Arabic_feh ف ARABIC LETTER FEH */
{ 0x05e2, 0x0642 }, /* Arabic_qaf ق ARABIC LETTER QAF */
{ 0x05e3, 0x0643 }, /* Arabic_kaf ك ARABIC LETTER KAF */
{ 0x05e4, 0x0644 }, /* Arabic_lam ل ARABIC LETTER LAM */
{ 0x05e5, 0x0645 }, /* Arabic_meem م ARABIC LETTER MEEM */
{ 0x05e6, 0x0646 }, /* Arabic_noon ن ARABIC LETTER NOON */
{ 0x05e7, 0x0647 }, /* Arabic_ha ه ARABIC LETTER HEH */
{ 0x05e8, 0x0648 }, /* Arabic_waw و ARABIC LETTER WAW */
{ 0x05e9, 0x0649 }, /* Arabic_alefmaksura ى ARABIC LETTER ALEF MAKSURA */
{ 0x05ea, 0x064a }, /* Arabic_yeh ي ARABIC LETTER YEH */
{ 0x05eb, 0x064b }, /* Arabic_fathatan ً ARABIC FATHATAN */
{ 0x05ec, 0x064c }, /* Arabic_dammatan ٌ ARABIC DAMMATAN */
{ 0x05ed, 0x064d }, /* Arabic_kasratan ٍ ARABIC KASRATAN */
{ 0x05ee, 0x064e }, /* Arabic_fatha َ ARABIC FATHA */
{ 0x05ef, 0x064f }, /* Arabic_damma ُ ARABIC DAMMA */
{ 0x05f0, 0x0650 }, /* Arabic_kasra ِ ARABIC KASRA */
{ 0x05f1, 0x0651 }, /* Arabic_shadda ّ ARABIC SHADDA */
{ 0x05f2, 0x0652 }, /* Arabic_sukun ْ ARABIC SUKUN */
{ 0x06a1, 0x0452 }, /* Serbian_dje ђ CYRILLIC SMALL LETTER DJE */
{ 0x06a2, 0x0453 }, /* Macedonia_gje ѓ CYRILLIC SMALL LETTER GJE */
{ 0x06a3, 0x0451 }, /* Cyrillic_io ё CYRILLIC SMALL LETTER IO */
{ 0x06a4, 0x0454 }, /* Ukrainian_ie є CYRILLIC SMALL LETTER UKRAINIAN IE */
{ 0x06a5, 0x0455 }, /* Macedonia_dse ѕ CYRILLIC SMALL LETTER DZE */
{ 0x06a6, 0x0456 }, /* Ukrainian_i і CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I */
{ 0x06a7, 0x0457 }, /* Ukrainian_yi ї CYRILLIC SMALL LETTER YI */
{ 0x06a8, 0x0458 }, /* Cyrillic_je ј CYRILLIC SMALL LETTER JE */
{ 0x06a9, 0x0459 }, /* Cyrillic_lje љ CYRILLIC SMALL LETTER LJE */
{ 0x06aa, 0x045a }, /* Cyrillic_nje њ CYRILLIC SMALL LETTER NJE */
{ 0x06ab, 0x045b }, /* Serbian_tshe ћ CYRILLIC SMALL LETTER TSHE */
{ 0x06ac, 0x045c }, /* Macedonia_kje ќ CYRILLIC SMALL LETTER KJE */
{ 0x06ae, 0x045e }, /* Byelorussian_shortu ў CYRILLIC SMALL LETTER SHORT U */
{ 0x06af, 0x045f }, /* Cyrillic_dzhe џ CYRILLIC SMALL LETTER DZHE */
{ 0x06b0, 0x2116 }, /* numerosign № NUMERO SIGN */
{ 0x06b1, 0x0402 }, /* Serbian_DJE Ђ CYRILLIC CAPITAL LETTER DJE */
{ 0x06b2, 0x0403 }, /* Macedonia_GJE Ѓ CYRILLIC CAPITAL LETTER GJE */
{ 0x06b3, 0x0401 }, /* Cyrillic_IO Ё CYRILLIC CAPITAL LETTER IO */
{ 0x06b4, 0x0404 }, /* Ukrainian_IE Є CYRILLIC CAPITAL LETTER UKRAINIAN IE */
{ 0x06b5, 0x0405 }, /* Macedonia_DSE Ѕ CYRILLIC CAPITAL LETTER DZE */
{ 0x06b6, 0x0406 }, /* Ukrainian_I І CYRILLIC CAPITAL LETTER BYELORUSSIAN-UKRAINIAN I */
{ 0x06b7, 0x0407 }, /* Ukrainian_YI Ї CYRILLIC CAPITAL LETTER YI */
{ 0x06b8, 0x0408 }, /* Cyrillic_JE Ј CYRILLIC CAPITAL LETTER JE */
{ 0x06b9, 0x0409 }, /* Cyrillic_LJE Љ CYRILLIC CAPITAL LETTER LJE */
{ 0x06ba, 0x040a }, /* Cyrillic_NJE Њ CYRILLIC CAPITAL LETTER NJE */
{ 0x06bb, 0x040b }, /* Serbian_TSHE Ћ CYRILLIC CAPITAL LETTER TSHE */
{ 0x06bc, 0x040c }, /* Macedonia_KJE Ќ CYRILLIC CAPITAL LETTER KJE */
{ 0x06be, 0x040e }, /* Byelorussian_SHORTU Ў CYRILLIC CAPITAL LETTER SHORT U */
{ 0x06bf, 0x040f }, /* Cyrillic_DZHE Џ CYRILLIC CAPITAL LETTER DZHE */
{ 0x06c0, 0x044e }, /* Cyrillic_yu ю CYRILLIC SMALL LETTER YU */
{ 0x06c1, 0x0430 }, /* Cyrillic_a а CYRILLIC SMALL LETTER A */
{ 0x06c2, 0x0431 }, /* Cyrillic_be б CYRILLIC SMALL LETTER BE */
{ 0x06c3, 0x0446 }, /* Cyrillic_tse ц CYRILLIC SMALL LETTER TSE */
{ 0x06c4, 0x0434 }, /* Cyrillic_de д CYRILLIC SMALL LETTER DE */
{ 0x06c5, 0x0435 }, /* Cyrillic_ie е CYRILLIC SMALL LETTER IE */
{ 0x06c6, 0x0444 }, /* Cyrillic_ef ф CYRILLIC SMALL LETTER EF */
{ 0x06c7, 0x0433 }, /* Cyrillic_ghe г CYRILLIC SMALL LETTER GHE */
{ 0x06c8, 0x0445 }, /* Cyrillic_ha х CYRILLIC SMALL LETTER HA */
{ 0x06c9, 0x0438 }, /* Cyrillic_i и CYRILLIC SMALL LETTER I */
{ 0x06ca, 0x0439 }, /* Cyrillic_shorti й CYRILLIC SMALL LETTER SHORT I */
{ 0x06cb, 0x043a }, /* Cyrillic_ka к CYRILLIC SMALL LETTER KA */
{ 0x06cc, 0x043b }, /* Cyrillic_el л CYRILLIC SMALL LETTER EL */
{ 0x06cd, 0x043c }, /* Cyrillic_em м CYRILLIC SMALL LETTER EM */
{ 0x06ce, 0x043d }, /* Cyrillic_en н CYRILLIC SMALL LETTER EN */
{ 0x06cf, 0x043e }, /* Cyrillic_o о CYRILLIC SMALL LETTER O */
{ 0x06d0, 0x043f }, /* Cyrillic_pe п CYRILLIC SMALL LETTER PE */
{ 0x06d1, 0x044f }, /* Cyrillic_ya я CYRILLIC SMALL LETTER YA */
{ 0x06d2, 0x0440 }, /* Cyrillic_er р CYRILLIC SMALL LETTER ER */
{ 0x06d3, 0x0441 }, /* Cyrillic_es с CYRILLIC SMALL LETTER ES */
{ 0x06d4, 0x0442 }, /* Cyrillic_te т CYRILLIC SMALL LETTER TE */
{ 0x06d5, 0x0443 }, /* Cyrillic_u у CYRILLIC SMALL LETTER U */
{ 0x06d6, 0x0436 }, /* Cyrillic_zhe ж CYRILLIC SMALL LETTER ZHE */
{ 0x06d7, 0x0432 }, /* Cyrillic_ve в CYRILLIC SMALL LETTER VE */
{ 0x06d8, 0x044c }, /* Cyrillic_softsign ь CYRILLIC SMALL LETTER SOFT SIGN */
{ 0x06d9, 0x044b }, /* Cyrillic_yeru ы CYRILLIC SMALL LETTER YERU */
{ 0x06da, 0x0437 }, /* Cyrillic_ze з CYRILLIC SMALL LETTER ZE */
{ 0x06db, 0x0448 }, /* Cyrillic_sha ш CYRILLIC SMALL LETTER SHA */
{ 0x06dc, 0x044d }, /* Cyrillic_e э CYRILLIC SMALL LETTER E */
{ 0x06dd, 0x0449 }, /* Cyrillic_shcha щ CYRILLIC SMALL LETTER SHCHA */
{ 0x06de, 0x0447 }, /* Cyrillic_che ч CYRILLIC SMALL LETTER CHE */
{ 0x06df, 0x044a }, /* Cyrillic_hardsign ъ CYRILLIC SMALL LETTER HARD SIGN */
{ 0x06e0, 0x042e }, /* Cyrillic_YU Ю CYRILLIC CAPITAL LETTER YU */
{ 0x06e1, 0x0410 }, /* Cyrillic_A А CYRILLIC CAPITAL LETTER A */
{ 0x06e2, 0x0411 }, /* Cyrillic_BE Б CYRILLIC CAPITAL LETTER BE */
{ 0x06e3, 0x0426 }, /* Cyrillic_TSE Ц CYRILLIC CAPITAL LETTER TSE */
{ 0x06e4, 0x0414 }, /* Cyrillic_DE Д CYRILLIC CAPITAL LETTER DE */
{ 0x06e5, 0x0415 }, /* Cyrillic_IE Е CYRILLIC CAPITAL LETTER IE */
{ 0x06e6, 0x0424 }, /* Cyrillic_EF Ф CYRILLIC CAPITAL LETTER EF */
{ 0x06e7, 0x0413 }, /* Cyrillic_GHE Г CYRILLIC CAPITAL LETTER GHE */
{ 0x06e8, 0x0425 }, /* Cyrillic_HA Х CYRILLIC CAPITAL LETTER HA */
{ 0x06e9, 0x0418 }, /* Cyrillic_I И CYRILLIC CAPITAL LETTER I */
{ 0x06ea, 0x0419 }, /* Cyrillic_SHORTI Й CYRILLIC CAPITAL LETTER SHORT I */
{ 0x06eb, 0x041a }, /* Cyrillic_KA К CYRILLIC CAPITAL LETTER KA */
{ 0x06ec, 0x041b }, /* Cyrillic_EL Л CYRILLIC CAPITAL LETTER EL */
{ 0x06ed, 0x041c }, /* Cyrillic_EM М CYRILLIC CAPITAL LETTER EM */
{ 0x06ee, 0x041d }, /* Cyrillic_EN Н CYRILLIC CAPITAL LETTER EN */
{ 0x06ef, 0x041e }, /* Cyrillic_O О CYRILLIC CAPITAL LETTER O */
{ 0x06f0, 0x041f }, /* Cyrillic_PE П CYRILLIC CAPITAL LETTER PE */
{ 0x06f1, 0x042f }, /* Cyrillic_YA Я CYRILLIC CAPITAL LETTER YA */
{ 0x06f2, 0x0420 }, /* Cyrillic_ER Р CYRILLIC CAPITAL LETTER ER */
{ 0x06f3, 0x0421 }, /* Cyrillic_ES С CYRILLIC CAPITAL LETTER ES */
{ 0x06f4, 0x0422 }, /* Cyrillic_TE Т CYRILLIC CAPITAL LETTER TE */
{ 0x06f5, 0x0423 }, /* Cyrillic_U У CYRILLIC CAPITAL LETTER U */
{ 0x06f6, 0x0416 }, /* Cyrillic_ZHE Ж CYRILLIC CAPITAL LETTER ZHE */
{ 0x06f7, 0x0412 }, /* Cyrillic_VE В CYRILLIC CAPITAL LETTER VE */
{ 0x06f8, 0x042c }, /* Cyrillic_SOFTSIGN Ь CYRILLIC CAPITAL LETTER SOFT SIGN */
{ 0x06f9, 0x042b }, /* Cyrillic_YERU Ы CYRILLIC CAPITAL LETTER YERU */
{ 0x06fa, 0x0417 }, /* Cyrillic_ZE З CYRILLIC CAPITAL LETTER ZE */
{ 0x06fb, 0x0428 }, /* Cyrillic_SHA Ш CYRILLIC CAPITAL LETTER SHA */
{ 0x06fc, 0x042d }, /* Cyrillic_E Э CYRILLIC CAPITAL LETTER E */
{ 0x06fd, 0x0429 }, /* Cyrillic_SHCHA Щ CYRILLIC CAPITAL LETTER SHCHA */
{ 0x06fe, 0x0427 }, /* Cyrillic_CHE Ч CYRILLIC CAPITAL LETTER CHE */
{ 0x06ff, 0x042a }, /* Cyrillic_HARDSIGN Ъ CYRILLIC CAPITAL LETTER HARD SIGN */
{ 0x07a1, 0x0386 }, /* Greek_ALPHAaccent Ά GREEK CAPITAL LETTER ALPHA WITH TONOS */
{ 0x07a2, 0x0388 }, /* Greek_EPSILONaccent Έ GREEK CAPITAL LETTER EPSILON WITH TONOS */
{ 0x07a3, 0x0389 }, /* Greek_ETAaccent Ή GREEK CAPITAL LETTER ETA WITH TONOS */
{ 0x07a4, 0x038a }, /* Greek_IOTAaccent Ί GREEK CAPITAL LETTER IOTA WITH TONOS */
{ 0x07a5, 0x03aa }, /* Greek_IOTAdiaeresis Ϊ GREEK CAPITAL LETTER IOTA WITH DIALYTIKA */
{ 0x07a7, 0x038c }, /* Greek_OMICRONaccent Ό GREEK CAPITAL LETTER OMICRON WITH TONOS */
{ 0x07a8, 0x038e }, /* Greek_UPSILONaccent Ύ GREEK CAPITAL LETTER UPSILON WITH TONOS */
{ 0x07a9, 0x03ab }, /* Greek_UPSILONdieresis Ϋ GREEK CAPITAL LETTER UPSILON WITH DIALYTIKA */
{ 0x07ab, 0x038f }, /* Greek_OMEGAaccent Ώ GREEK CAPITAL LETTER OMEGA WITH TONOS */
{ 0x07ae, 0x0385 }, /* Greek_accentdieresis ΅ GREEK DIALYTIKA TONOS */
{ 0x07af, 0x2015 }, /* Greek_horizbar ― HORIZONTAL BAR */
{ 0x07b1, 0x03ac }, /* Greek_alphaaccent ά GREEK SMALL LETTER ALPHA WITH TONOS */
{ 0x07b2, 0x03ad }, /* Greek_epsilonaccent έ GREEK SMALL LETTER EPSILON WITH TONOS */
{ 0x07b3, 0x03ae }, /* Greek_etaaccent ή GREEK SMALL LETTER ETA WITH TONOS */
{ 0x07b4, 0x03af }, /* Greek_iotaaccent ί GREEK SMALL LETTER IOTA WITH TONOS */
{ 0x07b5, 0x03ca }, /* Greek_iotadieresis ϊ GREEK SMALL LETTER IOTA WITH DIALYTIKA */
{ 0x07b6, 0x0390 }, /* Greek_iotaaccentdieresis ΐ GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS */
{ 0x07b7, 0x03cc }, /* Greek_omicronaccent ό GREEK SMALL LETTER OMICRON WITH TONOS */
{ 0x07b8, 0x03cd }, /* Greek_upsilonaccent ύ GREEK SMALL LETTER UPSILON WITH TONOS */
{ 0x07b9, 0x03cb }, /* Greek_upsilondieresis ϋ GREEK SMALL LETTER UPSILON WITH DIALYTIKA */
{ 0x07ba, 0x03b0 }, /* Greek_upsilonaccentdieresis ΰ GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS */
{ 0x07bb, 0x03ce }, /* Greek_omegaaccent ώ GREEK SMALL LETTER OMEGA WITH TONOS */
{ 0x07c1, 0x0391 }, /* Greek_ALPHA Α GREEK CAPITAL LETTER ALPHA */
{ 0x07c2, 0x0392 }, /* Greek_BETA Β GREEK CAPITAL LETTER BETA */
{ 0x07c3, 0x0393 }, /* Greek_GAMMA Γ GREEK CAPITAL LETTER GAMMA */
{ 0x07c4, 0x0394 }, /* Greek_DELTA Δ GREEK CAPITAL LETTER DELTA */
{ 0x07c5, 0x0395 }, /* Greek_EPSILON Ε GREEK CAPITAL LETTER EPSILON */
{ 0x07c6, 0x0396 }, /* Greek_ZETA Ζ GREEK CAPITAL LETTER ZETA */
{ 0x07c7, 0x0397 }, /* Greek_ETA Η GREEK CAPITAL LETTER ETA */
{ 0x07c8, 0x0398 }, /* Greek_THETA Θ GREEK CAPITAL LETTER THETA */
{ 0x07c9, 0x0399 }, /* Greek_IOTA Ι GREEK CAPITAL LETTER IOTA */
{ 0x07ca, 0x039a }, /* Greek_KAPPA Κ GREEK CAPITAL LETTER KAPPA */
{ 0x07cb, 0x039b }, /* Greek_LAMBDA Λ GREEK CAPITAL LETTER LAMDA */
{ 0x07cc, 0x039c }, /* Greek_MU Μ GREEK CAPITAL LETTER MU */
{ 0x07cd, 0x039d }, /* Greek_NU Ν GREEK CAPITAL LETTER NU */
{ 0x07ce, 0x039e }, /* Greek_XI Ξ GREEK CAPITAL LETTER XI */
{ 0x07cf, 0x039f }, /* Greek_OMICRON Ο GREEK CAPITAL LETTER OMICRON */
{ 0x07d0, 0x03a0 }, /* Greek_PI Π GREEK CAPITAL LETTER PI */
{ 0x07d1, 0x03a1 }, /* Greek_RHO Ρ GREEK CAPITAL LETTER RHO */
{ 0x07d2, 0x03a3 }, /* Greek_SIGMA Σ GREEK CAPITAL LETTER SIGMA */
{ 0x07d4, 0x03a4 }, /* Greek_TAU Τ GREEK CAPITAL LETTER TAU */
{ 0x07d5, 0x03a5 }, /* Greek_UPSILON Υ GREEK CAPITAL LETTER UPSILON */
{ 0x07d6, 0x03a6 }, /* Greek_PHI Φ GREEK CAPITAL LETTER PHI */
{ 0x07d7, 0x03a7 }, /* Greek_CHI Χ GREEK CAPITAL LETTER CHI */
{ 0x07d8, 0x03a8 }, /* Greek_PSI Ψ GREEK CAPITAL LETTER PSI */
{ 0x07d9, 0x03a9 }, /* Greek_OMEGA Ω GREEK CAPITAL LETTER OMEGA */
{ 0x07e1, 0x03b1 }, /* Greek_alpha α GREEK SMALL LETTER ALPHA */
{ 0x07e2, 0x03b2 }, /* Greek_beta β GREEK SMALL LETTER BETA */
{ 0x07e3, 0x03b3 }, /* Greek_gamma γ GREEK SMALL LETTER GAMMA */
{ 0x07e4, 0x03b4 }, /* Greek_delta δ GREEK SMALL LETTER DELTA */
{ 0x07e5, 0x03b5 }, /* Greek_epsilon ε GREEK SMALL LETTER EPSILON */
{ 0x07e6, 0x03b6 }, /* Greek_zeta ζ GREEK SMALL LETTER ZETA */
{ 0x07e7, 0x03b7 }, /* Greek_eta η GREEK SMALL LETTER ETA */
{ 0x07e8, 0x03b8 }, /* Greek_theta θ GREEK SMALL LETTER THETA */
{ 0x07e9, 0x03b9 }, /* Greek_iota ι GREEK SMALL LETTER IOTA */
{ 0x07ea, 0x03ba }, /* Greek_kappa κ GREEK SMALL LETTER KAPPA */
{ 0x07eb, 0x03bb }, /* Greek_lambda λ GREEK SMALL LETTER LAMDA */
{ 0x07ec, 0x03bc }, /* Greek_mu μ GREEK SMALL LETTER MU */
{ 0x07ed, 0x03bd }, /* Greek_nu ν GREEK SMALL LETTER NU */
{ 0x07ee, 0x03be }, /* Greek_xi ξ GREEK SMALL LETTER XI */
{ 0x07ef, 0x03bf }, /* Greek_omicron ο GREEK SMALL LETTER OMICRON */
{ 0x07f0, 0x03c0 }, /* Greek_pi π GREEK SMALL LETTER PI */
{ 0x07f1, 0x03c1 }, /* Greek_rho ρ GREEK SMALL LETTER RHO */
{ 0x07f2, 0x03c3 }, /* Greek_sigma σ GREEK SMALL LETTER SIGMA */
{ 0x07f3, 0x03c2 }, /* Greek_finalsmallsigma ς GREEK SMALL LETTER FINAL SIGMA */
{ 0x07f4, 0x03c4 }, /* Greek_tau τ GREEK SMALL LETTER TAU */
{ 0x07f5, 0x03c5 }, /* Greek_upsilon υ GREEK SMALL LETTER UPSILON */
{ 0x07f6, 0x03c6 }, /* Greek_phi φ GREEK SMALL LETTER PHI */
{ 0x07f7, 0x03c7 }, /* Greek_chi χ GREEK SMALL LETTER CHI */
{ 0x07f8, 0x03c8 }, /* Greek_psi ψ GREEK SMALL LETTER PSI */
{ 0x07f9, 0x03c9 }, /* Greek_omega ω GREEK SMALL LETTER OMEGA */
/* 0x08a1 leftradical ? ??? */
/* 0x08a2 topleftradical ? ??? */
/* 0x08a3 horizconnector ? ??? */
{ 0x08a4, 0x2320 }, /* topintegral ⌠ TOP HALF INTEGRAL */
{ 0x08a5, 0x2321 }, /* botintegral ⌡ BOTTOM HALF INTEGRAL */
{ 0x08a6, 0x2502 }, /* vertconnector │ BOX DRAWINGS LIGHT VERTICAL */
/* 0x08a7 topleftsqbracket ? ??? */
/* 0x08a8 botleftsqbracket ? ??? */
/* 0x08a9 toprightsqbracket ? ??? */
/* 0x08aa botrightsqbracket ? ??? */
/* 0x08ab topleftparens ? ??? */
/* 0x08ac botleftparens ? ??? */
/* 0x08ad toprightparens ? ??? */
/* 0x08ae botrightparens ? ??? */
/* 0x08af leftmiddlecurlybrace ? ??? */
/* 0x08b0 rightmiddlecurlybrace ? ??? */
/* 0x08b1 topleftsummation ? ??? */
/* 0x08b2 botleftsummation ? ??? */
/* 0x08b3 topvertsummationconnector ? ??? */
/* 0x08b4 botvertsummationconnector ? ??? */
/* 0x08b5 toprightsummation ? ??? */
/* 0x08b6 botrightsummation ? ??? */
/* 0x08b7 rightmiddlesummation ? ??? */
{ 0x08bc, 0x2264 }, /* lessthanequal ≤ LESS-THAN OR EQUAL TO */
{ 0x08bd, 0x2260 }, /* notequal ≠ NOT EQUAL TO */
{ 0x08be, 0x2265 }, /* greaterthanequal ≥ GREATER-THAN OR EQUAL TO */
{ 0x08bf, 0x222b }, /* integral ∫ INTEGRAL */
{ 0x08c0, 0x2234 }, /* therefore ∴ THEREFORE */
{ 0x08c1, 0x221d }, /* variation ∝ PROPORTIONAL TO */
{ 0x08c2, 0x221e }, /* infinity ∞ INFINITY */
{ 0x08c5, 0x2207 }, /* nabla ∇ NABLA */
{ 0x08c8, 0x2245 }, /* approximate ≅ APPROXIMATELY EQUAL TO */
/* 0x08c9 similarequal ? ??? */
{ 0x08cd, 0x21d4 }, /* ifonlyif ⇔ LEFT RIGHT DOUBLE ARROW */
{ 0x08ce, 0x21d2 }, /* implies ⇒ RIGHTWARDS DOUBLE ARROW */
{ 0x08cf, 0x2261 }, /* identical ≡ IDENTICAL TO */
{ 0x08d6, 0x221a }, /* radical √ SQUARE ROOT */
{ 0x08da, 0x2282 }, /* includedin ⊂ SUBSET OF */
{ 0x08db, 0x2283 }, /* includes ⊃ SUPERSET OF */
{ 0x08dc, 0x2229 }, /* intersection ∩ INTERSECTION */
{ 0x08dd, 0x222a }, /* union UNION */
{ 0x08de, 0x2227 }, /* logicaland ∧ LOGICAL AND */
{ 0x08df, 0x2228 }, /* logicalor LOGICAL OR */
{ 0x08ef, 0x2202 }, /* partialderivative ∂ PARTIAL DIFFERENTIAL */
{ 0x08f6, 0x0192 }, /* function ƒ LATIN SMALL LETTER F WITH HOOK */
{ 0x08fb, 0x2190 }, /* leftarrow ← LEFTWARDS ARROW */
{ 0x08fc, 0x2191 }, /* uparrow ↑ UPWARDS ARROW */
{ 0x08fd, 0x2192 }, /* rightarrow → RIGHTWARDS ARROW */
{ 0x08fe, 0x2193 }, /* downarrow ↓ DOWNWARDS ARROW */
{ 0x09df, 0x2422 }, /* blank ␢ BLANK SYMBOL */
{ 0x09e0, 0x25c6 }, /* soliddiamond ◆ BLACK DIAMOND */
{ 0x09e1, 0x2592 }, /* checkerboard ▒ MEDIUM SHADE */
{ 0x09e2, 0x2409 }, /* ht ␉ SYMBOL FOR HORIZONTAL TABULATION */
{ 0x09e3, 0x240c }, /* ff ␌ SYMBOL FOR FORM FEED */
{ 0x09e4, 0x240d }, /* cr ␍ SYMBOL FOR CARRIAGE RETURN */
{ 0x09e5, 0x240a }, /* lf ␊ SYMBOL FOR LINE FEED */
{ 0x09e8, 0x2424 }, /* nl ␤ SYMBOL FOR NEWLINE */
{ 0x09e9, 0x240b }, /* vt ␋ SYMBOL FOR VERTICAL TABULATION */
{ 0x09ea, 0x2518 }, /* lowrightcorner ┘ BOX DRAWINGS LIGHT UP AND LEFT */
{ 0x09eb, 0x2510 }, /* uprightcorner ┐ BOX DRAWINGS LIGHT DOWN AND LEFT */
{ 0x09ec, 0x250c }, /* upleftcorner ┌ BOX DRAWINGS LIGHT DOWN AND RIGHT */
{ 0x09ed, 0x2514 }, /* lowleftcorner └ BOX DRAWINGS LIGHT UP AND RIGHT */
{ 0x09ee, 0x253c }, /* crossinglines ┼ BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL */
/* 0x09ef horizlinescan1 ? ??? */
/* 0x09f0 horizlinescan3 ? ??? */
{ 0x09f1, 0x2500 }, /* horizlinescan5 ─ BOX DRAWINGS LIGHT HORIZONTAL */
/* 0x09f2 horizlinescan7 ? ??? */
/* 0x09f3 horizlinescan9 ? ??? */
{ 0x09f4, 0x251c }, /* leftt ├ BOX DRAWINGS LIGHT VERTICAL AND RIGHT */
{ 0x09f5, 0x2524 }, /* rightt ┤ BOX DRAWINGS LIGHT VERTICAL AND LEFT */
{ 0x09f6, 0x2534 }, /* bott ┴ BOX DRAWINGS LIGHT UP AND HORIZONTAL */
{ 0x09f7, 0x252c }, /* topt ┬ BOX DRAWINGS LIGHT DOWN AND HORIZONTAL */
{ 0x09f8, 0x2502 }, /* vertbar │ BOX DRAWINGS LIGHT VERTICAL */
{ 0x0aa1, 0x2003 }, /* emspace EM SPACE */
{ 0x0aa2, 0x2002 }, /* enspace EN SPACE */
{ 0x0aa3, 0x2004 }, /* em3space THREE-PER-EM SPACE */
{ 0x0aa4, 0x2005 }, /* em4space FOUR-PER-EM SPACE */
{ 0x0aa5, 0x2007 }, /* digitspace FIGURE SPACE */
{ 0x0aa6, 0x2008 }, /* punctspace PUNCTUATION SPACE */
{ 0x0aa7, 0x2009 }, /* thinspace THIN SPACE */
{ 0x0aa8, 0x200a }, /* hairspace HAIR SPACE */
{ 0x0aa9, 0x2014 }, /* emdash — EM DASH */
{ 0x0aaa, 0x2013 }, /* endash EN DASH */
/* 0x0aac signifblank ? ??? */
{ 0x0aae, 0x2026 }, /* ellipsis … HORIZONTAL ELLIPSIS */
/* 0x0aaf doubbaselinedot ? ??? */
{ 0x0ab0, 0x2153 }, /* onethird ⅓ VULGAR FRACTION ONE THIRD */
{ 0x0ab1, 0x2154 }, /* twothirds ⅔ VULGAR FRACTION TWO THIRDS */
{ 0x0ab2, 0x2155 }, /* onefifth ⅕ VULGAR FRACTION ONE FIFTH */
{ 0x0ab3, 0x2156 }, /* twofifths ⅖ VULGAR FRACTION TWO FIFTHS */
{ 0x0ab4, 0x2157 }, /* threefifths ⅗ VULGAR FRACTION THREE FIFTHS */
{ 0x0ab5, 0x2158 }, /* fourfifths ⅘ VULGAR FRACTION FOUR FIFTHS */
{ 0x0ab6, 0x2159 }, /* onesixth ⅙ VULGAR FRACTION ONE SIXTH */
{ 0x0ab7, 0x215a }, /* fivesixths ⅚ VULGAR FRACTION FIVE SIXTHS */
{ 0x0ab8, 0x2105 }, /* careof ℅ CARE OF */
{ 0x0abb, 0x2012 }, /* figdash FIGURE DASH */
{ 0x0abc, 0x2329 }, /* leftanglebracket 〈 LEFT-POINTING ANGLE BRACKET */
{ 0x0abd, 0x002e }, /* decimalpoint . FULL STOP */
{ 0x0abe, 0x232a }, /* rightanglebracket 〉 RIGHT-POINTING ANGLE BRACKET */
/* 0x0abf marker ? ??? */
{ 0x0ac3, 0x215b }, /* oneeighth ⅛ VULGAR FRACTION ONE EIGHTH */
{ 0x0ac4, 0x215c }, /* threeeighths ⅜ VULGAR FRACTION THREE EIGHTHS */
{ 0x0ac5, 0x215d }, /* fiveeighths ⅝ VULGAR FRACTION FIVE EIGHTHS */
{ 0x0ac6, 0x215e }, /* seveneighths ⅞ VULGAR FRACTION SEVEN EIGHTHS */
{ 0x0ac9, 0x2122 }, /* trademark ™ TRADE MARK SIGN */
{ 0x0aca, 0x2613 }, /* signaturemark ☓ SALTIRE */
/* 0x0acb trademarkincircle ? ??? */
{ 0x0acc, 0x25c1 }, /* leftopentriangle ◁ WHITE LEFT-POINTING TRIANGLE */
{ 0x0acd, 0x25b7 }, /* rightopentriangle ▷ WHITE RIGHT-POINTING TRIANGLE */
{ 0x0ace, 0x25cb }, /* emopencircle ○ WHITE CIRCLE */
{ 0x0acf, 0x25a1 }, /* emopenrectangle □ WHITE SQUARE */
{ 0x0ad0, 0x2018 }, /* leftsinglequotemark LEFT SINGLE QUOTATION MARK */
{ 0x0ad1, 0x2019 }, /* rightsinglequotemark RIGHT SINGLE QUOTATION MARK */
{ 0x0ad2, 0x201c }, /* leftdoublequotemark “ LEFT DOUBLE QUOTATION MARK */
{ 0x0ad3, 0x201d }, /* rightdoublequotemark ” RIGHT DOUBLE QUOTATION MARK */
{ 0x0ad4, 0x211e }, /* prescription ℞ PRESCRIPTION TAKE */
{ 0x0ad6, 0x2032 }, /* minutes PRIME */
{ 0x0ad7, 0x2033 }, /* seconds ″ DOUBLE PRIME */
{ 0x0ad9, 0x271d }, /* latincross ✝ LATIN CROSS */
/* 0x0ada hexagram ? ??? */
{ 0x0adb, 0x25ac }, /* filledrectbullet ▬ BLACK RECTANGLE */
{ 0x0adc, 0x25c0 }, /* filledlefttribullet ◀ BLACK LEFT-POINTING TRIANGLE */
{ 0x0add, 0x25b6 }, /* filledrighttribullet ▶ BLACK RIGHT-POINTING TRIANGLE */
{ 0x0ade, 0x25cf }, /* emfilledcircle ● BLACK CIRCLE */
{ 0x0adf, 0x25a0 }, /* emfilledrect ■ BLACK SQUARE */
{ 0x0ae0, 0x25e6 }, /* enopencircbullet ◦ WHITE BULLET */
{ 0x0ae1, 0x25ab }, /* enopensquarebullet ▫ WHITE SMALL SQUARE */
{ 0x0ae2, 0x25ad }, /* openrectbullet ▭ WHITE RECTANGLE */
{ 0x0ae3, 0x25b3 }, /* opentribulletup △ WHITE UP-POINTING TRIANGLE */
{ 0x0ae4, 0x25bd }, /* opentribulletdown ▽ WHITE DOWN-POINTING TRIANGLE */
{ 0x0ae5, 0x2606 }, /* openstar ☆ WHITE STAR */
{ 0x0ae6, 0x2022 }, /* enfilledcircbullet • BULLET */
{ 0x0ae7, 0x25aa }, /* enfilledsqbullet ▪ BLACK SMALL SQUARE */
{ 0x0ae8, 0x25b2 }, /* filledtribulletup ▲ BLACK UP-POINTING TRIANGLE */
{ 0x0ae9, 0x25bc }, /* filledtribulletdown ▼ BLACK DOWN-POINTING TRIANGLE */
{ 0x0aea, 0x261c }, /* leftpointer ☜ WHITE LEFT POINTING INDEX */
{ 0x0aeb, 0x261e }, /* rightpointer ☞ WHITE RIGHT POINTING INDEX */
{ 0x0aec, 0x2663 }, /* club ♣ BLACK CLUB SUIT */
{ 0x0aed, 0x2666 }, /* diamond ♦ BLACK DIAMOND SUIT */
{ 0x0aee, 0x2665 }, /* heart ♥ BLACK HEART SUIT */
{ 0x0af0, 0x2720 }, /* maltesecross ✠ MALTESE CROSS */
{ 0x0af1, 0x2020 }, /* dagger † DAGGER */
{ 0x0af2, 0x2021 }, /* doubledagger ‡ DOUBLE DAGGER */
{ 0x0af3, 0x2713 }, /* checkmark ✓ CHECK MARK */
{ 0x0af4, 0x2717 }, /* ballotcross ✗ BALLOT X */
{ 0x0af5, 0x266f }, /* musicalsharp ♯ MUSIC SHARP SIGN */
{ 0x0af6, 0x266d }, /* musicalflat ♭ MUSIC FLAT SIGN */
{ 0x0af7, 0x2642 }, /* malesymbol ♂ MALE SIGN */
{ 0x0af8, 0x2640 }, /* femalesymbol ♀ FEMALE SIGN */
{ 0x0af9, 0x260e }, /* telephone ☎ BLACK TELEPHONE */
{ 0x0afa, 0x2315 }, /* telephonerecorder ⌕ TELEPHONE RECORDER */
{ 0x0afb, 0x2117 }, /* phonographcopyright ℗ SOUND RECORDING COPYRIGHT */
{ 0x0afc, 0x2038 }, /* caret ‸ CARET */
{ 0x0afd, 0x201a }, /* singlelowquotemark SINGLE LOW-9 QUOTATION MARK */
{ 0x0afe, 0x201e }, /* doublelowquotemark „ DOUBLE LOW-9 QUOTATION MARK */
/* 0x0aff cursor ? ??? */
{ 0x0ba3, 0x003c }, /* leftcaret < LESS-THAN SIGN */
{ 0x0ba6, 0x003e }, /* rightcaret > GREATER-THAN SIGN */
{ 0x0ba8, 0x2228 }, /* downcaret LOGICAL OR */
{ 0x0ba9, 0x2227 }, /* upcaret ∧ LOGICAL AND */
{ 0x0bc0, 0x00af }, /* overbar ¯ MACRON */
{ 0x0bc2, 0x22a4 }, /* downtack DOWN TACK */
{ 0x0bc3, 0x2229 }, /* upshoe ∩ INTERSECTION */
{ 0x0bc4, 0x230a }, /* downstile ⌊ LEFT FLOOR */
{ 0x0bc6, 0x005f }, /* underbar _ LOW LINE */
{ 0x0bca, 0x2218 }, /* jot ∘ RING OPERATOR */
{ 0x0bcc, 0x2395 }, /* quad ⎕ APL FUNCTIONAL SYMBOL QUAD (Unicode 3.0) */
{ 0x0bce, 0x22a5 }, /* uptack ⊥ UP TACK */
{ 0x0bcf, 0x25cb }, /* circle ○ WHITE CIRCLE */
{ 0x0bd3, 0x2308 }, /* upstile ⌈ LEFT CEILING */
{ 0x0bd6, 0x222a }, /* downshoe UNION */
{ 0x0bd8, 0x2283 }, /* rightshoe ⊃ SUPERSET OF */
{ 0x0bda, 0x2282 }, /* leftshoe ⊂ SUBSET OF */
{ 0x0bdc, 0x22a3 }, /* lefttack ⊣ LEFT TACK */
{ 0x0bfc, 0x22a2 }, /* righttack ⊢ RIGHT TACK */
{ 0x0cdf, 0x2017 }, /* hebrew_doublelowline ‗ DOUBLE LOW LINE */
{ 0x0ce0, 0x05d0 }, /* hebrew_aleph א HEBREW LETTER ALEF */
{ 0x0ce1, 0x05d1 }, /* hebrew_bet ב HEBREW LETTER BET */
{ 0x0ce2, 0x05d2 }, /* hebrew_gimel ג HEBREW LETTER GIMEL */
{ 0x0ce3, 0x05d3 }, /* hebrew_dalet ד HEBREW LETTER DALET */
{ 0x0ce4, 0x05d4 }, /* hebrew_he ה HEBREW LETTER HE */
{ 0x0ce5, 0x05d5 }, /* hebrew_waw ו HEBREW LETTER VAV */
{ 0x0ce6, 0x05d6 }, /* hebrew_zain ז HEBREW LETTER ZAYIN */
{ 0x0ce7, 0x05d7 }, /* hebrew_chet ח HEBREW LETTER HET */
{ 0x0ce8, 0x05d8 }, /* hebrew_tet ט HEBREW LETTER TET */
{ 0x0ce9, 0x05d9 }, /* hebrew_yod י HEBREW LETTER YOD */
{ 0x0cea, 0x05da }, /* hebrew_finalkaph ך HEBREW LETTER FINAL KAF */
{ 0x0ceb, 0x05db }, /* hebrew_kaph כ HEBREW LETTER KAF */
{ 0x0cec, 0x05dc }, /* hebrew_lamed ל HEBREW LETTER LAMED */
{ 0x0ced, 0x05dd }, /* hebrew_finalmem ם HEBREW LETTER FINAL MEM */
{ 0x0cee, 0x05de }, /* hebrew_mem מ HEBREW LETTER MEM */
{ 0x0cef, 0x05df }, /* hebrew_finalnun ן HEBREW LETTER FINAL NUN */
{ 0x0cf0, 0x05e0 }, /* hebrew_nun נ HEBREW LETTER NUN */
{ 0x0cf1, 0x05e1 }, /* hebrew_samech ס HEBREW LETTER SAMEKH */
{ 0x0cf2, 0x05e2 }, /* hebrew_ayin ע HEBREW LETTER AYIN */
{ 0x0cf3, 0x05e3 }, /* hebrew_finalpe ף HEBREW LETTER FINAL PE */
{ 0x0cf4, 0x05e4 }, /* hebrew_pe פ HEBREW LETTER PE */
{ 0x0cf5, 0x05e5 }, /* hebrew_finalzade ץ HEBREW LETTER FINAL TSADI */
{ 0x0cf6, 0x05e6 }, /* hebrew_zade צ HEBREW LETTER TSADI */
{ 0x0cf7, 0x05e7 }, /* hebrew_qoph ק HEBREW LETTER QOF */
{ 0x0cf8, 0x05e8 }, /* hebrew_resh ר HEBREW LETTER RESH */
{ 0x0cf9, 0x05e9 }, /* hebrew_shin ש HEBREW LETTER SHIN */
{ 0x0cfa, 0x05ea }, /* hebrew_taw ת HEBREW LETTER TAV */
{ 0x0da1, 0x0e01 }, /* Thai_kokai ก THAI CHARACTER KO KAI */
{ 0x0da2, 0x0e02 }, /* Thai_khokhai ข THAI CHARACTER KHO KHAI */
{ 0x0da3, 0x0e03 }, /* Thai_khokhuat ฃ THAI CHARACTER KHO KHUAT */
{ 0x0da4, 0x0e04 }, /* Thai_khokhwai ค THAI CHARACTER KHO KHWAI */
{ 0x0da5, 0x0e05 }, /* Thai_khokhon ฅ THAI CHARACTER KHO KHON */
{ 0x0da6, 0x0e06 }, /* Thai_khorakhang ฆ THAI CHARACTER KHO RAKHANG */
{ 0x0da7, 0x0e07 }, /* Thai_ngongu ง THAI CHARACTER NGO NGU */
{ 0x0da8, 0x0e08 }, /* Thai_chochan จ THAI CHARACTER CHO CHAN */
{ 0x0da9, 0x0e09 }, /* Thai_choching ฉ THAI CHARACTER CHO CHING */
{ 0x0daa, 0x0e0a }, /* Thai_chochang ช THAI CHARACTER CHO CHANG */
{ 0x0dab, 0x0e0b }, /* Thai_soso ซ THAI CHARACTER SO SO */
{ 0x0dac, 0x0e0c }, /* Thai_chochoe ฌ THAI CHARACTER CHO CHOE */
{ 0x0dad, 0x0e0d }, /* Thai_yoying ญ THAI CHARACTER YO YING */
{ 0x0dae, 0x0e0e }, /* Thai_dochada ฎ THAI CHARACTER DO CHADA */
{ 0x0daf, 0x0e0f }, /* Thai_topatak ฏ THAI CHARACTER TO PATAK */
{ 0x0db0, 0x0e10 }, /* Thai_thothan ฐ THAI CHARACTER THO THAN */
{ 0x0db1, 0x0e11 }, /* Thai_thonangmontho ฑ THAI CHARACTER THO NANGMONTHO */
{ 0x0db2, 0x0e12 }, /* Thai_thophuthao ฒ THAI CHARACTER THO PHUTHAO */
{ 0x0db3, 0x0e13 }, /* Thai_nonen ณ THAI CHARACTER NO NEN */
{ 0x0db4, 0x0e14 }, /* Thai_dodek ด THAI CHARACTER DO DEK */
{ 0x0db5, 0x0e15 }, /* Thai_totao ต THAI CHARACTER TO TAO */
{ 0x0db6, 0x0e16 }, /* Thai_thothung ถ THAI CHARACTER THO THUNG */
{ 0x0db7, 0x0e17 }, /* Thai_thothahan ท THAI CHARACTER THO THAHAN */
{ 0x0db8, 0x0e18 }, /* Thai_thothong ธ THAI CHARACTER THO THONG */
{ 0x0db9, 0x0e19 }, /* Thai_nonu น THAI CHARACTER NO NU */
{ 0x0dba, 0x0e1a }, /* Thai_bobaimai บ THAI CHARACTER BO BAIMAI */
{ 0x0dbb, 0x0e1b }, /* Thai_popla ป THAI CHARACTER PO PLA */
{ 0x0dbc, 0x0e1c }, /* Thai_phophung ผ THAI CHARACTER PHO PHUNG */
{ 0x0dbd, 0x0e1d }, /* Thai_fofa ฝ THAI CHARACTER FO FA */
{ 0x0dbe, 0x0e1e }, /* Thai_phophan พ THAI CHARACTER PHO PHAN */
{ 0x0dbf, 0x0e1f }, /* Thai_fofan ฟ THAI CHARACTER FO FAN */
{ 0x0dc0, 0x0e20 }, /* Thai_phosamphao ภ THAI CHARACTER PHO SAMPHAO */
{ 0x0dc1, 0x0e21 }, /* Thai_moma ม THAI CHARACTER MO MA */
{ 0x0dc2, 0x0e22 }, /* Thai_yoyak ย THAI CHARACTER YO YAK */
{ 0x0dc3, 0x0e23 }, /* Thai_rorua ร THAI CHARACTER RO RUA */
{ 0x0dc4, 0x0e24 }, /* Thai_ru ฤ THAI CHARACTER RU */
{ 0x0dc5, 0x0e25 }, /* Thai_loling ล THAI CHARACTER LO LING */
{ 0x0dc6, 0x0e26 }, /* Thai_lu ฦ THAI CHARACTER LU */
{ 0x0dc7, 0x0e27 }, /* Thai_wowaen ว THAI CHARACTER WO WAEN */
{ 0x0dc8, 0x0e28 }, /* Thai_sosala ศ THAI CHARACTER SO SALA */
{ 0x0dc9, 0x0e29 }, /* Thai_sorusi ษ THAI CHARACTER SO RUSI */
{ 0x0dca, 0x0e2a }, /* Thai_sosua ส THAI CHARACTER SO SUA */
{ 0x0dcb, 0x0e2b }, /* Thai_hohip ห THAI CHARACTER HO HIP */
{ 0x0dcc, 0x0e2c }, /* Thai_lochula ฬ THAI CHARACTER LO CHULA */
{ 0x0dcd, 0x0e2d }, /* Thai_oang อ THAI CHARACTER O ANG */
{ 0x0dce, 0x0e2e }, /* Thai_honokhuk ฮ THAI CHARACTER HO NOKHUK */
{ 0x0dcf, 0x0e2f }, /* Thai_paiyannoi ฯ THAI CHARACTER PAIYANNOI */
{ 0x0dd0, 0x0e30 }, /* Thai_saraa ะ THAI CHARACTER SARA A */
{ 0x0dd1, 0x0e31 }, /* Thai_maihanakat ั THAI CHARACTER MAI HAN-AKAT */
{ 0x0dd2, 0x0e32 }, /* Thai_saraaa า THAI CHARACTER SARA AA */
{ 0x0dd3, 0x0e33 }, /* Thai_saraam ำ THAI CHARACTER SARA AM */
{ 0x0dd4, 0x0e34 }, /* Thai_sarai ิ THAI CHARACTER SARA I */
{ 0x0dd5, 0x0e35 }, /* Thai_saraii ี THAI CHARACTER SARA II */
{ 0x0dd6, 0x0e36 }, /* Thai_saraue ึ THAI CHARACTER SARA UE */
{ 0x0dd7, 0x0e37 }, /* Thai_sarauee ื THAI CHARACTER SARA UEE */
{ 0x0dd8, 0x0e38 }, /* Thai_sarau ุ THAI CHARACTER SARA U */
{ 0x0dd9, 0x0e39 }, /* Thai_sarauu ู THAI CHARACTER SARA UU */
{ 0x0dda, 0x0e3a }, /* Thai_phinthu ฺ THAI CHARACTER PHINTHU */
{ 0x0dde, 0x0e3e }, /* Thai_maihanakat_maitho ฾ ??? */
{ 0x0ddf, 0x0e3f }, /* Thai_baht ฿ THAI CURRENCY SYMBOL BAHT */
{ 0x0de0, 0x0e40 }, /* Thai_sarae เ THAI CHARACTER SARA E */
{ 0x0de1, 0x0e41 }, /* Thai_saraae แ THAI CHARACTER SARA AE */
{ 0x0de2, 0x0e42 }, /* Thai_sarao โ THAI CHARACTER SARA O */
{ 0x0de3, 0x0e43 }, /* Thai_saraaimaimuan ใ THAI CHARACTER SARA AI MAIMUAN */
{ 0x0de4, 0x0e44 }, /* Thai_saraaimaimalai ไ THAI CHARACTER SARA AI MAIMALAI */
{ 0x0de5, 0x0e45 }, /* Thai_lakkhangyao ๅ THAI CHARACTER LAKKHANGYAO */
{ 0x0de6, 0x0e46 }, /* Thai_maiyamok ๆ THAI CHARACTER MAIYAMOK */
{ 0x0de7, 0x0e47 }, /* Thai_maitaikhu ็ THAI CHARACTER MAITAIKHU */
{ 0x0de8, 0x0e48 }, /* Thai_maiek ่ THAI CHARACTER MAI EK */
{ 0x0de9, 0x0e49 }, /* Thai_maitho ้ THAI CHARACTER MAI THO */
{ 0x0dea, 0x0e4a }, /* Thai_maitri ๊ THAI CHARACTER MAI TRI */
{ 0x0deb, 0x0e4b }, /* Thai_maichattawa ๋ THAI CHARACTER MAI CHATTAWA */
{ 0x0dec, 0x0e4c }, /* Thai_thanthakhat ์ THAI CHARACTER THANTHAKHAT */
{ 0x0ded, 0x0e4d }, /* Thai_nikhahit ํ THAI CHARACTER NIKHAHIT */
{ 0x0df0, 0x0e50 }, /* Thai_leksun THAI DIGIT ZERO */
{ 0x0df1, 0x0e51 }, /* Thai_leknung ๑ THAI DIGIT ONE */
{ 0x0df2, 0x0e52 }, /* Thai_leksong ๒ THAI DIGIT TWO */
{ 0x0df3, 0x0e53 }, /* Thai_leksam ๓ THAI DIGIT THREE */
{ 0x0df4, 0x0e54 }, /* Thai_leksi ๔ THAI DIGIT FOUR */
{ 0x0df5, 0x0e55 }, /* Thai_lekha ๕ THAI DIGIT FIVE */
{ 0x0df6, 0x0e56 }, /* Thai_lekhok ๖ THAI DIGIT SIX */
{ 0x0df7, 0x0e57 }, /* Thai_lekchet ๗ THAI DIGIT SEVEN */
{ 0x0df8, 0x0e58 }, /* Thai_lekpaet ๘ THAI DIGIT EIGHT */
{ 0x0df9, 0x0e59 }, /* Thai_lekkao ๙ THAI DIGIT NINE */
{ 0x0ea1, 0x3131 }, /* Hangul_Kiyeog ㄱ HANGUL LETTER KIYEOK */
{ 0x0ea2, 0x3132 }, /* Hangul_SsangKiyeog ㄲ HANGUL LETTER SSANGKIYEOK */
{ 0x0ea3, 0x3133 }, /* Hangul_KiyeogSios ㄳ HANGUL LETTER KIYEOK-SIOS */
{ 0x0ea4, 0x3134 }, /* Hangul_Nieun ㄴ HANGUL LETTER NIEUN */
{ 0x0ea5, 0x3135 }, /* Hangul_NieunJieuj ㄵ HANGUL LETTER NIEUN-CIEUC */
{ 0x0ea6, 0x3136 }, /* Hangul_NieunHieuh ㄶ HANGUL LETTER NIEUN-HIEUH */
{ 0x0ea7, 0x3137 }, /* Hangul_Dikeud ㄷ HANGUL LETTER TIKEUT */
{ 0x0ea8, 0x3138 }, /* Hangul_SsangDikeud ㄸ HANGUL LETTER SSANGTIKEUT */
{ 0x0ea9, 0x3139 }, /* Hangul_Rieul ㄹ HANGUL LETTER RIEUL */
{ 0x0eaa, 0x313a }, /* Hangul_RieulKiyeog ㄺ HANGUL LETTER RIEUL-KIYEOK */
{ 0x0eab, 0x313b }, /* Hangul_RieulMieum ㄻ HANGUL LETTER RIEUL-MIEUM */
{ 0x0eac, 0x313c }, /* Hangul_RieulPieub ㄼ HANGUL LETTER RIEUL-PIEUP */
{ 0x0ead, 0x313d }, /* Hangul_RieulSios ㄽ HANGUL LETTER RIEUL-SIOS */
{ 0x0eae, 0x313e }, /* Hangul_RieulTieut ㄾ HANGUL LETTER RIEUL-THIEUTH */
{ 0x0eaf, 0x313f }, /* Hangul_RieulPhieuf ㄿ HANGUL LETTER RIEUL-PHIEUPH */
{ 0x0eb0, 0x3140 }, /* Hangul_RieulHieuh ㅀ HANGUL LETTER RIEUL-HIEUH */
{ 0x0eb1, 0x3141 }, /* Hangul_Mieum ㅁ HANGUL LETTER MIEUM */
{ 0x0eb2, 0x3142 }, /* Hangul_Pieub ㅂ HANGUL LETTER PIEUP */
{ 0x0eb3, 0x3143 }, /* Hangul_SsangPieub ㅃ HANGUL LETTER SSANGPIEUP */
{ 0x0eb4, 0x3144 }, /* Hangul_PieubSios ㅄ HANGUL LETTER PIEUP-SIOS */
{ 0x0eb5, 0x3145 }, /* Hangul_Sios ㅅ HANGUL LETTER SIOS */
{ 0x0eb6, 0x3146 }, /* Hangul_SsangSios ㅆ HANGUL LETTER SSANGSIOS */
{ 0x0eb7, 0x3147 }, /* Hangul_Ieung ㅇ HANGUL LETTER IEUNG */
{ 0x0eb8, 0x3148 }, /* Hangul_Jieuj ㅈ HANGUL LETTER CIEUC */
{ 0x0eb9, 0x3149 }, /* Hangul_SsangJieuj ㅉ HANGUL LETTER SSANGCIEUC */
{ 0x0eba, 0x314a }, /* Hangul_Cieuc ㅊ HANGUL LETTER CHIEUCH */
{ 0x0ebb, 0x314b }, /* Hangul_Khieuq ㅋ HANGUL LETTER KHIEUKH */
{ 0x0ebc, 0x314c }, /* Hangul_Tieut ㅌ HANGUL LETTER THIEUTH */
{ 0x0ebd, 0x314d }, /* Hangul_Phieuf ㅍ HANGUL LETTER PHIEUPH */
{ 0x0ebe, 0x314e }, /* Hangul_Hieuh ㅎ HANGUL LETTER HIEUH */
{ 0x0ebf, 0x314f }, /* Hangul_A ㅏ HANGUL LETTER A */
{ 0x0ec0, 0x3150 }, /* Hangul_AE ㅐ HANGUL LETTER AE */
{ 0x0ec1, 0x3151 }, /* Hangul_YA ㅑ HANGUL LETTER YA */
{ 0x0ec2, 0x3152 }, /* Hangul_YAE ㅒ HANGUL LETTER YAE */
{ 0x0ec3, 0x3153 }, /* Hangul_EO ㅓ HANGUL LETTER EO */
{ 0x0ec4, 0x3154 }, /* Hangul_E ㅔ HANGUL LETTER E */
{ 0x0ec5, 0x3155 }, /* Hangul_YEO ㅕ HANGUL LETTER YEO */
{ 0x0ec6, 0x3156 }, /* Hangul_YE ㅖ HANGUL LETTER YE */
{ 0x0ec7, 0x3157 }, /* Hangul_O ㅗ HANGUL LETTER O */
{ 0x0ec8, 0x3158 }, /* Hangul_WA ㅘ HANGUL LETTER WA */
{ 0x0ec9, 0x3159 }, /* Hangul_WAE ㅙ HANGUL LETTER WAE */
{ 0x0eca, 0x315a }, /* Hangul_OE ㅚ HANGUL LETTER OE */
{ 0x0ecb, 0x315b }, /* Hangul_YO ㅛ HANGUL LETTER YO */
{ 0x0ecc, 0x315c }, /* Hangul_U ㅜ HANGUL LETTER U */
{ 0x0ecd, 0x315d }, /* Hangul_WEO ㅝ HANGUL LETTER WEO */
{ 0x0ece, 0x315e }, /* Hangul_WE ㅞ HANGUL LETTER WE */
{ 0x0ecf, 0x315f }, /* Hangul_WI ㅟ HANGUL LETTER WI */
{ 0x0ed0, 0x3160 }, /* Hangul_YU ㅠ HANGUL LETTER YU */
{ 0x0ed1, 0x3161 }, /* Hangul_EU ㅡ HANGUL LETTER EU */
{ 0x0ed2, 0x3162 }, /* Hangul_YI ㅢ HANGUL LETTER YI */
{ 0x0ed3, 0x3163 }, /* Hangul_I ㅣ HANGUL LETTER I */
{ 0x0ed4, 0x11a8 }, /* Hangul_J_Kiyeog ᆨ HANGUL JONGSEONG KIYEOK */
{ 0x0ed5, 0x11a9 }, /* Hangul_J_SsangKiyeog ᆩ HANGUL JONGSEONG SSANGKIYEOK */
{ 0x0ed6, 0x11aa }, /* Hangul_J_KiyeogSios ᆪ HANGUL JONGSEONG KIYEOK-SIOS */
{ 0x0ed7, 0x11ab }, /* Hangul_J_Nieun ᆫ HANGUL JONGSEONG NIEUN */
{ 0x0ed8, 0x11ac }, /* Hangul_J_NieunJieuj ᆬ HANGUL JONGSEONG NIEUN-CIEUC */
{ 0x0ed9, 0x11ad }, /* Hangul_J_NieunHieuh ᆭ HANGUL JONGSEONG NIEUN-HIEUH */
{ 0x0eda, 0x11ae }, /* Hangul_J_Dikeud ᆮ HANGUL JONGSEONG TIKEUT */
{ 0x0edb, 0x11af }, /* Hangul_J_Rieul ᆯ HANGUL JONGSEONG RIEUL */
{ 0x0edc, 0x11b0 }, /* Hangul_J_RieulKiyeog ᆰ HANGUL JONGSEONG RIEUL-KIYEOK */
{ 0x0edd, 0x11b1 }, /* Hangul_J_RieulMieum ᆱ HANGUL JONGSEONG RIEUL-MIEUM */
{ 0x0ede, 0x11b2 }, /* Hangul_J_RieulPieub ᆲ HANGUL JONGSEONG RIEUL-PIEUP */
{ 0x0edf, 0x11b3 }, /* Hangul_J_RieulSios ᆳ HANGUL JONGSEONG RIEUL-SIOS */
{ 0x0ee0, 0x11b4 }, /* Hangul_J_RieulTieut ᆴ HANGUL JONGSEONG RIEUL-THIEUTH */
{ 0x0ee1, 0x11b5 }, /* Hangul_J_RieulPhieuf ᆵ HANGUL JONGSEONG RIEUL-PHIEUPH */
{ 0x0ee2, 0x11b6 }, /* Hangul_J_RieulHieuh ᆶ HANGUL JONGSEONG RIEUL-HIEUH */
{ 0x0ee3, 0x11b7 }, /* Hangul_J_Mieum ᆷ HANGUL JONGSEONG MIEUM */
{ 0x0ee4, 0x11b8 }, /* Hangul_J_Pieub ᆸ HANGUL JONGSEONG PIEUP */
{ 0x0ee5, 0x11b9 }, /* Hangul_J_PieubSios ᆹ HANGUL JONGSEONG PIEUP-SIOS */
{ 0x0ee6, 0x11ba }, /* Hangul_J_Sios ᆺ HANGUL JONGSEONG SIOS */
{ 0x0ee7, 0x11bb }, /* Hangul_J_SsangSios ᆻ HANGUL JONGSEONG SSANGSIOS */
{ 0x0ee8, 0x11bc }, /* Hangul_J_Ieung ᆼ HANGUL JONGSEONG IEUNG */
{ 0x0ee9, 0x11bd }, /* Hangul_J_Jieuj ᆽ HANGUL JONGSEONG CIEUC */
{ 0x0eea, 0x11be }, /* Hangul_J_Cieuc ᆾ HANGUL JONGSEONG CHIEUCH */
{ 0x0eeb, 0x11bf }, /* Hangul_J_Khieuq ᆿ HANGUL JONGSEONG KHIEUKH */
{ 0x0eec, 0x11c0 }, /* Hangul_J_Tieut ᇀ HANGUL JONGSEONG THIEUTH */
{ 0x0eed, 0x11c1 }, /* Hangul_J_Phieuf ᇁ HANGUL JONGSEONG PHIEUPH */
{ 0x0eee, 0x11c2 }, /* Hangul_J_Hieuh ᇂ HANGUL JONGSEONG HIEUH */
{ 0x0eef, 0x316d }, /* Hangul_RieulYeorinHieuh ㅭ HANGUL LETTER RIEUL-YEORINHIEUH */
{ 0x0ef0, 0x3171 }, /* Hangul_SunkyeongeumMieum ㅱ HANGUL LETTER KAPYEOUNMIEUM */
{ 0x0ef1, 0x3178 }, /* Hangul_SunkyeongeumPieub ㅸ HANGUL LETTER KAPYEOUNPIEUP */
{ 0x0ef2, 0x317f }, /* Hangul_PanSios ㅿ HANGUL LETTER PANSIOS */
/* 0x0ef3 Hangul_KkogjiDalrinIeung ? ??? */
{ 0x0ef4, 0x3184 }, /* Hangul_SunkyeongeumPhieuf ㆄ HANGUL LETTER KAPYEOUNPHIEUPH */
{ 0x0ef5, 0x3186 }, /* Hangul_YeorinHieuh ㆆ HANGUL LETTER YEORINHIEUH */
{ 0x0ef6, 0x318d }, /* Hangul_AraeA ㆍ HANGUL LETTER ARAEA */
{ 0x0ef7, 0x318e }, /* Hangul_AraeAE ㆎ HANGUL LETTER ARAEAE */
{ 0x0ef8, 0x11eb }, /* Hangul_J_PanSios ᇫ HANGUL JONGSEONG PANSIOS */
/* 0x0ef9 Hangul_J_KkogjiDalrinIeung ? ??? */
{ 0x0efa, 0x11f9 }, /* Hangul_J_YeorinHieuh ᇹ HANGUL JONGSEONG YEORINHIEUH */
{ 0x0eff, 0x20a9 }, /* Korean_Won ₩ WON SIGN */
{ 0x13bc, 0x0152 }, /* OE Œ LATIN CAPITAL LIGATURE OE */
{ 0x13bd, 0x0153 }, /* oe œ LATIN SMALL LIGATURE OE */
{ 0x13be, 0x0178 }, /* Ydiaeresis Ÿ LATIN CAPITAL LETTER Y WITH DIAERESIS */
{ 0x20a0, 0x20a0 }, /* EcuSign ₠ EURO-CURRENCY SIGN */
{ 0x20a1, 0x20a1 }, /* ColonSign ₡ COLON SIGN */
{ 0x20a2, 0x20a2 }, /* CruzeiroSign ₢ CRUZEIRO SIGN */
{ 0x20a3, 0x20a3 }, /* FFrancSign ₣ FRENCH FRANC SIGN */
{ 0x20a4, 0x20a4 }, /* LiraSign ₤ LIRA SIGN */
{ 0x20a5, 0x20a5 }, /* MillSign ₥ MILL SIGN */
{ 0x20a6, 0x20a6 }, /* NairaSign ₦ NAIRA SIGN */
{ 0x20a7, 0x20a7 }, /* PesetaSign ₧ PESETA SIGN */
{ 0x20a8, 0x20a8 }, /* RupeeSign ₨ RUPEE SIGN */
{ 0x20a9, 0x20a9 }, /* WonSign ₩ WON SIGN */
{ 0x20aa, 0x20aa }, /* NewSheqelSign ₪ NEW SHEQEL SIGN */
{ 0x20ab, 0x20ab }, /* DongSign ₫ DONG SIGN */
{ 0x20ac, 0x20ac }, /* EuroSign € EURO SIGN */
};
long keysym2ucs(KeySym keysym)
{
int min = 0;
int max = sizeof(keysymtab) / sizeof(struct codepair) - 1;
int mid;
/* first check for Latin-1 characters (1:1 mapping) */
if ((keysym >= 0x0020 && keysym <= 0x007e) ||
(keysym >= 0x00a0 && keysym <= 0x00ff))
return keysym;
/* also check for directly encoded 24-bit UCS characters */
if ((keysym & 0xff000000) == 0x01000000)
return keysym & 0x00ffffff;
/* binary search in table */
while (max >= min) {
mid = (min + max) / 2;
if (keysymtab[mid].keysym < keysym)
min = mid + 1;
else if (keysymtab[mid].keysym > keysym)
max = mid - 1;
else {
/* found it */
return keysymtab[mid].ucs;
}
}
/* no matching Unicode value found */
return -1;
}

View File

@ -1,57 +0,0 @@
/*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is from xterm-122 source XFree86:
* xc/programs/xterm/keysym2ucs.h,v 1.1 1999/06/12 15:37:18 dawes Exp.
*
* The Initial Developer of the Original Code is
* Markus G. Kuhn <mkuhn@acm.org> and Richard Verhoeven <river@win.tue.nl>.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Frank Tang <ftang@netscape.com> adopt into mozilla
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* This module converts keysym values into the corresponding ISO 10646-1
* (UCS, Unicode) values.
*/
#include <X11/X.h>
#ifdef __cplusplus
extern "C" {
#endif
long keysym2ucs(KeySym keysym);
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@ -1,292 +0,0 @@
/* XPM */
static char * mozilla_icon_xpm[] = {
"32 32 257 2",
" c None",
". c #AA7303",
"+ c #A67003",
"@ c #B77C03",
"# c #8D6003",
"$ c #8D6004",
"% c #6C4A04",
"& c #3A2804",
"* c #6B4802",
"= c #9B6903",
"- c #5A2C04",
"; c #411B04",
"> c #9D6A03",
", c #7A5203",
"' c #510D04",
") c #6B1104",
"! c #7D5503",
"~ c #674604",
"{ c #C21E04",
"] c #C21D04",
"^ c #523804",
"/ c #513702",
"( c #552904",
"_ c #DD2204",
": c #DF2204",
"< c #582904",
"[ c #5F3F02",
"} c #6B2504",
"| c #FE2604",
"1 c #AB7303",
"2 c #9B6904",
"3 c #C31F04",
"4 c #FE2704",
"5 c #A81904",
"6 c #926304",
"7 c #4D3302",
"8 c #483104",
"9 c #C61E04",
"0 c #B11B04",
"a c #891604",
"b c #761204",
"c c #614304",
"d c #775102",
"e c #795102",
"f c #785102",
"g c #C58603",
"h c #642404",
"i c #B21A04",
"j c #1F0604",
"k c #550E04",
"l c #631004",
"m c #402404",
"n c #AF7703",
"o c #3D2902",
"p c #7F5602",
"q c #805604",
"r c #0C0904",
"s c #080604",
"t c #080706",
"u c #090604",
"v c #060404",
"w c #620F04",
"x c #7A1304",
"y c #030204",
"z c #570E04",
"A c #721204",
"B c #270704",
"C c #080504",
"D c #0A0604",
"E c #533804",
"F c #A56F02",
"G c #B87C03",
"H c #3B2804",
"I c #A51904",
"J c #FC2704",
"K c #D62004",
"L c #691004",
"M c #C01E04",
"N c #6D1004",
"O c #9C1804",
"P c #B31C04",
"Q c #150404",
"R c #801404",
"S c #DD2304",
"T c #120404",
"U c #130404",
"V c #500C04",
"W c #CC1E04",
"X c #AA1A04",
"Y c #100904",
"Z c #B47A03",
"` c #A77103",
" . c #513704",
".. c #891704",
"+. c #F62604",
"@. c #BA1D04",
"#. c #3C0A04",
"$. c #EB2304",
"%. c #DE2304",
"&. c #560E04",
"*. c #E82304",
"=. c #FE2804",
"-. c #BE1D04",
";. c #F12404",
">. c #661004",
",. c #020204",
"'. c #5E0F04",
"). c #A61A04",
"!. c #4A3204",
"~. c #BC7E03",
"{. c #8E6002",
"]. c #684604",
"^. c #390D04",
"/. c #EE2404",
"(. c #FE2904",
"_. c #7D1304",
":. c #8C1504",
"<. c #200604",
"[. c #A81A04",
"}. c #E72204",
"|. c #DA2004",
"1. c #070204",
"2. c #280704",
"3. c #543904",
"4. c #9F6C02",
"5. c #674602",
"6. c #B47B04",
"7. c #311004",
"8. c #B11C04",
"9. c #AA1B04",
"0. c #6A1104",
"a. c #801504",
"b. c #2B0704",
"c. c #09090A",
"d. c #450B04",
"e. c #360904",
"f. c #DC2204",
"g. c #EE2504",
"h. c #C11D04",
"i. c #6F1104",
"j. c #704B04",
"k. c #9C6902",
"l. c #A56F03",
"m. c #5F4004",
"n. c #8D1604",
"o. c #440A04",
"p. c #1A0504",
"q. c #931604",
"r. c #621004",
"s. c #7F1404",
"t. c #921704",
"u. c #F82504",
"v. c #F52504",
"w. c #981804",
"x. c #241804",
"y. c #5B3E04",
"z. c #D82204",
"A. c #D02004",
"B. c #DA2104",
"C. c #D52104",
"D. c #2A1A04",
"E. c #AC7403",
"F. c #2B1C04",
"G. c #D04004",
"H. c #FC3C04",
"I. c #F94E04",
"J. c #881504",
"K. c #FC2604",
"L. c #792804",
"M. c #AC7503",
"N. c #9A6803",
"O. c #782804",
"P. c #F66504",
"Q. c #F94B04",
"R. c #F46804",
"S. c #F46604",
"T. c #F76504",
"U. c #FB4204",
"V. c #C13D04",
"W. c #5D0E04",
"X. c #DA2204",
"Y. c #741604",
"Z. c #8C5E03",
"`. c #885B03",
" + c #8B1904",
".+ c #DE2204",
"++ c #D22D04",
"@+ c #C42D04",
"#+ c #580E04",
"$+ c #9F1804",
"%+ c #895D04",
"&+ c #D62204",
"*+ c #371904",
"=+ c #2C1A04",
"-+ c #4A0C04",
";+ c #140404",
">+ c #AB1A04",
",+ c #DA2304",
"'+ c #6A4702",
")+ c #754F02",
"!+ c #821404",
"~+ c #462B04",
"{+ c #B37A03",
"]+ c #B17803",
"^+ c #714C04",
"/+ c #580F04",
"(+ c #E32204",
"_+ c #DD2104",
":+ c #611D04",
"<+ c #BA7F03",
"[+ c #B27803",
"}+ c #6F1D04",
"|+ c #FD2704",
"1+ c #F22504",
"2+ c #634304",
"3+ c #875B03",
"4+ c #734F02",
"5+ c #805704",
"6+ c #1D0504",
"7+ c #DB2204",
"8+ c #EA2404",
"9+ c #2E0804",
"0+ c #815803",
"a+ c #941704",
"b+ c #C11E04",
"c+ c #391B04",
"d+ c #A77104",
"e+ c #B67C04",
"f+ c #371D04",
"g+ c #360A04",
"h+ c #573A04",
"i+ c #372604",
"j+ c #3E2104",
"k+ c #B57A03",
"l+ c #B57B03",
"m+ c #603F04",
"n+ c #430A04",
"o+ c #351904",
"p+ c #A36E03",
"q+ c #BE8103",
"r+ c #1D1404",
"s+ c #483004",
"t+ c #A26E03",
"u+ c #6D4B02",
"v+ c #825804",
"w+ c #0B0804",
"x+ c #976603",
"y+ c #815703",
"z+ c #926404",
"A+ c #895D03",
"B+ c #614202",
"C+ c #9A6804",
"D+ c #C88704",
"E+ c #C18303",
"F+ c #654302",
"G+ c #744F02",
"H+ c #704B02",
" ",
" . ",
" + @ ",
" # $ ",
" % & * ",
" = - ; > ",
" , ' ) ! ",
" ~ { ] ^ ",
" / ( _ : < [ ",
" . } | | } 1 ",
" 2 3 | 4 5 6 ",
" 7 8 9 0 a b c ",
" d e f f f d d d d d d g h i j k l m n d d d d d d d d d d d o ",
" p q r s s s s t s s u v w x y z A B C D D D D D s s s s E F ",
" G H I J 4 | 4 | K L L M N O P Q R | S T U V W X Y Z ",
" ` ...+.| 4 @.#.$.4 | %.&.*.4 =.-.;.>.,.'.).!.~. ",
" {.].^./.(.X _.;.| :.T <.[.| }.z | |.1.2.3.4. ",
" 5.6.7.8.9.0.a.b.c.d.e.f.g.h.&.| i.u j.k. ",
" l.m.n.o.p.q._.r.a.s.t.u.v.w.x.Z ",
" {.y.P z.R A.v.x j B.| C.D.E. ",
" F.G.H.I.4 | 4 t.J.f.K.L.M. ",
" N.O.P.Q.R.S.T.U.V.W.X.4 Y.Z. ",
" `. +4 =.| | .+++@+#+$+| K %+ ",
" %+&+| | | I *+=+-+;+>+,+&+x.'+ ",
" )+=+X.=.| !+~+{+]+^+,./+(+_+:+<+ ",
" [+}+|+1+) 2+3+ 4+5+6+7+8+9+0+ ",
" $ a+b+c+d+ e+f+0.g+h+ ",
" i+A j+k+ l+m+n+o+p+ ",
" q+r+s+t+ u+v+w+x+ ",
" y+z+A+ B+C+2 ",
" D+ E+F+ ",
" G+ H+ "};

View File

@ -1,105 +0,0 @@
/* XPM */
static char * minimozicon_xpm[] = {
"16 16 86 1",
" c None",
". c #9A6803",
"+ c #A26E04",
"@ c #764A04",
"# c #613D03",
"$ c #7D3104",
"% c #7F2F04",
"& c #7E5502",
"* c #A72604",
"= c #A82604",
"- c #855902",
"; c #654403",
"> c #CE2004",
", c #A91A04",
"' c #7A5304",
") c #7B5402",
"! c #5F4003",
"~ c #402C03",
"{ c #402C04",
"] c #642F04",
"^ c #540D04",
"/ c #601004",
"( c #482A04",
"_ c #523803",
": c #734E02",
"< c #763A04",
"[ c #DE2304",
"} c #FE2604",
"| c #B21B04",
"1 c #AF1A04",
"2 c #C21E04",
"3 c #A31904",
"4 c #A41A04",
"5 c #E22204",
"6 c #230604",
"7 c #881504",
"8 c #703504",
"9 c #6F4504",
"0 c #B41E04",
"a c #8F1604",
"b c #A61A04",
"c c #3B0B06",
"d c #761304",
"e c #E52204",
"f c #AA1A04",
"g c #560E04",
"h c #623D04",
"i c #865A03",
"j c #781E04",
"k c #811404",
"l c #661004",
"m c #D82104",
"n c #A31E04",
"o c #815703",
"p c #9A3A04",
"q c #F84F04",
"r c #FA4604",
"s c #D32F04",
"t c #A71A04",
"u c #BA2304",
"v c #9C6A03",
"w c #885C04",
"x c #D72204",
"y c #AE1E04",
"z c #832004",
"A c #6E1104",
"B c #E12304",
"C c #5D3F03",
"D c #704003",
"E c #F22604",
"F c #942404",
"G c #805503",
"H c #875C03",
"I c #3E1B04",
"J c #E12204",
"K c #723F04",
"L c #722C04",
"M c #7B3504",
"N c #6E3A04",
"O c #411A04",
"P c #A06C03",
"Q c #604104",
"R c #624204",
"S c #996804",
"T c #9E6B03",
"U c #875B02",
" ",
" .+ ",
" @# ",
" $% ",
" &*=- ",
" ;>,' ",
")!~~{~]^/(~~~~_:",
" <[}|12345678 ",
" 90abcdefgh ",
" ijk,lmno ",
" pqrstuv ",
" wx}yzABC ",
" DEFGHIJK ",
" LM NO ",
" PQ RS ",
" T U "};

View File

@ -1,63 +0,0 @@
/* XPM */
static char * mozicon50_xpm[] = {
"50 51 9 1",
" c None",
". c #000000",
"+ c #FF0000",
"@ c #808000",
"# c #800000",
"$ c #FF6633",
"% c #990066",
"& c #FF00FF",
"* c #222222",
" ",
" @ ",
" $@ ",
" @@ ",
" @@$ ",
" $@*@ ",
" @@.@ ",
" @..@ ",
" $@..@@ ",
" $@##*@ ",
" @*#+.@ ",
" @.++.@$ ",
" $@.++.@$ ",
" @*#++#*@ ",
" @.++++.@ ",
" $@.++++.@$ ",
" @*#++++**@ ",
" @.#++++#.@ ",
" $@.++####.@ ",
" @@*+#*##*.@@ ",
"*@@@@@@@@@@@@@@@@@@@.#+..*##*#@@@@@@@@@@@@@@@@@@@*",
" *@@*................+#..*###.................@@* ",
" %@@@.#++++++++++++#**#*#++.###++*...#+++#.*@@* ",
" *@@.#+++++++++#.##++#+#+*.#+++#..##++#.@@@% ",
" $@..+++++++.#++++++##++++#++#...++*.@@$ ",
" @@*.#+++++.#+++++*.#++++##++#.*...@@ ",
" $@@.#+++#*++++#....#+++*#+++...*@$ ",
" *@@..++#*++#**.*.*+++#.#++*..@@$ ",
" $@*.++******#+++++#+#+++..@@ ",
" $@@.##..*$#**#+#*#++++..@@ ",
" $@@.#+#***##...#++++.*@@ ",
" %@@*++++++++#.#++++.@@ ",
" @.#+++++++++.##+++.@$ ",
" @.+$$$$$+$$$#*#+++*@@ ",
" $@*+$$$$$$$+$#.#+++#.@ ",
" @*#+++++++++++.#++++.@ ",
" @.#+++++++#*++.##+++.@$ ",
" $@.+++++++....#..+#++*@@ ",
" @@*+++++#.*@@@...*+++#.@ ",
" @.#++++#.@@@ @@..#++++.@ ",
" @.++++*.@@$ %@@..+++#.@@ ",
" $@.+++..@@* $@*.#+#**@ ",
" @@#+#.*@$% $@@.##..@ ",
" @.##.@@ @@..#.@$ ",
" $@.*.@@$ @@**.@$ ",
" $@.*@@ %$@@.*@ ",
" @.@@$ *@@.@ ",
" @@@$ %@@@$ ",
" $@@% %@@@ ",
" @@ $@ ",
" $ * "};

View File

@ -1,127 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Christopher Blizzard
* <blizzard@mozilla.org>. Portions created by the Initial Developer
* are Copyright (C) 2001 the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <gtk/gtkmain.h>
#include "nsAppShell.h"
#include "prlog.h"
#include "prenv.h"
#define NOTIFY_TOKEN 0xFA
/*static*/ gboolean
nsAppShell::EventProcessorCallback(GIOChannel *source,
GIOCondition condition,
gpointer data)
{
nsAppShell *self = NS_STATIC_CAST(nsAppShell *, data);
unsigned char c;
read(self->mPipeFDs[0], &c, 1);
NS_ASSERTION(c == (unsigned char) NOTIFY_TOKEN, "wrong token");
self->NativeEventCallback();
return TRUE;
}
nsAppShell::~nsAppShell()
{
if (mTag)
g_source_remove(mTag);
if (mPipeFDs[0])
close(mPipeFDs[0]);
if (mPipeFDs[1])
close(mPipeFDs[1]);
}
nsresult
nsAppShell::Init()
{
GIOChannel *ioc;
int err = pipe(mPipeFDs);
if (err)
return NS_ERROR_OUT_OF_MEMORY;
// make the pipe nonblocking
int flags = fcntl(mPipeFDs[0], F_GETFL, 0);
if (flags == -1)
goto failed;
err = fcntl(mPipeFDs[0], F_SETFL, flags | O_NONBLOCK);
if (err == -1)
goto failed;
flags = fcntl(mPipeFDs[1], F_GETFL, 0);
if (flags == -1)
goto failed;
err = fcntl(mPipeFDs[1], F_SETFL, flags | O_NONBLOCK);
if (err == -1)
goto failed;
ioc = g_io_channel_unix_new(mPipeFDs[0]);
mTag = g_io_add_watch_full(ioc, G_PRIORITY_DEFAULT, G_IO_IN,
EventProcessorCallback, this, nsnull);
g_io_channel_unref(ioc);
return nsBaseAppShell::Init();
failed:
close(mPipeFDs[0]);
close(mPipeFDs[1]);
mPipeFDs[0] = mPipeFDs[1] = 0;
return NS_ERROR_FAILURE;
}
void
nsAppShell::ScheduleNativeEventCallback()
{
unsigned char buf[] = { NOTIFY_TOKEN };
write(mPipeFDs[1], buf, 1);
}
PRBool
nsAppShell::ProcessNextNativeEvent(PRBool mayWait)
{
PRBool hasEvents = gtk_events_pending();
gtk_main_iteration_do(mayWait);
return hasEvents || mayWait;
}

View File

@ -1,71 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Christopher Blizzard
* <blizzard@mozilla.org>. Portions created by the Initial Developer
* are Copyright (C) 2001 the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsAppShell_h__
#define nsAppShell_h__
#include <glib.h>
#include "nsBaseAppShell.h"
#include "nsCOMPtr.h"
class nsAppShell : public nsBaseAppShell {
public:
nsAppShell()
: mTag(0), mRunningMain(0)
{
mPipeFDs[0] = mPipeFDs[1] = 0;
}
// nsBaseAppShell overrides:
nsresult Init();
virtual void ScheduleNativeEventCallback();
virtual PRBool ProcessNextNativeEvent(PRBool mayWait);
private:
virtual ~nsAppShell();
static gboolean EventProcessorCallback(GIOChannel *source,
GIOCondition condition,
gpointer data);
int mPipeFDs[2];
PRUintn mTag;
PRInt32 mRunningMain;
};
#endif /* nsAppShell_h__ */

View File

@ -1,63 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is IBM code.
*
* The Initial Developer of the Original Code is
* IBM. Portions created by IBM are Copyright (C) International Business Machines Corporation, 2000. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Simon Montagu
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsBidiKeyboard.h"
NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard)
nsBidiKeyboard::nsBidiKeyboard() : nsIBidiKeyboard()
{
}
nsBidiKeyboard::~nsBidiKeyboard()
{
}
NS_IMETHODIMP nsBidiKeyboard::IsLangRTL(PRBool *aIsRTL)
{
*aIsRTL = PR_FALSE;
// XXX Insert platform specific code to determine keyboard direction
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsBidiKeyboard::SetLangFromBidiLevel(PRUint8 aLevel)
{
// XXX Insert platform specific code to set keyboard language
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -1,56 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is IBM code.
*
* The Initial Developer of the Original Code is
* IBM. Portions created by IBM are Copyright (C) International Business Machines Corporation, 2000. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Simon Montagu
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsBidiKeyboard
#define __nsBidiKeyboard
#include "nsIBidiKeyboard.h"
class nsBidiKeyboard : public nsIBidiKeyboard
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIBIDIKEYBOARD
nsBidiKeyboard();
virtual ~nsBidiKeyboard();
/* additional members */
};
#endif // __nsBidiKeyboard

File diff suppressed because it is too large Load Diff

View File

@ -1,169 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1999-2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
* Mike Pinkerton <pinkerton@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsClipboard_h__
#define nsClipboard_h__
#include <gtk/gtk.h>
#include <gtk/gtkinvisible.h>
#include "nsIClipboard.h"
#include "nsITransferable.h"
#include "nsIClipboardOwner.h"
#include <nsCOMPtr.h>
class nsITransferable;
class nsIClipboardOwner;
class nsIWidget;
/**
* Native Gtk Clipboard wrapper
*/
class nsClipboard : public nsIClipboard
{
public:
nsClipboard();
virtual ~nsClipboard();
//nsISupports
NS_DECL_ISUPPORTS
// nsIClipboard
NS_DECL_NSICLIPBOARD
protected:
void Init(void);
NS_IMETHOD SetNativeClipboardData(PRInt32 aWhichClipboard);
NS_IMETHOD GetNativeClipboardData(nsITransferable * aTransferable,
PRInt32 aWhichClipboard );
inline nsITransferable *GetTransferable(PRInt32 aWhichClipboard);
PRBool mIgnoreEmptyNotification;
private:
inline GdkAtom GetSelectionAtom(PRInt32 aWhichClipboard);
inline void AddTarget(GdkAtom aAtom, GdkAtom aSelectionAtom);
void RegisterFormat(const char *aMimeStr, GdkAtom aSelectionAtom);
PRBool DoRealConvert(GdkAtom type, GdkAtom aSelectionAtom);
PRBool DoConvert(const char *aMimeStr, GdkAtom aSelectionAtom);
PRBool GetTargets(GdkAtom aSelectionAtom);
nsCOMPtr<nsIClipboardOwner> mSelectionOwner;
nsCOMPtr<nsIClipboardOwner> mGlobalOwner;
nsCOMPtr<nsITransferable> mSelectionTransferable;
nsCOMPtr<nsITransferable> mGlobalTransferable;
// Used for communicating pasted data
// from the asynchronous X routines back to a blocking paste:
GtkSelectionData mSelectionData;
PRBool mBlocking;
// invisible widget. also used by dragndrop
static GtkWidget *sWidget;
void SelectionReceiver(GtkWidget *aWidget,
GtkSelectionData *aSD);
/**
* This is the callback which is called when another app
* requests the selection.
*
* @param widget The widget
* @param aSelectionData Selection data
* @param info Value passed in from the callback init
* @param time Time when the selection request came in
*/
static void SelectionGetCB(GtkWidget *aWidget,
GtkSelectionData *aSelectionData,
guint /*info*/,
guint /*time*/);
/**
* Called when another app requests selection ownership
*
* @param aWidget the widget
* @param aEvent the GdkEvent for the selection
* @param aData value passed in from the callback init
*/
static void SelectionClearCB(GtkWidget *aWidget,
GdkEventSelection *aEvent,
gpointer aData);
/**
* The routine called when another app asks for the content of the selection
*
* @param aWidget the widget
* @param aSelectionData gtk selection stuff
* @param aData value passed in from the callback init
*/
static void SelectionRequestCB(GtkWidget *aWidget,
GtkSelectionData *aSelectionData,
gpointer data);
/**
* Called when the data from a paste comes in
*
* @param aWidget the widget
* @param aSelectionData gtk selection stuff
* @param aTime time the selection was requested
*/
static void SelectionReceivedCB(GtkWidget *aWidget,
GtkSelectionData *aSelectionData,
guint aTime);
static void SelectionNotifyCB(GtkWidget *aWidget,
GtkSelectionData *aSelectionData,
gpointer aData);
/* functions to do blocking when trying to get info from another client */
PRBool FindSelectionNotifyEvent();
void SetCutBuffer();
};
#endif // nsClipboard_h__

File diff suppressed because it is too large Load Diff

View File

@ -1,150 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard <blizzard@mozilla.org>.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDragService_h__
#define nsDragService_h__
#include "nsBaseDragService.h"
#include "nsIDragSessionGTK.h"
#include "nsIObserver.h"
#include <gtk/gtk.h>
/**
* Native GTK DragService wrapper
*/
class nsDragService : public nsBaseDragService,
public nsIDragSessionGTK,
public nsIObserver
{
public:
nsDragService();
virtual ~nsDragService();
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIOBSERVER
// nsIDragService
NS_IMETHOD InvokeDragSession (nsIDOMNode *aDOMNode,
nsISupportsArray * anArrayTransferables,
nsIScriptableRegion * aRegion,
PRUint32 aActionType);
NS_IMETHOD StartDragSession();
NS_IMETHOD EndDragSession(PRBool aDragDone);
// nsIDragSession
NS_IMETHOD SetCanDrop (PRBool aCanDrop);
NS_IMETHOD GetCanDrop (PRBool *aCanDrop);
NS_IMETHOD GetNumDropItems (PRUint32 * aNumItems);
NS_IMETHOD GetData (nsITransferable * aTransferable,
PRUint32 aItemIndex);
NS_IMETHOD IsDataFlavorSupported (const char *aDataFlavor, PRBool *_retval);
// nsIDragSessionGTK
NS_IMETHOD TargetSetLastContext (GtkWidget *aWidget,
GdkDragContext *aContext,
guint aTime);
NS_IMETHOD TargetStartDragMotion (void);
NS_IMETHOD TargetEndDragMotion (GtkWidget *aWidget,
GdkDragContext *aContext,
guint aTime);
NS_IMETHOD TargetDataReceived (GtkWidget *aWidget,
GdkDragContext *aContext,
gint aX,
gint aY,
GtkSelectionData *aSelection_data,
guint aInfo,
guint32 aTime);
NS_IMETHOD TargetSetTimeCallback (nsIDragSessionGTKTimeCB aCallback);
// This is called when the drag started with the invisible widget
// finishes. It's called from within the drag service code but from
// a callback - it needs to be public.
void SourceEndDrag(void);
void SourceDataGet(GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint32 aTime);
// END PUBLIC API
private:
// target side vars
// the last widget that was the target of a drag
GtkWidget *mTargetWidget;
GdkDragContext *mTargetDragContext;
guint mTargetTime;
// is it OK to drop on us?
PRBool mCanDrop;
// have we received our drag data?
PRBool mTargetDragDataReceived;
// last data received and its length
void *mTargetDragData;
PRUint32 mTargetDragDataLen;
// is the current target drag context contain a list?
PRBool IsTargetContextList(void);
// this will get the native data from the last target given a
// specific flavor
void GetTargetDragData(GdkAtom aFlavor);
// this will reset all of the target vars
void TargetResetData(void);
// source side vars
// the source of our drags
GtkWidget *mHiddenWidget;
// our source data items
nsCOMPtr<nsISupportsArray> mSourceDataItems;
// get a list of the sources in gtk's format
GtkTargetList *GetSourceList(void);
// this is our callback to get the most recent event's time
nsIDragSessionGTKTimeCB mTimeCB;
};
#endif // nsDragService_h__

View File

@ -1,493 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:expandtab:shiftwidth=2:tabstop=2:
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Tim Copperfield. Portions created by Tim Copperfield are Copyright (C) Tim Copperfield. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Tim Copperfield <timecop@network.email.ne.jp>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsGtkCursors_h__
#define nsGtkCursors_h__
typedef struct {
const unsigned char *bits;
const unsigned char *mask_bits;
int hot_x;
int hot_y;
} nsGtkCursor;
/* MOZ_CURSOR_QUESTION_ARROW */
static const unsigned char moz_question_arrow_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
0x7c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00,
0xfc, 0xe3, 0x00, 0x00, 0x7c, 0xb0, 0x01, 0x00, 0x6c, 0x80, 0x01, 0x00,
0xc4, 0xc0, 0x00, 0x00, 0xc0, 0x60, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00,
0x80, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char moz_question_arrow_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
0xfe, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0xfe, 0xe3, 0x00, 0x00,
0xfe, 0xf7, 0x01, 0x00, 0xfe, 0xfb, 0x03, 0x00, 0xfe, 0xf0, 0x03, 0x00,
0xee, 0xe1, 0x01, 0x00, 0xe4, 0xf1, 0x00, 0x00, 0xc0, 0x63, 0x00, 0x00,
0xc0, 0xf3, 0x00, 0x00, 0x80, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* MOZ_CURSOR_HAND_GRAB */
static const unsigned char moz_hand_grab_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00,
0x60, 0x39, 0x00, 0x00, 0x90, 0x49, 0x00, 0x00, 0x90, 0x49, 0x01, 0x00,
0x20, 0xc9, 0x02, 0x00, 0x20, 0x49, 0x02, 0x00, 0x58, 0x40, 0x02, 0x00,
0x64, 0x00, 0x02, 0x00, 0x44, 0x00, 0x01, 0x00, 0x08, 0x00, 0x01, 0x00,
0x10, 0x00, 0x01, 0x00, 0x10, 0x80, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00,
0x40, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char moz_hand_grab_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x60, 0x3f, 0x00, 0x00,
0xf0, 0x7f, 0x00, 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf8, 0xff, 0x03, 0x00,
0xf0, 0xff, 0x07, 0x00, 0xf8, 0xff, 0x07, 0x00, 0xfc, 0xff, 0x07, 0x00,
0xfe, 0xff, 0x07, 0x00, 0xfe, 0xff, 0x03, 0x00, 0xfc, 0xff, 0x03, 0x00,
0xf8, 0xff, 0x03, 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf0, 0xff, 0x01, 0x00,
0xe0, 0xff, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* MOZ_CURSOR_HAND_GRABBING */
static const unsigned char moz_hand_grabbing_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xc0, 0x36, 0x00, 0x00, 0x20, 0xc9, 0x00, 0x00, 0x20, 0x40, 0x01, 0x00,
0x40, 0x00, 0x01, 0x00, 0x60, 0x00, 0x01, 0x00, 0x10, 0x00, 0x01, 0x00,
0x10, 0x00, 0x01, 0x00, 0x10, 0x80, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00,
0x40, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char moz_hand_grabbing_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x36, 0x00, 0x00,
0xe0, 0xff, 0x00, 0x00, 0xf0, 0xff, 0x01, 0x00, 0xf0, 0xff, 0x03, 0x00,
0xe0, 0xff, 0x03, 0x00, 0xf0, 0xff, 0x03, 0x00, 0xf8, 0xff, 0x03, 0x00,
0xf8, 0xff, 0x03, 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf0, 0xff, 0x01, 0x00,
0xe0, 0xff, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* MOZ_CURSOR_COPY */
static const unsigned char moz_copy_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
0x7c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00,
0xfc, 0x03, 0x00, 0x00, 0x7c, 0x30, 0x00, 0x00, 0x6c, 0x30, 0x00, 0x00,
0xc4, 0xfc, 0x00, 0x00, 0xc0, 0xfc, 0x00, 0x00, 0x80, 0x31, 0x00, 0x00,
0x80, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char moz_copy_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
0xfe, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00,
0xfe, 0x37, 0x00, 0x00, 0xfe, 0x7b, 0x00, 0x00, 0xfe, 0xfc, 0x00, 0x00,
0xee, 0xff, 0x01, 0x00, 0xe4, 0xff, 0x01, 0x00, 0xc0, 0xff, 0x00, 0x00,
0xc0, 0x7b, 0x00, 0x00, 0x80, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* MOZ_CURSOR_ALIAS */
static const unsigned char moz_alias_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
0x7c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00,
0xfc, 0x03, 0x00, 0x00, 0x7c, 0xf0, 0x00, 0x00, 0x6c, 0xe0, 0x00, 0x00,
0xc4, 0xf0, 0x00, 0x00, 0xc0, 0xb0, 0x00, 0x00, 0x80, 0x19, 0x00, 0x00,
0x80, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char moz_alias_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
0xfe, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0xfe, 0x03, 0x00, 0x00,
0xfe, 0xf7, 0x00, 0x00, 0xfe, 0xfb, 0x01, 0x00, 0xfe, 0xf0, 0x01, 0x00,
0xee, 0xf9, 0x01, 0x00, 0xe4, 0xf9, 0x01, 0x00, 0xc0, 0xbf, 0x00, 0x00,
0xc0, 0x3f, 0x00, 0x00, 0x80, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* MOZ_CURSOR_CONTEXT_MENU */
static const unsigned char moz_menu_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
0x7c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0xfd, 0x00, 0x00,
0xfc, 0xff, 0x00, 0x00, 0x7c, 0x84, 0x00, 0x00, 0x6c, 0xfc, 0x00, 0x00,
0xc4, 0x84, 0x00, 0x00, 0xc0, 0xfc, 0x00, 0x00, 0x80, 0x85, 0x00, 0x00,
0x80, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char moz_menu_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
0xfe, 0x00, 0x00, 0x00, 0xfe, 0xfd, 0x00, 0x00, 0xfe, 0xff, 0x01, 0x00,
0xfe, 0xff, 0x01, 0x00, 0xfe, 0xff, 0x01, 0x00, 0xfe, 0xfe, 0x01, 0x00,
0xee, 0xff, 0x01, 0x00, 0xe4, 0xff, 0x01, 0x00, 0xc0, 0xff, 0x01, 0x00,
0xc0, 0xff, 0x01, 0x00, 0x80, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* MOZ_CURSOR_SPINNING */
static const unsigned char moz_spinning_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x0c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00,
0x7c, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x01, 0x00, 0x00,
0xfc, 0x3b, 0x00, 0x00, 0x7c, 0x38, 0x00, 0x00, 0x6c, 0x54, 0x00, 0x00,
0xc4, 0xdc, 0x00, 0x00, 0xc0, 0x44, 0x00, 0x00, 0x80, 0x39, 0x00, 0x00,
0x80, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char moz_spinning_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00,
0x1e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00,
0xfe, 0x00, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0xfe, 0x3b, 0x00, 0x00,
0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0xfe, 0x00, 0x00,
0xee, 0xff, 0x01, 0x00, 0xe4, 0xff, 0x00, 0x00, 0xc0, 0x7f, 0x00, 0x00,
0xc0, 0x7f, 0x00, 0x00, 0x80, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* MOZ_CURSOR_ZOOM_IN */
static const unsigned char moz_zoom_in_bits[] = {
0xf0, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00,
0x62, 0x04, 0x00, 0x00, 0x61, 0x08, 0x00, 0x00, 0xf9, 0x09, 0x00, 0x00,
0xf9, 0x09, 0x00, 0x00, 0x61, 0x08, 0x00, 0x00, 0x62, 0x04, 0x00, 0x00,
0x02, 0x04, 0x00, 0x00, 0x0c, 0x0f, 0x00, 0x00, 0xf0, 0x1c, 0x00, 0x00,
0x00, 0x38, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char moz_zoom_in_mask_bits[] = {
0xf0, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00,
0xfe, 0x07, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00,
0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00,
0xfe, 0x07, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xf0, 0x1c, 0x00, 0x00,
0x00, 0x38, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* MOZ_CURSOR_ZOOM_OUT */
static const unsigned char moz_zoom_out_bits[] = {
0xf0, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00,
0x02, 0x04, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0xf9, 0x09, 0x00, 0x00,
0xf9, 0x09, 0x00, 0x00, 0x01, 0x08, 0x00, 0x00, 0x02, 0x04, 0x00, 0x00,
0x02, 0x04, 0x00, 0x00, 0x0c, 0x0f, 0x00, 0x00, 0xf0, 0x1c, 0x00, 0x00,
0x00, 0x38, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char moz_zoom_out_mask_bits[] = {
0xf0, 0x00, 0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00,
0xfe, 0x07, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00,
0xff, 0x0f, 0x00, 0x00, 0xff, 0x0f, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00,
0xfe, 0x07, 0x00, 0x00, 0xfc, 0x0f, 0x00, 0x00, 0xf0, 0x1c, 0x00, 0x00,
0x00, 0x38, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00,
0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* MOZ_CURSOR_NOT_ALLOWED */
static const unsigned char moz_not_allowed_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, 0xe0, 0x7f, 0x00, 0x00,
0xf0, 0xf0, 0x00, 0x00, 0x38, 0xc0, 0x01, 0x00, 0x7c, 0x80, 0x03, 0x00,
0xec, 0x00, 0x03, 0x00, 0xce, 0x01, 0x07, 0x00, 0x86, 0x03, 0x06, 0x00,
0x06, 0x07, 0x06, 0x00, 0x06, 0x0e, 0x06, 0x00, 0x06, 0x1c, 0x06, 0x00,
0x0e, 0x38, 0x07, 0x00, 0x0c, 0x70, 0x03, 0x00, 0x1c, 0xe0, 0x03, 0x00,
0x38, 0xc0, 0x01, 0x00, 0xf0, 0xf0, 0x00, 0x00, 0xe0, 0x7f, 0x00, 0x00,
0x80, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char moz_not_allowed_mask_bits[] = {
0x80, 0x1f, 0x00, 0x00, 0xe0, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00,
0xf8, 0xff, 0x01, 0x00, 0xfc, 0xf0, 0x03, 0x00, 0xfe, 0xc0, 0x07, 0x00,
0xfe, 0x81, 0x07, 0x00, 0xff, 0x83, 0x0f, 0x00, 0xcf, 0x07, 0x0f, 0x00,
0x8f, 0x0f, 0x0f, 0x00, 0x0f, 0x1f, 0x0f, 0x00, 0x0f, 0x3e, 0x0f, 0x00,
0x1f, 0xfc, 0x0f, 0x00, 0x1e, 0xf8, 0x07, 0x00, 0x3e, 0xf0, 0x07, 0x00,
0xfc, 0xf0, 0x03, 0x00, 0xf8, 0xff, 0x01, 0x00, 0xf0, 0xff, 0x00, 0x00,
0xe0, 0x7f, 0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* MOZ_CURSOR_COL_RESIZE */
static const unsigned char moz_col_resize_bits[] = {
0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
0x00, 0x05, 0x00, 0x00, 0x10, 0x45, 0x00, 0x00, 0x18, 0xc5, 0x00, 0x00,
0x1c, 0xc5, 0x01, 0x00, 0x7e, 0xf5, 0x03, 0x00, 0x1c, 0xc5, 0x01, 0x00,
0x18, 0xc5, 0x00, 0x00, 0x10, 0x45, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char moz_col_resize_mask_bits[] = {
0x80, 0x0f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00,
0x90, 0x4f, 0x00, 0x00, 0xb8, 0xef, 0x00, 0x00, 0xbc, 0xef, 0x01, 0x00,
0xbe, 0xef, 0x03, 0x00, 0xff, 0xff, 0x07, 0x00, 0xbe, 0xef, 0x03, 0x00,
0xbc, 0xef, 0x01, 0x00, 0xb8, 0xef, 0x00, 0x00, 0x90, 0x4f, 0x00, 0x00,
0x80, 0x0f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* MOZ_CURSOR_ROW_RESIZE */
static const unsigned char moz_row_resize_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00,
0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00,
0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char moz_row_resize_mask_bits[] = {
0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00,
0xf0, 0x07, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00,
0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00,
0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00,
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* MOZ_CURSOR_VERTICAL_TEXT */
static const unsigned char moz_vertical_text_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00,
0x06, 0x60, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00,
0x02, 0x40, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char moz_vertical_text_mask_bits[] = {
0x07, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00,
0xff, 0xff, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
0x0f, 0xf0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* MOZ_CURSOR_NESW_RESIZE */
static const unsigned char moz_nesw_resize_bits[] = {
0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
0x00, 0xbe, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x00,
0x02, 0xb4, 0x00, 0x00, 0x02, 0xa2, 0x00, 0x00, 0x02, 0x81, 0x00, 0x00,
0x8a, 0x80, 0x00, 0x00, 0x5a, 0x80, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00,
0x7a, 0x00, 0x00, 0x00, 0xfa, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0xfe, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char moz_nesw_resize_mask_bits[] = {
0xc0, 0xff, 0x01, 0x00, 0xc0, 0xff, 0x01, 0x00, 0xc0, 0xff, 0x01, 0x00,
0x00, 0xff, 0x01, 0x00, 0x00, 0xfe, 0x01, 0x00, 0x00, 0xfc, 0x01, 0x00,
0x07, 0xfe, 0x01, 0x00, 0x07, 0xf7, 0x01, 0x00, 0x8f, 0xe3, 0x01, 0x00,
0xdf, 0xc1, 0x01, 0x00, 0xff, 0xc0, 0x01, 0x00, 0x7f, 0x00, 0x00, 0x00,
0xff, 0x00, 0x00, 0x00, 0xff, 0x01, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00,
0xff, 0x07, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
/* MOZ_CURSOR_NWSE_RESIZE */
static const unsigned char moz_nwse_resize_bits[] = {
0x00, 0x00, 0x00, 0x00, 0xfe, 0x07, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0xfa, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00,
0x5a, 0x80, 0x00, 0x00, 0x8a, 0x80, 0x00, 0x00, 0x02, 0x81, 0x00, 0x00,
0x02, 0xa2, 0x00, 0x00, 0x02, 0xb4, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x00,
0x00, 0xbc, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
0xc0, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char moz_nwse_resize_mask_bits[] = {
0xff, 0x07, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00, 0xff, 0x07, 0x00, 0x00,
0xff, 0x01, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00,
0xff, 0xc0, 0x01, 0x00, 0xdf, 0xc1, 0x01, 0x00, 0x8f, 0xe3, 0x01, 0x00,
0x07, 0xf7, 0x01, 0x00, 0x07, 0xfe, 0x01, 0x00, 0x00, 0xfc, 0x01, 0x00,
0x00, 0xfe, 0x01, 0x00, 0x00, 0xff, 0x01, 0x00, 0xc0, 0xff, 0x01, 0x00,
0xc0, 0xff, 0x01, 0x00, 0xc0, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
enum {
MOZ_CURSOR_QUESTION_ARROW = 0,
MOZ_CURSOR_HAND_GRAB,
MOZ_CURSOR_HAND_GRABBING,
MOZ_CURSOR_COPY,
MOZ_CURSOR_ALIAS,
MOZ_CURSOR_CONTEXT_MENU,
MOZ_CURSOR_SPINNING,
MOZ_CURSOR_ZOOM_IN,
MOZ_CURSOR_ZOOM_OUT,
MOZ_CURSOR_NOT_ALLOWED,
MOZ_CURSOR_COL_RESIZE,
MOZ_CURSOR_ROW_RESIZE,
MOZ_CURSOR_VERTICAL_TEXT,
MOZ_CURSOR_NESW_RESIZE,
MOZ_CURSOR_NWSE_RESIZE
};
// create custom pixmap cursor from cursors in nsGTKCursorData.h
static const nsGtkCursor GtkCursors[] = {
{ moz_question_arrow_bits, moz_question_arrow_mask_bits, 2, 2 },
{ moz_hand_grab_bits, moz_hand_grab_mask_bits, 10, 10 },
{ moz_hand_grabbing_bits, moz_hand_grabbing_mask_bits, 10, 10 },
{ moz_copy_bits, moz_copy_mask_bits, 2, 2 },
{ moz_alias_bits, moz_alias_mask_bits, 2, 2 },
{ moz_menu_bits, moz_menu_mask_bits, 2, 2 },
{ moz_spinning_bits, moz_spinning_mask_bits, 2, 2 },
{ moz_zoom_in_bits, moz_zoom_in_mask_bits, 6, 6 },
{ moz_zoom_out_bits, moz_zoom_out_mask_bits, 6, 6 },
{ moz_not_allowed_bits, moz_not_allowed_mask_bits, 9, 9 },
{ moz_col_resize_bits, moz_col_resize_mask_bits, 9, 7 },
{ moz_row_resize_bits, moz_row_resize_mask_bits, 7, 9 },
{ moz_vertical_text_bits, moz_vertical_text_mask_bits, 8, 4 },
{ moz_nesw_resize_bits, moz_nesw_resize_mask_bits, 8, 8 },
{ moz_nwse_resize_bits, moz_nwse_resize_mask_bits, 8, 8 }
};
#endif /* nsGtkCursors_h__ */

View File

@ -1,899 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Annema <disttsc@bart.nl>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsWidget.h"
#include "keysym2ucs.h"
#include "nsWindow.h"
#include "nsAppShell.h"
#include "nsGUIEvent.h"
#include "nsGtkIMEHelper.h"
#include <stdio.h>
#include <gtk/gtk.h>
#include <gtk/gtkprivate.h>
#include "nsGtkEventHandler.h"
#include <gdk/gdkkeysyms.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#ifdef DEBUG_pavlov
//#define DEBUG_EVENTS 1
#endif
//#define DEBUG_MOVE
static void
dispatch_superwin_event(GdkEvent *event, nsWindow *window);
static PRBool
gdk_window_child_of_gdk_window(GdkWindow *window, GdkWindow *ancestor);
// This is a flag that says if we should suppress the next key down
// event. This is used when that last key release event was
// suppressed and we want the next key press event to not generate the
// key down event since it is part of a key repeat sequence.
static PRBool suppressNextKeyDown = PR_FALSE;
//==============================================================
void InitAllocationEvent(GtkAllocation *aAlloc,
nsSizeEvent &anEvent)
{
if (aAlloc != nsnull) {
// HACK
// nsRect *foo = new nsRect(aAlloc->x, aAlloc->y, aAlloc->width, aAlloc->height);
nsRect *foo = new nsRect(0, 0, aAlloc->width, aAlloc->height);
anEvent.windowSize = foo;
// anEvent.point.x = aAlloc->x;
// anEvent.point.y = aAlloc->y;
// HACK
anEvent.mWinWidth = aAlloc->width;
anEvent.mWinHeight = aAlloc->height;
}
anEvent.time = PR_IntervalNow();
}
//==============================================================
struct nsKeyConverter {
int vkCode; // Platform independent key code
int keysym; // GDK keysym key code
};
//
// Netscape keycodes are defined in widget/public/nsGUIEvent.h
// GTK keycodes are defined in <gdk/gdkkeysyms.h>
//
struct nsKeyConverter nsKeycodes[] = {
{ NS_VK_CANCEL, GDK_Cancel },
{ NS_VK_BACK, GDK_BackSpace },
{ NS_VK_TAB, GDK_Tab },
{ NS_VK_TAB, GDK_ISO_Left_Tab },
{ NS_VK_CLEAR, GDK_Clear },
{ NS_VK_RETURN, GDK_Return },
{ NS_VK_SHIFT, GDK_Shift_L },
{ NS_VK_SHIFT, GDK_Shift_R },
{ NS_VK_CONTROL, GDK_Control_L },
{ NS_VK_CONTROL, GDK_Control_R },
{ NS_VK_ALT, GDK_Alt_L },
{ NS_VK_ALT, GDK_Alt_R },
{ NS_VK_META, GDK_Meta_L },
{ NS_VK_META, GDK_Meta_R },
{ NS_VK_PAUSE, GDK_Pause },
{ NS_VK_CAPS_LOCK, GDK_Caps_Lock },
{ NS_VK_ESCAPE, GDK_Escape },
{ NS_VK_SPACE, GDK_space },
{ NS_VK_PAGE_UP, GDK_Page_Up },
{ NS_VK_PAGE_DOWN, GDK_Page_Down },
{ NS_VK_END, GDK_End },
{ NS_VK_HOME, GDK_Home },
{ NS_VK_LEFT, GDK_Left },
{ NS_VK_UP, GDK_Up },
{ NS_VK_RIGHT, GDK_Right },
{ NS_VK_DOWN, GDK_Down },
{ NS_VK_PRINTSCREEN, GDK_Print },
{ NS_VK_INSERT, GDK_Insert },
{ NS_VK_DELETE, GDK_Delete },
// keypad keys
{ NS_VK_LEFT, GDK_KP_Left },
{ NS_VK_RIGHT, GDK_KP_Right },
{ NS_VK_UP, GDK_KP_Up },
{ NS_VK_DOWN, GDK_KP_Down },
{ NS_VK_PAGE_UP, GDK_KP_Page_Up },
// Not sure what these are
//{ NS_VK_, GDK_KP_Prior },
//{ NS_VK_, GDK_KP_Next },
// GDK_KP_Begin is the 5 on the non-numlock keypad
//{ NS_VK_, GDK_KP_Begin },
{ NS_VK_PAGE_DOWN, GDK_KP_Page_Down },
{ NS_VK_HOME, GDK_KP_Home },
{ NS_VK_END, GDK_KP_End },
{ NS_VK_INSERT, GDK_KP_Insert },
{ NS_VK_DELETE, GDK_KP_Delete },
{ NS_VK_MULTIPLY, GDK_KP_Multiply },
{ NS_VK_ADD, GDK_KP_Add },
{ NS_VK_SEPARATOR, GDK_KP_Separator },
{ NS_VK_SUBTRACT, GDK_KP_Subtract },
{ NS_VK_DECIMAL, GDK_KP_Decimal },
{ NS_VK_DIVIDE, GDK_KP_Divide },
{ NS_VK_RETURN, GDK_KP_Enter },
{ NS_VK_NUM_LOCK, GDK_Num_Lock },
{ NS_VK_SCROLL_LOCK,GDK_Scroll_Lock },
{ NS_VK_COMMA, GDK_comma },
{ NS_VK_PERIOD, GDK_period },
{ NS_VK_SLASH, GDK_slash },
{ NS_VK_BACK_SLASH, GDK_backslash },
{ NS_VK_BACK_QUOTE, GDK_grave },
{ NS_VK_OPEN_BRACKET, GDK_bracketleft },
{ NS_VK_CLOSE_BRACKET, GDK_bracketright },
{ NS_VK_SEMICOLON, GDK_colon },
{ NS_VK_QUOTE, GDK_apostrophe },
// context menu key, keysym 0xff67, typically keycode 117 on 105-key (Microsoft)
// x86 keyboards, located between right 'Windows' key and right Ctrl key
{ NS_VK_CONTEXT_MENU, GDK_Menu },
// NS doesn't have dash or equals distinct from the numeric keypad ones,
// so we'll use those for now. See bug 17008:
{ NS_VK_SUBTRACT, GDK_minus },
{ NS_VK_EQUALS, GDK_equal },
// Some shifted keys, see bug 15463 as well as 17008.
// These should be subject to different keyboard mappings.
{ NS_VK_QUOTE, GDK_quotedbl },
{ NS_VK_OPEN_BRACKET, GDK_braceleft },
{ NS_VK_CLOSE_BRACKET, GDK_braceright },
{ NS_VK_BACK_SLASH, GDK_bar },
{ NS_VK_SEMICOLON, GDK_semicolon },
{ NS_VK_BACK_QUOTE, GDK_asciitilde },
{ NS_VK_COMMA, GDK_less },
{ NS_VK_PERIOD, GDK_greater },
{ NS_VK_SLASH, GDK_question },
{ NS_VK_1, GDK_exclam },
{ NS_VK_2, GDK_at },
{ NS_VK_3, GDK_numbersign },
{ NS_VK_4, GDK_dollar },
{ NS_VK_5, GDK_percent },
{ NS_VK_6, GDK_asciicircum },
{ NS_VK_7, GDK_ampersand },
{ NS_VK_8, GDK_asterisk },
{ NS_VK_9, GDK_parenleft },
{ NS_VK_0, GDK_parenright },
{ NS_VK_SUBTRACT, GDK_underscore },
{ NS_VK_EQUALS, GDK_plus }
};
#define IS_XSUN_XSERVER(dpy) \
(strstr(XServerVendor(dpy), "Sun Microsystems") != NULL)
// map Sun Keyboard special keysyms on to NS_VK keys
struct nsKeyConverter nsSunKeycodes[] = {
{NS_VK_ESCAPE, GDK_F11 }, //bug 57262, Sun Stop key generates F11 keysym
{NS_VK_F11, 0x1005ff10 }, //Sun F11 key generates SunF36(0x1005ff10) keysym
{NS_VK_F12, 0x1005ff11 }, //Sun F12 key generates SunF37(0x1005ff11) keysym
{NS_VK_PAGE_UP, GDK_F29 }, //KP_Prior
{NS_VK_PAGE_DOWN, GDK_F35 }, //KP_Next
{NS_VK_HOME, GDK_F27 }, //KP_Home
{NS_VK_END, GDK_F33 }, //KP_End
};
//==============================================================
// Input keysym is in gtk format; output is in NS_VK format
int nsPlatformToDOMKeyCode(GdkEventKey *aGEK)
{
int i, length = 0;
int keysym = aGEK->keyval;
// First, try to handle alphanumeric input, not listed in nsKeycodes:
// most likely, more letters will be getting typed in than things in
// the key list, so we will look through these first.
// since X has different key symbols for upper and lowercase letters and
// mozilla does not, convert gdk's to mozilla's
if (keysym >= GDK_a && keysym <= GDK_z)
return keysym - GDK_a + NS_VK_A;
if (keysym >= GDK_A && keysym <= GDK_Z)
return keysym - GDK_A + NS_VK_A;
// numbers
if (keysym >= GDK_0 && keysym <= GDK_9)
return keysym - GDK_0 + NS_VK_0;
// keypad numbers
if (keysym >= GDK_KP_0 && keysym <= GDK_KP_9)
return keysym - GDK_KP_0 + NS_VK_NUMPAD0;
// map Sun Keyboard special keysyms
if (IS_XSUN_XSERVER(GDK_DISPLAY())) {
length = sizeof(nsSunKeycodes) / sizeof(struct nsKeyConverter);
for (i = 0; i < length; i++) {
if (nsSunKeycodes[i].keysym == keysym)
return(nsSunKeycodes[i].vkCode);
}
}
// misc other things
length = sizeof(nsKeycodes) / sizeof(struct nsKeyConverter);
for (i = 0; i < length; i++) {
if (nsKeycodes[i].keysym == keysym)
return(nsKeycodes[i].vkCode);
}
if (keysym >= GDK_F1 && keysym <= GDK_F24)
return keysym - GDK_F1 + NS_VK_F1;
#if defined(DEBUG_akkana) || defined(DEBUG_ftang)
printf("No match in nsPlatformToDOMKeyCode: keysym is 0x%x, string is '%s', keyval = %d\n", keysym, aGEK->string, aGEK->keyval);
#endif
return((int)0);
}
//==============================================================
// Convert gdk key event keyvals to char codes if printable, 0 otherwise
PRUint32 nsConvertCharCodeToUnicode(GdkEventKey* aGEK)
{
// Anything above 0xf000 is considered a non-printable
// Exception: directly encoded UCS characters
if (aGEK->keyval > 0xf000 && (aGEK->keyval & 0xff000000) != 0x01000000) {
// Keypad keys are an exception: they return a value different
// from their non-keypad equivalents, but mozilla doesn't distinguish.
switch (aGEK->keyval)
{
case GDK_KP_Space:
return ' ';
case GDK_KP_Equal:
return '=';
case GDK_KP_Multiply:
return '*';
case GDK_KP_Add:
return '+';
case GDK_KP_Separator:
return ',';
case GDK_KP_Subtract:
return '-';
case GDK_KP_Decimal:
return '.';
case GDK_KP_Divide:
return '/';
case GDK_KP_0:
return '0';
case GDK_KP_1:
return '1';
case GDK_KP_2:
return '2';
case GDK_KP_3:
return '3';
case GDK_KP_4:
return '4';
case GDK_KP_5:
return '5';
case GDK_KP_6:
return '6';
case GDK_KP_7:
return '7';
case GDK_KP_8:
return '8';
case GDK_KP_9:
return '9';
}
// non-printables
return 0;
}
#if defined(USE_XIM) && defined(_AIX)
// On AIX, GDK doesn't get correct keysyms from XIM. Follow GDK
// reference recommending to use the 'string' member of GdkEventKey
// instead. See:
//
// developer.gnome.org/doc/API/gdk/gdk-event-structures.html#GDKEVENTKEY
PRBool controlChar = (aGEK->state & GDK_CONTROL_MASK ||
aGEK->state & GDK_MOD1_MASK ||
aGEK->state & GDK_MOD4_MASK);
// Use 'string' as opposed to 'keyval' when control, alt, or meta is
// not pressed. This allows keyboard shortcuts to continue to function
// properly, while fixing input problems and mode switching in certain
// locales where the 'keyval' does not correspond to the actual input.
// See Bug #157397 and Bug #161581 for more details.
if (!controlChar && gdk_im_ready() && aGEK->length > 0
&& aGEK->keyval != (guint)*aGEK->string) {
nsGtkIMEHelper* IMEHelper = nsGtkIMEHelper::GetSingleton();
if (IMEHelper != nsnull) {
PRUnichar* unichars = IMEHelper->GetUnichars();
PRInt32 unilen = IMEHelper->GetUnicharsSize();
PRInt32 unichar_size = IMEHelper->MultiByteToUnicode(
aGEK->string, aGEK->length,
&unichars, &unilen);
if (unichar_size > 0) {
IMEHelper->SetUnichars(unichars);
IMEHelper->SetUnicharsSize(unilen);
return (long)*unichars;
}
}
}
#endif
// we're supposedly printable, let's try to convert
long ucs = keysym2ucs(aGEK->keyval);
if ((ucs != -1) && (ucs < 0x10000))
return ucs;
// I guess we couldn't convert
return 0;
}
//==============================================================
void InitKeyEvent(GdkEventKey *aGEK,
nsKeyEvent &anEvent)
{
if (aGEK != nsnull) {
anEvent.keyCode = nsPlatformToDOMKeyCode(aGEK);
anEvent.time = aGEK->time;
anEvent.isShift = (aGEK->state & GDK_SHIFT_MASK) ? PR_TRUE : PR_FALSE;
anEvent.isControl = (aGEK->state & GDK_CONTROL_MASK) ? PR_TRUE : PR_FALSE;
anEvent.isAlt = (aGEK->state & GDK_MOD1_MASK) ? PR_TRUE : PR_FALSE;
anEvent.isMeta = (aGEK->state & GDK_MOD4_MASK) ? PR_TRUE : PR_FALSE;
}
}
void InitKeyPressEvent(GdkEventKey *aGEK,
nsKeyEvent &anEvent)
{
//
// init the basic event fields
//
if (aGEK!=nsnull) {
anEvent.isShift = (aGEK->state & GDK_SHIFT_MASK) ? PR_TRUE : PR_FALSE;
anEvent.isControl = (aGEK->state & GDK_CONTROL_MASK) ? PR_TRUE : PR_FALSE;
anEvent.isAlt = (aGEK->state & GDK_MOD1_MASK) ? PR_TRUE : PR_FALSE;
anEvent.isMeta = (aGEK->state & GDK_MOD4_MASK) ? PR_TRUE : PR_FALSE;
anEvent.charCode = nsConvertCharCodeToUnicode(aGEK);
if (anEvent.charCode) {
// if the control, meta, or alt key is down, then we should leave
// the isShift flag alone (probably not a printable character)
// if none of the other modifier keys are pressed then we need to
// clear isShift so the character can be inserted in the editor
if ( anEvent.isControl || anEvent.isAlt || anEvent.isMeta ) {
// make Ctrl+uppercase functional as same as Ctrl+lowercase
// when Ctrl+uppercase(eg.Ctrl+C) is pressed,convert the charCode
// from uppercase to lowercase(eg.Ctrl+c),so do Alt and Meta Key
// It is hack code for bug 61355, there is same code snip for
// Windows platform in widget/src/windows/nsWindow.cpp: See bug 16486
// Note: if Shift is pressed at the same time, do not to_lower()
// Because Ctrl+Shift has different function with Ctrl
if ( (anEvent.charCode >= GDK_A && anEvent.charCode <= GDK_Z) ||
(anEvent.charCode >= GDK_a && anEvent.charCode <= GDK_z) ) {
anEvent.charCode = (anEvent.isShift) ?
gdk_keyval_to_upper(anEvent.charCode) :
gdk_keyval_to_lower(anEvent.charCode);
}
}
} else {
anEvent.keyCode = nsPlatformToDOMKeyCode(aGEK);
}
#if defined(DEBUG_akkana_not) || defined (DEBUG_ftang)
if (!aGEK->length) printf("!length, ");
printf("Key Press event: gtk string = '%s', keyval = '%c' = %d,\n",
aGEK->string, aGEK->keyval, aGEK->keyval);
printf(" --> keyCode = 0x%x, char code = '%c'",
anEvent.keyCode, anEvent.charCode);
if (anEvent.isShift)
printf(" [shift]");
if (anEvent.isControl)
printf(" [ctrl]");
if (anEvent.isAlt)
printf(" [alt]");
if (anEvent.isMeta)
printf(" [meta]");
printf("\n");
#endif
anEvent.time = aGEK->time;
}
}
/*==============================================================
==============================================================
=============================================================
==============================================================*/
void handle_size_allocate(GtkWidget *w, GtkAllocation *alloc, gpointer p)
{
nsWindow *widget = (nsWindow *)p;
nsSizeEvent event(PR_TRUE, NS_SIZE, widget);
InitAllocationEvent(alloc, event);
NS_ADDREF(widget);
widget->OnResize(&event);
NS_RELEASE(widget);
delete event.windowSize;
}
//==============================================================
gint handle_key_press_event(GtkObject *w, GdkEventKey* event, gpointer p)
{
nsWidget *win = (nsWidget*)p;
// if there's a focused window rewrite the event to use that window.
if (nsWidget::sFocusWindow)
win = nsWidget::sFocusWindow;
// work around for annoying things.
if (event->keyval == GDK_Tab)
if (event->state & GDK_CONTROL_MASK)
if (event->state & GDK_MOD1_MASK)
return PR_FALSE;
NS_ADDREF(win);
//
// First, dispatch the Key event as a virtual key down event
// but lie about where it came from and say it is from the
// window that currently has focus inside our app...
//
PRBool noDefault = PR_FALSE;
nsKeyEvent keyDownEvent(PR_TRUE, NS_KEY_DOWN, win);
InitKeyEvent(event, keyDownEvent);
// if we need to suppress this NS_KEY_DOWN event, reset the flag
if (suppressNextKeyDown == PR_TRUE)
suppressNextKeyDown = PR_FALSE;
else
noDefault = win->OnKey(keyDownEvent);
// Don't pass Shift, Alt, Control and Meta as NS_KEY_PRESS events.
if (event->keyval == GDK_Shift_L
|| event->keyval == GDK_Shift_R
|| event->keyval == GDK_Control_L
|| event->keyval == GDK_Control_R
|| event->keyval == GDK_Alt_L
|| event->keyval == GDK_Alt_R
|| event->keyval == GDK_Meta_L
|| event->keyval == GDK_Meta_R)
return PR_TRUE;
//
// Second, dispatch the Key event as a key press event w/ a Unicode
// character code. Note we have to check for modifier keys, since
// gtk returns a character value for them
//
// Call nsConvertCharCodeToUnicode() here to get kevent.charCode
nsKeyEvent keyPressEvent(PR_TRUE, NS_KEY_PRESS, win);
InitKeyPressEvent(event, keyPressEvent);
if (noDefault) { // If prevent default set for onkeydown, do the same for onkeypress
keyPressEvent.flags |= NS_EVENT_FLAG_NO_DEFAULT;
}
if (event->length) {
if (keyPressEvent.charCode || keyPressEvent.keyCode) {
// keyPressEvent.charCode or keyPressEvent.keyCode is valid, just
// pass to OnKey()
win->OnKey(keyPressEvent);
} else if (nsGtkIMEHelper::GetSingleton()) {
// commit request from IME
win->IMECommitEvent(event);
}
} else { // for Home/End/Up/Down/Left/Right/PageUp/PageDown key
win->OnKey(keyPressEvent);
}
NS_RELEASE(win);
if (w)
{
gtk_signal_emit_stop_by_name (GTK_OBJECT(w), "key_press_event");
}
return PR_TRUE;
}
//==============================================================
gint handle_key_release_event(GtkObject *w, GdkEventKey* event, gpointer p)
{
XEvent nextEvent;
PRBool shouldDrop = PR_FALSE;
// According to the DOM spec if this is the result of a key repeat
// event we don't let it through since the DOM wants the event
// stream to look like this: press press press press release. The
// way that X does things is to do press release press release, etc.
// We check to see if this is a key release by checking to see if
// the next event in the queue is a key press event and it has the
// exact same timestamp as the current event.
// have a look in the X queue to see if there's another event in the
// queue.
if (XPending(GDK_DISPLAY())) {
// get a copy of the next event
XPeekEvent(GDK_DISPLAY(), &nextEvent);
// see if it's a key press event and if it has the same time as
// the last event.
if ((nextEvent.xany.type == KeyPress) &&
(nextEvent.xkey.time == event->time))
{
shouldDrop = PR_TRUE;
// the next key press event shouldn't generate a key down event.
// this is a global variable
suppressNextKeyDown = PR_TRUE;
}
}
// should we drop this event?
if (shouldDrop)
return PR_TRUE;
nsWidget *win = (nsWidget *)p;
if (nsWidget::sFocusWindow)
win = nsWidget::sFocusWindow;
nsKeyEvent kevent(PR_TRUE, NS_KEY_UP, win);
InitKeyEvent(event, kevent);
NS_ADDREF(win);
win->OnKey(kevent);
NS_RELEASE(win);
if (w)
{
gtk_signal_emit_stop_by_name (GTK_OBJECT(w), "key_release_event");
}
return PR_TRUE;
}
//==============================================================
void
handle_gdk_event (GdkEvent *event, gpointer data)
{
GtkObject *eventObject = nsnull;
// set the last time that we got an event. we need this for drag
// and drop if you can believe that.
guint32 event_time = gdk_event_get_time(event);
if (event_time)
nsWidget::SetLastEventTime(event_time);
// Get the next X event serial ID and save it for later for event
// processing. If it stays zero then events won't be processed
// later. We're using this as a flag too but with a number this big
// we're probably not going to overflow and even if we did there
// wouldn't be any harm.
unsigned long serial = 0;
if (XPending(GDK_DISPLAY())) {
XEvent temp_event;
XPeekEvent(GDK_DISPLAY(), &temp_event);
serial = temp_event.xany.serial - 1;
}
// try to get the user data for the event window.
if (event->any.window)
gdk_window_get_user_data (event->any.window, (void **)&eventObject);
// If there is an event object and it's a superwin then we need to
// make sure that the event either is handled locally or is passed
// on with a legitimate GtkWidget object associated with it so the
// Gtk mainloop doesn't go spastic.
if (eventObject && GDK_IS_SUPERWIN(eventObject)) {
// try to find the nsWindow object associated with this superwin
nsWindow *window = (nsWindow *)gtk_object_get_data (eventObject,
"nsWindow");
// If we don't have a window here anymore, we are probably in
// the process of being or have been destroyed. give up now.
if (!window)
goto end;
// Find out if there's a grabbing widget. If there is and it's a
// regular gtk widget, and our current event window is not the
// child of that grab widget, we need to rewrite the event to that
// gtk grabbing widget.
PRBool rewriteEvent = PR_FALSE;
GtkWidget *grabWidget = gtk_grab_get_current();
GtkWidget *owningWidget = window->GetOwningWidget();
if (grabWidget &&
!GTK_IS_MOZAREA(grabWidget) &&
!gdk_window_child_of_gdk_window(owningWidget->window,
grabWidget->window)) {
rewriteEvent = PR_TRUE;
}
// There are a lot of events that are always dispatched to our
// internal handler, no matter if there is a grab or not.
switch(event->type)
{
case GDK_NOTHING:
break;
case GDK_DESTROY:
case GDK_DELETE:
case GDK_PROPERTY_NOTIFY:
case GDK_EXPOSE:
case GDK_NO_EXPOSE:
case GDK_FOCUS_CHANGE:
case GDK_CONFIGURE:
case GDK_MAP:
case GDK_UNMAP:
case GDK_SELECTION_CLEAR:
case GDK_SELECTION_REQUEST:
case GDK_SELECTION_NOTIFY:
case GDK_CLIENT_EVENT:
case GDK_VISIBILITY_NOTIFY:
dispatch_superwin_event(event, window);
break;
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_KEY_PRESS:
case GDK_KEY_RELEASE:
// If we need to rewrite this to the nearest real gtk widget,
// do it here.
if (rewriteEvent) {
gdk_window_unref(event->any.window);
event->any.window = owningWidget->window;
gdk_window_ref(event->any.window);
gtk_main_do_event(event);
break;
}
// Otherwise, just send it to our event handler
if (GTK_WIDGET_IS_SENSITIVE(owningWidget))
dispatch_superwin_event(event, window);
break;
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_RELEASE:
case GDK_PROXIMITY_IN:
case GDK_PROXIMITY_OUT:
// See above.
if (rewriteEvent) {
gdk_window_unref(event->any.window);
event->any.window = owningWidget->window;
gdk_window_ref(event->any.window);
gtk_propagate_event(grabWidget, event);
break;
}
if (GTK_WIDGET_IS_SENSITIVE(owningWidget))
dispatch_superwin_event(event, window);
break;
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
// Always dispatch enter and leave notify events to the
// windows that they happened on so that state can be properly
// tracked. The code that handles the enter and leave events
// tracks sensitivity as well.
dispatch_superwin_event(event, window);
break;
default:
// XXX lots of DND events not handled? I don't think that we have to.
NS_WARNING("Odd, hit default case in handle_gdk_event()\n");
break;
}
}
else {
nsWindow *grabbingWindow = nsWindow::GetGrabWindow();
nsCOMPtr<nsIWidget> grabbingWindowGuard(grabbingWindow);
GtkWidget *tempWidget = NULL;
if (grabbingWindow) {
// get the GdkWindow that we are grabbing on
GdkWindow *grabbingGdkWindow =
NS_STATIC_CAST(GdkWindow *,
grabbingWindow->GetNativeData(NS_NATIVE_WINDOW));
// If the object getting the event in question is a GtkWidget
// and it's a child of the grabbing window, we need to put a
// grab on that window before dispatching the event. We do this
// so that the gtk mainloop will recognize the widget in
// question as having the grab. If we didn't the mainloop
// wouldn't think that the widget that got the event is the
// child of the grabbing window, due to the superwin(s) in the
// middle.
if (GTK_IS_WIDGET(eventObject)) {
tempWidget = GTK_WIDGET(eventObject);
if (gdk_window_child_of_gdk_window(tempWidget->window,
grabbingGdkWindow)) {
// this is so awesome. gtk_grab_add/gtk_grab_remove don't
// have exact push and pop semantics. if we call grab_add
// on the object and as part of the dispatching of this
// event another grab_add is called on it, we can end up
// releasing the grab early because we always call
// grab_remove on the object after dispatching the event.
// we can end up with a widget that doesn't have a grab on
// it, even though it should. the scrollbar does this.
//
// so, what we do here is to check and see if the widget in
// question has a parent. if it does and it's a mozbox
// object we slam a grab on that instead of the widget
// itself. we know that no one is doing grabs on those.
if (tempWidget->parent) {
if (GTK_IS_MOZBOX(tempWidget->parent)) {
tempWidget = tempWidget->parent;
}
}
gtk_grab_add(tempWidget);
}
else {
// if the gtk widget in question wasn't the child of the
// grabbing window then the grabbing window gets it.
dispatch_superwin_event(event, grabbingWindow);
goto end;
}
}
}
gtk_main_do_event(event);
if (tempWidget)
gtk_grab_remove(tempWidget);
if (event->type == GDK_BUTTON_RELEASE) {
// Always clear the button motion target when sending a
// button release event to a real gtk widget, otherwise
// mozilla will still think it has the grab. This happens
// when there's a native gtk widget popup over a Mozilla
// area.
nsWidget::DropMotionTarget();
}
}
end:
;
#if 0
// use the saved serial to process any pending events, now that all
// the window events have been processed
if (serial)
nsAppShell::ProcessBeforeID(serial);
#endif
}
void
dispatch_superwin_event(GdkEvent *event, nsWindow *window)
{
if (event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE)
{
// Check to see whether or not we need to send this to the
// toplevel window to get passed to the GtkWidget with focus.
// This happens in the embedding case.
if (!nsWidget::sFocusWindow)
{
GtkWidget *mozArea = window->GetOwningWidget();
NS_ASSERTION(mozArea, "Failed to get GtkMozArea for superwin event!\n");
// get the toplevel window for that widget
GtkWidget *toplevel = gtk_widget_get_toplevel(mozArea);
// pass it off to gtk's event system and return
gboolean handled = gtk_widget_event(toplevel, event);
if (handled)
return;
}
}
switch (event->type)
{
case GDK_KEY_PRESS:
handle_key_press_event (NULL, &event->key, window);
break;
case GDK_KEY_RELEASE:
handle_key_release_event (NULL, &event->key, window);
break;
default:
window->HandleGDKEvent (event);
break;
}
}
PRBool
gdk_window_child_of_gdk_window(GdkWindow *window, GdkWindow *ancestor)
{
GdkWindow *this_window = window;
while (this_window)
{
if (this_window == ancestor)
return PR_TRUE;
this_window = gdk_window_get_parent(this_window);
}
return PR_FALSE;
}
//==============================================================
void
handle_xlib_shell_event(GdkSuperWin *superwin, XEvent *event, gpointer p)
{
nsWindow *window = (nsWindow *)p;
switch(event->xany.type) {
case ConfigureNotify:
window->HandleXlibConfigureNotifyEvent(event);
break;
default:
break;
}
}
//==============================================================
void
handle_superwin_paint(gint aX, gint aY,
gint aWidth, gint aHeight, gpointer aData)
{
nsWindow *window = (nsWindow *)aData;
nsRect rect;
rect.x = aX;
rect.y = aY;
rect.width = aWidth;
rect.height = aHeight;
window->Invalidate(rect, PR_FALSE);
}
void
handle_superwin_flush(gpointer aData)
{
nsWindow *window = (nsWindow *)aData;
window->Update();
}

View File

@ -1,58 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsGtkEventHandler_h
#define __nsGtkEventHandler_h
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
#include "gdksuperwin.h"
void handle_size_allocate(GtkWidget *w, GtkAllocation *alloc, gpointer p);
gint handle_key_release_event(GtkObject *w, GdkEventKey* event, gpointer p);
gint handle_key_press_event(GtkObject *w, GdkEventKey* event, gpointer p);
//----------------------------------------------------
void handle_xlib_shell_event(GdkSuperWin *superwin, XEvent *event, gpointer p);
void handle_superwin_paint(gint aX, gint aY,
gint aWidth, gint aHeight, gpointer aData);
void handle_superwin_flush(gpointer aData);
void handle_gdk_event (GdkEvent *event, gpointer data);
#endif // __nsGtkEventHandler.h

File diff suppressed because it is too large Load Diff

View File

@ -1,191 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Frank Tang <ftang@netsape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsGtkIMEHelper_h__
#define nsGtkIMEHelper_h__
#include "nsIUnicodeDecoder.h"
#include "nsString.h"
#include <gtk/gtk.h>
/*
* We are gradually moving IME related function into this class
*/
class nsGtkIMEHelper {
public:
~nsGtkIMEHelper();
nsresult ConvertToUnicode(const char* aSrc, PRInt32* aSrcLen,
PRUnichar* aDes, PRInt32* aDesLen);
static nsGtkIMEHelper *GetSingleton();
void ResetDecoder();
static void Shutdown();
PRInt32 MultiByteToUnicode(const char*, const PRInt32,
PRUnichar**, PRInt32*);
#if defined(USE_XIM) && defined(_AIX)
PRUnichar* GetUnichars() const { return mUnichars; }
PRInt32 GetUnicharsSize() const { return mUnicharsSize; }
// It is the caller's responsibility to free any data in
// mUnichars prior to calling SetUnichars()
void SetUnichars(PRUnichar *aUnichars) { mUnichars = aUnichars; }
void SetUnicharsSize(PRInt32 aUnicharsSize)
{ mUnicharsSize = aUnicharsSize; }
#endif
private:
nsGtkIMEHelper();
nsIUnicodeDecoder* mDecoder;
void SetupUnicodeDecoder();
static nsGtkIMEHelper *gSingleton;
#if defined(USE_XIM) && defined(_AIX)
PRUnichar* mUnichars;
PRInt32 mUnicharsSize;
#endif
};
#ifdef USE_XIM
class nsIMEPreedit {
private:
PRInt32 mCaretPosition;
nsString* mIMECompUnicode;
nsCString* mIMECompAttr;
PRUnichar* mCompositionUniString;
PRInt32 mCompositionUniStringSize;
public:
nsIMEPreedit();
~nsIMEPreedit();
void Reset();
const PRUnichar* GetPreeditString() const;
const char* GetPreeditFeedback() const;
int GetPreeditLength() const;
void SetPreeditString(const XIMText* aText,
const PRInt32 aChangeFirst,
const PRInt32 aChangeLength);
static void IMSetTextRange(const PRInt32 aLen,
const char *aFeedback,
PRUint32 *,
nsTextRangeArray*);
};
class nsWindow;
class nsIMEStatus {
private:
Window mIMStatusWindow;
Window mIMStatusLabel;
XFontSet mFontset;
int mWidth;
int mHeight;
GC mGC;
void resize(const char *);
void remove_decoration();
void getAtoms();
static Bool client_filter(Display *d, Window w, XEvent *ev,
XPointer client_data);
static Bool repaint_filter(Display *d, Window w, XEvent *ev,
XPointer client_data);
static Bool clientmessage_filter(Display *d, Window w, XEvent *ev,
XPointer client_data);
void CreateNative();
void DestroyNative();
public:
nsIMEStatus();
nsIMEStatus(GdkFont*);
void SetFont(GdkFont*);
~nsIMEStatus();
void UnregisterClientFilter(Window);
void RegisterClientFilter(Window);
void setText(const char*);
void setParentWindow(nsWindow*);
void resetParentWindow(nsWindow*);
void show();
void hide();
nsWindow *mAttachedWindow;
GdkWindow *mParent;
};
/* for XIM callback */
typedef int (*XIMProc1)(XIC, XPointer, XPointer);
typedef struct {
XPointer client_data;
XIMProc1 callback;
} XIMCallback1;
class nsIMEGtkIC {
private:
static int preedit_start_cbproc(XIC, XPointer, XPointer);
static int preedit_draw_cbproc(XIC, XPointer, XPointer);
static int preedit_done_cbproc(XIC, XPointer, XPointer);
static int preedit_caret_cbproc(XIC, XPointer, XPointer) { return 0; };
static int status_draw_cbproc(XIC, XPointer, XPointer);
static int status_start_cbproc(XIC, XPointer, XPointer) { return 0; };
static int status_done_cbproc(XIC, XPointer, XPointer) { return 0; };
static nsIMEStatus *gStatus;
nsWindow *mClientWindow;
nsWindow *mFocusWindow;
static nsWindow *gGlobalFocusWindow;
nsIMEGtkIC(nsWindow*, GdkFont*, GdkFont*);
nsIMEGtkIC(nsWindow*, GdkFont*);
GdkICPrivate *mIC;
GdkICPrivate *mIC_backup;
nsIMEPreedit *mPreedit;
GdkFont *mStatusFontset;
public:
nsIMEPreedit *GetPreedit() {return mPreedit;}
~nsIMEGtkIC();
static nsIMEGtkIC *GetXIC(nsWindow*, GdkFont*, GdkFont*);
static nsIMEGtkIC *GetXIC(nsWindow*, GdkFont*);
void SetFocusWindow(nsWindow * aFocusWindow);
nsWindow* GetFocusWindow();
nsWindow* GetGlobalFocusWindow();
static void UnsetFocusWindow();
static GdkIMStyle GetInputStyle();
GdkIMStyle mInputStyle;
char *mStatusText;
void SetStatusText(const char*);
void SetPreeditFont(GdkFont*);
void SetStatusFont(GdkFont*);
void SetPreeditSpotLocation(unsigned long, unsigned long);
void SetPreeditArea(int, int, int, int);
void ResetStatusWindow(nsWindow * aWindow);
PRBool IsPreeditComposing();
PRInt32 ResetIC(PRUnichar **aUnichar, PRInt32 *aUnisize);
};
#endif // USE_XIM
#endif // nsGtkIMEHelper_h__

View File

@ -1,214 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <unistd.h>
#include <string.h>
#include "nsGtkUtils.h"
#include <gdk/gdkx.h>
#include <gdk/gdkprivate.h>
#ifdef NEED_USLEEP_PROTOTYPE
extern "C" int usleep(unsigned int);
#endif
#if defined(__QNX__)
#define usleep(s) sleep(s)
#endif
//////////////////////////////////////////////////////////////////
#if 0
/* staitc */ gint
nsGtkUtils::gdk_query_pointer(GdkWindow * window,
gint * x_out,
gint * y_out)
{
g_return_val_if_fail(NULL != window, FALSE);
g_return_val_if_fail(NULL != x_out, FALSE);
g_return_val_if_fail(NULL != y_out, FALSE);
Window root;
Window child;
int rootx, rooty;
int winx = 0;
int winy = 0;
unsigned int xmask = 0;
gint result = FALSE;
*x_out = -1;
*y_out = -1;
result = XQueryPointer(GDK_WINDOW_XDISPLAY(window),
GDK_WINDOW_XWINDOW(window),
&root,
&child,
&rootx,
&rooty,
&winx,
&winy,
&xmask);
if (result)
{
*x_out = rootx;
*y_out = rooty;
}
return result;
}
#endif
//////////////////////////////////////////////////////////////////
/* static */ void
nsGtkUtils::gtk_widget_set_color(GtkWidget * widget,
GtkRcFlags flags,
GtkStateType state,
GdkColor * color)
{
GtkRcStyle * rc_style;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WIDGET (widget));
g_return_if_fail (color != NULL);
g_return_if_fail (flags == 0);
rc_style = (GtkRcStyle *) gtk_object_get_data (GTK_OBJECT (widget),
"modify-style");
if (!rc_style)
{
rc_style = gtk_rc_style_new ();
gtk_widget_modify_style (widget, rc_style);
gtk_object_set_data (GTK_OBJECT (widget), "modify-style", rc_style);
}
if (flags & GTK_RC_FG)
{
rc_style->color_flags[state] = GtkRcFlags(rc_style->color_flags[state] | GTK_RC_FG);
rc_style->fg[state] = *color;
}
if (flags & GTK_RC_BG)
{
rc_style->color_flags[state] = GtkRcFlags(rc_style->color_flags[state] | GTK_RC_BG);
rc_style->bg[state] = *color;
}
if (flags & GTK_RC_TEXT)
{
rc_style->color_flags[state] = GtkRcFlags(rc_style->color_flags[state] | GTK_RC_TEXT);
rc_style->text[state] = *color;
}
if (flags & GTK_RC_BASE)
{
rc_style->color_flags[state] = GtkRcFlags(rc_style->color_flags[state] | GTK_RC_BASE);
rc_style->base[state] = *color;
}
}
//////////////////////////////////////////////////////////////////
/* static */ GdkModifierType
nsGtkUtils::gdk_keyboard_get_modifiers()
{
GdkModifierType m = (GdkModifierType) 0;
gdk_window_get_pointer(NULL,NULL,NULL,&m);
return m;
}
//////////////////////////////////////////////////////////////////
/* static */ void
nsGtkUtils::gdk_window_flash(GdkWindow * aGdkWindow,
unsigned int aTimes,
unsigned long aInterval,
GdkRegion * aRegion)
{
gint x;
gint y;
gint width;
gint height;
guint i;
GdkGC * gc = 0;
GdkColor white;
gdk_window_get_geometry(aGdkWindow,
NULL,
NULL,
&width,
&height,
NULL);
gdk_window_get_origin (aGdkWindow,
&x,
&y);
gc = gdk_gc_new(GDK_ROOT_PARENT());
white.pixel = WhitePixel(gdk_display,DefaultScreen(gdk_display));
gdk_gc_set_foreground(gc,&white);
gdk_gc_set_function(gc,GDK_XOR);
gdk_gc_set_subwindow(gc,GDK_INCLUDE_INFERIORS);
gdk_region_offset(aRegion, x, y);
gdk_gc_set_clip_region(gc, aRegion);
/*
* Need to do this twice so that the XOR effect can replace
* the original window contents.
*/
for (i = 0; i < aTimes * 2; i++)
{
gdk_draw_rectangle(GDK_ROOT_PARENT(),
gc,
TRUE,
x,
y,
width,
height);
gdk_flush();
usleep(aInterval);
}
gdk_gc_destroy(gc);
gdk_region_offset(aRegion, -x, -y);
}
//////////////////////////////////////////////////////////////////

View File

@ -1,100 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsGtkUtils_h
#define __nsGtkUtils_h
#include <gtk/gtk.h>
struct nsGtkUtils
{
//
// Wrapper for XQueryPointer
//
#if 0
static gint gdk_query_pointer(GdkWindow * window,
gint * x_out,
gint * y_out);
#endif
//
// Change a widget's background
//
// flags isa bit mask of the following bits:
//
// GTK_RC_FG
// GTK_RC_BG
// GTK_RC_TEXT
// GTK_RC_BASE
//
// state is an enum:
//
// GTK_STATE_NORMAL,
// GTK_STATE_ACTIVE,
// GTK_STATE_PRELIGHT,
// GTK_STATE_SELECTED,
// GTK_STATE_INSENSITIVE
//
static void gtk_widget_set_color(GtkWidget * widget,
GtkRcFlags flags,
GtkStateType state,
GdkColor * color);
/**
* Return the current keyboard modifier state.
*
* @return the current keyboard modifier state.
*
*/
static GdkModifierType gdk_keyboard_get_modifiers();
/**
* Flash an area within a GDK window (or the whole window)
*
* @param aGdkWindow The GDK window to flash.
* @param aTimes Number of times to flash the area.
* @param aInterval Interval between flashes in milliseconds.
* @param aArea The area to flash. The whole window if NULL.
*
*/
static void gdk_window_flash(GdkWindow * aGdkWindow,
unsigned int aTimes,
unsigned long aInterval,
GdkRegion * aArea);
};
#endif // __nsGtkEventHandler.h

View File

@ -1,274 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org Code.
*
* The Initial Developer of the Original Code is
* Brian Stell <bstell@netscape.com>.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <X11/Xlib.h>
#ifdef HAVE_X11_XKBLIB_H
# if (defined (__digital__) && defined (__unix__)) || defined(_AIX) || defined(__hpux) || defined (__osf__)
# define explicit Explicit
# include <X11/XKBlib.h>
# undef explicit
#else
# include <X11/XKBlib.h>
#endif
#endif
#include <X11/keysym.h>
#include <gdk/gdkx.h>
#include <string.h>
#include "nsKeyboardUtils.h"
#include "nspr.h"
#include "nsWindow.h"
#include "nsPrintfCString.h"
//
// xkbms: X KeyBoard Mode Switch
//
// Mode_switch during XGrabKeyboard workaround
//
// During a keyboard grab some (all?) X servers do not
// set the Mode_switch bit in the XKeyEvent state value
// even if the user is pressing the Mode_switch key.
// Thus some important keysym mappings are not available
// during a keyboard grab; eg: German keyboards use
// Mode_switch (AltGr) and Q for '@' which is an
// important key for entering email addresses.
// Finnish keyboards use dead_tilde for '~' which is an
// important key for entering user's home page URLs
//
// This workaround turns off the keyboard grab when
// the Mode_switch down.
//
// Note:
// Mode_switch MappingNotify should be called when the
// keyboard mapping changes (a MappingNotify event) but
// the XMappingNotify event has a null window and gdk only allows an
// application to filter events with a non-null window
//
// Xlib should define this!
#define MODIFIERMAP_ROW_SIZE 8
PRUint32 nsXKBModeSwitch::gModeSwitchKeycode1 = 0;
PRUint32 nsXKBModeSwitch::gModeSwitchKeycode2 = 0;
PRBool nsXKBModeSwitch::gGrabDuringPopup = PR_TRUE;
PRBool nsXKBModeSwitch::gUnGrabDuringModeSwitch = PR_TRUE;
PRBool nsXKBModeSwitch::gModeSwitchDown = PR_FALSE;
gint nsXKBModeSwitch::gOwnerEvents;
guint32 nsXKBModeSwitch::gGrabTime;
void
nsXKBModeSwitch::ControlWorkaround(gboolean grab_during_popup,
gboolean ungrab_during_mode_switch)
{
#ifdef DEBUG_bzbarsky
NS_WARNING("nsXKBModeSwitch::ControlWorkaround:");
NS_WARNING(nsPrintfCString(" grab_during_popup = %d", grab_during_popup).get());
NS_WARNING(nsPrintfCString(" ungrab_during_mode_switch = %d", ungrab_during_mode_switch).get());
#endif
gGrabDuringPopup = grab_during_popup;
gUnGrabDuringModeSwitch = ungrab_during_mode_switch;
//
// This really should be called whenever a MappingNotify
// event happens but gdk does not support that.
//
HandleMappingNotify();
}
gint
nsXKBModeSwitch::GrabKeyboard(GdkWindow *win, gint owner_events, guint32 time)
{
// if grab is disabled pretend it succeeded
if (!gGrabDuringPopup) {
return GrabSuccess;
}
gint retval;
retval = gdk_keyboard_grab(win, owner_events, time);
if (retval == GrabSuccess) {
gOwnerEvents = owner_events;
gGrabTime = time;
}
else {
gOwnerEvents = 0;
gGrabTime = 0;
}
return retval;
}
void
nsXKBModeSwitch::HandleMappingNotify()
{
XModifierKeymap *xmodmap;
int i, j, max_keypermod;
// since the mapping could change we (re)initialize variables
Init();
Display *lGdkDisplay = GDK_DISPLAY();
if (!lGdkDisplay)
return;
xmodmap = XGetModifierMapping(lGdkDisplay);
if (!xmodmap)
return;
max_keypermod = MIN(xmodmap->max_keypermod,5);
for (i=0; i<max_keypermod; i++) {
for (j=0; j<MODIFIERMAP_ROW_SIZE; j++) {
KeyCode keycode;
KeySym keysym;
char *keysymName;
keycode = *((xmodmap->modifiermap)+(i*MODIFIERMAP_ROW_SIZE)+j);
if (!keycode)
continue;
keysym = XKeycodeToKeysym(GDK_DISPLAY(), keycode, 0);
if (!keysym)
continue;
keysymName = XKeysymToString(keysym);
if (!keysymName)
continue;
if (!strcmp(keysymName,"Mode_switch")) {
if (!gModeSwitchKeycode1)
gModeSwitchKeycode1 = keycode;
else if (!gModeSwitchKeycode2)
gModeSwitchKeycode2 = keycode;
}
}
}
XFreeModifiermap(xmodmap);
#ifdef DEBUG_bzbarsky
if (!gModeSwitchKeycode1) {
NS_WARNING("\n\nnsXKBModeSwitch::HandleMappingNotify: no Mode_switch\n\n");
}
NS_WARNING("\n\nnsXKBModeSwitch::HandleMappingNotify:");
NS_WARNING(nsPrintfCString(" gModeSwitchKeycode1 = %d", gModeSwitchKeycode1).get());
NS_WARNING(nsPrintfCString(" gModeSwitchKeycode2 = %d", gModeSwitchKeycode2).get());
#endif
#if defined(HAVE_X11_XKBLIB_H) && \
defined(XkbMajorVersion) && defined(XbMinorVersion)
{
gint xkb_major = XkbMajorVersion;
gint xkb_minor = XkbMinorVersion;
if (XkbLibraryVersion (&xkb_major, &xkb_minor)) {
xkb_major = XkbMajorVersion;
xkb_minor = XkbMinorVersion;
if (XkbQueryExtension (gdk_display, NULL, NULL, NULL,
&xkb_major, &xkb_minor)) {
}
}
}
#endif
}
void
nsXKBModeSwitch::Init()
{
gModeSwitchKeycode1 = 0;
gModeSwitchKeycode2 = 0;
gModeSwitchDown = FALSE;
}
void
nsXKBModeSwitch::HandleKeyPress(XKeyEvent *xke)
{
// if grab is completely disabled then there is nothing to do
if (!gGrabDuringPopup) {
return;
}
// check for a Mode_switch keypress
if ((xke->keycode == gModeSwitchKeycode1)
|| (xke->keycode == gModeSwitchKeycode2)) {
gModeSwitchDown = TRUE;
NS_WARNING("nsXKBModeSwitch::HandleKeyPress: Mode_switch is down");
nsWindow *win = nsWindow::GetGrabWindow();
if (!win)
return;
if (win->GrabInProgress()) {
if (gUnGrabDuringModeSwitch) {
gdk_keyboard_ungrab(GDK_CURRENT_TIME);
NS_WARNING("\n\n*** ungrab keyboard ***\n\n");
}
}
}
}
void
nsXKBModeSwitch::HandleKeyRelease(XKeyEvent *xke)
{
// if grab is completely disabled then there is nothing to do
if (!gGrabDuringPopup) {
return;
}
// check for a Mode_switch keyrelease
if ((xke->keycode == gModeSwitchKeycode1)
|| (xke->keycode == gModeSwitchKeycode2)) {
gModeSwitchDown = FALSE;
NS_WARNING("nsXKBModeSwitch::HandleKeyPress: Mode_switch is up");
nsWindow *win = nsWindow::GetGrabWindow();
if (!win)
return;
if (win->GrabInProgress()) {
if (gUnGrabDuringModeSwitch) {
if (!win->GetGdkGrabWindow())
return;
gdk_keyboard_grab(win->GetGdkGrabWindow(), gOwnerEvents, gGrabTime);
NS_WARNING("\n\n*** re-grab keyboard ***\n\n");
}
}
}
}
void
nsXKBModeSwitch::UnGrabKeyboard(guint32 time)
{
// if grab is completely disabled then there is nothing to do
if (!gGrabDuringPopup) {
return;
}
gdk_keyboard_ungrab(time);
gOwnerEvents = 0;
gGrabTime = 0;
}

View File

@ -1,72 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org Code.
*
* The Initial Developer of the Original Code is
* Brian Stell <bstell@netscape.com>.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* <bstell@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef _NSKEYBOARDUTILS_H_
#define _NSKEYBOARDUTILS_H_
extern "C" {
#include <X11/Xlib.h>
#include <gdk/gdk.h>
}
#include "prtypes.h"
class nsXKBModeSwitch {
public:
static void ControlWorkaround(gboolean grab_during_popup,
gboolean ungrab_during_mode_switch);
static gint GrabKeyboard(GdkWindow *win, gint owner_events, guint32 time);
static void UnGrabKeyboard(guint32 time);
static void HandleKeyPress(XKeyEvent *xke);
static void HandleKeyRelease(XKeyEvent *xke);
static void HandleMappingNotify();
private:
static void Init();
static PRUint32 gModeSwitchKeycode1;
static PRUint32 gModeSwitchKeycode2;
static PRBool gGrabDuringPopup;
static PRBool gUnGrabDuringModeSwitch;
static PRBool gModeSwitchDown;
static gint gOwnerEvents;
static guint32 gGrabTime;
};
#endif /* _NSKEYBOARDUTILS_H_ */

View File

@ -1,543 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Brian Ryner <bryner@brianryner.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsLookAndFeel.h"
#include <gtk/gtkinvisible.h>
#define GDK_COLOR_TO_NS_RGB(c) \
((nscolor) NS_RGB(c.red>>8, c.green>>8, c.blue>>8))
nscolor nsLookAndFeel::sInfoText = 0;
nscolor nsLookAndFeel::sInfoBackground = 0;
nscolor nsLookAndFeel::sMenuText = 0;
nscolor nsLookAndFeel::sMenuBackground = 0;
nscolor nsLookAndFeel::sButtonBackground = 0;
nscolor nsLookAndFeel::sButtonText = 0;
nscolor nsLookAndFeel::sButtonOuterLightBorder = 0;
nscolor nsLookAndFeel::sButtonInnerDarkBorder = 0;
PRBool nsLookAndFeel::sColorsInitialized = PR_FALSE;
//-------------------------------------------------------------------------
//
// Query interface implementation
//
//-------------------------------------------------------------------------
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
{
mWidget = gtk_invisible_new();
gtk_widget_ensure_style(mWidget);
mStyle = gtk_widget_get_style(mWidget);
if (!sColorsInitialized)
InitColors();
}
nsLookAndFeel::~nsLookAndFeel()
{
// gtk_widget_destroy(mWidget);
gtk_widget_unref(mWidget);
}
nsresult nsLookAndFeel::NativeGetColor(const nsColorID aID, nscolor& aColor)
{
nsresult res = NS_OK;
aColor = 0; // default color black
switch (aID) {
// These colors don't seem to be used for anything anymore
// in Mozilla. The CSS2 colors below are used.
case eColor_WindowBackground:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
break;
case eColor_WindowForeground:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_NORMAL]);
break;
case eColor_WidgetBackground:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
break;
case eColor_WidgetForeground:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_NORMAL]);
break;
case eColor_WidgetSelectBackground:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_SELECTED]);
break;
case eColor_WidgetSelectForeground:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_SELECTED]);
break;
case eColor_Widget3DHighlight:
aColor = NS_RGB(0xa0,0xa0,0xa0);
break;
case eColor_Widget3DShadow:
aColor = NS_RGB(0x40,0x40,0x40);
break;
case eColor_TextBackground:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
break;
case eColor_TextForeground:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_NORMAL]);
break;
case eColor_TextSelectBackground:
case eColor_IMESelectedRawTextBackground:
case eColor_IMESelectedConvertedTextBackground:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_SELECTED]);
break;
case eColor_TextSelectForeground:
case eColor_IMESelectedRawTextForeground:
case eColor_IMESelectedConvertedTextForeground:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_SELECTED]);
break;
case eColor_IMERawInputBackground:
case eColor_IMEConvertedTextBackground:
aColor = NS_TRANSPARENT;
break;
case eColor_IMERawInputForeground:
case eColor_IMEConvertedTextForeground:
aColor = NS_SAME_AS_FOREGROUND_COLOR;
break;
case eColor_IMERawInputUnderline:
case eColor_IMEConvertedTextUnderline:
aColor = NS_SAME_AS_FOREGROUND_COLOR;
break;
case eColor_IMESelectedRawTextUnderline:
case eColor_IMESelectedConvertedTextUnderline:
aColor = NS_TRANSPARENT;
break;
// css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
case eColor_activeborder:
// active window border
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
break;
case eColor_activecaption:
// active window caption background
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
break;
case eColor_appworkspace:
// MDI background color
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
break;
case eColor_background:
// desktop background
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
break;
case eColor_captiontext:
// text in active window caption, size box, and scrollbar arrow box (!)
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_NORMAL]);
break;
case eColor_graytext:
// disabled text
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_INSENSITIVE]);
// or maybe mStyle->text?
break;
case eColor_highlight:
case eColor__moz_menuhover:
// background of selected item
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_SELECTED]);
break;
case eColor_highlighttext:
case eColor__moz_menuhovertext:
// text of selected item
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_SELECTED]);
break;
case eColor_inactiveborder:
// inactive window border
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
break;
case eColor_inactivecaption:
// inactive window caption
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_INSENSITIVE]);
break;
case eColor_inactivecaptiontext:
// text in inactive window caption
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_INSENSITIVE]);
break;
case eColor_infobackground:
// tooltip background color
aColor = sInfoBackground;
break;
case eColor_infotext:
// tooltip text color
aColor = sInfoText;
break;
case eColor_menu:
// menu background
aColor = sMenuBackground;
break;
case eColor_menutext:
// menu text
aColor = sMenuText;
break;
case eColor_scrollbar:
// scrollbar gray area
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_ACTIVE]);
break;
case eColor_threedface:
case eColor_buttonface:
case eColor__moz_buttonhoverface:
// 3-D face color
aColor = sButtonBackground;
break;
case eColor_buttontext:
case eColor__moz_buttonhovertext:
// text on push buttons
aColor = sButtonText;
break;
case eColor_buttonhighlight:
// 3-D highlighted edge color
case eColor_threedhighlight:
// 3-D highlighted outer edge color
aColor = sButtonOuterLightBorder;
break;
case eColor_threedlightshadow:
// 3-D highlighted inner edge color
aColor = sButtonBackground; // always same as background in GTK code
break;
case eColor_buttonshadow:
// 3-D shadow edge color
case eColor_threedshadow:
// 3-D shadow inner edge color
aColor = sButtonInnerDarkBorder;
break;
case eColor_threeddarkshadow:
// 3-D shadow outer edge color
aColor = GDK_COLOR_TO_NS_RGB(mStyle->black);
break;
case eColor_window:
case eColor_windowframe:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
break;
case eColor_windowtext:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_NORMAL]);
break;
// from the CSS3 working draft (not yet finalized)
// http://www.w3.org/tr/2000/wd-css3-userint-20000216.html#color
case eColor__moz_field:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->base[GTK_STATE_NORMAL]);
break;
case eColor__moz_fieldtext:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_NORMAL]);
break;
case eColor__moz_dialog:
case eColor__moz_cellhighlight:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_NORMAL]);
break;
case eColor__moz_dialogtext:
case eColor__moz_cellhighlighttext:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->fg[GTK_STATE_NORMAL]);
break;
case eColor__moz_dragtargetzone:
aColor = GDK_COLOR_TO_NS_RGB(mStyle->bg[GTK_STATE_SELECTED]);
break;
case eColor__moz_buttondefault:
// default button border color
aColor = GDK_COLOR_TO_NS_RGB(mStyle->black);
break;
default:
/* default color is BLACK */
aColor = 0;
res = NS_ERROR_FAILURE;
break;
}
// printf("%i, %i, %i\n", NS_GET_R(aColor), NS_GET_B(aColor), NS_GET_G(aColor));
return res;
}
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
{
nsresult res = NS_OK;
res = nsXPLookAndFeel::GetMetric(aID, aMetric);
if (NS_SUCCEEDED(res))
return res;
res = NS_OK;
switch (aID) {
case eMetric_WindowTitleHeight:
aMetric = 0;
break;
case eMetric_WindowBorderWidth:
// XXXldb Why is this commented out?
// aMetric = mStyle->klass->xthickness;
break;
case eMetric_WindowBorderHeight:
// XXXldb Why is this commented out?
// aMetric = mStyle->klass->ythickness;
break;
case eMetric_Widget3DBorder:
// XXXldb Why is this commented out?
// aMetric = 4;
break;
case eMetric_TextFieldHeight:
{
GtkRequisition req;
GtkWidget *text = gtk_entry_new();
// needed to avoid memory leak
gtk_widget_ref(text);
gtk_object_sink(GTK_OBJECT(text));
gtk_widget_size_request(text,&req);
aMetric = req.height;
gtk_widget_destroy(text);
gtk_widget_unref(text);
}
break;
case eMetric_TextFieldBorder:
aMetric = 2;
break;
case eMetric_TextVerticalInsidePadding:
aMetric = 0;
break;
case eMetric_TextShouldUseVerticalInsidePadding:
aMetric = 0;
break;
case eMetric_TextHorizontalInsideMinimumPadding:
aMetric = 15;
break;
case eMetric_TextShouldUseHorizontalInsideMinimumPadding:
aMetric = 1;
break;
case eMetric_ButtonHorizontalInsidePaddingNavQuirks:
aMetric = 10;
break;
case eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks:
aMetric = 8;
break;
case eMetric_CheckboxSize:
aMetric = 15;
break;
case eMetric_RadioboxSize:
aMetric = 15;
break;
case eMetric_ListShouldUseHorizontalInsideMinimumPadding:
aMetric = 15;
break;
case eMetric_ListHorizontalInsideMinimumPadding:
aMetric = 15;
break;
case eMetric_ListShouldUseVerticalInsidePadding:
aMetric = 1;
break;
case eMetric_ListVerticalInsidePadding:
aMetric = 1;
break;
case eMetric_CaretBlinkTime:
aMetric = 500;
break;
case eMetric_CaretWidth:
aMetric = 1;
break;
case eMetric_ShowCaretDuringSelection:
aMetric = 0;
break;
case eMetric_SelectTextfieldsOnKeyFocus:
// Select textfield content when focused by kbd
// used by nsEventStateManager::sTextfieldSelectModel
aMetric = 1;
break;
case eMetric_SubmenuDelay:
aMetric = 200;
break;
case eMetric_MenusCanOverlapOSBar:
// we want XUL popups to be able to overlap the task bar.
aMetric = 1;
break;
case eMetric_SkipNavigatingDisabledMenuItem:
aMetric = 1;
break;
case eMetric_DragFullWindow:
aMetric = 1;
break;
case eMetric_DragThresholdX:
case eMetric_DragThresholdY:
// hardcoded in gtkdnd.c
aMetric = 3;
break;
case eMetric_ScrollArrowStyle:
aMetric = eMetric_ScrollArrowStyleSingle;
break;
case eMetric_ScrollSliderStyle:
aMetric = eMetric_ScrollThumbStyleProportional;
break;
case eMetric_TreeOpenDelay:
aMetric = 1000;
break;
case eMetric_TreeCloseDelay:
aMetric = 1000;
break;
case eMetric_TreeLazyScrollDelay:
aMetric = 150;
break;
case eMetric_TreeScrollDelay:
aMetric = 100;
break;
case eMetric_TreeScrollLinesMax:
aMetric = 3;
break;
default:
aMetric = 0;
res = NS_ERROR_FAILURE;
}
return res;
}
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID, float & aMetric)
{
nsresult res = NS_OK;
res = nsXPLookAndFeel::GetMetric(aID, aMetric);
if (NS_SUCCEEDED(res))
return res;
res = NS_OK;
switch (aID) {
case eMetricFloat_TextFieldVerticalInsidePadding:
aMetric = 0.25f;
break;
case eMetricFloat_TextFieldHorizontalInsidePadding:
aMetric = 0.95f; // large number on purpose so minimum padding is used
break;
case eMetricFloat_TextAreaVerticalInsidePadding:
aMetric = 0.40f;
break;
case eMetricFloat_TextAreaHorizontalInsidePadding:
aMetric = 0.40f; // large number on purpose so minimum padding is used
break;
case eMetricFloat_ListVerticalInsidePadding:
aMetric = 0.10f;
break;
case eMetricFloat_ListHorizontalInsidePadding:
aMetric = 0.40f;
break;
case eMetricFloat_ButtonVerticalInsidePadding:
aMetric = 0.25f;
break;
case eMetricFloat_ButtonHorizontalInsidePadding:
aMetric = 0.25f;
break;
case eMetricFloat_IMEUnderlineRelativeSize:
aMetric = 1.0f;
break;
default:
aMetric = -1.0;
res = NS_ERROR_FAILURE;
}
return res;
}
void
nsLookAndFeel::InitColors()
{
sColorsInitialized = PR_TRUE;
GtkStyle *style;
// tooltip foreground and background
GtkTooltips *tooltips = gtk_tooltips_new();
gtk_tooltips_force_window(tooltips);
GtkWidget *tip_window = tooltips->tip_window;
gtk_widget_set_rc_style(tip_window);
style = gtk_widget_get_style(tip_window);
sInfoBackground = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
sInfoText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
gtk_object_unref(GTK_OBJECT(tooltips));
// menu foreground & menu background
GtkWidget *accel_label = gtk_accel_label_new("M");
GtkWidget *menuitem = gtk_menu_item_new();
GtkWidget *menu = gtk_menu_new();
gtk_container_add(GTK_CONTAINER(menuitem), accel_label);
gtk_menu_append(GTK_MENU(menu), menuitem);
gtk_widget_set_rc_style(accel_label);
gtk_widget_set_rc_style(menu);
gtk_widget_realize(menu);
gtk_widget_realize(accel_label);
style = gtk_widget_get_style(accel_label);
sMenuText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
style = gtk_widget_get_style(menu);
sMenuBackground = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
gtk_widget_unref(menu);
// button styles
GtkWidget *parent = gtk_fixed_new();
GtkWidget *button = gtk_button_new();
GtkWidget *label = gtk_label_new("M");
GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP);
gtk_container_add(GTK_CONTAINER(button), label);
gtk_container_add(GTK_CONTAINER(parent), button);
gtk_container_add(GTK_CONTAINER(window), parent);
gtk_widget_set_rc_style(button);
gtk_widget_set_rc_style(label);
gtk_widget_realize(button);
gtk_widget_realize(label);
style = gtk_widget_get_style(label);
sButtonText = GDK_COLOR_TO_NS_RGB(style->fg[GTK_STATE_NORMAL]);
style = gtk_widget_get_style(button);
sButtonBackground = GDK_COLOR_TO_NS_RGB(style->bg[GTK_STATE_NORMAL]);
sButtonOuterLightBorder =
GDK_COLOR_TO_NS_RGB(style->light[GTK_STATE_NORMAL]);
sButtonInnerDarkBorder =
GDK_COLOR_TO_NS_RGB(style->dark[GTK_STATE_NORMAL]);
gtk_widget_destroy(window);
}

View File

@ -1,72 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsLookAndFeel
#define __nsLookAndFeel
#include "nsXPLookAndFeel.h"
#include "nsCOMPtr.h"
#include <gtk/gtk.h>
class nsLookAndFeel: public nsXPLookAndFeel {
public:
nsLookAndFeel();
virtual ~nsLookAndFeel();
nsresult NativeGetColor(const nsColorID aID, nscolor &aColor);
NS_IMETHOD GetMetric(const nsMetricID aID, PRInt32 & aMetric);
NS_IMETHOD GetMetric(const nsMetricFloatID aID, float & aMetric);
protected:
GtkStyle *mStyle;
GtkWidget *mWidget;
// Cached colors, we have to create a dummy widget to actually
// get the style
static PRBool sColorsInitialized;
static nscolor sInfoBackground;
static nscolor sInfoText;
static nscolor sMenuBackground;
static nscolor sMenuText;
static nscolor sButtonBackground;
static nscolor sButtonText;
static nscolor sButtonOuterLightBorder;
static nscolor sButtonInnerDarkBorder;
static void InitColors();
};
#endif

View File

@ -1,872 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Brian Ryner <bryner@brianryner.com> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsNativeThemeGTK.h"
#include "nsThemeConstants.h"
#include "gtkdrawing.h"
#include "nsIObserverService.h"
#include "nsIServiceManager.h"
#include "nsIFrame.h"
#include "nsIPresShell.h"
#include "nsIDocument.h"
#include "nsIContent.h"
#include "nsIEventStateManager.h"
#include "nsIViewManager.h"
#include "nsINameSpaceManager.h"
#include "nsILookAndFeel.h"
#include "nsIDeviceContext.h"
#include "nsGfxCIID.h"
#include "nsTransform2D.h"
#include "nsIMenuFrame.h"
#include "nsIMenuParent.h"
#include "nsWidgetAtoms.h"
#include "prlink.h"
#include <gdk/gdkprivate.h>
#include <gdk/gdkx.h>
NS_IMPL_ISUPPORTS2(nsNativeThemeGTK, nsITheme, nsIObserver)
static int gLastXError;
nsNativeThemeGTK::nsNativeThemeGTK()
{
if (moz_gtk_init() != MOZ_GTK_SUCCESS) {
memset(mDisabledWidgetTypes, 0xff, sizeof(mDisabledWidgetTypes));
return;
}
// We have to call moz_gtk_shutdown before the event loop stops running.
nsCOMPtr<nsIObserverService> obsServ =
do_GetService("@mozilla.org/observer-service;1");
obsServ->AddObserver(this, "xpcom-shutdown", PR_FALSE);
memset(mDisabledWidgetTypes, 0, sizeof(mDisabledWidgetTypes));
memset(mSafeWidgetStates, 0, sizeof(mSafeWidgetStates));
#ifdef MOZ_WIDGET_GTK
// Look up the symbol for gtk_style_get_prop_experimental
PRLibrary* gtkLibrary;
PRFuncPtr stylePropFunc = PR_FindFunctionSymbolAndLibrary("gtk_style_get_prop_experimental", &gtkLibrary);
if (stylePropFunc) {
moz_gtk_enable_style_props((style_prop_t) stylePropFunc);
PR_UnloadLibrary(gtkLibrary);
}
#endif
}
nsNativeThemeGTK::~nsNativeThemeGTK() {
}
NS_IMETHODIMP
nsNativeThemeGTK::Observe(nsISupports *aSubject, const char *aTopic,
const PRUnichar *aData)
{
if (!nsCRT::strcmp(aTopic, "xpcom-shutdown")) {
moz_gtk_shutdown();
} else {
NS_NOTREACHED("unexpected topic");
return NS_ERROR_UNEXPECTED;
}
return NS_OK;
}
void
nsNativeThemeGTK::RefreshWidgetWindow(nsIFrame* aFrame)
{
nsIPresShell *shell = GetPresShell(aFrame);
if (!shell)
return;
nsIViewManager* vm = shell->GetViewManager();
if (!vm)
return;
vm->UpdateAllViews(NS_VMREFRESH_NO_SYNC);
}
static PRBool IsWidgetTypeDisabled(PRUint8* aDisabledVector, PRUint8 aWidgetType) {
return aDisabledVector[aWidgetType >> 3] & (1 << (aWidgetType & 7));
}
static void SetWidgetTypeDisabled(PRUint8* aDisabledVector, PRUint8 aWidgetType) {
aDisabledVector[aWidgetType >> 3] |= (1 << (aWidgetType & 7));
}
static inline PRUint16
GetWidgetStateKey(PRUint8 aWidgetType, GtkWidgetState *aWidgetState)
{
return (aWidgetState->active |
aWidgetState->focused << 1 |
aWidgetState->inHover << 2 |
aWidgetState->disabled << 3 |
aWidgetState->isDefault << 4 |
aWidgetType << 5);
}
static PRBool IsWidgetStateSafe(PRUint8* aSafeVector,
PRUint8 aWidgetType,
GtkWidgetState *aWidgetState)
{
PRUint8 key = GetWidgetStateKey(aWidgetType, aWidgetState);
return aSafeVector[key >> 3] & (1 << (key & 7));
}
static void SetWidgetStateSafe(PRUint8 *aSafeVector,
PRUint8 aWidgetType,
GtkWidgetState *aWidgetState)
{
PRUint8 key = GetWidgetStateKey(aWidgetType, aWidgetState);
aSafeVector[key >> 3] |= (1 << (key & 7));
}
PRBool
nsNativeThemeGTK::GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
GtkThemeWidgetType& aGtkWidgetType,
GtkWidgetState* aState,
gint* aWidgetFlags)
{
if (aState) {
if (!aFrame) {
// reset the entire struct to zero
memset(aState, 0, sizeof(GtkWidgetState));
} else {
// for dropdown textfields, look at the parent frame (textbox or menulist)
if (aWidgetType == NS_THEME_DROPDOWN_TEXTFIELD)
aFrame = aFrame->GetParent();
// For XUL checkboxes and radio buttons, the state of the parent
// determines our state.
nsIFrame *stateFrame = aFrame;
if (aFrame && ((aWidgetFlags && (aWidgetType == NS_THEME_CHECKBOX ||
aWidgetType == NS_THEME_RADIO)) ||
aWidgetType == NS_THEME_CHECKBOX_LABEL ||
aWidgetType == NS_THEME_RADIO_LABEL)) {
nsIAtom* atom = nsnull;
nsIContent *content = aFrame->GetContent();
if (content->IsNodeOfType(nsINode::eXUL)) {
if (aWidgetType == NS_THEME_CHECKBOX_LABEL ||
aWidgetType == NS_THEME_RADIO_LABEL) {
// Adjust stateFrame so GetContentState finds the correct state.
stateFrame = aFrame = aFrame->GetParent()->GetParent();
} else {
// GetContentState knows to look one frame up for radio/checkbox
// widgets, so don't adjust stateFrame here.
aFrame = aFrame->GetParent();
}
} else if (content->Tag() == nsWidgetAtoms::input) {
atom = nsWidgetAtoms::mozinputchecked;
}
if (aWidgetFlags) {
if (!atom) {
atom = (aWidgetType == NS_THEME_CHECKBOX ||
aWidgetType == NS_THEME_CHECKBOX_LABEL) ? nsWidgetAtoms::checked
: nsWidgetAtoms::selected;
}
*aWidgetFlags = CheckBooleanAttr(aFrame, atom);
}
}
PRInt32 eventState = GetContentState(stateFrame, aWidgetType);
aState->disabled = IsDisabled(aFrame);
aState->active = (eventState & NS_EVENT_STATE_ACTIVE) == NS_EVENT_STATE_ACTIVE;
aState->focused = (eventState & NS_EVENT_STATE_FOCUS) == NS_EVENT_STATE_FOCUS;
aState->inHover = (eventState & NS_EVENT_STATE_HOVER) == NS_EVENT_STATE_HOVER;
aState->isDefault = FALSE; // XXX fix me
aState->canDefault = FALSE; // XXX fix me
// For these widget types, some element (either a child or parent)
// actually has element focus, so we check the focused attribute
// to see whether to draw in the focused state.
if (aWidgetType == NS_THEME_TEXTFIELD ||
aWidgetType == NS_THEME_DROPDOWN_TEXTFIELD ||
aWidgetType == NS_THEME_RADIO_CONTAINER ||
aWidgetType == NS_THEME_RADIO_LABEL ||
aWidgetType == NS_THEME_RADIO) {
aState->focused = IsFocused(aFrame);
}
if (aWidgetType == NS_THEME_SCROLLBAR_THUMB_VERTICAL ||
aWidgetType == NS_THEME_SCROLLBAR_THUMB_HORIZONTAL) {
// for scrollbars we need to go up two to go from the thumb to
// the slider to the actual scrollbar object
nsIFrame *tmpFrame = aFrame->GetParent()->GetParent();
aState->curpos = CheckIntAttr(tmpFrame, nsWidgetAtoms::curpos);
aState->maxpos = CheckIntAttr(tmpFrame, nsWidgetAtoms::maxpos);
}
// menu item state is determined by the attribute "_moz-menuactive",
// and not by the mouse hovering (accessibility). as a special case,
// menus which are children of a menu bar are only marked as prelight
// if they are open, not on normal hover.
if (aWidgetType == NS_THEME_MENUITEM ||
aWidgetType == NS_THEME_CHECKMENUITEM ||
aWidgetType == NS_THEME_RADIOMENUITEM) {
PRBool isTopLevel = PR_FALSE;
nsIMenuFrame *menuFrame;
CallQueryInterface(aFrame, &menuFrame);
if (menuFrame) {
nsIMenuParent *menuParent = menuFrame->GetMenuParent();
if (menuParent)
menuParent->IsMenuBar(isTopLevel);
}
if (isTopLevel) {
PRBool isOpen;
menuFrame->MenuIsOpen(isOpen);
aState->inHover = isOpen;
} else {
aState->inHover = CheckBooleanAttr(aFrame, nsWidgetAtoms::mozmenuactive);
}
aState->active = FALSE;
if (aWidgetType == NS_THEME_CHECKMENUITEM ||
aWidgetType == NS_THEME_RADIOMENUITEM) {
*aWidgetFlags = aFrame && aFrame->GetContent()->
AttrValueIs(kNameSpaceID_None, nsWidgetAtoms::checked,
nsWidgetAtoms::_true, eIgnoreCase);
}
}
}
}
switch (aWidgetType) {
case NS_THEME_BUTTON:
case NS_THEME_TOOLBAR_BUTTON:
case NS_THEME_TOOLBAR_DUAL_BUTTON:
if (aWidgetFlags)
*aWidgetFlags = (aWidgetType == NS_THEME_BUTTON) ? GTK_RELIEF_NORMAL : GTK_RELIEF_NONE;
aGtkWidgetType = MOZ_GTK_BUTTON;
break;
case NS_THEME_CHECKBOX:
case NS_THEME_RADIO:
aGtkWidgetType = (aWidgetType == NS_THEME_RADIO) ? MOZ_GTK_RADIOBUTTON : MOZ_GTK_CHECKBUTTON;
break;
case NS_THEME_SCROLLBAR_BUTTON_UP:
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
if (aWidgetFlags)
*aWidgetFlags = GtkArrowType(aWidgetType - NS_THEME_SCROLLBAR_BUTTON_UP);
aGtkWidgetType = MOZ_GTK_SCROLLBAR_BUTTON;
break;
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
aGtkWidgetType = MOZ_GTK_SCROLLBAR_TRACK_VERTICAL;
break;
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
aGtkWidgetType = MOZ_GTK_SCROLLBAR_TRACK_HORIZONTAL;
break;
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
aGtkWidgetType = MOZ_GTK_SCROLLBAR_THUMB_VERTICAL;
break;
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
aGtkWidgetType = MOZ_GTK_SCROLLBAR_THUMB_HORIZONTAL;
break;
case NS_THEME_SPINNER_UP_BUTTON:
aGtkWidgetType = MOZ_GTK_SPINBUTTON_UP;
break;
case NS_THEME_SPINNER_DOWN_BUTTON:
aGtkWidgetType = MOZ_GTK_SPINBUTTON_DOWN;
break;
case NS_THEME_SCALE_HORIZONTAL:
if (aWidgetFlags)
*aWidgetFlags = GTK_ORIENTATION_HORIZONTAL;
aGtkWidgetType = MOZ_GTK_SCALE_HORIZONTAL;
break;
case NS_THEME_SCALE_THUMB_HORIZONTAL:
if (aWidgetFlags)
*aWidgetFlags = GTK_ORIENTATION_HORIZONTAL;
aGtkWidgetType = MOZ_GTK_SCALE_THUMB_HORIZONTAL;
break;
case NS_THEME_SCALE_VERTICAL:
if (aWidgetFlags)
*aWidgetFlags = GTK_ORIENTATION_VERTICAL;
aGtkWidgetType = MOZ_GTK_SCALE_VERTICAL;
break;
case NS_THEME_SCALE_THUMB_VERTICAL:
if (aWidgetFlags)
*aWidgetFlags = GTK_ORIENTATION_VERTICAL;
aGtkWidgetType = MOZ_GTK_SCALE_THUMB_VERTICAL;
break;
case NS_THEME_TOOLBAR_GRIPPER:
aGtkWidgetType = MOZ_GTK_GRIPPER;
break;
case NS_THEME_TEXTFIELD:
case NS_THEME_DROPDOWN_TEXTFIELD:
aGtkWidgetType = MOZ_GTK_ENTRY;
break;
case NS_THEME_DROPDOWN:
aGtkWidgetType = MOZ_GTK_DROPDOWN;
break;
case NS_THEME_DROPDOWN_TEXT:
return PR_FALSE; // nothing to do, but prevents the bg from being drawn
case NS_THEME_DROPDOWN_BUTTON:
aGtkWidgetType = MOZ_GTK_DROPDOWN_ARROW;
break;
case NS_THEME_CHECKBOX_CONTAINER:
aGtkWidgetType = MOZ_GTK_CHECKBUTTON_CONTAINER;
break;
case NS_THEME_RADIO_CONTAINER:
aGtkWidgetType = MOZ_GTK_RADIOBUTTON_CONTAINER;
break;
case NS_THEME_CHECKBOX_LABEL:
aGtkWidgetType = MOZ_GTK_CHECKBUTTON_LABEL;
break;
case NS_THEME_RADIO_LABEL:
aGtkWidgetType = MOZ_GTK_RADIOBUTTON_LABEL;
break;
case NS_THEME_TOOLBAR:
aGtkWidgetType = MOZ_GTK_TOOLBAR;
break;
case NS_THEME_TOOLTIP:
aGtkWidgetType = MOZ_GTK_TOOLTIP;
break;
case NS_THEME_STATUSBAR_PANEL:
aGtkWidgetType = MOZ_GTK_FRAME;
break;
case NS_THEME_PROGRESSBAR:
case NS_THEME_PROGRESSBAR_VERTICAL:
aGtkWidgetType = MOZ_GTK_PROGRESSBAR;
break;
case NS_THEME_PROGRESSBAR_CHUNK:
case NS_THEME_PROGRESSBAR_CHUNK_VERTICAL:
aGtkWidgetType = MOZ_GTK_PROGRESS_CHUNK;
break;
case NS_THEME_TAB_PANELS:
aGtkWidgetType = MOZ_GTK_TABPANELS;
break;
case NS_THEME_TAB:
case NS_THEME_TAB_LEFT_EDGE:
case NS_THEME_TAB_RIGHT_EDGE:
{
if (aWidgetFlags) {
*aWidgetFlags = 0;
if (aWidgetType == NS_THEME_TAB &&
CheckBooleanAttr(aFrame, nsWidgetAtoms::selected))
*aWidgetFlags |= MOZ_GTK_TAB_SELECTED;
else if (aWidgetType == NS_THEME_TAB_LEFT_EDGE)
*aWidgetFlags |= MOZ_GTK_TAB_BEFORE_SELECTED;
if (aFrame->GetContent()->HasAttr(kNameSpaceID_None,
nsWidgetAtoms::firsttab))
*aWidgetFlags |= MOZ_GTK_TAB_FIRST;
}
aGtkWidgetType = MOZ_GTK_TAB;
}
break;
case NS_THEME_MENUBAR:
aGtkWidgetType = MOZ_GTK_MENUBAR;
break;
case NS_THEME_MENUPOPUP:
aGtkWidgetType = MOZ_GTK_MENUPOPUP;
break;
case NS_THEME_MENUITEM:
aGtkWidgetType = MOZ_GTK_MENUITEM;
break;
case NS_THEME_CHECKMENUITEM:
aGtkWidgetType = MOZ_GTK_CHECKMENUITEM;
break;
case NS_THEME_RADIOMENUITEM:
aGtkWidgetType = MOZ_GTK_RADIOMENUITEM;
break;
case NS_THEME_WINDOW:
case NS_THEME_DIALOG:
aGtkWidgetType = MOZ_GTK_WINDOW;
break;
default:
return PR_FALSE;
}
return PR_TRUE;
}
static int
NativeThemeErrorHandler(Display* dpy, XErrorEvent* error) {
gLastXError = error->error_code;
return 0;
}
NS_IMETHODIMP
nsNativeThemeGTK::DrawWidgetBackground(nsIRenderingContext* aContext,
nsIFrame* aFrame,
PRUint8 aWidgetType,
const nsRect& aRect,
const nsRect& aClipRect)
{
GtkWidgetState state;
GtkThemeWidgetType gtkWidgetType;
gint flags;
if (!GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, &state,
&flags))
return NS_OK;
GdkWindow* window = NS_STATIC_CAST(GdkWindow*,
aContext->GetNativeGraphicData(nsIRenderingContext::NATIVE_GDK_DRAWABLE));
nsTransform2D* transformMatrix;
aContext->GetCurrentTransform(transformMatrix);
nsRect tr(aRect);
transformMatrix->TransformCoord(&tr.x, &tr.y, &tr.width, &tr.height);
GdkRectangle gdk_rect = {tr.x, tr.y, tr.width, tr.height};
nsRect cr(aClipRect);
transformMatrix->TransformCoord(&cr.x, &cr.y, &cr.width, &cr.height);
GdkRectangle gdk_clip = {cr.x, cr.y, cr.width, cr.height};
NS_ASSERTION(!IsWidgetTypeDisabled(mDisabledWidgetTypes, aWidgetType),
"Trying to render an unsafe widget!");
PRBool safeState = IsWidgetStateSafe(mSafeWidgetStates, aWidgetType, &state);
XErrorHandler oldHandler = nsnull;
if (!safeState) {
gLastXError = 0;
oldHandler = XSetErrorHandler(NativeThemeErrorHandler);
}
moz_gtk_widget_paint(gtkWidgetType, window, &gdk_rect, &gdk_clip, &state,
flags);
if (!safeState) {
gdk_flush();
XSetErrorHandler(oldHandler);
if (gLastXError) {
#ifdef DEBUG
printf("GTK theme failed for widget type %d, error was %d, state was "
"[active=%d,focused=%d,inHover=%d,disabled=%d]\n",
aWidgetType, gLastXError, state.active, state.focused,
state.inHover, state.disabled);
#endif
NS_WARNING("GTK theme failed; disabling unsafe widget");
SetWidgetTypeDisabled(mDisabledWidgetTypes, aWidgetType);
// force refresh of the window, because the widget was not
// successfully drawn it must be redrawn using the default look
RefreshWidgetWindow(aFrame);
} else {
SetWidgetStateSafe(mSafeWidgetStates, aWidgetType, &state);
}
}
return NS_OK;
}
NS_IMETHODIMP
nsNativeThemeGTK::GetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame,
PRUint8 aWidgetType, nsMargin* aResult)
{
aResult->top = aResult->left = 0;
switch (aWidgetType) {
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
{
MozGtkScrollbarMetrics metrics;
moz_gtk_get_scrollbar_metrics(&metrics);
aResult->top = aResult->left = metrics.trough_border;
}
break;
case NS_THEME_TOOLBOX:
// gtk has no toolbox equivalent. So, although we map toolbox to
// gtk's 'toolbar' for purposes of painting the widget background,
// we don't use the toolbar border for toolbox.
break;
case NS_THEME_TOOLBAR_DUAL_BUTTON:
// TOOLBAR_DUAL_BUTTON is an interesting case. We want a border to draw
// around the entire button + dropdown, and also an inner border if you're
// over the button part. But, we want the inner button to be right up
// against the edge of the outer button so that the borders overlap.
// To make this happen, we draw a button border for the outer button,
// but don't reserve any space for it.
break;
default:
{
GtkThemeWidgetType gtkWidgetType;
if (GetGtkWidgetAndState(aWidgetType, aFrame, gtkWidgetType, nsnull,
nsnull))
moz_gtk_get_widget_border(gtkWidgetType, &aResult->left,
&aResult->top);
}
}
aResult->right = aResult->left;
aResult->bottom = aResult->top;
return NS_OK;
}
PRBool
nsNativeThemeGTK::GetWidgetPadding(nsIDeviceContext* aContext,
nsIFrame* aFrame, PRUint8 aWidgetType,
nsMargin* aResult)
{
if (aWidgetType == NS_THEME_BUTTON_FOCUS ||
aWidgetType == NS_THEME_TOOLBAR_BUTTON ||
aWidgetType == NS_THEME_TOOLBAR_DUAL_BUTTON) {
aResult->SizeTo(0, 0, 0, 0);
return PR_TRUE;
}
return PR_FALSE;
}
PRBool
nsNativeThemeGTK::GetWidgetOverflow(nsIDeviceContext* aContext,
nsIFrame* aFrame, PRUint8 aWidgetType,
nsRect* aResult)
{
nsIntMargin extraSize(0,0,0,0);
// Allow an extra one pixel above and below the thumb for certain
// GTK2 themes (Ximian Industrial, Bluecurve, Misty, at least);
// see moz_gtk_scrollbar_thumb_paint in gtk2drawing.c
switch (aWidgetType) {
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
extraSize.top = extraSize.bottom = 1;
break;
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
extraSize.left = extraSize.right = 1;
break;
default:
return PR_FALSE;
}
float p2t = aContext->DevUnitsToAppUnits();
nsMargin m(NSIntPixelsToTwips(extraSize.left, p2t),
NSIntPixelsToTwips(extraSize.top, p2t),
NSIntPixelsToTwips(extraSize.right, p2t),
NSIntPixelsToTwips(extraSize.bottom, p2t));
nsRect r(nsPoint(0, 0), aFrame->GetSize());
r.Inflate(m);
*aResult = r;
return PR_TRUE;
}
NS_IMETHODIMP
nsNativeThemeGTK::GetMinimumWidgetSize(nsIRenderingContext* aContext,
nsIFrame* aFrame, PRUint8 aWidgetType,
nsSize* aResult, PRBool* aIsOverridable)
{
aResult->width = aResult->height = 0;
*aIsOverridable = PR_TRUE;
switch (aWidgetType) {
case NS_THEME_SCROLLBAR_BUTTON_UP:
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
{
MozGtkScrollbarMetrics metrics;
moz_gtk_get_scrollbar_metrics(&metrics);
aResult->width = metrics.slider_width;
aResult->height = metrics.stepper_size;
*aIsOverridable = PR_FALSE;
}
break;
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
{
MozGtkScrollbarMetrics metrics;
moz_gtk_get_scrollbar_metrics(&metrics);
aResult->width = metrics.stepper_size;
aResult->height = metrics.slider_width;
*aIsOverridable = PR_FALSE;
}
break;
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
{
MozGtkScrollbarMetrics metrics;
moz_gtk_get_scrollbar_metrics(&metrics);
if (aWidgetType == NS_THEME_SCROLLBAR_THUMB_VERTICAL) {
aResult->width = metrics.slider_width;
aResult->height = metrics.min_slider_size;
} else {
aResult->width = metrics.min_slider_size;
aResult->height = metrics.slider_width;
}
*aIsOverridable = PR_FALSE;
}
break;
case NS_THEME_SCALE_THUMB_HORIZONTAL:
case NS_THEME_SCALE_THUMB_VERTICAL:
{
gint thumb_length, thumb_height;
if (aWidgetType == NS_THEME_SCALE_THUMB_VERTICAL) {
moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_VERTICAL, &thumb_length, &thumb_height);
aResult->width = thumb_height;
aResult->height = thumb_length;
} else {
moz_gtk_get_scalethumb_metrics(GTK_ORIENTATION_HORIZONTAL, &thumb_length, &thumb_height);
aResult->width = thumb_length;
aResult->height = thumb_height;
}
*aIsOverridable = PR_FALSE;
}
break;
case NS_THEME_DROPDOWN_BUTTON:
{
moz_gtk_get_dropdown_arrow_size(&aResult->width, &aResult->height);
*aIsOverridable = PR_FALSE;
}
break;
case NS_THEME_CHECKBOX:
case NS_THEME_RADIO:
{
gint indicator_size, indicator_spacing;
if (aWidgetType == NS_THEME_CHECKBOX) {
moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing);
} else {
moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing);
}
// Include space for the indicator and the padding around it.
aResult->width = indicator_size + 3 * indicator_spacing;
aResult->height = indicator_size + 2 * indicator_spacing;
*aIsOverridable = PR_FALSE;
}
break;
case NS_THEME_CHECKBOX_CONTAINER:
case NS_THEME_RADIO_CONTAINER:
case NS_THEME_CHECKBOX_LABEL:
case NS_THEME_RADIO_LABEL:
case NS_THEME_BUTTON:
case NS_THEME_TOOLBAR_BUTTON:
{
// Just include our border, and let the box code augment the size.
nsCOMPtr<nsIDeviceContext> dc;
aContext->GetDeviceContext(*getter_AddRefs(dc));
nsMargin border;
nsNativeThemeGTK::GetWidgetBorder(dc, aFrame, aWidgetType, &border);
aResult->width = border.left + border.right;
aResult->height = border.top + border.bottom;
}
break;
case NS_THEME_SPINNER_UP_BUTTON:
case NS_THEME_SPINNER_DOWN_BUTTON:
// hard-code these sizes
aResult->width = 14;
aResult->height = 13;
break;
}
return NS_OK;
}
NS_IMETHODIMP
nsNativeThemeGTK::WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
nsIAtom* aAttribute, PRBool* aShouldRepaint)
{
// Some widget types just never change state.
if (aWidgetType == NS_THEME_TOOLBOX ||
aWidgetType == NS_THEME_TOOLBAR ||
aWidgetType == NS_THEME_STATUSBAR ||
aWidgetType == NS_THEME_STATUSBAR_PANEL ||
aWidgetType == NS_THEME_STATUSBAR_RESIZER_PANEL ||
aWidgetType == NS_THEME_PROGRESSBAR_CHUNK ||
aWidgetType == NS_THEME_PROGRESSBAR_CHUNK_VERTICAL ||
aWidgetType == NS_THEME_PROGRESSBAR ||
aWidgetType == NS_THEME_PROGRESSBAR_VERTICAL ||
aWidgetType == NS_THEME_MENUBAR ||
aWidgetType == NS_THEME_MENUPOPUP ||
aWidgetType == NS_THEME_TOOLTIP ||
aWidgetType == NS_THEME_WINDOW ||
aWidgetType == NS_THEME_DIALOG) {
*aShouldRepaint = PR_FALSE;
return NS_OK;
}
// XXXdwh Not sure what can really be done here. Can at least guess for
// specific widgets that they're highly unlikely to have certain states.
// For example, a toolbar doesn't care about any states.
if (!aAttribute) {
// Hover/focus/active changed. Always repaint.
*aShouldRepaint = PR_TRUE;
}
else {
// Check the attribute to see if it's relevant.
// disabled, checked, dlgtype, default, etc.
*aShouldRepaint = PR_FALSE;
if (aAttribute == nsWidgetAtoms::disabled ||
aAttribute == nsWidgetAtoms::checked ||
aAttribute == nsWidgetAtoms::selected ||
aAttribute == nsWidgetAtoms::focused ||
aAttribute == nsWidgetAtoms::mozmenuactive)
*aShouldRepaint = PR_TRUE;
}
return NS_OK;
}
NS_IMETHODIMP
nsNativeThemeGTK::ThemeChanged()
{
// this totally sucks. this method is really supposed to be
// static, which is why we can call it without any initialization.
static NS_DEFINE_CID(kDeviceContextCID, NS_DEVICE_CONTEXT_CID);
nsCOMPtr<nsIDeviceContext> dctx = do_CreateInstance(kDeviceContextCID);
dctx->ClearCachedSystemFonts();
memset(mDisabledWidgetTypes, 0, sizeof(mDisabledWidgetTypes));
return NS_OK;
}
NS_IMETHODIMP_(PRBool)
nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext,
nsIFrame* aFrame,
PRUint8 aWidgetType)
{
if (aFrame) {
// For now don't support HTML.
if (aFrame->GetContent()->IsNodeOfType(nsINode::eHTML))
return PR_FALSE;
}
if (IsWidgetTypeDisabled(mDisabledWidgetTypes, aWidgetType))
return PR_FALSE;
switch (aWidgetType) {
case NS_THEME_BUTTON:
case NS_THEME_BUTTON_FOCUS:
case NS_THEME_RADIO:
case NS_THEME_CHECKBOX:
case NS_THEME_TOOLBOX: // N/A
case NS_THEME_TOOLBAR:
case NS_THEME_TOOLBAR_BUTTON:
case NS_THEME_TOOLBAR_DUAL_BUTTON: // so we can override the border with 0
// case NS_THEME_TOOLBAR_DUAL_BUTTON_DROPDOWN:
// case NS_THEME_TOOLBAR_SEPARATOR:
case NS_THEME_TOOLBAR_GRIPPER:
case NS_THEME_STATUSBAR:
case NS_THEME_STATUSBAR_PANEL:
// case NS_THEME_RESIZER: (n/a for gtk)
// case NS_THEME_LISTBOX:
// case NS_THEME_LISTBOX_LISTITEM:
// case NS_THEME_TREEVIEW:
// case NS_THEME_TREEVIEW_TREEITEM:
// case NS_THEME_TREEVIEW_TWISTY:
// case NS_THEME_TREEVIEW_LINE:
// case NS_THEME_TREEVIEW_HEADER:
// case NS_THEME_TREEVIEW_HEADER_CELL:
// case NS_THEME_TREEVIEW_HEADER_SORTARROW:
// case NS_THEME_TREEVIEW_TWISTY_OPEN:
case NS_THEME_PROGRESSBAR:
case NS_THEME_PROGRESSBAR_CHUNK:
case NS_THEME_PROGRESSBAR_VERTICAL:
case NS_THEME_PROGRESSBAR_CHUNK_VERTICAL:
case NS_THEME_TAB:
// case NS_THEME_TAB_PANEL:
case NS_THEME_TAB_LEFT_EDGE:
case NS_THEME_TAB_RIGHT_EDGE:
case NS_THEME_TAB_PANELS:
case NS_THEME_TOOLTIP:
// case NS_THEME_SPINNER:
case NS_THEME_SPINNER_UP_BUTTON:
case NS_THEME_SPINNER_DOWN_BUTTON:
// case NS_THEME_SCROLLBAR: (n/a for gtk)
case NS_THEME_SCROLLBAR_BUTTON_UP:
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
case NS_THEME_SCROLLBAR_BUTTON_LEFT:
case NS_THEME_SCROLLBAR_BUTTON_RIGHT:
case NS_THEME_SCROLLBAR_TRACK_HORIZONTAL:
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
// case NS_THEME_SCROLLBAR_GRIPPER_HORIZONTAL: (n/a for gtk)
// case NS_THEME_SCROLLBAR_GRIPPER_VERTICAL: (n/a for gtk)
case NS_THEME_TEXTFIELD:
// case NS_THEME_TEXTFIELD_CARET:
case NS_THEME_DROPDOWN_BUTTON:
case NS_THEME_DROPDOWN_TEXTFIELD:
case NS_THEME_SCALE_HORIZONTAL:
case NS_THEME_SCALE_THUMB_HORIZONTAL:
case NS_THEME_SCALE_VERTICAL:
case NS_THEME_SCALE_THUMB_VERTICAL:
// case NS_THEME_SCALE_THUMB_START:
// case NS_THEME_SCALE_THUMB_END:
// case NS_THEME_SCALE_TICK:
case NS_THEME_CHECKBOX_CONTAINER:
case NS_THEME_RADIO_CONTAINER:
case NS_THEME_CHECKBOX_LABEL:
case NS_THEME_RADIO_LABEL:
#ifdef MOZ_WIDGET_GTK2
case NS_THEME_MENUBAR:
case NS_THEME_MENUPOPUP:
case NS_THEME_MENUITEM:
case NS_THEME_CHECKMENUITEM:
case NS_THEME_RADIOMENUITEM:
case NS_THEME_WINDOW:
case NS_THEME_DIALOG:
case NS_THEME_DROPDOWN:
case NS_THEME_DROPDOWN_TEXT:
#endif
return !IsWidgetStyled(aPresContext, aFrame, aWidgetType);
}
return PR_FALSE;
}
NS_IMETHODIMP_(PRBool)
nsNativeThemeGTK::WidgetIsContainer(PRUint8 aWidgetType)
{
// XXXdwh At some point flesh all of this out.
if (aWidgetType == NS_THEME_DROPDOWN_BUTTON ||
aWidgetType == NS_THEME_RADIO ||
aWidgetType == NS_THEME_CHECKBOX)
return PR_FALSE;
return PR_TRUE;
}

View File

@ -1,103 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2002
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Brian Ryner <bryner@brianryner.com> (Original Author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsITheme.h"
#include "nsCOMPtr.h"
#include "nsIAtom.h"
#include "nsIObserver.h"
#include "nsNativeTheme.h"
#include <gtk/gtkwidget.h>
#include "gtkdrawing.h"
class nsNativeThemeGTK: private nsNativeTheme,
public nsITheme,
public nsIObserver {
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIOBSERVER
// The nsITheme interface.
NS_IMETHOD DrawWidgetBackground(nsIRenderingContext* aContext,
nsIFrame* aFrame, PRUint8 aWidgetType,
const nsRect& aRect,
const nsRect& aClipRect);
NS_IMETHOD GetWidgetBorder(nsIDeviceContext* aContext, nsIFrame* aFrame,
PRUint8 aWidgetType, nsMargin* aResult);
virtual NS_HIDDEN_(PRBool) GetWidgetPadding(nsIDeviceContext* aContext,
nsIFrame* aFrame,
PRUint8 aWidgetType,
nsMargin* aResult);
virtual NS_HIDDEN_(PRBool) GetWidgetOverflow(nsIDeviceContext* aContext,
nsIFrame* aFrame,
PRUint8 aWidgetType,
nsRect* aResult);
NS_IMETHOD GetMinimumWidgetSize(nsIRenderingContext* aContext,
nsIFrame* aFrame, PRUint8 aWidgetType,
nsSize* aResult, PRBool* aIsOverridable);
NS_IMETHOD WidgetStateChanged(nsIFrame* aFrame, PRUint8 aWidgetType,
nsIAtom* aAttribute, PRBool* aShouldRepaint);
NS_IMETHOD ThemeChanged();
NS_IMETHOD_(PRBool) ThemeSupportsWidget(nsPresContext* aPresContext,
nsIFrame* aFrame,
PRUint8 aWidgetType);
NS_IMETHOD_(PRBool) WidgetIsContainer(PRUint8 aWidgetType);
nsNativeThemeGTK();
virtual ~nsNativeThemeGTK();
private:
PRBool GetGtkWidgetAndState(PRUint8 aWidgetType, nsIFrame* aFrame,
GtkThemeWidgetType& aGtkWidgetType,
GtkWidgetState* aState, gint* aWidgetFlags);
void RefreshWidgetWindow(nsIFrame* aFrame);
PRUint8 mDisabledWidgetTypes[32];
PRUint8 mSafeWidgetStates[1024]; // 256 widgets * 32 bits per widget
static const char* sDisabledEngines[];
};

View File

@ -1,138 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include "nsPointerService.h"
#include "nsWindow.h"
NS_IMPL_ADDREF_INHERITED(nsPointerService, nsBasePointerService)
NS_IMPL_RELEASE_INHERITED(nsPointerService, nsBasePointerService)
NS_IMPL_QUERY_INTERFACE_INHERITED0(nsPointerService, nsBasePointerService)
NS_IMETHODIMP
nsPointerService::WidgetUnderPointer(nsIWidget **_retval,
PRUint32 *aXOffset, PRUint32 *aYOffset)
{
*_retval = nsnull;
*aXOffset = 0;
*aYOffset = 0;
Bool retval;
Window root_return;
Window child_return = None;
int root_x_return, root_y_return;
int win_x_return, win_y_return;
unsigned int mask_return;
// Flush the queue to get any pending destroys out the door. If we
// don't then we can end up with a sitution where the XQueryPointer
// flushes the queue and then the XTranslateCoordinates will cause
// an X error since the window doesn't exist anymore. God,
// sometimes I just hate X.
XSync(GDK_DISPLAY(), False);
// Query the pointer
retval = XQueryPointer(GDK_DISPLAY(),
GDK_WINDOW_XWINDOW(GDK_ROOT_PARENT()),
&root_return, &child_return,
&root_x_return, &root_y_return,
&win_x_return, &win_y_return,
&mask_return);
// the pointer is on a different window
if (!retval || child_return == None)
return NS_OK;
int done = 0;
Window dest_w = child_return;
int xlate_x_return;
int xlate_y_return;
// loop to find the inner most window
while (!done) {
Window xlate_return = None;
retval = XTranslateCoordinates(GDK_DISPLAY(),
GDK_WINDOW_XWINDOW(GDK_ROOT_PARENT()),
dest_w,
win_x_return, win_y_return,
&xlate_x_return, &xlate_y_return,
&xlate_return);
// the pointer is on a different screen
if (!retval)
return NS_OK;
// if xlate_return was None then we've reached the inner most window
if (xlate_return == None)
done = 1;
// otherwise set our new destination window to the return from the
// translation
else
dest_w = xlate_return;
}
GdkWindow *window;
nsWindow *widget;
// get the gdk window under the pointer
window = gdk_window_lookup(dest_w);
// it's not a gdk window
if (!window)
return NS_OK;
// is that an nsWindow window?
gpointer data = NULL;
gdk_window_get_user_data(window, &data);
// nope
if (!data)
return NS_OK;
// downcast
widget = (nsWindow *)gtk_object_get_data(GTK_OBJECT(data), "nsWindow");
if (!widget)
return NS_OK;
*_retval = NS_STATIC_CAST(nsIWidget *, widget);
*aXOffset = xlate_x_return;
*aYOffset = xlate_y_return;
NS_ADDREF(*_retval);
return NS_OK;
}

View File

@ -1,48 +0,0 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsBasePointerService.h"
class nsPointerService : public nsBasePointerService {
public:
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD WidgetUnderPointer(nsIWidget **_retval,
PRUint32 *aXOffset, PRUint32 *aYOffset);
};

View File

@ -1,190 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher A. Aillon <caillon@redhat.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsScreenGtk.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <X11/Xatom.h>
nsScreenGtk :: nsScreenGtk ( )
: mScreenNum(0),
mRect(0, 0, 0, 0),
mAvailRect(0, 0, 0, 0)
{
}
nsScreenGtk :: ~nsScreenGtk()
{
}
// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenGtk, nsIScreen)
NS_IMETHODIMP
nsScreenGtk :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{
*outLeft = mRect.x;
*outTop = mRect.y;
*outWidth = mRect.width;
*outHeight = mRect.height;
return NS_OK;
} // GetRect
NS_IMETHODIMP
nsScreenGtk :: GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{
*outLeft = mAvailRect.x;
*outTop = mAvailRect.y;
*outWidth = mAvailRect.width;
*outHeight = mAvailRect.height;
return NS_OK;
} // GetAvailRect
NS_IMETHODIMP
nsScreenGtk :: GetPixelDepth(PRInt32 *aPixelDepth)
{
GdkVisual * rgb_visual = gdk_rgb_get_visual();
*aPixelDepth = rgb_visual->depth;
return NS_OK;
} // GetPixelDepth
NS_IMETHODIMP
nsScreenGtk :: GetColorDepth(PRInt32 *aColorDepth)
{
return GetPixelDepth ( aColorDepth );
} // GetColorDepth
void
nsScreenGtk :: Init ()
{
mAvailRect = mRect = nsRect(0, 0, gdk_screen_width(), gdk_screen_height());
// We need to account for the taskbar, etc in the available rect.
// See http://freedesktop.org/Standards/wm-spec/index.html#id2767771
// XXX It doesn't change that often, but we should probably
// listen for changes to _NET_WORKAREA.
// XXX do we care about _NET_WM_STRUT_PARTIAL? That will
// add much more complexity to the code here (our screen
// could have a non-rectangular shape), but should
// lead to greater accuracy.
#if GTK_CHECK_VERSION(2,2,0)
GdkWindow *root_window = gdk_get_default_root_window();
#else
GdkWindow *root_window = GDK_ROOT_PARENT();
#endif // GTK_CHECK_VERSION(2,2,0)
long *workareas;
GdkAtom type_returned;
int format_returned;
int length_returned;
#if GTK_CHECK_VERSION(2,0,0)
GdkAtom cardinal_atom = gdk_x11_xatom_to_atom(XA_CARDINAL);
#else
GdkAtom cardinal_atom = (GdkAtom) XA_CARDINAL;
#endif
gdk_error_trap_push();
// gdk_property_get uses (length + 3) / 4, hence G_MAXLONG - 3 here.
if (!gdk_property_get(root_window,
gdk_atom_intern ("_NET_WORKAREA", FALSE),
cardinal_atom,
0, G_MAXLONG - 3, FALSE,
&type_returned,
&format_returned,
&length_returned,
(guchar **) &workareas)) {
// This window manager doesn't support the freedesktop standard.
// Nothing we can do about it, so assume full screen size.
return;
}
// Flush the X queue to catch errors now.
gdk_flush();
if (!gdk_error_trap_pop() &&
type_returned == cardinal_atom &&
length_returned && (length_returned % 4) == 0 &&
format_returned == 32) {
int num_items = length_returned / sizeof(long);
for (int i = 0; i < num_items; i += 4) {
nsRect workarea(workareas[i], workareas[i + 1],
workareas[i + 2], workareas[i + 3]);
if (!mRect.Contains(workarea)) {
NS_WARNING("Invalid bounds");
continue;
}
mAvailRect.IntersectRect(mAvailRect, workarea);
}
}
g_free (workareas);
}
#ifdef MOZ_ENABLE_XINERAMA
void
nsScreenGtk :: Init (XineramaScreenInfo *aScreenInfo)
{
nsRect xineRect(aScreenInfo->x_org, aScreenInfo->y_org,
aScreenInfo->width, aScreenInfo->height);
mScreenNum = aScreenInfo->screen_number;
mAvailRect = mRect = xineRect;
}
#endif // MOZ_ENABLE_XINERAMA

View File

@ -1,71 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsScreenGtk_h___
#define nsScreenGtk_h___
#include "nsIScreen.h"
#include "nsRect.h"
#ifdef MOZ_ENABLE_XINERAMA
#include <X11/Xlib.h>
#include <X11/extensions/Xinerama.h>
#endif // MOZ_ENABLE_XINERAMA
//------------------------------------------------------------------------
class nsScreenGtk : public nsIScreen
{
public:
nsScreenGtk();
~nsScreenGtk();
NS_DECL_ISUPPORTS
NS_DECL_NSISCREEN
void Init();
#ifdef MOZ_ENABLE_XINERAMA
void Init(XineramaScreenInfo *aScreenInfo);
#endif
private:
PRUint32 mScreenNum;
nsRect mRect; // in pixels, not twips
nsRect mAvailRect; // in pixels, not twips
};
#endif // nsScreenGtk_h___

View File

@ -1,246 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsScreenManagerGtk.h"
#include "nsScreenGtk.h"
#include "nsIComponentManager.h"
#include "nsRect.h"
#include "nsAutoPtr.h"
#include <gdk/gdkx.h>
#ifdef MOZ_ENABLE_XINERAMA
// this header rocks!
extern "C"
{
#include <X11/extensions/Xinerama.h>
}
#endif /* MOZ_ENABLE_XINERAMA */
nsScreenManagerGtk :: nsScreenManagerGtk ( )
{
// nothing else to do. I guess we could cache a bunch of information
// here, but we want to ask the device at runtime in case anything
// has changed.
mNumScreens = 0;
}
nsScreenManagerGtk :: ~nsScreenManagerGtk()
{
// nothing to see here.
}
// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenManagerGtk, nsIScreenManager)
// this function will make sure that everything has been initialized.
nsresult
nsScreenManagerGtk :: EnsureInit(void)
{
if (!mCachedScreenArray) {
mCachedScreenArray = do_CreateInstance("@mozilla.org/supports-array;1");
if (!mCachedScreenArray) {
return NS_ERROR_OUT_OF_MEMORY;
}
#ifdef MOZ_ENABLE_XINERAMA
// get the number of screens via xinerama
XineramaScreenInfo *screenInfo;
if (XineramaIsActive(GDK_DISPLAY())) {
screenInfo = XineramaQueryScreens(GDK_DISPLAY(), &mNumScreens);
}
else {
screenInfo = NULL;
mNumScreens = 1;
}
#else
mNumScreens = 1;
#endif
// there will be < 2 screens if we are either not building with
// xinerama support or xinerama isn't running on the current
// display.
if (mNumScreens < 2) {
mNumScreens = 1;
nsRefPtr<nsScreenGtk> screen = new nsScreenGtk();
if (!screen)
return NS_ERROR_OUT_OF_MEMORY;
screen->Init();
nsISupports *supportsScreen = screen;
mCachedScreenArray->AppendElement(supportsScreen);
}
// If Xinerama is enabled and there's more than one screen, fill
// in the info for all of the screens. If that's not the case
// then nsScreenGTK() defaults to the screen width + height
#ifdef MOZ_ENABLE_XINERAMA
else {
#ifdef DEBUG
printf("Xinerama superpowers activated for %d screens!\n", mNumScreens);
#endif
int i;
for (i=0; i < mNumScreens; i++) {
nsRefPtr<nsScreenGtk> screen = new nsScreenGtk();
if (!screen) {
return NS_ERROR_OUT_OF_MEMORY;
}
// initialize this screen object
screen->Init(&screenInfo[i]);
nsISupports *screenSupports = screen;
mCachedScreenArray->AppendElement(screenSupports);
}
}
if (screenInfo) {
XFree(screenInfo);
}
#endif /* MOZ_ENABLE_XINERAMA */
}
return NS_OK;;
}
//
// ScreenForRect
//
// Returns the screen that contains the rectangle. If the rect overlaps
// multiple screens, it picks the screen with the greatest area of intersection.
//
// The coordinates are in pixels (not twips) and in screen coordinates.
//
NS_IMETHODIMP
nsScreenManagerGtk :: ScreenForRect ( PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight,
nsIScreen **aOutScreen )
{
nsresult rv;
rv = EnsureInit();
if (NS_FAILED(rv)) {
NS_ERROR("nsScreenManagerGtk::EnsureInit() failed from ScreenForRect\n");
return rv;
}
// which screen ( index from zero ) should we return?
PRUint32 which = 0;
// Optimize for the common case. If the number of screens is only
// one then this will fall through with which == 0 and will get the
// primary screen.
if (mNumScreens > 1) {
// walk the list of screens and find the one that has the most
// surface area.
PRUint32 count;
mCachedScreenArray->Count(&count);
PRUint32 i;
PRUint32 area = 0;
nsRect windowRect(aX, aY, aWidth, aHeight);
for (i=0; i < count; i++) {
PRInt32 x, y, width, height;
x = y = width = height = 0;
nsCOMPtr<nsIScreen> screen;
mCachedScreenArray->GetElementAt(i, getter_AddRefs(screen));
screen->GetRect(&x, &y, &width, &height);
// calculate the surface area
nsRect screenRect(x, y, width, height);
screenRect.IntersectRect(screenRect, windowRect);
PRUint32 tempArea = screenRect.width * screenRect.height;
if (tempArea >= area) {
which = i;
area = tempArea;
}
}
}
nsCOMPtr<nsIScreen> outScreen;
mCachedScreenArray->GetElementAt(which, getter_AddRefs(outScreen));
*aOutScreen = outScreen.get();
NS_IF_ADDREF(*aOutScreen);
return NS_OK;
} // ScreenForRect
//
// GetPrimaryScreen
//
// The screen with the menubar/taskbar. This shouldn't be needed very
// often.
//
NS_IMETHODIMP
nsScreenManagerGtk :: GetPrimaryScreen(nsIScreen * *aPrimaryScreen)
{
nsresult rv;
rv = EnsureInit();
if (NS_FAILED(rv)) {
NS_ERROR("nsScreenManagerGtk::EnsureInit() failed from GetPrimaryScreen\n");
return rv;
}
nsCOMPtr <nsIScreen> screen;
mCachedScreenArray->GetElementAt(0, getter_AddRefs(screen));
*aPrimaryScreen = screen.get();
NS_IF_ADDREF(*aPrimaryScreen);
return NS_OK;
} // GetPrimaryScreen
//
// GetNumberOfScreens
//
// Returns how many physical screens are available.
//
NS_IMETHODIMP
nsScreenManagerGtk :: GetNumberOfScreens(PRUint32 *aNumberOfScreens)
{
nsresult rv;
rv = EnsureInit();
if (NS_FAILED(rv)) {
NS_ERROR("nsScreenManagerGtk::EnsureInit() failed from GetNumberOfScreens\n");
return rv;
}
*aNumberOfScreens = mNumScreens;
return NS_OK;
} // GetNumberOfScreens
NS_IMETHODIMP
nsScreenManagerGtk :: ScreenForNativeWidget(void *nativeWidget, nsIScreen **aScreen)
{
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -1,69 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsScreenManagerGtk_h___
#define nsScreenManagerGtk_h___
#include "nsIScreenManager.h"
#include "nsIScreen.h"
#include "nsCOMPtr.h"
#include "nsISupportsArray.h"
//------------------------------------------------------------------------
class nsScreenManagerGtk : public nsIScreenManager
{
public:
nsScreenManagerGtk ( );
virtual ~nsScreenManagerGtk();
NS_DECL_ISUPPORTS
NS_DECL_NSISCREENMANAGER
private:
nsresult EnsureInit(void);
// cache the primary screen object to avoid memory allocation every
// time
nsCOMPtr<nsISupportsArray> mCachedScreenArray;
// how many screens do we have?
int mNumScreens;
};
#endif // nsScreenManagerGtk_h___

View File

@ -1,324 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include <string.h>
#include "nscore.h"
#include "plstr.h"
#include "prlink.h"
#include "nsSound.h"
#include "nsIURL.h"
#include "nsIFileURL.h"
#include "nsNetUtil.h"
#include "nsCOMPtr.h"
#include <stdio.h>
#include <unistd.h>
#include <gtk/gtk.h>
/* used with esd_open_sound */
static int esdref = -1;
static PRLibrary *elib = nsnull;
// the following from esd.h
#define ESD_BITS8 (0x0000)
#define ESD_BITS16 (0x0001)
#define ESD_MONO (0x0010)
#define ESD_STEREO (0x0020)
#define ESD_STREAM (0x0000)
#define ESD_PLAY (0x1000)
#define WAV_MIN_LENGTH 44
typedef int (PR_CALLBACK *EsdOpenSoundType)(const char *host);
typedef int (PR_CALLBACK *EsdCloseType)(int);
/* used to play the sounds from the find symbol call */
typedef int (PR_CALLBACK *EsdPlayStreamFallbackType)(int, int, const char *, const char *);
NS_IMPL_ISUPPORTS2(nsSound, nsISound, nsIStreamLoaderObserver)
////////////////////////////////////////////////////////////////////////
nsSound::nsSound()
{
mInited = PR_FALSE;
}
nsSound::~nsSound()
{
/* see above comment */
if (esdref != -1) {
EsdCloseType EsdClose = (EsdCloseType) PR_FindSymbol(elib, "esd_close");
(*EsdClose)(esdref);
esdref = -1;
}
}
NS_IMETHODIMP
nsSound::Init()
{
/* we don't need to do esd_open_sound if we are only going to play files
but we will if we want to do things like streams, etc
*/
if (mInited) return NS_OK;
if (elib) return NS_OK;
EsdOpenSoundType EsdOpenSound;
elib = PR_LoadLibrary("libesd.so.0");
if (!elib) return NS_ERROR_FAILURE;
EsdOpenSound = (EsdOpenSoundType) PR_FindSymbol(elib, "esd_open_sound");
if (!EsdOpenSound)
return NS_ERROR_FAILURE;
esdref = (*EsdOpenSound)("localhost");
if (!esdref)
return NS_ERROR_FAILURE;
mInited = PR_TRUE;
return NS_OK;
}
/* static */ void
nsSound::Shutdown()
{
if (elib) {
PR_UnloadLibrary(elib)
elib = nsnull;
}
}
#define GET_WORD(s, i) (s[i+1] << 8) | s[i]
#define GET_DWORD(s, i) (s[i+3] << 24) | (s[i+2] << 16) | (s[i+1] << 8) | s[i]
NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader,
nsISupports *context,
nsresult aStatus,
PRUint32 dataLen,
const PRUint8 *data)
{
// print a load error on bad status
if (NS_FAILED(aStatus)) {
#ifdef DEBUG
if (aLoader) {
nsCOMPtr<nsIRequest> request;
aLoader->GetRequest(getter_AddRefs(request));
if (request) {
nsCOMPtr<nsIURI> uri;
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
if (channel) {
channel->GetURI(getter_AddRefs(uri));
if (uri) {
nsCAutoString uriSpec;
uri->GetSpec(uriSpec);
printf("Failed to load %s\n", uriSpec.get());
}
}
}
}
#endif
return aStatus;
}
int fd, mask = 0;
unsigned long samples_per_sec=0, avg_bytes_per_sec=0;
unsigned long rate=0;
unsigned short format, channels = 1, block_align, bits_per_sample=0;
if (memcmp(data, "RIFF", 4)) {
#ifdef DEBUG
printf("We only support WAV files currently.\n");
#endif
return NS_ERROR_FAILURE;
}
if (dataLen <= WAV_MIN_LENGTH) {
NS_WARNING("WAV files should be longer than 44 bytes.");
return NS_ERROR_FAILURE;
}
PRUint32 i;
for (i= 0; i < dataLen; i++) {
if (i+3 <= dataLen)
if ((data[i] == 'f') &&
(data[i+1] == 'm') &&
(data[i+2] == 't') &&
(data[i+3] == ' ')) {
i += 4;
/* length of the rest of this subblock (should be 16 for PCM data */
// long len = GET_DWORD(data, i);
i+=4;
format = GET_WORD(data, i);
i+=2;
channels = GET_WORD(data, i);
i+=2;
samples_per_sec = GET_DWORD(data, i);
i+=4;
avg_bytes_per_sec = GET_DWORD(data, i);
i+=4;
block_align = GET_WORD(data, i);
i+=2;
bits_per_sample = GET_WORD(data, i);
i+=2;
rate = samples_per_sec;
break;
}
}
#ifdef DEBUG
printf("f: %d | c: %d | sps: %li | abps: %li | ba: %d | bps: %d | rate: %li\n",
format, channels, samples_per_sec, avg_bytes_per_sec, block_align, bits_per_sample, rate);
#endif
/* open up conneciton to esd */
EsdPlayStreamFallbackType EsdPlayStreamFallback = (EsdPlayStreamFallbackType) PR_FindSymbol(elib, "esd_play_stream_fallback");
mask = ESD_PLAY | ESD_STREAM;
if (bits_per_sample == 8)
mask |= ESD_BITS8;
else
mask |= ESD_BITS16;
if (channels == 1)
mask |= ESD_MONO;
else
mask |= ESD_STEREO;
fd = (*EsdPlayStreamFallback)(mask, rate, NULL, "mozillaSound");
if (fd < 0) {
return NS_ERROR_FAILURE;
}
/* write data out */
// ESD only handle little-endian data.
// Swap the byte order if we're on a big-endian architecture.
#ifdef IS_BIG_ENDIAN
if (bits_per_sample == 8)
write(fd, data, dataLen);
else {
PRUint8 *buf = new PRUint8[dataLen - WAV_MIN_LENGTH];
// According to the wav file format, the first 44 bytes are headers.
// We don't really need to send them.
if (!buf)
return NS_ERROR_OUT_OF_MEMORY;
for (PRUint32 j = 0; j < dataLen - WAV_MIN_LENGTH - 1; j += 2) {
buf[j] = data[j + WAV_MIN_LENGTH + 1];
buf[j + 1] = data[j + WAV_MIN_LENGTH];
}
write(fd, buf, (dataLen - WAV_MIN_LENGTH));
delete [] buf;
}
#else
write(fd, data, dataLen);
#endif
close(fd);
return NS_OK;
}
NS_METHOD nsSound::Beep()
{
::gdk_beep();
return NS_OK;
}
NS_METHOD nsSound::Play(nsIURL *aURL)
{
nsresult rv;
if (!mInited)
Init();
if (!elib) return NS_ERROR_FAILURE;
nsCOMPtr<nsIStreamLoader> loader;
rv = NS_NewStreamLoader(getter_AddRefs(loader), aURL, this);
return rv;
}
NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
{
if (aSoundAlias.EqualsLiteral("_moz_mailbeep"))
{
return Beep();
}
nsresult rv;
nsCOMPtr <nsIURI> fileURI;
// create a nsILocalFile and then a nsIFileURL from that
nsCOMPtr <nsILocalFile> soundFile;
rv = NS_NewLocalFile(aSoundAlias, PR_TRUE,
getter_AddRefs(soundFile));
NS_ENSURE_SUCCESS(rv,rv);
rv = NS_NewFileURI(getter_AddRefs(fileURI), soundFile);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIFileURL> fileURL = do_QueryInterface(fileURI,&rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = Play(fileURL);
return rv;
}

View File

@ -1,67 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsSound_h__
#define __nsSound_h__
#include "nsISound.h"
#include "nsIStreamLoader.h"
#include <gtk/gtk.h>
class nsSound : public nsISound,
public nsIStreamLoaderObserver
{
public:
nsSound();
virtual ~nsSound();
static void Shutdown();
NS_DECL_ISUPPORTS
NS_DECL_NSISOUND
NS_DECL_NSISTREAMLOADEROBSERVER
private:
PRBool mInited;
};
#endif /* __nsSound_h__ */

View File

@ -1,161 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nscore.h" // needed for 'nsnull'
#include "nsToolkit.h"
#include "nsWidgetAtoms.h"
//
// Static thread local storage index of the Toolkit
// object associated with a given thread...
//
static PRUintn gToolkitTLSIndex = 0;
//-------------------------------------------------------------------------
//
// constructor
//
//-------------------------------------------------------------------------
nsToolkit::nsToolkit()
{
mSharedGC = nsnull;
}
//-------------------------------------------------------------------------
//
// destructor
//
//-------------------------------------------------------------------------
nsToolkit::~nsToolkit()
{
if (mSharedGC) {
gdk_gc_unref(mSharedGC);
}
// Remove the TLS reference to the toolkit...
PR_SetThreadPrivate(gToolkitTLSIndex, nsnull);
}
//-------------------------------------------------------------------------
//
// nsISupports implementation macro
//
//-------------------------------------------------------------------------
NS_IMPL_ISUPPORTS1(nsToolkit, nsIToolkit)
void nsToolkit::CreateSharedGC(void)
{
GdkPixmap *pixmap;
if (mSharedGC)
return;
pixmap = gdk_pixmap_new(NULL, 1, 1, gdk_rgb_get_visual()->depth);
mSharedGC = gdk_gc_new(pixmap);
gdk_pixmap_unref(pixmap);
}
GdkGC *nsToolkit::GetSharedGC(void)
{
return gdk_gc_ref(mSharedGC);
}
//-------------------------------------------------------------------------
//
//
//-------------------------------------------------------------------------
NS_IMETHODIMP nsToolkit::Init(PRThread *aThread)
{
CreateSharedGC();
nsWidgetAtoms::RegisterAtoms();
return NS_OK;
}
//-------------------------------------------------------------------------
//
// Return the nsIToolkit for the current thread. If a toolkit does not
// yet exist, then one will be created...
//
//-------------------------------------------------------------------------
NS_METHOD NS_GetCurrentToolkit(nsIToolkit* *aResult)
{
nsIToolkit* toolkit = nsnull;
nsresult rv = NS_OK;
PRStatus status;
// Create the TLS index the first time through...
if (0 == gToolkitTLSIndex) {
status = PR_NewThreadPrivateIndex(&gToolkitTLSIndex, NULL);
if (PR_FAILURE == status) {
rv = NS_ERROR_FAILURE;
}
}
if (NS_SUCCEEDED(rv)) {
toolkit = (nsIToolkit*)PR_GetThreadPrivate(gToolkitTLSIndex);
//
// Create a new toolkit for this thread...
//
if (!toolkit) {
toolkit = new nsToolkit();
if (!toolkit) {
rv = NS_ERROR_OUT_OF_MEMORY;
} else {
NS_ADDREF(toolkit);
toolkit->Init(PR_GetCurrentThread());
//
// The reference stored in the TLS is weak. It is removed in the
// nsToolkit destructor...
//
PR_SetThreadPrivate(gToolkitTLSIndex, (void*)toolkit);
}
} else {
NS_ADDREF(toolkit);
}
*aResult = toolkit;
}
return rv;
}

View File

@ -1,70 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef TOOLKIT_H
#define TOOLKIT_H
#include "nsIToolkit.h"
#include <gtk/gtk.h>
/**
* Wrapper around the thread running the message pump.
* The toolkit abstraction is necessary because the message pump must
* execute within the same thread that created the widget under Win32.
*/
class nsToolkit : public nsIToolkit
{
public:
nsToolkit();
virtual ~nsToolkit();
NS_DECL_ISUPPORTS
NS_IMETHOD Init(PRThread *aThread);
void CreateSharedGC(void);
GdkGC *GetSharedGC(void);
private:
GdkGC *mSharedGC;
};
#endif // TOOLKIT_H

File diff suppressed because it is too large Load Diff

View File

@ -1,436 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsWidget_h__
#define nsWidget_h__
#include "nsBaseWidget.h"
#include "nsWeakReference.h"
#include "nsIKBStateControl.h"
#include "nsIRegion.h"
#include "nsIRollupListener.h"
class nsILookAndFeel;
class nsIAppShell;
class nsIToolkit;
#include <gtk/gtk.h>
#include <gdk/gdkprivate.h>
#include "gtkmozbox.h"
#include "nsITimer.h"
#define NSRECT_TO_GDKRECT(ns,gdk) \
PR_BEGIN_MACRO \
gdk.x = ns.x; \
gdk.y = ns.y; \
gdk.width = ns.width; \
gdk.height = ns.height; \
PR_END_MACRO
#define NSCOLOR_TO_GDKCOLOR(n,g) \
PR_BEGIN_MACRO \
g.red = 256 * NS_GET_R(n); \
g.green = 256 * NS_GET_G(n); \
g.blue = 256 * NS_GET_B(n); \
PR_END_MACRO
/**
* Base of all GTK+ native widgets.
*/
class nsWidget : public nsBaseWidget, public nsIKBStateControl, public nsSupportsWeakReference
{
public:
nsWidget();
virtual ~nsWidget();
NS_DECL_ISUPPORTS_INHERITED
// nsIWidget
NS_IMETHOD Create(nsIWidget *aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
NS_IMETHOD Create(nsNativeWidget aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell = nsnull,
nsIToolkit *aToolkit = nsnull,
nsWidgetInitData *aInitData = nsnull);
NS_IMETHOD Destroy(void);
nsIWidget* GetParent(void);
virtual void OnDestroy();
NS_IMETHOD Show(PRBool state);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener *aListener, PRBool aDoCapture, PRBool aConsumeRollupEvent);
NS_IMETHOD IsVisible(PRBool &aState);
NS_IMETHOD ConstrainPosition(PRBool aAllowSlop, PRInt32 *aX, PRInt32 *aY);
NS_IMETHOD Move(PRInt32 aX, PRInt32 aY);
NS_IMETHOD Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint);
NS_IMETHOD Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth,
PRInt32 aHeight, PRBool aRepaint);
NS_IMETHOD Enable(PRBool aState);
NS_IMETHOD IsEnabled(PRBool *aState);
NS_IMETHOD SetFocus(PRBool aRaise);
virtual void LoseFocus(void);
PRBool OnResize(nsSizeEvent *event);
virtual PRBool OnResize(nsRect &aRect);
virtual PRBool OnMove(PRInt32 aX, PRInt32 aY);
NS_IMETHOD SetZIndex(PRInt32 aZIndex);
nsIFontMetrics *GetFont(void);
NS_IMETHOD SetFont(const nsFont &aFont);
NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
NS_IMETHOD SetCursor(nsCursor aCursor);
NS_IMETHOD SetColorMap(nsColorMap *aColorMap);
void* GetNativeData(PRUint32 aDataType);
NS_IMETHOD WidgetToScreen(const nsRect &aOldRect, nsRect &aNewRect);
NS_IMETHOD ScreenToWidget(const nsRect &aOldRect, nsRect &aNewRect);
NS_IMETHOD BeginResizingChildren(void);
NS_IMETHOD EndResizingChildren(void);
NS_IMETHOD GetPreferredSize(PRInt32& aWidth, PRInt32& aHeight);
NS_IMETHOD SetPreferredSize(PRInt32 aWidth, PRInt32 aHeight);
// Use this to set the name of a widget for normal widgets.. not the same as the nsWindow version
NS_IMETHOD SetTitle(const nsAString& aTitle);
virtual void ConvertToDeviceCoordinates(nscoord &aX, nscoord &aY);
// the following are nsWindow specific, and just stubbed here
NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect) { return NS_ERROR_FAILURE; }
NS_IMETHOD SetMenuBar(nsIMenuBar *aMenuBar) { return NS_ERROR_FAILURE; }
NS_IMETHOD ShowMenuBar(PRBool aShow) { return NS_ERROR_FAILURE; }
// *could* be done on a widget, but that would be silly wouldn't it?
NS_IMETHOD CaptureMouse(PRBool aCapture) { return NS_ERROR_FAILURE; }
NS_IMETHOD GetWindowClass(char *aClass);
NS_IMETHOD SetWindowClass(char *aClass);
NS_IMETHOD Validate();
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
NS_IMETHOD Invalidate(const nsRect &aRect, PRBool aIsSynchronous);
NS_IMETHOD InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous);
NS_IMETHOD Update(void);
NS_IMETHOD DispatchEvent(nsGUIEvent* event, nsEventStatus & aStatus);
// nsIKBStateControl
NS_IMETHOD ResetInputState();
NS_IMETHOD SetIMEOpenState(PRBool aState);
NS_IMETHOD GetIMEOpenState(PRBool* aState);
NS_IMETHOD SetIMEEnabled(PRUint32 aState);
NS_IMETHOD GetIMEEnabled(PRUint32* aState);
NS_IMETHOD CancelIMEComposition();
void InitEvent(nsGUIEvent& event, nsPoint* aPoint = nsnull);
// Utility functions
PRBool ConvertStatus(nsEventStatus aStatus)
{ return aStatus == nsEventStatus_eConsumeNoDefault; }
PRBool DispatchMouseEvent(nsMouseEvent& aEvent);
PRBool DispatchStandardEvent(PRUint32 aMsg);
PRBool DispatchFocus(nsGUIEvent &aEvent);
// are we a "top level" widget?
PRBool mIsToplevel;
virtual void DispatchSetFocusEvent(void);
virtual void DispatchLostFocusEvent(void);
virtual void DispatchActivateEvent(void);
virtual void DispatchDeactivateEvent(void);
#ifdef DEBUG
void IndentByDepth(FILE* out);
#endif
// Return the Gdk window used for rendering
virtual GdkWindow * GetRenderWindow(GtkObject * aGtkWidget);
// Return the Gdk window used for positioning, raising and lowering
virtual GdkWindow* GetLayeringWindow();
// get the toplevel window for this widget
virtual GtkWindow *GetTopLevelWindow(void);
PRBool OnKey(nsKeyEvent &aEvent);
PRBool OnText(nsTextEvent &aEvent) { return OnInput(aEvent); };
PRBool OnComposition(nsCompositionEvent &aEvent) { return OnInput(aEvent); };
PRBool OnInput(nsInputEvent &aEvent);
// this will return the GtkWidget * that owns this object
virtual GtkWidget *GetOwningWidget();
// the event handling code needs to let us know the time of the last event
static void SetLastEventTime(guint32 aTime);
static void GetLastEventTime(guint32 *aTime);
static void DropMotionTarget(void);
// inform the widget code that we are about to do a drag - it must
// release the sButtonMotionTarget if it is set.
static void DragStarted(void) { DropMotionTarget(); };
virtual void ThemeChanged();
protected:
virtual void InitCallbacks(char * aName = nsnull);
NS_IMETHOD CreateNative(GtkObject *parentWindow) { return NS_OK; }
nsresult CreateWidget(nsIWidget *aParent,
const nsRect &aRect,
EVENT_CALLBACK aHandleEventFunction,
nsIDeviceContext *aContext,
nsIAppShell *aAppShell,
nsIToolkit *aToolkit,
nsWidgetInitData *aInitData,
nsNativeWidget aNativeParent = nsnull);
PRBool DispatchWindowEvent(nsGUIEvent* event);
// this is the "native" destroy code that will destroy any
// native windows / widgets for this logical widget
virtual void DestroyNative(void);
// Sets font for widgets
virtual void SetFontNative(GdkFont *aFont);
// Sets backround for widgets
virtual void SetBackgroundColorNative(GdkColor *aColorNor,
GdkColor *aColorBri,
GdkColor *aColorDark);
// this is set when a given widget has the focus.
PRBool mHasFocus;
// if anyone uses this for public access other than the key
// press/release code on the main window, i will kill you. pav
public:
// this is the current GdkSuperWin with the focus
static nsWidget *sFocusWindow;
protected:
//
//////////////////////////////////////////////////////////////////
//
// GTK signal installers
//
//////////////////////////////////////////////////////////////////
void InstallEnterNotifySignal(GtkWidget * aWidget);
void InstallLeaveNotifySignal(GtkWidget * aWidget);
void InstallButtonPressSignal(GtkWidget * aWidget);
void InstallButtonReleaseSignal(GtkWidget * aWidget);
virtual
void InstallFocusInSignal(GtkWidget * aWidget);
virtual
void InstallFocusOutSignal(GtkWidget * aWidget);
void InstallRealizeSignal(GtkWidget * aWidget);
void AddToEventMask(GtkWidget * aWidget,
gint aEventMask);
//////////////////////////////////////////////////////////////////
//
// OnSomething handlers
//
//////////////////////////////////////////////////////////////////
virtual void OnMotionNotifySignal(GdkEventMotion * aGdkMotionEvent);
virtual void OnEnterNotifySignal(GdkEventCrossing * aGdkCrossingEvent);
virtual void OnLeaveNotifySignal(GdkEventCrossing * aGdkCrossingEvent);
virtual void OnButtonPressSignal(GdkEventButton * aGdkButtonEvent);
virtual void OnButtonReleaseSignal(GdkEventButton * aGdkButtonEvent);
virtual void OnFocusInSignal(GdkEventFocus * aGdkFocusEvent);
virtual void OnFocusOutSignal(GdkEventFocus * aGdkFocusEvent);
virtual void OnRealize(GtkWidget *aWidget);
virtual void OnDestroySignal(GtkWidget* aGtkWidget);
// Static method used to trampoline to OnDestroySignal
static gint DestroySignal(GtkWidget * aGtkWidget,
nsWidget* aWidget);
public:
virtual void IMECommitEvent(GdkEventKey *aEvent);
// This MUST be called after you change the widget bounds
// or after the parent's size changes
// or when you show the widget
// We will decide whether to really show the widget or not
// We will hide the widget if it doesn't overlap the parent bounds
// This reduces problems with 16-bit coordinates wrapping.
virtual void ResetInternalVisibility();
// Reestablish the correct Z-ordering of this widget among
// its siblings
void ResetZOrder();
protected:
// override this method to do whatever you have to do to make this
// widget visible or invisibile --- i.e., the real work of Show()
virtual void SetInternalVisibility(PRBool aVisible);
//////////////////////////////////////////////////////////////////
//
// GTK widget signals
//
//////////////////////////////////////////////////////////////////
static gint EnterNotifySignal(GtkWidget * aWidget,
GdkEventCrossing * aGdkCrossingEvent,
gpointer aData);
static gint LeaveNotifySignal(GtkWidget * aWidget,
GdkEventCrossing * aGdkCrossingEvent,
gpointer aData);
static gint ButtonPressSignal(GtkWidget * aWidget,
GdkEventButton * aGdkButtonEvent,
gpointer aData);
static gint ButtonReleaseSignal(GtkWidget * aWidget,
GdkEventButton * aGdkButtonEvent,
gpointer aData);
static gint RealizeSignal(GtkWidget * aWidget,
gpointer aData);
static gint FocusInSignal(GtkWidget * aWidget,
GdkEventFocus * aGdkFocusEvent,
gpointer aData);
static gint FocusOutSignal(GtkWidget * aWidget,
GdkEventFocus * aGdkFocusEvent,
gpointer aData);
protected:
//////////////////////////////////////////////////////////////////
//
// GTK event support methods
//
//////////////////////////////////////////////////////////////////
void InstallSignal(GtkWidget * aWidget,
gchar * aSignalName,
GtkSignalFunc aSignalFunction);
void InitMouseEvent(GdkEventButton * aGdkButtonEvent,
nsMouseEvent & anEvent);
#ifdef DEBUG
nsCAutoString debug_GetName(GtkObject * aGtkWidget);
nsCAutoString debug_GetName(GtkWidget * aGtkWidget);
PRInt32 debug_GetRenderXID(GtkObject * aGtkWidget);
PRInt32 debug_GetRenderXID(GtkWidget * aGtkWidget);
#endif
GtkWidget *mWidget;
// our mozbox for those native widgets
GtkWidget *mMozBox;
nsCOMPtr<nsIWidget> mParent;
// This is the composite update area (union of all the calls to
// Invalidate)
nsCOMPtr<nsIRegion> mUpdateArea;
PRUint32 mPreferredWidth, mPreferredHeight;
PRPackedBool mListenForResizes;
PRPackedBool mShown;
PRPackedBool mInternalShown;
// this is the rollup listener variables
static nsCOMPtr<nsIRollupListener> gRollupListener;
static nsWeakPtr gRollupWidget;
// this is the last time that an event happened. we keep this
// around so that we can synth drag events properly
static guint32 sLastEventTime;
private:
// this will keep track of whether or not the gdk handler
// is installed yet
static PRBool mGDKHandlerInstalled;
// this will keep track of whether or not we've told the drag
// service how to call back into us to get the last event time
static PRBool sTimeCBSet;
//
// Keep track of the last widget being "dragged"
//
public:
static nsWidget *sButtonMotionTarget;
static gint sButtonMotionRootX;
static gint sButtonMotionRootY;
static gint sButtonMotionWidgetX;
static gint sButtonMotionWidgetY;
};
#endif /* nsWidget_h__ */

View File

@ -1,158 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzzard <blizzard@mozilla.org>
* Stuart Parmenter <pavlov@netscape.com>
* Dan Rosen <dr@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIGenericFactory.h"
#include "nsIModule.h"
#include "nsCOMPtr.h"
#include "nsWidgetsCID.h"
#include "nsWindow.h"
#include "nsAppShell.h"
#include "nsAppShellSingleton.h"
#include "nsToolkit.h"
#include "nsLookAndFeel.h"
#include "nsTransferable.h"
#include "nsClipboard.h"
#include "nsClipboardHelper.h"
#include "nsHTMLFormatConverter.h"
#include "nsDragService.h"
#include "nsSound.h"
#include "nsBidiKeyboard.h"
#include "nsScreenManagerGtk.h"
#ifdef NATIVE_THEME_SUPPORT
#include "nsNativeThemeGTK.h"
#endif
#include "nsGtkIMEHelper.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindow)
NS_GENERIC_FACTORY_CONSTRUCTOR(ChildWindow)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsToolkit)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsLookAndFeel)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsTransferable)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboard)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsClipboardHelper)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsHTMLFormatConverter)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDragService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsSound)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBidiKeyboard)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerGtk)
#ifdef NATIVE_THEME_SUPPORT
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNativeThemeGTK)
#endif
static const nsModuleComponentInfo components[] =
{
{ "Gtk nsWindow",
NS_WINDOW_CID,
"@mozilla.org/widgets/window/gtk;1",
nsWindowConstructor },
{ "Gtk Child nsWindow",
NS_CHILD_CID,
"@mozilla.org/widgets/child_window/gtk;1",
ChildWindowConstructor },
{ "Gtk AppShell",
NS_APPSHELL_CID,
"@mozilla.org/widget/appshell/gtk;1",
nsAppShellConstructor },
{ "Gtk Toolkit",
NS_TOOLKIT_CID,
"@mozilla.org/widget/toolkit/gtk;1",
nsToolkitConstructor },
{ "Gtk Look And Feel",
NS_LOOKANDFEEL_CID,
"@mozilla.org/widget/lookandfeel;1",
nsLookAndFeelConstructor },
{ "Gtk Sound",
NS_SOUND_CID,
// "@mozilla.org/widget/sound/gtk;1"
"@mozilla.org/sound;1",
nsSoundConstructor },
{ "Transferable",
NS_TRANSFERABLE_CID,
// "@mozilla.org/widget/transferable/gtk;1",
"@mozilla.org/widget/transferable;1",
nsTransferableConstructor },
{ "Gtk Clipboard",
NS_CLIPBOARD_CID,
// "@mozilla.org/widget/clipboard/gtk;1",
"@mozilla.org/widget/clipboard;1",
nsClipboardConstructor },
{ "Clipboard Helper",
NS_CLIPBOARDHELPER_CID,
"@mozilla.org/widget/clipboardhelper;1",
nsClipboardHelperConstructor },
{ "HTML Format Converter",
NS_HTMLFORMATCONVERTER_CID,
"@mozilla.org/widget/htmlformatconverter;1",
nsHTMLFormatConverterConstructor },
{ "Gtk Drag Service",
NS_DRAGSERVICE_CID,
// "@mozilla.org/widget/dragservice/gtk;1",
"@mozilla.org/widget/dragservice;1",
nsDragServiceConstructor },
{ "Gtk Bidi Keyboard",
NS_BIDIKEYBOARD_CID,
"@mozilla.org/widget/bidikeyboard;1",
nsBidiKeyboardConstructor },
{ "Gtk Screen Manager",
NS_SCREENMANAGER_CID,
"@mozilla.org/gfx/screenmanager;1",
nsScreenManagerGtkConstructor },
#ifdef NATIVE_THEME_SUPPORT
{ "Native Theme Renderer",
NS_THEMERENDERER_CID,
"@mozilla.org/chrome/chrome-native-theme;1",
nsNativeThemeGTKConstructor }
#endif
};
PR_STATIC_CALLBACK(void)
nsWidgetGTKModuleDtor(nsIModule *self)
{
nsWindow::ReleaseGlobals();
nsGtkIMEHelper::Shutdown();
nsAppShellShutdown(self);
}
NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(nsWidgetGTKModule,
components,
nsAppShellInit,
nsWidgetGTKModuleDtor)

File diff suppressed because it is too large Load Diff

View File

@ -1,439 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsWindow_h__
#define nsWindow_h__
#include "nsISupports.h"
#include "nsWidget.h"
#include "nsString.h"
#include "nsIDragService.h"
#include "gtkmozarea.h"
#include "gdksuperwin.h"
#ifdef USE_XIM
#include "pldhash.h"
class nsIMEGtkIC;
class nsIMEPreedit;
#endif // USE_XIM
class nsFont;
class nsIAppShell;
/**
* Native GTK+ window wrapper.
*/
class nsWindow : public nsWidget
{
public:
// nsIWidget interface
nsWindow();
virtual ~nsWindow();
static void ReleaseGlobals();
NS_DECL_ISUPPORTS_INHERITED
NS_IMETHOD WidgetToScreen(const nsRect &aOldRect, nsRect &aNewRect);
NS_IMETHOD PreCreateWidget(nsWidgetInitData *aWidgetInitData);
virtual void* GetNativeData(PRUint32 aDataType);
NS_IMETHOD Scroll(PRInt32 aDx, PRInt32 aDy, nsRect *aClipRect);
NS_IMETHOD ScrollWidgets(PRInt32 aDx, PRInt32 aDy);
NS_IMETHOD ScrollRect(nsRect &aSrcRect, PRInt32 aDx, PRInt32 aDy);
NS_IMETHOD SetTitle(const nsAString& aTitle);
NS_IMETHOD Show(PRBool aShow);
NS_IMETHOD CaptureMouse(PRBool aCapture);
NS_IMETHOD ConstrainPosition(PRBool aAllowSlop,
PRInt32 *aX, PRInt32 *aY);
NS_IMETHOD Move(PRInt32 aX, PRInt32 aY);
NS_IMETHOD Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepaint);
NS_IMETHOD Resize(PRInt32 aX, PRInt32 aY, PRInt32 aWidth,
PRInt32 aHeight, PRBool aRepaint);
NS_IMETHOD BeginResizingChildren(void);
NS_IMETHOD EndResizingChildren(void);
NS_IMETHOD GetScreenBounds(nsRect &aRect);
NS_IMETHOD CaptureRollupEvents(nsIRollupListener * aListener,
PRBool aDoCapture,
PRBool aConsumeRollupEvent);
NS_IMETHOD Validate();
NS_IMETHOD Invalidate(PRBool aIsSynchronous);
NS_IMETHOD Invalidate(const nsRect &aRect, PRBool aIsSynchronous);
NS_IMETHOD InvalidateRegion(const nsIRegion* aRegion, PRBool aIsSynchronous);
NS_IMETHOD SetBackgroundColor(const nscolor &aColor);
NS_IMETHOD SetCursor(nsCursor aCursor);
NS_IMETHOD Enable (PRBool aState);
NS_IMETHOD IsEnabled (PRBool *aState);
NS_IMETHOD SetFocus(PRBool aRaise);
NS_IMETHOD GetAttention(PRInt32 aCycleCount);
NS_IMETHOD Destroy();
NS_IMETHOD SetParent(nsIWidget* aNewParent);
void ResizeTransparencyBitmap(PRInt32 aNewWidth, PRInt32 aNewHeight);
void ApplyTransparencyBitmap();
#ifdef MOZ_XUL
NS_IMETHOD SetWindowTranslucency(PRBool aTransparent);
NS_IMETHOD GetWindowTranslucency(PRBool& aTransparent);
NS_IMETHOD UpdateTranslucentWindowAlpha(const nsRect& aRect, PRUint8* aAlphas);
NS_IMETHOD HideWindowChrome(PRBool aShouldHide);
NS_IMETHOD MakeFullScreen(PRBool aFullScreen);
#endif
NS_IMETHOD SetIcon(const nsAString& aIcon);
GdkCursor *GtkCreateCursor(nsCursor aCursorType);
virtual void LoseFocus(void);
// nsIKBStateControl
NS_IMETHOD ResetInputState();
void QueueDraw();
void UnqueueDraw();
void DoPaint(nsIRegion *aClipRegion);
static gboolean UpdateIdle (gpointer data);
// get the toplevel window for this widget
virtual GtkWindow *GetTopLevelWindow(void);
NS_IMETHOD Update(void);
virtual void OnMotionNotifySignal(GdkEventMotion *aGdkMotionEvent);
virtual void OnEnterNotifySignal(GdkEventCrossing *aGdkCrossingEvent);
virtual void OnLeaveNotifySignal(GdkEventCrossing *aGdkCrossingEvent);
virtual void OnButtonPressSignal(GdkEventButton *aGdkButtonEvent);
virtual void OnButtonReleaseSignal(GdkEventButton *aGdkButtonEvent);
virtual void OnFocusInSignal(GdkEventFocus * aGdkFocusEvent);
virtual void OnFocusOutSignal(GdkEventFocus * aGdkFocusEvent);
virtual void InstallFocusInSignal(GtkWidget * aWidget);
virtual void InstallFocusOutSignal(GtkWidget * aWidget);
void HandleGDKEvent(GdkEvent *event);
gint ConvertBorderStyles(nsBorderStyle bs);
void InvalidateWindowPos(void);
// in nsWidget now
// virtual PRBool OnResize(nsSizeEvent &aEvent);
void HandleXlibConfigureNotifyEvent(XEvent *event);
// Return the GtkMozArea that is the nearest parent of this widget
virtual GtkWidget *GetOwningWidget();
// Get the owning window for this window
nsWindow *GetOwningWindow();
// Return the type of the window that is the toplevel mozilla window
// for this (possibly) inner window
nsWindowType GetOwningWindowType();
// Return the Gdk window used for rendering
virtual GdkWindow * GetRenderWindow(GtkObject * aGtkWidget);
// this is the "native" destroy code that will destroy any
// native windows / widgets for this logical widget
virtual void DestroyNative(void);
// grab in progress
PRBool GrabInProgress(void);
// drag in progress
static PRBool DragInProgress(void);
// XXX Chris - fix these
// virtual void OnButtonPressSignal(GdkEventButton * aGdkButtonEvent);
// this will get the nsWindow with the grab. The return will not be
// addrefed.
static nsWindow *GetGrabWindow(void);
GdkWindow *GetGdkGrabWindow(void);
// Return the Gdk window used for positioning, raising and lowering
virtual GdkWindow* GetLayeringWindow();
virtual void DispatchSetFocusEvent(void);
virtual void DispatchLostFocusEvent(void);
virtual void DispatchActivateEvent(void);
virtual void DispatchDeactivateEvent(void);
PRBool mBlockMozAreaFocusIn;
void HandleMozAreaFocusIn(void);
void HandleMozAreaFocusOut(void);
// Window icon cache
static PRBool IconEntryMatches(PLDHashTable* aTable,
const PLDHashEntryHdr* aHdr,
const void* aKey);
static void ClearIconEntry(PLDHashTable* aTable, PLDHashEntryHdr* aHdr);
protected:
virtual void ResetInternalVisibility();
virtual void SetInternalVisibility(PRBool aVisible);
virtual void OnRealize(GtkWidget *aWidget);
virtual void OnDestroySignal(GtkWidget* aGtkWidget);
//////////////////////////////////////////////////////////////////////
virtual void InitCallbacks(char * aName = nsnull);
NS_IMETHOD CreateNative(GtkObject *parentWidget);
PRBool mIsTooSmall;
GtkWidget *mShell; /* used for toplevel windows */
GdkSuperWin *mSuperWin;
GtkWidget *mMozArea;
GtkWidget *mMozAreaClosestParent;
PRBool GetWindowPos(nscoord &x, nscoord &y);
nscoord mCachedX, mCachedY;
// are we doing a grab?
static PRBool sIsGrabbing;
static nsWindow *sGrabWindow;
static PRBool sIsDraggingOutOf;
// our wonderful hash table with our window -> nsWindow * lookup
static GHashTable *mWindowLookupTable;
// this will query all of it's children trying to find a child
// that has a containing rectangle and return it.
static Window GetInnerMostWindow(Window aOriginWindow,
Window aWindow,
nscoord x, nscoord y,
nscoord *retx, nscoord *rety,
int depth);
// given an X window this will find the nsWindow * for it.
static nsWindow *GetnsWindowFromXWindow(Window aWindow);
static gint ClientEventSignal(GtkWidget* widget, GdkEventClient* event, void* data);
virtual void ThemeChanged();
// all of our DND stuff
// this is the last window that had a drag event happen on it.
static nsWindow *mLastDragMotionWindow;
static GdkCursor *gsGtkCursorCache[eCursorCount];
void InitDragEvent(nsMouseEvent &aEvent);
void UpdateDragStatus(nsMouseEvent &aEvent,
GdkDragContext *aDragContext,
nsIDragService *aDragService);
// DragBegin not needed ?
// always returns TRUE
static gint DragMotionSignal (GtkWidget * aWidget,
GdkDragContext *aDragContext,
gint aX,
gint aY,
guint aTime,
void *aData);
gint OnDragMotionSignal (GtkWidget * aWidget,
GdkDragContext *aDragContext,
gint aX,
gint aY,
guint aTime,
void *aData);
static void DragLeaveSignal (GtkWidget * aWidget,
GdkDragContext *aDragContext,
guint aTime,
gpointer aData);
void OnDragLeaveSignal (GtkWidget * aWidget,
GdkDragContext *aDragContext,
guint aTime,
gpointer aData);
// always returns TRUE
static gint DragDropSignal (GtkWidget *aWidget,
GdkDragContext *aDragContext,
gint aX,
gint aY,
guint aTime,
void *aData);
gint OnDragDropSignal (GtkWidget *aWidget,
GdkDragContext *aDragContext,
gint aX,
gint aY,
guint aTime,
void *aData);
// when the data has been received
static void DragDataReceived (GtkWidget *aWidget,
GdkDragContext *aDragContext,
gint aX,
gint aY,
GtkSelectionData *aSelectionData,
guint aInfo,
guint32 aTime,
gpointer aData);
void OnDragDataReceived (GtkWidget *aWidget,
GdkDragContext *aDragContext,
gint aX,
gint aY,
GtkSelectionData *aSelectionData,
guint aInfo,
guint32 aTime,
gpointer aData);
// these are drag and drop events that aren't generated by widget
// events but we do synthesize
void OnDragLeave(void);
void OnDragEnter(nscoord aX, nscoord aY);
// this is everything we need to be able to fire motion events
// repeatedly
GtkWidget *mDragMotionWidget;
GdkDragContext *mDragMotionContext;
gint mDragMotionX;
gint mDragMotionY;
guint mDragMotionTime;
guint mDragMotionTimerID;
nsCOMPtr<nsITimer> mDragLeaveTimer;
void ResetDragMotionTimer (GtkWidget *aWidget,
GdkDragContext *aDragContext,
gint aX,
gint aY,
guint aTime);
void FireDragMotionTimer (void);
void FireDragLeaveTimer (void);
static guint DragMotionTimerCallback (gpointer aClosure);
static void DragLeaveTimerCallback (nsITimer *aTimer, void *aClosure);
// Hash table for icon spec -> icon set lookup
static PLDHashTable* sIconCache;
#ifdef USE_XIM
protected:
static GdkFont *gPreeditFontset;
static GdkFont *gStatusFontset;
static GdkIMStyle gInputStyle;
static PLDHashTable gXICLookupTable;
PRPackedBool mIMEEnable;
PRPackedBool mIMECallComposeStart;
PRPackedBool mIMECallComposeEnd;
PRPackedBool mIMEIsBeingActivate;
nsWindow* mIMEShellWindow;
void SetXICSpotLocation(nsIMEGtkIC* aXIC, nsPoint aPoint);
void SetXICBaseFontSize(nsIMEGtkIC* aXIC, int height);
nsCOMPtr<nsITimer> mICSpotTimer;
static void ICSpotCallback(nsITimer* aTimer, void* aClosure);
nsresult KillICSpotTimer();
nsresult PrimeICSpotTimer();
nsresult UpdateICSpot(nsIMEGtkIC* aXIC);
int mXICFontSize;
public:
nsIMEGtkIC* IMEGetInputContext(PRBool aCreate);
void ime_preedit_start();
void ime_preedit_draw(nsIMEGtkIC* aXIC);
void ime_preedit_done();
void ime_status_draw();
void IMEUnsetFocusWindow();
void IMESetFocusWindow();
void IMEGetShellWindow();
void IMEDestroyIC();
void IMEBeingActivate(PRBool aActive);
#endif // USE_XIM
protected:
void IMEComposeStart(guint aTime);
void IMEComposeText(GdkEventKey*,
const PRUnichar *aText,
const PRInt32 aLen,
const char *aFeedback);
void IMEComposeEnd(guint aTime);
public:
virtual void IMECommitEvent(GdkEventKey *aEvent);
private:
PRUnichar* mIMECompositionUniString;
PRInt32 mIMECompositionUniStringSize;
nsresult SetMiniIcon(GdkPixmap *window_pixmap,
GdkBitmap *window_mask);
nsresult SetIcon(GdkPixmap *window_pixmap,
GdkBitmap *window_mask);
void NativeGrab(PRBool aGrab);
PRPackedBool mLastGrabFailed;
PRPackedBool mIsUpdating;
PRPackedBool mLeavePending;
PRPackedBool mRestoreFocus;
/**
* Whether this widget has child widgets that are not linked into
* its explicit nsIWidget child list
*/
PRPackedBool mHasAnonymousChildren;
PRPackedBool mIsTranslucent;
// This bitmap tracks which pixels are transparent. We don't support
// full translucency at this time; each pixel is either fully opaque
// or fully transparent.
gchar* mTransparencyBitmap;
void DestroyNativeChildren(void);
GtkWindow *mTransientParent;
};
//
// A child window is a window with different style
//
class ChildWindow : public nsWindow {
public:
ChildWindow();
~ChildWindow();
};
#endif // Window_h__

View File

@ -1,10 +0,0 @@
[gecko]
#if SHARED_LIBRARY
dist/bin/components/@SHARED_LIBRARY@
#else
!staticcomp @LIBRARY@ @MODULE_NAME@
#endif
[xpfe-browser]
dist/bin/icons/mozicon50.xpm
dist/bin/icons/mozicon16.xpm

View File

@ -1,79 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org Code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = widget
LIBRARY_NAME = gtksuperwin
EXPORT_LIBRARY = 1
LIBXUL_LIBRARY = 1
PACKAGE_FILE = gtksuperwin.pkg
CSRCS = \
gdksuperwin.c \
gtkmozarea.c \
gtkmozbox.c
EXTRA_DSO_LDOPTS += $(MOZ_GTK_LDFLAGS)
EXPORTS = gdksuperwin.h \
gtkmozarea.h \
gtkmozbox.h
REQUIRES = xpcom
include $(topsrcdir)/config/rules.mk
CFLAGS += $(MOZ_GTK_CFLAGS)
DEFINES += -D_IMPL_GTKSUPERWIN_API -DUSE_XIM
ifeq ($(OS_ARCH), OpenVMS)
DEFINES += -DGENERIC_MOTIF_REDEFINES
endif
INCLUDES += \
-I$(srcdir) \
$(NULL)

View File

@ -1,729 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org Code.
*
* The Initial Developer of the Original Code is
* Owen Taylor <otaylor@redhat.com> and Christopher Blizzard <blizzard@redhat.com>.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "gdksuperwin.h"
static void gdk_superwin_class_init(GdkSuperWinClass *klass);
static void gdk_superwin_init(GdkSuperWin *superwin);
static void gdk_superwin_expose_area (GdkSuperWin *superwin,
gint x,
gint y,
gint width,
gint height);
static void gdk_superwin_flush(GdkSuperWin *superwin);
static void gdk_superwin_destroy(GtkObject *object);
static void gdk_superwin_add_translation(GdkSuperWin *superwin, unsigned long serial,
gint dx, gint dy);
static void gdk_superwin_add_antiexpose (GdkSuperWin *superwin, unsigned long serial,
gint x, gint y,
gint width, gint height);
static void gdk_superwin_handle_expose (GdkSuperWin *superwin, XEvent *xevent,
GdkRegion **region, gboolean dont_recurse);
static Bool gdk_superwin_expose_predicate(Display *display,
XEvent *xevent,
XPointer arg);
typedef struct _GdkSuperWinTranslate GdkSuperWinTranslate;
enum {
GDK_SUPERWIN_TRANSLATION = 1,
GDK_SUPERWIN_ANTIEXPOSE
};
struct _GdkSuperWinTranslate
{
int type;
unsigned long serial;
union {
struct {
gint dx;
gint dy;
} translation;
struct {
GdkRectangle rect;
} antiexpose;
} data;
};
GtkType
gdk_superwin_get_type(void)
{
static GtkType superwin_type = 0;
if (!superwin_type)
{
static const GtkTypeInfo superwin_info =
{
"GtkSuperWin",
sizeof(GdkSuperWin),
sizeof(GdkSuperWinClass),
(GtkClassInitFunc) gdk_superwin_class_init,
(GtkObjectInitFunc) gdk_superwin_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
superwin_type = gtk_type_unique (gtk_object_get_type(), &superwin_info);
}
return superwin_type;
}
static void
gdk_superwin_class_init(GdkSuperWinClass *klass)
{
GtkObjectClass *object_class;
object_class = GTK_OBJECT_CLASS(klass);
object_class->destroy = gdk_superwin_destroy;
}
static void
gdk_superwin_init(GdkSuperWin *superwin)
{
}
static GdkFilterReturn gdk_superwin_bin_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data);
static GdkFilterReturn gdk_superwin_shell_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data);
static gboolean gravity_works;
GdkSuperWin *
gdk_superwin_new (GdkWindow *parent_window,
guint x,
guint y,
guint width,
guint height)
{
GdkWindowAttr attributes;
gint attributes_mask;
Window bin_xwindow;
Display *xdisplay;
XSetWindowAttributes xattr;
unsigned long xattr_mask;
GdkSuperWin *superwin = gtk_type_new(GDK_TYPE_SUPERWIN);
superwin->translate_queue = NULL;
superwin->shell_func = NULL;
superwin->paint_func = NULL;
superwin->flush_func = NULL;
superwin->func_data = NULL;
superwin->notify = NULL;
/* Create the shell (clipping) window */
attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = x;
attributes.y = y;
attributes.width = width;
attributes.height = height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.colormap = gdk_rgb_get_cmap();
attributes.visual = gdk_rgb_get_visual();
attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK;
attributes_mask = GDK_WA_VISUAL | GDK_WA_X | GDK_WA_Y | GDK_WA_COLORMAP;
superwin->shell_window = gdk_window_new (parent_window,
&attributes, attributes_mask);
/* set the back pixmap to None so that you don't end up with the gtk
default which is BlackPixel */
gdk_window_set_back_pixmap (superwin->shell_window, NULL, FALSE);
/* if we failed to create a window, die a horrible death */
g_assert((superwin->shell_window));
/* Create the bin window for drawing */
attributes.x = 0;
attributes.y = 0;
attributes.event_mask = GDK_EXPOSURE_MASK;
superwin->bin_window = gdk_window_new (superwin->shell_window,
&attributes, attributes_mask);
/* set the back pixmap to None so that you don't end up with the gtk
default which is BlackPixel */
gdk_window_set_back_pixmap (superwin->bin_window, NULL, FALSE);
/* set the backing store for the bin window */
bin_xwindow = GDK_WINDOW_XWINDOW(superwin->bin_window);
xdisplay = GDK_WINDOW_XDISPLAY(superwin->bin_window);
/* XXX should we make this Always? */
xattr.backing_store = WhenMapped;
xattr_mask = CWBackingStore;
/* XChangeWindowAttributes(xdisplay, bin_xwindow, xattr_mask, &xattr); */
gdk_window_show (superwin->bin_window);
gdk_window_add_filter (superwin->shell_window, gdk_superwin_shell_filter, superwin);
gdk_window_add_filter (superwin->bin_window, gdk_superwin_bin_filter, superwin);
gravity_works = gdk_window_set_static_gravities (superwin->bin_window, TRUE);
return superwin;
}
/* XXX this should really be part of the object... */
/* XXX and it should chain up to the object's destructor */
void gdk_superwin_destroy(GtkObject *object)
{
GdkSuperWin *superwin = NULL;
g_return_if_fail(object != NULL);
g_return_if_fail(GTK_IS_OBJECT(object));
g_return_if_fail(GTK_OBJECT_CONSTRUCTED(object));
g_return_if_fail(GDK_IS_SUPERWIN(object));
superwin = GDK_SUPERWIN(object);
gdk_window_remove_filter(superwin->shell_window,
gdk_superwin_shell_filter,
superwin);
gdk_window_remove_filter(superwin->bin_window,
gdk_superwin_bin_filter,
superwin);
gdk_window_destroy(superwin->bin_window);
gdk_window_destroy(superwin->shell_window);
if (superwin->translate_queue) {
GSList *tmp_list = superwin->translate_queue;
while (tmp_list) {
g_free(tmp_list->data);
tmp_list = tmp_list->next;
}
g_slist_free(superwin->translate_queue);
}
}
void gdk_superwin_reparent(GdkSuperWin *superwin,
GdkWindow *parent_window)
{
gdk_window_reparent(superwin->shell_window,
parent_window, 0, 0);
}
void
gdk_superwin_scroll (GdkSuperWin *superwin,
gint dx,
gint dy)
{
gint width, height;
gint first_resize_x = 0;
gint first_resize_y = 0;
gint first_resize_width = 0;
gint first_resize_height = 0;
unsigned long first_resize_serial = 0;
unsigned long move_serial = 0;
unsigned long last_resize_serial = 0;
gint move_x = 0;
gint move_y = 0;
/* get the current dimensions of the window */
gdk_window_get_size (superwin->shell_window, &width, &height);
/* calculate the first resize. */
/* for the first move resize, the width + height default to the
width and height of the window. */
first_resize_width = width;
first_resize_height = height;
/* if scrolling left ( dx < 0 ) need to extend window right by
ABS(dx) and left side of window won't move. */
if (dx < 0) {
/* left side of the window doesn't move. */
first_resize_x = 0;
/* right side of window will be the width + the offset of the
scroll */
first_resize_width = width + ABS(dx);
}
/* if scrolling right ( dx > 0 ) need to extend window left by
ABS(dx) and right side of the window doesn't move */
if (dx > 0) {
/* left side of the window will be offset to the left by ABS(dx) (
x will be < 0 ) */
first_resize_x = -dx;
/* right side of the window won't move. We have to add the offset
to the width so that it doesn't. */
first_resize_width = width + dx;
}
/* if scrolling down ( dy < 0 ) need to extend window down by
ABS(dy) and top of window won't move */
if (dy < 0) {
/* top of window not moving */
first_resize_y = 0;
/* bottom of window will be the height + the offset of the scroll */
first_resize_height = height + ABS(dy);
}
/* if scrolling up ( dy > 0 ) need to extend window up by ABS(dy)
and bottom of window won't move. */
if (dy > 0) {
/* top of the window will be moved up by ABS(dy) ( y will be < 0 ) */
first_resize_y = -dy;
/* this will cause the bottom of the window not to move since
we're moving y by the offset up. */
first_resize_height = height + dy;
}
/* calculate our move offsets */
/* if scrolling left ( dx < 0 ) we need to move the window left by
ABS(dx) */
if (dx < 0) {
/* dx will be negative - this will move it left */
move_x = dx;
}
/* if scrolling right ( dx > 0 ) we need to move the window right by
ABS(dx). Because we already resized the window to -dx by moving
it to zero we are actually moving the window to the right. */
if (dx > 0) {
move_x = 0;
}
/* If scrolling down ( dy < 0 ) we need to move the window up by
ABS(dy) */
if (dy < 0) {
/* dy will be negative - this will move it up */
move_y = dy;
}
/* If scrolling up ( dy > 0 ) we need to move the window down by
ABS(dy). In this case we already resized the top of the window
to -dy so by moving it to zero we are actually moving the window
down. */
if (dy > 0) {
move_y = 0;
}
/* save the serial of the first request */
first_resize_serial = NextRequest(GDK_DISPLAY());
/* move our window */
gdk_window_move_resize(superwin->bin_window,
first_resize_x, first_resize_y,
first_resize_width, first_resize_height);
/* window move - this move will cause all of the exposes to happen
and is where all the translation magic has to be applied. we
need to save the serial of this operation since any expose events
with serial request numbers lower than it will have to have their
coordinates translated into the new coordinate system. */
move_serial = NextRequest(GDK_DISPLAY());
gdk_window_move(superwin->bin_window,
move_x, move_y);
/* last resize. This will resize the window to its original
position. */
/* save the request of the last resize */
last_resize_serial = NextRequest(GDK_DISPLAY());
gdk_window_move_resize(superwin->bin_window,
0, 0, width, height);
/* now that we have moved everything, repaint the damaged areas */
/* if scrolling left ( dx < 0 ) moving window left so expose area at
the right of the window. Clip the width of the exposure to the
width of the window or the offset, whichever is smaller. Also
clip the start to the origin ( 0 ) if the width minus the
absolute value of the offset is < 0 to handle > 1 page
scrolls. */
if (dx < 0) {
gdk_superwin_expose_area(superwin, MAX(0, width - ABS(dx)), 0,
MIN(width, ABS(dx)), height);
/* If we've exposed this area add an antiexpose for it. When the
window was moved left the expose will be offset by ABS(dx).
For greated than one page scrolls, the expose will be offset by
the actual offset of the move, hence the MAX(height,
ABS(dy)). */
gdk_superwin_add_antiexpose(superwin, move_serial,
MAX(width, ABS(dx)),
0, MIN(width, ABS(dx)), height);
}
/* if scrolling right ( dx > 0 ) moving window right so expose area
at the left of the window. Clip the width of the exposure to the
width of the window or the offset, whichever is smaller. */
if (dx > 0) {
gdk_superwin_expose_area(superwin, 0, 0,
MIN(width, ABS(dx)), height);
/* If we've exposed this area add an antiexpose for it. */
gdk_superwin_add_antiexpose(superwin, move_serial,
0, 0, MIN(width, ABS(dx)), height);
}
/* if scrolling down ( dy < 0 ) moving window up so expose area at
the bottom of the window. Clip the exposed area to the height of
the window or the offset, whichever is smaller. Also clip the
start to the origin ( 0 ) if the the height minus the absolute
value of the offset is < 0 to handle > 1 page scrolls. */
if (dy < 0) {
gdk_superwin_expose_area(superwin, 0, MAX(0, height - ABS(dy)),
width, MIN(height, ABS(dy)));
/* If we've exposed this area add an antiexpose for it. When the
was moved up before the second move the expose will be offset
by ABS(dy). For greater than one page scrolls, the expose will
be offset by actual offset of the move, hence the MAX(height,
ABS(dy)). */
gdk_superwin_add_antiexpose(superwin, move_serial,
0,
MAX(height, ABS(dy)),
width, MIN(height, ABS(dy)));
}
/* if scrolling up ( dy > 0 ) moving window down so expose area at
the top of the window. Clip the exposed area to the height or
the offset, whichever is smaller. */
if (dy > 0) {
gdk_superwin_expose_area(superwin, 0, 0,
width, MIN(height, ABS(dy)));
/* if we've exposed this area add an antiexpose for it. */
gdk_superwin_add_antiexpose(superwin, move_serial,
0, 0, width, MIN(height, ABS(dy)));
}
/* if we are scrolling right or down ( dx > 0 or dy > 0 ) we need to
add our translation before the fist move_resize. Once we do this
all previous expose events will be translated into the new
coordinate space */
if (dx > 0 || dy > 0) {
gdk_superwin_add_translation(superwin, first_resize_serial,
MAX(0, dx), MAX(0, dy));
}
/* If we are scrolling left or down ( x < 0 or y < 0 ) we need to
add our translation before the last move_resize. Once we do this
all previous expose events will be translated in the new
coordinate space. */
if (dx < 0 || dy < 0) {
gdk_superwin_add_translation(superwin, last_resize_serial,
MIN(0, dx), MIN(0, dy));
}
/* sync so we get the windows moved now */
XSync(GDK_DISPLAY(), False);
}
void
gdk_superwin_set_event_funcs (GdkSuperWin *superwin,
GdkSuperWinFunc shell_func,
GdkSuperWinPaintFunc paint_func,
GdkSuperWinPaintFlushFunc flush_func,
GdkSuperWinKeyPressFunc keyprs_func,
GdkSuperWinKeyReleaseFunc keyrel_func,
gpointer func_data,
GDestroyNotify notify)
{
if (superwin->notify && superwin->func_data)
superwin->notify (superwin->func_data);
superwin->shell_func = shell_func;
superwin->paint_func = paint_func;
superwin->flush_func = flush_func;
superwin->keyprs_func = keyprs_func;
superwin->keyrel_func = keyrel_func;
superwin->func_data = func_data;
superwin->notify = notify;
}
void gdk_superwin_resize (GdkSuperWin *superwin,
gint width,
gint height)
{
gdk_window_resize (superwin->bin_window, width, height);
gdk_window_resize (superwin->shell_window, width, height);
}
static void
gdk_superwin_expose_area (GdkSuperWin *superwin,
gint x,
gint y,
gint width,
gint height)
{
if (superwin->paint_func)
superwin->paint_func(x, y, width, height, superwin->func_data);
}
static void
gdk_superwin_flush(GdkSuperWin *superwin)
{
if (superwin->flush_func)
superwin->flush_func(superwin->func_data);
}
static GdkFilterReturn
gdk_superwin_bin_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data)
{
XEvent *xevent = (XEvent *)gdk_xevent;
GdkSuperWin *superwin = data;
GdkFilterReturn retval = GDK_FILTER_CONTINUE;
GdkRegion *region = NULL;
switch (xevent->xany.type) {
case Expose:
region = gdk_region_new();
retval = GDK_FILTER_REMOVE;
gdk_superwin_handle_expose(superwin, xevent, &region, FALSE);
gdk_region_destroy(region);
break;
case KeyPress:
if (superwin->keyprs_func)
superwin->keyprs_func(&xevent->xkey);
break;
case KeyRelease:
if (superwin->keyrel_func)
superwin->keyrel_func(&xevent->xkey);
break;
default:
break;
}
return retval;
}
static GdkFilterReturn
gdk_superwin_shell_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
gpointer data)
{
XEvent *xevent = (XEvent *)gdk_xevent;
GdkSuperWin *superwin = data;
if (xevent->type == VisibilityNotify)
{
switch (xevent->xvisibility.state)
{
case VisibilityFullyObscured:
superwin->visibility = GDK_VISIBILITY_FULLY_OBSCURED;
break;
case VisibilityPartiallyObscured:
superwin->visibility = GDK_VISIBILITY_PARTIAL;
break;
case VisibilityUnobscured:
superwin->visibility = GDK_VISIBILITY_UNOBSCURED;
break;
}
return GDK_FILTER_REMOVE;
}
if (superwin->shell_func) {
superwin->shell_func (superwin, xevent, superwin->func_data);
}
return GDK_FILTER_CONTINUE;
}
/* this function is used to check whether or not a particular event is
for a specific superwin and is a ConfigureNotify or Expose
event. */
Bool gdk_superwin_expose_predicate(Display *display,
XEvent *xevent,
XPointer arg) {
GdkSuperWin *superwin = (GdkSuperWin *)arg;
if (xevent->xany.window != GDK_WINDOW_XWINDOW(superwin->bin_window))
return False;
switch (xevent->xany.type) {
case Expose:
return True;
break;
default:
return False;
break;
}
}
/* static */
void gdk_superwin_add_translation(GdkSuperWin *superwin, unsigned long serial,
gint dx, gint dy)
{
GdkSuperWinTranslate *translate = g_new(GdkSuperWinTranslate, 1);
translate->type = GDK_SUPERWIN_TRANSLATION;
translate->serial = serial;
translate->data.translation.dx = dx;
translate->data.translation.dy = dy;
superwin->translate_queue = g_slist_append(superwin->translate_queue, translate);
}
/* static */
void gdk_superwin_add_antiexpose (GdkSuperWin *superwin, unsigned long serial,
gint x, gint y,
gint width, gint height)
{
GdkSuperWinTranslate *translate = g_new(GdkSuperWinTranslate, 1);
translate->type = GDK_SUPERWIN_ANTIEXPOSE;
translate->serial = serial;
translate->data.antiexpose.rect.x = x;
translate->data.antiexpose.rect.y = y;
translate->data.antiexpose.rect.width = width;
translate->data.antiexpose.rect.height = height;
superwin->translate_queue = g_slist_append(superwin->translate_queue, translate);
}
/* static */
void gdk_superwin_handle_expose (GdkSuperWin *superwin, XEvent *xevent,
GdkRegion **region, gboolean dont_recurse)
{
GSList *tmp_list;
gboolean send_event = TRUE;
unsigned long serial = xevent->xany.serial;
XEvent extra_event;
GdkRectangle rect;
GdkRegion *tmp_region = NULL;
gboolean is_special = TRUE;
/* set up our rect for the damaged area */
rect.x = xevent->xexpose.x;
rect.y = xevent->xexpose.y;
rect.width = xevent->xexpose.width;
rect.height = xevent->xexpose.height;
/* try to see if this is a special event that matches an antiexpose */
tmp_list = superwin->translate_queue;
while (tmp_list) {
GdkSuperWinTranslate *xlate = tmp_list->data;
if (xlate->type == GDK_SUPERWIN_ANTIEXPOSE && serial == xlate->serial) {
GdkRegion *antiexpose_region = gdk_region_new();
tmp_region = gdk_region_union_with_rect(antiexpose_region,
&xlate->data.antiexpose.rect);
gdk_region_destroy(antiexpose_region);
antiexpose_region = tmp_region;
/* if the rect of the expose event is contained in the
antiexpose then we should just drop it on the floor. */
if (gdk_region_rect_in(antiexpose_region, &rect) == GDK_OVERLAP_RECTANGLE_IN) {
gdk_region_destroy(antiexpose_region);
goto end;
}
gdk_region_destroy(antiexpose_region);
}
tmp_list = tmp_list->next;
}
/* we walk the list looking for any transformations */
tmp_list = superwin->translate_queue;
while (tmp_list) {
GdkSuperWinTranslate *xlate = tmp_list->data;
/* apply translations to this event if we can. */
if (xlate->type == GDK_SUPERWIN_TRANSLATION && serial < xlate->serial ) {
rect.x += xlate->data.translation.dx;
rect.y += xlate->data.translation.dy;
}
tmp_list = tmp_list->next;
}
/* add this expose area to our damaged rect */
tmp_region = gdk_region_union_with_rect(*region, &rect);
gdk_region_destroy(*region);
*region = tmp_region;
end:
/* remove any events from the queue that are old */
tmp_list = superwin->translate_queue;
while (tmp_list) {
GdkSuperWinTranslate *xlate = tmp_list->data;
if (serial > xlate->serial) {
GSList *tmp_link = tmp_list;
tmp_list = tmp_list->next;
superwin->translate_queue = g_slist_remove_link(superwin->translate_queue,
tmp_link);
g_free(tmp_link->data);
g_slist_free_1(tmp_link);
}
else {
tmp_list = tmp_list->next;
}
}
/* if we're not supposed to recurse or paint then return now */
if (dont_recurse)
return;
/* try to do any expose event compression we can */
while (XCheckTypedWindowEvent(xevent->xany.display,
xevent->xany.window,
Expose,
&extra_event) == True) {
gdk_superwin_handle_expose(superwin, &extra_event, region, TRUE);
}
/* if the region isn't empty, send the paint event */
if (gdk_region_empty(*region) == FALSE) {
GdkRectangle clip_box;
gdk_region_get_clipbox(*region, &clip_box);
if (superwin->paint_func)
superwin->paint_func(clip_box.x, clip_box.y,
clip_box.width, clip_box.height,
superwin->func_data);
}
}

View File

@ -1,139 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org Code.
*
* The Initial Developer of the Original Code is
* Owen Taylor <otaylor@redhat.com> and Christopher Blizzard
* <blizzard@redhat.com>.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __GDK_SUPERWIN_H__
#define __GDK_SUPERWIN_H__
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gtk/gtkobject.h>
#ifdef MOZILLA_CLIENT
#include "nscore.h"
#ifdef _IMPL_GTKSUPERWIN_API
#define GTKSUPERWIN_API(type) NS_EXPORT_(type)
#else
#define GTKSUPERWIN_API(type) NS_IMPORT_(type)
#endif
#else
#define GTKSUPERWIN_API(type) type
#endif
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _GdkSuperWin GdkSuperWin;
typedef struct _GdkSuperWinClass GdkSuperWinClass;
#define GDK_TYPE_SUPERWIN (gdk_superwin_get_type())
#define GDK_SUPERWIN(obj) (GTK_CHECK_CAST((obj), GDK_TYPE_SUPERWIN, GdkSuperWin))
#define GDK_SUPERWIN_CLASS(klass) (GTK_CHECK_CLASS_CAST((klass), GDK_TYPE_SUPERWIN, GdkSuperWinClass))
#define GDK_IS_SUPERWIN(obj) (GTK_CHECK_TYPE((obj), GDK_TYPE_SUPERWIN))
#define GDK_IS_SUPERWIN_CLASS(klass) (GTK_CHECK_CLASS_TYPE((klass), GDK_TYPE_SUPERWIN))
typedef void (*GdkSuperWinFunc) (GdkSuperWin *super_win,
XEvent *event,
gpointer data);
typedef void (*GdkSuperWinPaintFunc) (gint x, gint y,
gint width, gint height,
gpointer data);
typedef void (*GdkSuperWinPaintFlushFunc) (gpointer data);
typedef void (*GdkSuperWinKeyPressFunc) (XKeyEvent *event);
typedef void (*GdkSuperWinKeyReleaseFunc) (XKeyEvent *event);
struct _GdkSuperWin
{
GtkObject object;
GdkWindow *shell_window;
GdkWindow *bin_window;
/* Private */
GSList *translate_queue;
GdkSuperWinFunc shell_func;
GdkSuperWinPaintFunc paint_func;
GdkSuperWinPaintFlushFunc flush_func;
GdkSuperWinKeyPressFunc keyprs_func;
GdkSuperWinKeyReleaseFunc keyrel_func;
gpointer func_data;
GDestroyNotify notify;
GdkVisibilityState visibility;
};
struct _GdkSuperWinClass
{
GtkObjectClass object_class;
};
GTKSUPERWIN_API(GtkType) gdk_superwin_get_type(void);
GTKSUPERWIN_API(GdkSuperWin*) gdk_superwin_new (GdkWindow *parent_window,
guint x,
guint y,
guint width,
guint height);
GTKSUPERWIN_API(void) gdk_superwin_reparent(GdkSuperWin *superwin,
GdkWindow *parent_window);
GTKSUPERWIN_API(void)
gdk_superwin_set_event_funcs (GdkSuperWin *superwin,
GdkSuperWinFunc shell_func,
GdkSuperWinPaintFunc paint_func,
GdkSuperWinPaintFlushFunc flush_func,
GdkSuperWinKeyPressFunc keyprs_func,
GdkSuperWinKeyReleaseFunc keyrel_func,
gpointer func_data,
GDestroyNotify notify);
GTKSUPERWIN_API(void) gdk_superwin_scroll (GdkSuperWin *superwin,
gint dx,
gint dy);
GTKSUPERWIN_API(void) gdk_superwin_resize (GdkSuperWin *superwin,
gint width,
gint height);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* _GDK_SUPERWIN_H__ */

View File

@ -1,414 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org Code.
*
* The Initial Developer of the Original Code is
* Owen Taylor <otaylor@redhat.com> and Christopher Blizzard
* <blizzard@redhat.com>.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "gtkmozarea.h"
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
static void gtk_mozarea_class_init (GtkMozAreaClass *klass);
static void gtk_mozarea_init (GtkMozArea *mozarea);
static void gtk_mozarea_realize (GtkWidget *widget);
static void gtk_mozarea_unrealize (GtkWidget *widget);
static void gtk_mozarea_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_mozarea_destroy (GtkObject *object);
static void
attach_toplevel_listener(GtkMozArea *mozarea);
static void
remove_toplevel_listener(GtkMozArea *mozarea);
static Window
get_real_toplevel(Window aWindow);
static GdkWindow *
get_real_gdk_toplevel(GtkMozArea *mozarea);
static GdkFilterReturn
toplevel_window_filter(GdkXEvent *aGdkXEvent,
GdkEvent *aEvent,
gpointer data);
static GdkFilterReturn
widget_window_filter(GdkXEvent *aGdkXEvent,
GdkEvent *aEvent,
gpointer data);
GtkWidgetClass *parent_class = NULL;
enum {
TOPLEVEL_FOCUS_IN,
TOPLEVEL_FOCUS_OUT,
TOPLEVEL_CONFIGURE,
LAST_SIGNAL
};
static guint mozarea_signals[LAST_SIGNAL] = { 0 };
GtkType
gtk_mozarea_get_type (void)
{
static GtkType mozarea_type = 0;
if (!mozarea_type)
{
static const GtkTypeInfo mozarea_info =
{
"GtkMozArea",
sizeof (GtkMozArea),
sizeof (GtkMozAreaClass),
(GtkClassInitFunc) gtk_mozarea_class_init,
(GtkObjectInitFunc) gtk_mozarea_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
mozarea_type = gtk_type_unique (GTK_TYPE_WIDGET, &mozarea_info);
}
return mozarea_type;
}
static void
gtk_mozarea_class_init (GtkMozAreaClass *klass)
{
GtkWidgetClass *widget_class;
GtkObjectClass *object_class;
widget_class = GTK_WIDGET_CLASS (klass);
object_class = GTK_OBJECT_CLASS (klass);
widget_class->realize = gtk_mozarea_realize;
widget_class->unrealize = gtk_mozarea_unrealize;
widget_class->size_allocate = gtk_mozarea_size_allocate;
object_class->destroy = gtk_mozarea_destroy;
parent_class = gtk_type_class(gtk_widget_get_type());
/* set up our signals */
mozarea_signals[TOPLEVEL_FOCUS_IN] =
gtk_signal_new("toplevel_focus_in",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET(GtkMozAreaClass, toplevel_focus_in),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
mozarea_signals[TOPLEVEL_FOCUS_OUT] =
gtk_signal_new("toplevel_focus_out",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET(GtkMozAreaClass, toplevel_focus_out),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
mozarea_signals[TOPLEVEL_CONFIGURE] =
gtk_signal_new("toplevel_configure",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET(GtkMozAreaClass, toplevel_configure),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
gtk_object_class_add_signals(object_class, mozarea_signals, LAST_SIGNAL);
}
static void
gtk_mozarea_init (GtkMozArea *mozarea)
{
mozarea->superwin = NULL;
mozarea->toplevel_focus = FALSE;
mozarea->toplevel_window = NULL;
gtk_widget_set_name(GTK_WIDGET(mozarea), "gtkmozarea");
}
static void
gtk_mozarea_realize (GtkWidget *widget)
{
GtkMozArea *mozarea;
g_return_if_fail (GTK_IS_MOZAREA (widget));
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
mozarea = GTK_MOZAREA (widget);
mozarea->superwin = gdk_superwin_new (gtk_widget_get_parent_window (widget),
widget->allocation.x,
widget->allocation.y,
widget->allocation.width,
widget->allocation.height);
gdk_window_set_user_data (mozarea->superwin->shell_window, mozarea);
widget->window = mozarea->superwin->shell_window;
widget->style = gtk_style_attach (widget->style, widget->window);
/* make sure that we add a reference to this window.
if we don't then it will be destroyed by both the superwin
destroy method and the widget class destructor */
gdk_window_ref(widget->window);
/* attach the toplevel X listener */
attach_toplevel_listener(mozarea);
/* Attach a filter so that we can get reparent notifications so we
can reset our toplevel window. This will automatically be
removed when our window is destroyed. */
gdk_window_add_filter(widget->window, widget_window_filter, mozarea);
}
static void
gtk_mozarea_unrealize(GtkWidget *widget)
{
GtkMozArea *mozarea;
g_return_if_fail(GTK_IS_MOZAREA(widget));
GTK_WIDGET_UNSET_FLAGS(widget, GTK_REALIZED);
mozarea = GTK_MOZAREA(widget);
if (mozarea->superwin) {
gtk_object_unref(GTK_OBJECT(mozarea->superwin));
mozarea->superwin = NULL;
}
GTK_WIDGET_CLASS(parent_class)->unrealize(widget);
}
static void
gtk_mozarea_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkMozArea *mozarea;
g_return_if_fail (GTK_IS_MOZAREA (widget));
mozarea = GTK_MOZAREA (widget);
if (GTK_WIDGET_REALIZED (widget))
{
gdk_window_move (mozarea->superwin->shell_window,
allocation->x, allocation->y);
gdk_superwin_resize (mozarea->superwin,
allocation->width, allocation->height);
}
}
static void
gtk_mozarea_destroy(GtkObject *object)
{
GtkMozArea *mozarea;
g_return_if_fail(GTK_IS_MOZAREA(object));
mozarea = GTK_MOZAREA(object);
/* remove the listener from the toplevel */
remove_toplevel_listener(mozarea);
GTK_OBJECT_CLASS(parent_class)->destroy(object);
}
GtkWidget*
gtk_mozarea_new (GdkWindow *parent_window)
{
return GTK_WIDGET (gtk_type_new (GTK_TYPE_MOZAREA));
}
gboolean
gtk_mozarea_get_toplevel_focus(GtkMozArea *area)
{
g_return_val_if_fail(GTK_IS_MOZAREA(area), FALSE);
return area->toplevel_focus;
}
/* this function will attach a listener to this widget's real toplevel
window */
static void
attach_toplevel_listener(GtkMozArea *mozarea)
{
/* get the real gdk toplevel window */
GdkWindow *gdk_window = get_real_gdk_toplevel(mozarea);
/* attach our passive filter. when this widget is destroyed it will
be removed in our destroy method. */
gdk_window_add_filter(gdk_window, toplevel_window_filter, mozarea);
/* save it so that we can remove the filter later */
mozarea->toplevel_window = gdk_window;
}
/* this function will remove a toplevel listener for a widget */
static void
remove_toplevel_listener(GtkMozArea *mozarea)
{
gdk_window_remove_filter(mozarea->toplevel_window, toplevel_window_filter,
mozarea);
}
/* this function will try to find the real toplevel for a gdk window. */
static Window
get_real_toplevel(Window aWindow)
{
Window current = aWindow;
Atom atom;
/* get the atom for the WM_STATE variable that you get on WM
managed windows. */
atom = XInternAtom(GDK_DISPLAY(), "WM_STATE", FALSE);
while (current) {
Atom type = None;
int format;
unsigned long nitems, after;
unsigned char *data;
Window root_return;
Window parent_return;
Window *children_return = NULL;
unsigned int nchildren_return;
/* check for the atom on this window */
XGetWindowProperty(GDK_DISPLAY(), current, atom,
0, 0, /* offsets */
False, /* don't delete */
AnyPropertyType,
&type, &format, &nitems, &after, &data);
/* did we get something? */
if (type != None) {
XFree(data);
data = NULL;
/* ok, this is the toplevel window since it has the property set
on it. */
break;
}
/* what is the parent? */
XQueryTree(GDK_DISPLAY(), current, &root_return,
&parent_return, &children_return,
&nchildren_return);
if (children_return)
XFree(children_return);
/* If the parent window of this window is the root window then
there is no window manager running so the current window is the
toplevel window. */
if (parent_return == root_return)
break;
current = parent_return;
}
return current;
}
static GdkWindow *
get_real_gdk_toplevel(GtkMozArea *mozarea)
{
/* get the native window for this widget */
GtkWidget *widget = GTK_WIDGET(mozarea);
Window window = GDK_WINDOW_XWINDOW(widget->window);
Window toplevel = get_real_toplevel(window);
/* check to see if this is an already registered window with the
type system. */
GdkWindow *gdk_window = gdk_window_lookup(toplevel);
/* This isn't our window? It is now, fool! */
if (!gdk_window) {
/* import it into the type system */
gdk_window = gdk_window_foreign_new(toplevel);
/* make sure that we are listening for the right events on it. */
gdk_window_set_events(gdk_window, GDK_FOCUS_CHANGE_MASK);
}
return gdk_window;
}
static GdkFilterReturn
toplevel_window_filter(GdkXEvent *aGdkXEvent,
GdkEvent *aEvent,
gpointer data)
{
XEvent *xevent = (XEvent *)aGdkXEvent;
GtkMozArea *mozarea = (GtkMozArea *)data;
switch (xevent->xany.type) {
case FocusIn:
mozarea->toplevel_focus = TRUE;
gtk_signal_emit(GTK_OBJECT(mozarea), mozarea_signals[TOPLEVEL_FOCUS_IN]);
break;
case FocusOut:
mozarea->toplevel_focus = FALSE;
gtk_signal_emit(GTK_OBJECT(mozarea), mozarea_signals[TOPLEVEL_FOCUS_OUT]);
break;
case ConfigureNotify:
gtk_signal_emit(GTK_OBJECT(mozarea), mozarea_signals[TOPLEVEL_CONFIGURE]);
break;
default:
break;
}
return GDK_FILTER_CONTINUE;
}
static GdkFilterReturn
widget_window_filter(GdkXEvent *aGdkXEvent,
GdkEvent *aEvent,
gpointer data)
{
XEvent *xevent = (XEvent *)aGdkXEvent;
GtkMozArea *mozarea = (GtkMozArea *)data;
switch(xevent->xany.type) {
case ReparentNotify:
/* remove the old filter on the toplevel and attach to the new one */
remove_toplevel_listener(mozarea);
attach_toplevel_listener(mozarea);
break;
default:
break;
}
return GDK_FILTER_CONTINUE;
}

View File

@ -1,87 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org Code.
*
* The Initial Developer of the Original Code is
* Owen Taylor <otaylor@redhat.com> and Christopher Blizzard
* <blizzard@redhat.com>.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __GTK_MOZAREA_H__
#define __GTK_MOZAREA_H__
#include <gtk/gtkwindow.h>
#include "gdksuperwin.h"
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _GtkMozArea GtkMozArea;
typedef struct _GtkMozAreaClass GtkMozAreaClass;
#define GTK_TYPE_MOZAREA (gtk_mozarea_get_type ())
#define GTK_MOZAREA(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_MOZAREA, GtkMozArea))
#define GTK_MOZAREA_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MOZAREA, GtkMozAreaClass))
#define GTK_IS_MOZAREA(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_MOZAREA))
#define GTK_IS_MOZAREA_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MOZAREA))
struct _GtkMozArea
{
GtkWidget widget;
GdkSuperWin *superwin;
gboolean toplevel_focus;
/* store away the toplevel window */
GdkWindow *toplevel_window;
};
struct _GtkMozAreaClass
{
GtkWindowClass window_class;
/* signals */
void (* toplevel_focus_in ) (GtkMozArea *area);
void (* toplevel_focus_out) (GtkMozArea *area);
void (* toplevel_configure) (GtkMozArea *area);
};
GTKSUPERWIN_API(GtkType) gtk_mozarea_get_type (void);
GTKSUPERWIN_API(GtkWidget*) gtk_mozarea_new ();
GTKSUPERWIN_API(gboolean) gtk_mozarea_get_toplevel_focus(GtkMozArea *area);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GTK_MOZAREA_H__ */

View File

@ -1,269 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org Code.
*
* The Initial Developer of the Original Code is
* Owen Taylor <otaylor@redhat.com> and Christopher Blizzard
* <blizzard@redhat.com>.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "gtkmozbox.h"
#include <gtk/gtkmain.h>
#include <X11/Xlib.h>
static void gtk_mozbox_class_init (GtkMozBoxClass *klass);
static void gtk_mozbox_init (GtkMozBox *mozbox);
static void gtk_mozbox_realize (GtkWidget *widget);
static void gtk_mozbox_set_focus (GtkWindow *window,
GtkWidget *focus);
static gint gtk_mozbox_key_press_event (GtkWidget *widget,
GdkEventKey *event);
static GdkFilterReturn gtk_mozbox_filter (GdkXEvent *xevent,
GdkEvent *event,
gpointer data);
static GtkWindow * gtk_mozbox_get_parent_gtkwindow (GtkMozBox *mozbox);
void (*parent_class_set_focus)(GtkWindow *, GtkWidget *);
GtkType
gtk_mozbox_get_type (void)
{
static GtkType mozbox_type = 0;
if (!mozbox_type)
{
static const GtkTypeInfo mozbox_info =
{
"GtkMozBox",
sizeof (GtkMozBox),
sizeof (GtkMozBoxClass),
(GtkClassInitFunc) gtk_mozbox_class_init,
(GtkObjectInitFunc) gtk_mozbox_init,
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL
};
mozbox_type = gtk_type_unique (GTK_TYPE_WINDOW, &mozbox_info);
}
return mozbox_type;
}
static void
gtk_mozbox_class_init (GtkMozBoxClass *klass)
{
GtkWidgetClass *widget_class;
GtkWindowClass *window_class;
widget_class = GTK_WIDGET_CLASS (klass);
window_class = GTK_WINDOW_CLASS (klass);
widget_class->realize = gtk_mozbox_realize;
widget_class->key_press_event = gtk_mozbox_key_press_event;
/* save the parent class' set_focus method */
parent_class_set_focus = window_class->set_focus;
window_class->set_focus = gtk_mozbox_set_focus;
}
static void
gtk_mozbox_init (GtkMozBox *mozbox)
{
mozbox->parent_window = NULL;
mozbox->x = 0;
mozbox->y = 0;
}
static void
gtk_mozbox_realize (GtkWidget *widget)
{
GdkWindowAttr attributes;
gint attributes_mask;
GtkMozBox *mozbox;
g_return_if_fail (GTK_IS_MOZBOX (widget));
mozbox = GTK_MOZBOX (widget);
/* GtkWindow checks against premature realization here. Just
* don't do it.
*/
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
attributes.window_type = GDK_WINDOW_CHILD;
attributes.x = mozbox->x;
attributes.y = mozbox->y;
attributes.width = widget->allocation.width;
attributes.height = widget->allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
attributes.event_mask = gtk_widget_get_events (widget);
attributes.event_mask |= GDK_EXPOSURE_MASK;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
widget->window = gdk_window_new (mozbox->parent_window,
&attributes, attributes_mask);
/* set the back pixmap to None so that you don't end up with the gtk
default which is BlackPixel */
gdk_window_set_back_pixmap (widget->window, NULL, FALSE);
gdk_window_set_user_data (widget->window, mozbox);
widget->style = gtk_style_attach (widget->style, widget->window);
gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL);
gdk_window_add_filter (widget->window, gtk_mozbox_filter, mozbox);
}
static void
gtk_mozbox_set_focus (GtkWindow *window,
GtkWidget *focus)
{
GtkMozBox *mozbox;
GdkWindow *tmpWindow;
GtkWindow *parentGtkWindow;
g_return_if_fail(window != NULL);
g_return_if_fail(GTK_IS_MOZBOX(window));
mozbox = GTK_MOZBOX(window);
parentGtkWindow = gtk_mozbox_get_parent_gtkwindow (mozbox);
if (parentGtkWindow) {
parent_class_set_focus(parentGtkWindow, focus);
return;
}
/* as a fall back just hand it off to our parent class */
parent_class_set_focus(window, focus);
}
static gint
gtk_mozbox_key_press_event (GtkWidget *widget,
GdkEventKey *event)
{
GtkWindow *window;
GtkMozBox *mozbox;
GtkWindow *parentWindow;
gboolean handled = FALSE;
window = GTK_WINDOW (widget);
mozbox = GTK_MOZBOX (widget);
parentWindow = gtk_mozbox_get_parent_gtkwindow(mozbox);
/* give the focus window the chance to handle the event first. */
if (parentWindow && parentWindow->focus_widget) {
handled = gtk_widget_event (parentWindow->focus_widget, (GdkEvent*) event);
}
/* pass it off to the parent widget */
if (!handled) {
gdk_window_unref(event->window);
event->window = mozbox->parent_window;
gdk_window_ref(event->window);
gdk_event_put((GdkEvent *)event);
}
return TRUE;
}
static GdkFilterReturn
gtk_mozbox_filter (GdkXEvent *xevent,
GdkEvent *event,
gpointer data)
{
XEvent *xev = xevent;
GtkWidget *widget = data;
switch (xev->xany.type)
{
case ConfigureNotify:
event->configure.type = GDK_CONFIGURE;
event->configure.window = widget->window;
event->configure.x = 0;
event->configure.y = 0;
event->configure.width = xev->xconfigure.width;
event->configure.height = xev->xconfigure.height;
return GDK_FILTER_TRANSLATE;
default:
return GDK_FILTER_CONTINUE;
}
}
static GtkWindow *
gtk_mozbox_get_parent_gtkwindow (GtkMozBox *mozbox)
{
GdkWindow *tmpWindow;
/* look for a parent GtkWindow in the heirarchy */
tmpWindow = mozbox->parent_window;
while (tmpWindow) {
gpointer data = NULL;
gdk_window_get_user_data(tmpWindow, &data);
if (data && GTK_IS_WINDOW(data)) {
return GTK_WINDOW(data);
}
tmpWindow = gdk_window_get_parent(tmpWindow);
}
return NULL;
}
GtkWidget*
gtk_mozbox_new (GdkWindow *parent_window)
{
GtkMozBox *mozbox;
mozbox = gtk_type_new (GTK_TYPE_MOZBOX);
mozbox->parent_window = parent_window;
return GTK_WIDGET (mozbox);
}
void
gtk_mozbox_set_position (GtkMozBox *mozbox,
gint x,
gint y)
{
mozbox->x = x;
mozbox->y = y;
if (GTK_WIDGET_REALIZED (mozbox))
gdk_window_move (GTK_WIDGET (mozbox)->window, x, y);
}

View File

@ -1,82 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org Code.
*
* The Initial Developer of the Original Code is
* Owen Taylor <otaylor@redhat.com> and Christopher Blizzard
* <blizzard@redhat.com>.
* Portions created by the Initial Developer are Copyright (C) 1999
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __GTK_MOZBOX_H__
#define __GTK_MOZBOX_H__
#include <gtk/gtkwindow.h>
#include "gdksuperwin.h" /* for GTKSUPERWIN_API */
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _GtkMozBox GtkMozBox;
typedef struct _GtkMozBoxClass GtkMozBoxClass;
#define GTK_TYPE_MOZBOX (gtk_mozbox_get_type ())
#define GTK_MOZBOX(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_MOZBOX, GtkMozBox))
#define GTK_MOZBOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_MOZBOX, GtkMozBoxClass))
#define GTK_IS_MOZBOX(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_MOZBOX))
#define GTK_IS_MOZBOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_MOZBOX))
struct _GtkMozBox
{
GtkWindow window;
GdkWindow *parent_window;
gint x;
gint y;
};
struct _GtkMozBoxClass
{
GtkWindowClass window_class;
};
GTKSUPERWIN_API(GtkType) gtk_mozbox_get_type (void);
GTKSUPERWIN_API(GtkWidget*) gtk_mozbox_new (GdkWindow *parent_window);
GTKSUPERWIN_API(void) gtk_mozbox_set_position (GtkMozBox *mozbox,
gint x,
gint y);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GTK_MOZBOX_H__ */

View File

@ -1,4 +0,0 @@
[gecko]
#if SHARED_LIBRARY
dist/bin/@SHARED_LIBRARY@
#endif

View File

@ -1,106 +0,0 @@
#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is mozilla.org code.
#
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1998
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
#
# Alternatively, the contents of this file may be used under the terms of
# either the GNU General Public License Version 2 or later (the "GPL"), or
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
#
# ***** END LICENSE BLOCK *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = widget
LIBRARY_NAME = widget_xlib
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsWidgetXLIBModule
GRE_MODULE = 1
LIBXUL_LIBRARY = 1
PACKAGE_FILE = widget_xlib.pkg
REQUIRES = xpcom \
string \
appshell \
gfx \
layout \
content \
dom \
js \
xlibrgb \
uconv \
pref \
webshell \
htmlparser \
view \
necko \
$(NULL)
CPPSRCS = \
nsAppShell.cpp \
nsBidiKeyboard.cpp \
nsClipboard.cpp \
nsDragService.cpp \
nsKeyCode.cpp \
nsLookAndFeel.cpp \
nsScreenXlib.cpp \
nsScreenManagerXlib.cpp \
nsSound.cpp \
nsToolkit.cpp \
nsWidget.cpp \
nsWidgetFactory.cpp \
nsWindow.cpp \
nsXUtils.cpp \
$(NULL)
SHARED_LIBRARY_LIBS = $(DIST)/lib/libxpwidgets_s.a
include $(topsrcdir)/config/rules.mk
EXTRA_DSO_LDOPTS += -L$(DIST)/bin -L$(DIST)/lib -lgkgfx $(MOZ_COMPONENT_LIBS)
EXTRA_DSO_LDOPTS += -L$(DIST)/bin -lXt -lxlibrgb -lxlibxtbin $(MOZ_XLIB_LDFLAGS)
CXXFLAGS += $(MOZ_XLIB_CFLAGS)
DEFINES += -D_IMPL_NS_WIDGET
LOCAL_INCLUDES = \
-I$(srcdir)/../xpwidgets \
-I$(srcdir) \
$(NULL)

File diff suppressed because it is too large Load Diff

View File

@ -1,114 +0,0 @@
/* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsAppShell_h__
#define nsAppShell_h__
#include "nsIAppShell.h"
#include "nsIEventQueueService.h"
#include "nsWidget.h"
#include "prtime.h"
#include "xlibrgb.h"
#include <X11/Intrinsic.h>
class nsAppShell : public nsIAppShell
{
public:
nsAppShell();
virtual ~nsAppShell();
NS_DECL_ISUPPORTS
// nsIAppShellInterface
NS_IMETHOD Create(int* argc, char ** argv);
virtual nsresult Run();
NS_IMETHOD Spinup();
NS_IMETHOD Spindown();
NS_IMETHOD ListenToEventQueue(nsIEventQueue *aQueue, PRBool aListen);
NS_IMETHOD GetNativeEvent(PRBool &aRealEvent, void *&aEvent);
NS_IMETHOD DispatchNativeEvent(PRBool aRealEvent, void *aEvent);
NS_IMETHOD Exit();
virtual void * GetNativeData(PRUint32 aDataType);
static void DispatchXEvent(XEvent *event);
/* |xxlib_find_handle(XXLIBRGB_DEFAULT_HANDLE)| would be the official
* way - but |nsAppShell::GetXlibRgbHandle()| one is little bit faster... :-)
*/
static XtAppContext mAppContext;
static XlibRgbHandle *GetXlibRgbHandle() { return mXlib_rgb_handle; }
static Display *mDisplay;
private:
static XlibRgbHandle *mXlib_rgb_handle;
static void HandleButtonEvent(XEvent *event, nsWidget *aWidget);
static void HandleMotionNotifyEvent(XEvent *event, nsWidget *aWidget);
static void HandleExposeEvent(XEvent *event, nsWidget *aWidget);
static void HandleConfigureNotifyEvent(XEvent *event, nsWidget *aWidget);
static void HandleKeyPressEvent(XEvent *event, nsWidget *aWidget);
static void HandleKeyReleaseEvent(XEvent *event, nsWidget *aWidget);
static void HandleFocusInEvent(XEvent *event, nsWidget *aWidget);
static void HandleFocusOutEvent(XEvent *event, nsWidget *aWidget);
static void HandleVisibilityNotifyEvent(XEvent *event, nsWidget *aWidget);
static void HandleMapNotifyEvent(XEvent *event, nsWidget *aWidget);
static void HandleUnmapNotifyEvent(XEvent *event, nsWidget *aWidget);
static void HandleEnterEvent(XEvent *event, nsWidget *aWidget);
static void HandleLeaveEvent(XEvent *event, nsWidget *aWidget);
static void HandleClientMessageEvent(XEvent *event, nsWidget *aWidget);
static void HandleSelectionRequestEvent(XEvent *event, nsWidget *aWidget);
static void HandleDragMotionEvent(XEvent *event, nsWidget *aWidget);
static void HandleDragEnterEvent(XEvent *event, nsWidget *aWidget);
static void HandleDragLeaveEvent(XEvent *event, nsWidget *aWidget);
static void HandleDragDropEvent(XEvent *event, nsWidget *aWidget);
static void ForwardEvent(XEvent *event, nsWidget *aWidget);
static PRInt16 mClicks;
static PRUint16 mClickedButton;
static PRTime mClickTime;
static PRPackedBool mClicked;
static PRPackedBool mDragging;
static PRPackedBool mAltDown;
static PRPackedBool mShiftDown;
static PRPackedBool mCtrlDown;
static PRPackedBool mMetaDown;
static PRPackedBool DieAppShellDie;
protected:
nsCOMPtr<nsIEventQueue> mEventQueue;
};
#endif /* !nsAppShell_h__ */

View File

@ -1,63 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is IBM code.
*
* The Initial Developer of the Original Code is
* IBM. Portions created by IBM are Copyright (C) International Business Machines Corporation, 2000. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Simon Montagu
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsBidiKeyboard.h"
NS_IMPL_ISUPPORTS1(nsBidiKeyboard, nsIBidiKeyboard)
nsBidiKeyboard::nsBidiKeyboard() : nsIBidiKeyboard()
{
}
nsBidiKeyboard::~nsBidiKeyboard()
{
}
NS_IMETHODIMP nsBidiKeyboard::IsLangRTL(PRBool *aIsRTL)
{
*aIsRTL = PR_FALSE;
// XXX Insert platform specific code to determine keyboard direction
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsBidiKeyboard::SetLangFromBidiLevel(PRUint8 aLevel)
{
// XXX Insert platform specific code to set keyboard language
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@ -1,56 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is IBM code.
*
* The Initial Developer of the Original Code is
* IBM. Portions created by IBM are Copyright (C) International Business Machines Corporation, 2000. All Rights Reserved.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Simon Montagu
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsBidiKeyboard
#define __nsBidiKeyboard
#include "nsIBidiKeyboard.h"
class nsBidiKeyboard : public nsIBidiKeyboard
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIBIDIKEYBOARD
nsBidiKeyboard();
virtual ~nsBidiKeyboard();
/* additional members */
};
#endif // __nsBidiKeyboard

View File

@ -1,437 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Hartshorn <peter@igelaus.com.au>
* Ken Faulkner <faulkner@igelaus.com.au>
* Dan Rosen <dr@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/* TODO:
* Currently this only supports the transfer of TEXT! FIXME
*/
#include "nsAppShell.h"
#include "nsClipboard.h"
#include "nsCOMPtr.h"
#include "nsCRT.h"
#include "nsISupportsArray.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsIComponentManager.h"
#include "nsIServiceManager.h"
#include "nsWidgetsCID.h"
#include "nsXPIDLString.h"
#include "nsPrimitiveHelpers.h"
#include "nsTextFormatter.h"
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include "xlibrgb.h"
#include "nsIServiceManager.h"
#include "nsICharsetConverterManager.h"
// unicode conversion
# include "nsIPlatformCharset.h"
// The class statics:
nsITransferable *nsClipboard::mTransferable = nsnull;
Window nsClipboard::sWindow;
Display *nsClipboard::sDisplay;
#if defined(DEBUG_mcafee) || defined(DEBUG_pavlov)
#define DEBUG_CLIPBOARD
#endif
NS_IMPL_ISUPPORTS1(nsClipboard, nsIClipboard)
nsClipboard::nsClipboard() {
sDisplay = xxlib_rgb_get_display(nsAppShell::GetXlibRgbHandle());
Init();
}
nsClipboard::~nsClipboard() {
NS_IF_RELEASE(sWidget);
}
/*static*/ void nsClipboard::Shutdown() {
NS_IF_RELEASE(mTransferable);
}
// Initialize the clipboard and create a nsWidget for communications
void nsClipboard::Init() {
NS_ASSERTION(!sWidget, "already initialized");
sWidget = new nsWidget();
if (!sWidget) return;
NS_ADDREF(sWidget);
const nsRect rect(0,0,100,100);
sWidget->Create((nsIWidget *)nsnull, rect, Callback,
(nsIDeviceContext *)nsnull, (nsIAppShell *)nsnull,
(nsIToolkit *)nsnull, (nsWidgetInitData *)nsnull);
sWindow = (Window)sWidget->GetNativeData(NS_NATIVE_WINDOW);
XSelectInput(sDisplay, sWindow, 0x0fffff);
}
// This is the callback function for our nsWidget. It is given the
// XEvent from nsAppShell.
// FIXME: We _should_ assign mTransferable here depending on if its a
// selectionrequest
nsEventStatus PR_CALLBACK nsClipboard::Callback(nsGUIEvent *event) {
XEvent *ev = (XEvent *)event->nativeMsg;
/* may be nsnull in the |event->message == NS_DESTROY| case... */
if(ev == nsnull)
return nsEventStatus_eIgnore;
// Check the event type
if (ev->type == SelectionRequest) {
if (mTransferable == nsnull) {
fprintf(stderr, "nsClipboard::Callback: null transferable\n");
return nsEventStatus_eIgnore;
}
// Get the data from the Transferable
const char *dataFlavor = kUnicodeMime;
nsCOMPtr<nsISupports> genDataWrapper;
nsresult rv;
PRUint32 dataLength;
void *data;
data = malloc(16384);
rv = mTransferable->GetTransferData(dataFlavor,
getter_AddRefs(genDataWrapper),
&dataLength);
nsPrimitiveHelpers::CreateDataFromPrimitive(dataFlavor, genDataWrapper,
&data, dataLength);
if (NS_SUCCEEDED(rv) && data && dataLength) {
char *plainText = nsnull;
PRUnichar* unicodeData = NS_REINTERPRET_CAST(PRUnichar*, data);
PRInt32 plainLen = 0;
nsPrimitiveHelpers::ConvertUnicodeToPlatformPlainText(unicodeData,
dataLength/2,
&plainText,
&plainLen);
if (data) {
free(data);
data = plainText;
dataLength = plainLen;
}
// Set the window property to contain the data
XChangeProperty(sDisplay,
ev->xselectionrequest.requestor,
ev->xselectionrequest.property,
ev->xselectionrequest.target,
8, PropModeReplace,
(unsigned char *)data, dataLength);
// Send the requestor a SelectionNotify event
XEvent aEvent;
aEvent.type = SelectionNotify;
aEvent.xselection.serial = ev->xselectionrequest.serial;
aEvent.xselection.display = ev->xselectionrequest.display;
aEvent.xselection.requestor = ev->xselectionrequest.requestor;
aEvent.xselection.selection = ev->xselectionrequest.selection;
aEvent.xselection.target = ev->xselectionrequest.target;
aEvent.xselection.property = ev->xselectionrequest.property;
aEvent.xselection.time = CurrentTime;
XSendEvent(sDisplay, ev->xselectionrequest.requestor, 1, 0, &aEvent);
}
}
return nsEventStatus_eIgnore;
}
nsITransferable *nsClipboard::GetTransferable(PRInt32 aWhichClipboard)
{
nsITransferable *transferable = nsnull;
switch (aWhichClipboard)
{
case kGlobalClipboard:
transferable = mGlobalTransferable;
break;
case kSelectionClipboard:
transferable = mSelectionTransferable;
break;
}
return transferable;
}
// Ripped from GTK. Does the writing to the appropriate transferable.
// Does *some* flavour stuff, but not all!!!
// FIXME: Needs to be completed.
NS_IMETHODIMP nsClipboard::SetNativeClipboardData(PRInt32 aWhichClipboard)
{
// bomb out if we cannot get ownership.
if (XSetSelectionOwner(sDisplay, XA_PRIMARY, sWindow, CurrentTime))
if (XGetSelectionOwner(sDisplay, XA_PRIMARY) != sWindow) {
fprintf(stderr, "nsClipboard::SetData: Cannot get ownership\n");
return NS_ERROR_FAILURE;
}
// get flavor list that includes all flavors that can be written (including ones
// obtained through conversion)
nsCOMPtr<nsISupportsArray> flavorList;
nsCOMPtr<nsITransferable> transferable(GetTransferable(aWhichClipboard));
// FIXME Need to make sure mTransferable has reference to selectionclipboard.
// This solves the problem with copying to an external app.
// but cannot be sure if its fully correct until menu copy/paste is working.
if (aWhichClipboard == kSelectionClipboard) {
NS_IF_RELEASE(mTransferable);
mTransferable = transferable;
NS_IF_ADDREF(mTransferable);
}
// make sure we have a good transferable
if (nsnull == transferable) {
#ifdef DEBUG_faulkner
fprintf(stderr, "nsClipboard::SetNativeClipboardData(): no transferable!\n");
#endif /* DEBUG_faulkner */
return NS_ERROR_FAILURE;
}
nsresult errCode = transferable->FlavorsTransferableCanExport ( getter_AddRefs(flavorList) );
if ( NS_FAILED(errCode) )
return NS_ERROR_FAILURE;
PRUint32 cnt;
flavorList->Count(&cnt);
for ( PRUint32 i=0; i<cnt; ++i )
{
nsCOMPtr<nsISupports> genericFlavor;
flavorList->GetElementAt ( i, getter_AddRefs(genericFlavor) );
nsCOMPtr<nsISupportsCString> currentFlavor ( do_QueryInterface(genericFlavor) );
if ( currentFlavor ) {
nsXPIDLCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
// FIXME Do we need to register this in XLIB? KenF
// add these types as selection targets
// RegisterFormat(flavorStr, selectionAtom);
}
}
mIgnoreEmptyNotification = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsClipboard::SetData(nsITransferable *aTransferable,
nsIClipboardOwner *anOwner,
PRInt32 aWhichClipboard)
{
if (XSetSelectionOwner(sDisplay, XA_PRIMARY, sWindow, CurrentTime))
if (XGetSelectionOwner(sDisplay, XA_PRIMARY) != sWindow) {
fprintf(stderr, "nsClipboard::SetData: Cannot get ownership\n");
return NS_ERROR_FAILURE;
}
// Check from GTK. (must double check this!!)
if ((aTransferable == mGlobalTransferable.get() &&
anOwner == mGlobalOwner.get() &&
aWhichClipboard == kGlobalClipboard ) ||
(aTransferable == mSelectionTransferable.get() &&
anOwner == mSelectionOwner.get() &&
aWhichClipboard == kSelectionClipboard)
)
{
return NS_OK;
}
EmptyClipboard(aWhichClipboard);
switch(aWhichClipboard) {
case kSelectionClipboard:
mSelectionOwner = anOwner;
mSelectionTransferable = aTransferable;
break;
case kGlobalClipboard:
mGlobalOwner = anOwner;
mGlobalTransferable = aTransferable;
break;
}
return SetNativeClipboardData(aWhichClipboard);
}
NS_IMETHODIMP nsClipboard::GetData(nsITransferable *aTransferable,
PRInt32 aWhichClipboard)
{
unsigned char *data = 0;
unsigned long bytes = 0;
Bool only_if_exists;
Atom data_atom;
int i;
if (aTransferable == nsnull) {
fprintf(stderr, "nsClipboard::GetData: NULL transferable\n");
return NS_ERROR_FAILURE;
}
// Get which transferable we should use.
NS_IF_RELEASE(mTransferable);
mTransferable = GetTransferable(aWhichClipboard);
NS_ASSERTION(!mTransferable,"mTransferable is null!! see bug 80181");
if (!mTransferable) return NS_ERROR_FAILURE;
NS_ADDREF(mTransferable);
// If we currently own the selection, we will handle the paste
// internally, otherwise get the data from the X server
if (XGetSelectionOwner(sDisplay, XA_PRIMARY) == sWindow) {
const char *dataFlavor = kUnicodeMime;
nsCOMPtr<nsISupports> genDataWrapper;
nsresult rv;
PRUint32 dataLength;
nsCOMPtr<nsITransferable> trans = do_QueryInterface(aTransferable);
if (!trans)
return NS_ERROR_FAILURE;
rv = mTransferable->GetTransferData(dataFlavor,
getter_AddRefs(genDataWrapper),
&dataLength);
if (NS_SUCCEEDED(rv)) {
rv = trans->SetTransferData(dataFlavor,
genDataWrapper,
dataLength);
}
} else {
data_atom = XInternAtom(sDisplay, "DATA_ATOM", only_if_exists = False);
XConvertSelection(sDisplay, XA_PRIMARY, XA_STRING, data_atom,
sWindow, CurrentTime);
// Wait for the SelectNotify event
mBlocking = PR_TRUE;
XEvent event;
for (i=0; (mBlocking == PR_TRUE) && i<10000; i++) {
if (XPending(sDisplay)) {
XNextEvent(sDisplay, &event);
if (event.type == SelectionNotify) {
mBlocking = PR_FALSE;
}
}
}
// If we got the event, mBlocking will still be true.
// So, get the data.
if (mBlocking == PR_FALSE) {
Atom type;
int format;
unsigned long items;
if (event.xselection.property != None) {
XGetWindowProperty(sDisplay, event.xselection.requestor,
event.xselection.property, 0, 16384/4,
0, AnyPropertyType,
&type, &format, &items, &bytes, &data);
// XXX could return BadValue or BadWindow or ...
bytes = strlen((char *)data);
}
}
mBlocking = PR_FALSE;
// Place the data in the transferable
PRInt32 length = 0;
PRUnichar *testing = nsnull;
const char *constData = "";
if (data)
constData = (char*) data;
nsPrimitiveHelpers::ConvertPlatformPlainTextToUnicode(constData,
(PRInt32)bytes,
&testing,
&length);
nsCOMPtr<nsISupports> genDataWrapper;
nsPrimitiveHelpers::CreatePrimitiveForData("text/unicode",
testing, length,
getter_AddRefs(genDataWrapper));
aTransferable->SetTransferData("text/unicode",
genDataWrapper,
length);
if (data)
XFree(data);
free(testing);
}
return NS_OK;
}
NS_IMETHODIMP nsClipboard::EmptyClipboard(PRInt32 aWhichClipboard)
{
if (mIgnoreEmptyNotification) {
return NS_OK;
}
switch(aWhichClipboard) {
case kSelectionClipboard:
if (mSelectionOwner) {
mSelectionOwner->LosingOwnership(mSelectionTransferable);
mSelectionOwner = nsnull;
}
mSelectionTransferable = nsnull;
break;
case kGlobalClipboard:
if (mGlobalOwner) {
mGlobalOwner->LosingOwnership(mGlobalTransferable);
mGlobalOwner = nsnull;
}
mGlobalTransferable = nsnull;
break;
}
return NS_OK;
}
NS_IMETHODIMP nsClipboard::HasDataMatchingFlavors(nsISupportsArray *aFlavorList,
PRInt32 aWhichClipboard,
PRBool *_retval) {
*_retval = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsClipboard::SupportsSelectionClipboard(PRBool *_retval) {
NS_ENSURE_ARG_POINTER(_retval);
*_retval = PR_TRUE; // we support the selection clipboard on unix.
return NS_OK;
}

View File

@ -1,101 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
* Peter Hartshorn <peter@igelaus.com.au>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsClipboard_h__
#define nsClipboard_h__
#include "nsIClipboard.h"
#include "nsITransferable.h"
#include "nsIClipboardOwner.h"
#include <nsCOMPtr.h>
#include "nsWidget.h"
#include <X11/X.h>
#include <X11/Xlib.h>
class nsITransferable;
class nsIClipboardOwner;
class nsIWidget;
/**
* Native Xlib Clipboard wrapper
*/
class nsClipboard : public nsIClipboard
{
public:
nsClipboard();
virtual ~nsClipboard();
static void Shutdown();
//nsISupports
NS_DECL_ISUPPORTS
// nsIClipboard
NS_DECL_NSICLIPBOARD
protected:
void Init(void);
static nsEventStatus PR_CALLBACK Callback(nsGUIEvent *event);
PRBool mIgnoreEmptyNotification;
inline nsITransferable *GetTransferable(PRInt32 aWhichClipboard);
NS_IMETHOD SetNativeClipboardData(PRInt32 aWhichClipboard);
private:
static nsITransferable* mTransferable; // strong reference
nsCOMPtr<nsIClipboardOwner> mSelectionOwner;
nsCOMPtr<nsIClipboardOwner> mGlobalOwner;
nsCOMPtr<nsITransferable> mSelectionTransferable;
nsCOMPtr<nsITransferable> mGlobalTransferable;
// Used for communicating pasted data
// from the asynchronous X routines back to a blocking paste:
PRBool mBlocking;
static Window sWindow;
nsWidget *sWidget;
static Display *sDisplay;
};
#endif // nsClipboard_h__

View File

@ -1,313 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim:ts=2:et:sw=2
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard <blizzard@mozilla.org>.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Peter Hartshorn <peter@igelaus.com.au>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsAppShell.h"
#include "nsDragService.h"
#include "nsWidgetsCID.h"
#include "nsIWidget.h"
#include "nsIServiceManager.h"
#include "nsXPIDLString.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsPrimitiveHelpers.h"
#include "nsString.h"
#include <X11/extensions/shape.h>
#include "xlibrgb.h"
NS_IMPL_ISUPPORTS_INHERITED1(nsDragService,
nsBaseDragService,
nsIDragSessionXlib)
/* drag bitmaps */
static const unsigned char drag_bitmap[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00,
0x00, 0xc0, 0x02, 0x00, 0x00, 0x60, 0x06, 0x00, 0x00, 0x38, 0x04, 0x00,
0x00, 0x0e, 0x0c, 0x00, 0x80, 0x03, 0x08, 0x00, 0xe0, 0x00, 0x18, 0x00,
0xb0, 0x00, 0x30, 0x00, 0x20, 0x01, 0x60, 0x00, 0x20, 0x02, 0xc0, 0x00,
0x20, 0x04, 0x80, 0x00, 0x20, 0x02, 0x80, 0x01, 0x20, 0x01, 0x00, 0x03,
0xa0, 0x00, 0x00, 0x06, 0x60, 0x00, 0x00, 0x0c, 0x60, 0x00, 0x00, 0x08,
0x20, 0x00, 0x00, 0x0c, 0x60, 0x00, 0x00, 0x03, 0x40, 0x00, 0x80, 0x01,
0xc0, 0x00, 0xe0, 0x00, 0x80, 0x00, 0x30, 0x00, 0x80, 0x01, 0x0c, 0x00,
0x00, 0x01, 0x06, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x82, 0x01, 0x00,
0x00, 0x64, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const unsigned char drag_mask[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00,
0x00, 0xc0, 0x03, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xf8, 0x07, 0x00,
0x00, 0xfe, 0x0f, 0x00, 0x80, 0xff, 0x0f, 0x00, 0xe0, 0xff, 0x1f, 0x00,
0xf0, 0xff, 0x3f, 0x00, 0xe0, 0xff, 0x7f, 0x00, 0xe0, 0xff, 0xff, 0x00,
0xe0, 0xff, 0xff, 0x00, 0xe0, 0xff, 0xff, 0x01, 0xe0, 0xff, 0xff, 0x03,
0xe0, 0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0x0f, 0xe0, 0xff, 0xff, 0x0f,
0xe0, 0xff, 0xff, 0x0f, 0xe0, 0xff, 0xff, 0x03, 0xc0, 0xff, 0xff, 0x01,
0xc0, 0xff, 0xff, 0x00, 0x80, 0xff, 0x3f, 0x00, 0x80, 0xff, 0x0f, 0x00,
0x00, 0xff, 0x07, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xfe, 0x01, 0x00,
0x00, 0x7c, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
nsWidget *nsDragService::sWidget = nsnull;
Window nsDragService::sWindow;
XlibRgbHandle *nsDragService::sXlibRgbHandle;
Display *nsDragService::sDisplay;
PRBool nsDragService::mDragging = PR_FALSE;
nsDragService::nsDragService()
{
sXlibRgbHandle = nsAppShell::GetXlibRgbHandle();
sDisplay = xxlib_rgb_get_display(sXlibRgbHandle);
mCanDrop = PR_FALSE;
sWindow = None;
}
nsDragService::~nsDragService()
{
}
// nsIDragService
NS_IMETHODIMP nsDragService::InvokeDragSession (nsIDOMNode *aDOMNode,
nsISupportsArray *aArrayTransferables,
nsIScriptableRegion *aRegion,
PRUint32 aActionType)
{
nsBaseDragService::InvokeDragSession(aDOMNode, aArrayTransferables,
aRegion, aActionType);
/* no data - no dnd */
if (!aArrayTransferables)
return NS_ERROR_INVALID_ARG;
nsresult rv;
PRUint32 numItemsToDrag = 0;
mSourceDataItems = aArrayTransferables;
rv = mSourceDataItems->Count(&numItemsToDrag);
if (!numItemsToDrag)
return NS_ERROR_FAILURE;
mDragging = PR_TRUE;
CreateDragCursor(aActionType);
return NS_OK;
}
NS_IMETHODIMP nsDragService::StartDragSession()
{
mDragging = PR_TRUE;
return nsBaseDragService::StartDragSession();
}
NS_IMETHODIMP nsDragService::EndDragSession(PRBool aDoneDrag)
{
if (sWindow) {
XDestroyWindow(sDisplay, sWindow);
sWindow = 0;
}
mDragging = PR_FALSE;
return nsBaseDragService::EndDragSession(aDoneDrag);
}
// nsIDragSession
// For some reason we need this, but GTK does not. Hmmm...
NS_IMETHODIMP nsDragService::GetCurrentSession(nsIDragSession **aSession)
{
if (!aSession)
return NS_ERROR_FAILURE;
if (!mDragging) {
*aSession = nsnull;
return NS_OK;
}
*aSession = (nsIDragSession *)this;
NS_ADDREF(*aSession);
return NS_OK;
}
NS_IMETHODIMP nsDragService::SetCanDrop(PRBool aCanDrop)
{
mCanDrop = aCanDrop;
return NS_OK;
}
NS_IMETHODIMP nsDragService::GetCanDrop(PRBool *aCanDrop)
{
*aCanDrop = mCanDrop;
return NS_OK;
}
NS_IMETHODIMP nsDragService::GetNumDropItems(PRUint32 *aNumItems)
{
mSourceDataItems->Count(aNumItems);
return NS_OK;
}
NS_IMETHODIMP nsDragService::GetData(nsITransferable *aTransferable, PRUint32 anItemIndex)
{
if (!aTransferable)
return NS_ERROR_INVALID_ARG;
nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr <nsISupportsArray> flavorList;
rv = aTransferable->FlavorsTransferableCanImport(getter_AddRefs(flavorList));
if (NS_FAILED(rv))
return rv;
PRUint32 cnt, i;
flavorList->Count (&cnt);
for (i = 0; i < cnt; ++i) {
nsCAutoString foundFlavor;
nsCOMPtr <nsISupports> genericWrapper;
flavorList->GetElementAt(i, getter_AddRefs(genericWrapper));
nsCOMPtr <nsISupportsCString> currentFlavor;
currentFlavor = do_QueryInterface(genericWrapper);
if (currentFlavor) {
nsXPIDLCString flavorStr;
currentFlavor->ToString(getter_Copies(flavorStr));
foundFlavor = nsCAutoString(flavorStr);
#if 0
g_print("Looking for data in type %s\n",
NS_STATIC_CAST(const char*, flavorStr));
#endif
/* set the data */
nsCOMPtr <nsISupports> genItem;
mSourceDataItems->GetElementAt(anItemIndex, getter_AddRefs(genItem));
nsCOMPtr <nsITransferable> item(do_QueryInterface(genItem));
nsCOMPtr <nsISupports> data;
PRUint32 dataLen = 0;
item->GetTransferData(foundFlavor.get(), getter_AddRefs(data), &dataLen);
aTransferable->SetTransferData(foundFlavor.get(), data, dataLen);
}
}
EndDragSession(PR_TRUE);
return NS_OK;
}
NS_IMETHODIMP nsDragService::IsDataFlavorSupported(const char *aDataFlavor, PRBool *_retval)
{
/* XXX Please implement this - for now - support all flavors */
*_retval = PR_TRUE;
return NS_OK;
}
// nsIDragSessionXlib
NS_IMETHODIMP nsDragService::IsDragging(PRBool *result) {
*result = mDragging;
return NS_OK;
}
NS_IMETHODIMP nsDragService::UpdatePosition(PRInt32 x, PRInt32 y)
{
if (sWindow) {
Window aRoot, aChild;
int cx, cy;
unsigned int mask;
XQueryPointer(sDisplay, sWindow, &aRoot, &aChild, &x, &y, &cx, &cy, &mask);
XMoveWindow(sDisplay, sWindow, x, y);
}
return NS_OK;
}
void nsDragService::CreateDragCursor(PRUint32 aActionType)
{
if (sWindow == None) {
Pixmap aPixmap;
Pixmap aShapeMask;
XSetWindowAttributes wattr;
unsigned long wattr_mask;
XWMHints wmHints;
int depth;
Screen *screen = xxlib_rgb_get_screen(sXlibRgbHandle);
int screennum = XScreenNumberOfScreen(screen);
wattr.override_redirect = True;
wattr.background_pixel = XWhitePixel(sDisplay, screennum);
wattr.border_pixel = XBlackPixel(sDisplay, screennum);
wattr.colormap = xxlib_rgb_get_cmap(sXlibRgbHandle);
wattr_mask = CWOverrideRedirect | CWBorderPixel | CWBackPixel;
if (wattr.colormap)
wattr_mask |= CWColormap;
depth = xxlib_rgb_get_depth(sXlibRgbHandle);
/* make a window off-screen at -64, -64 */
sWindow = XCreateWindow(sDisplay, XRootWindowOfScreen(screen),
-64, -64, 32, 32, 0, depth,
InputOutput, xxlib_rgb_get_visual(sXlibRgbHandle),
wattr_mask, &wattr);
aPixmap = XCreatePixmapFromBitmapData(sDisplay, sWindow,
(char *)drag_bitmap,
32, 32, 0x0, 0xffffffff, depth);
aShapeMask = XCreatePixmapFromBitmapData(sDisplay, sWindow,
(char *)drag_mask,
32, 32, 0xffffffff, 0x0, 1);
wmHints.flags = StateHint;
wmHints.initial_state = NormalState;
XSetWMProperties(sDisplay, sWindow, nsnull, nsnull, nsnull, 0, nsnull,
&wmHints, nsnull);
XSetTransientForHint(sDisplay, sWindow, sWindow);
XShapeCombineMask(sDisplay, sWindow, ShapeClip, 0, 0,
aShapeMask, ShapeSet);
XShapeCombineMask(sDisplay, sWindow, ShapeBounding, 0, 0,
aShapeMask, ShapeSet);
XSetWindowBackgroundPixmap(sDisplay, sWindow, aPixmap);
XMapWindow(sDisplay, sWindow);
}
}

View File

@ -1,102 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Christopher Blizzard <blizzard@mozilla.org>.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Christopher Blizzard <blizzard@mozilla.org>
* Peter Hartshorn <peter@igelaus.com.au>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsDragService_h__
#define nsDragService_h__
#include "nsBaseDragService.h"
#include "nsIDragService.h"
#include "nsIDragSessionXlib.h"
#include "nsGUIEvent.h"
#include "nsIWidget.h"
#include "nsWidget.h"
/**
* xlib shell based on gtk
*/
class nsDragService : public nsBaseDragService, public nsIDragSessionXlib
{
public:
NS_DECL_ISUPPORTS_INHERITED
nsDragService();
virtual ~nsDragService();
// nsIDragService
NS_IMETHOD InvokeDragSession (nsIDOMNode *aDOMNode,
nsISupportsArray * anArrayTransferables,
nsIScriptableRegion * aRegion,
PRUint32 aActionType);
NS_IMETHOD StartDragSession();
NS_IMETHOD EndDragSession(PRBool aDoneDrag);
// nsIDragSession
NS_IMETHOD GetCurrentSession (nsIDragSession **aSession);
NS_IMETHOD SetCanDrop (PRBool aCanDrop);
NS_IMETHOD GetCanDrop (PRBool *aCanDrop);
NS_IMETHOD GetNumDropItems (PRUint32 * aNumItems);
NS_IMETHOD GetData (nsITransferable * aTransferable, PRUint32 anItemIndex);
NS_IMETHOD IsDataFlavorSupported (const char *aDataFlavor, PRBool *_retval);
//nsIDragSessionXlib
NS_IMETHOD IsDragging(PRBool *result);
NS_IMETHOD UpdatePosition(PRInt32 x, PRInt32 y);
protected:
static nsEventStatus PR_CALLBACK Callback(nsGUIEvent *event);
private:
static nsWidget *sWidget;
static Window sWindow;
static XlibRgbHandle *sXlibRgbHandle;
static Display *sDisplay;
static PRBool mDragging;
PRBool mCanDrop;
nsWidget *mDropWidget;
nsCOMPtr <nsISupportsArray> mSourceDataItems;
void CreateDragCursor(PRUint32 aActionType);
};
#endif // nsDragService_h__

View File

@ -1,213 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Hartshorn <peter@igelaus.com.au>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsKeyCode.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <X11/keysymdef.h>
#include "nsGUIEvent.h" // For NS_VK
struct nsKeyConverter
{
int vkCode; // Platform independent key code
unsigned int keysym; // XK keysym key code
};
struct nsKeyConverter nsKeycodes[] =
{
{ NS_VK_CANCEL, XK_Cancel},
{ NS_VK_BACK, XK_BackSpace},
{ NS_VK_TAB, XK_Tab},
#ifdef XK_ISO_Left_Tab
{ NS_VK_TAB, XK_ISO_Left_Tab }, // SunOS 5.5.1 doesn't have it.
#endif
{ NS_VK_CLEAR, XK_Clear},
{ NS_VK_RETURN, XK_Return},
{ NS_VK_ENTER, XK_KP_Enter},
{ NS_VK_SHIFT, XK_Shift_L},
{ NS_VK_SHIFT, XK_Shift_R},
{ NS_VK_CONTROL, XK_Control_L},
{ NS_VK_CONTROL, XK_Control_R},
{ NS_VK_ALT, XK_Alt_L},
{ NS_VK_ALT, XK_Alt_R},
{ NS_VK_PAUSE, XK_Pause},
{ NS_VK_CAPS_LOCK, XK_Caps_Lock},
{ NS_VK_ESCAPE, XK_Escape},
{ NS_VK_SPACE, XK_KP_Space},
{ NS_VK_SPACE, XK_space},
{ NS_VK_PAGE_UP, XK_Page_Up},
{ NS_VK_PAGE_UP, XK_KP_Page_Up},
{ NS_VK_PAGE_DOWN, XK_Page_Down},
{ NS_VK_PAGE_DOWN, XK_KP_Page_Down},
{ NS_VK_END, XK_End},
{ NS_VK_END, XK_KP_End},
{ NS_VK_HOME, XK_Home},
{ NS_VK_HOME, XK_KP_Home},
{ NS_VK_LEFT, XK_Left},
{ NS_VK_LEFT, XK_KP_Left},
{ NS_VK_UP, XK_Up},
{ NS_VK_UP, XK_KP_Up},
{ NS_VK_RIGHT, XK_Right},
{ NS_VK_RIGHT, XK_KP_Right},
{ NS_VK_DOWN, XK_Down},
{ NS_VK_DOWN, XK_KP_Down},
{ NS_VK_PRINTSCREEN, XK_Print},
{ NS_VK_INSERT, XK_Insert},
{ NS_VK_INSERT, XK_KP_Insert},
{ NS_VK_DELETE, XK_Delete},
{ NS_VK_DELETE, XK_KP_Delete},
{ NS_VK_0, XK_0},
{ NS_VK_1, XK_1},
{ NS_VK_2, XK_2},
{ NS_VK_3, XK_3},
{ NS_VK_4, XK_4},
{ NS_VK_5, XK_5},
{ NS_VK_6, XK_6},
{ NS_VK_7, XK_7},
{ NS_VK_8, XK_8},
{ NS_VK_9, XK_9},
{ NS_VK_SEMICOLON, XK_semicolon},
{ NS_VK_EQUALS, XK_equal},
{ NS_VK_NUMPAD0, XK_KP_0},
{ NS_VK_NUMPAD1, XK_KP_1},
{ NS_VK_NUMPAD2, XK_KP_2},
{ NS_VK_NUMPAD3, XK_KP_3},
{ NS_VK_NUMPAD4, XK_KP_4},
{ NS_VK_NUMPAD5, XK_KP_5},
{ NS_VK_NUMPAD6, XK_KP_6},
{ NS_VK_NUMPAD7, XK_KP_7},
{ NS_VK_NUMPAD8, XK_KP_8},
{ NS_VK_NUMPAD9, XK_KP_9},
{ NS_VK_MULTIPLY, XK_KP_Multiply},
{ NS_VK_ADD, XK_KP_Add},
{ NS_VK_SEPARATOR, XK_KP_Separator},
{ NS_VK_SUBTRACT, XK_KP_Subtract},
{ NS_VK_DECIMAL, XK_KP_Decimal},
{ NS_VK_DIVIDE, XK_KP_Divide},
{ NS_VK_F1, XK_F1},
{ NS_VK_F2, XK_F2},
{ NS_VK_F3, XK_F3},
{ NS_VK_F4, XK_F4},
{ NS_VK_F5, XK_F5},
{ NS_VK_F6, XK_F6},
{ NS_VK_F7, XK_F7},
{ NS_VK_F8, XK_F8},
{ NS_VK_F9, XK_F9},
{ NS_VK_F10, XK_F10},
{ NS_VK_F11, XK_F11},
{ NS_VK_F12, XK_F12},
{ NS_VK_F13, XK_F13},
{ NS_VK_F14, XK_F14},
{ NS_VK_F15, XK_F15},
{ NS_VK_F16, XK_F16},
{ NS_VK_F17, XK_F17},
{ NS_VK_F18, XK_F18},
{ NS_VK_F19, XK_F19},
{ NS_VK_F20, XK_F20},
{ NS_VK_F21, XK_F21},
{ NS_VK_F22, XK_F22},
{ NS_VK_F23, XK_F23},
{ NS_VK_F24, XK_F24},
{ NS_VK_NUM_LOCK, XK_Num_Lock},
{ NS_VK_SCROLL_LOCK, XK_Scroll_Lock},
{ NS_VK_COMMA, XK_comma},
{ NS_VK_PERIOD, XK_period},
{ NS_VK_SLASH, XK_slash},
{ NS_VK_BACK_QUOTE, XK_grave},
{ NS_VK_OPEN_BRACKET, XK_bracketleft},
{ NS_VK_BACK_SLASH, XK_backslash},
{ NS_VK_CLOSE_BRACKET, XK_bracketright},
{ NS_VK_QUOTE, XK_apostrophe}
};
PRInt32
nsKeyCode::ConvertKeySymToVirtualKey(KeySym keysym)
{
unsigned int i;
unsigned int length = sizeof(nsKeycodes) / sizeof(struct nsKeyConverter);
if (keysym >= XK_a && keysym <= XK_z)
return keysym - XK_a + NS_VK_A;
if (keysym >= XK_A && keysym <= XK_Z)
return keysym - XK_A + NS_VK_A;
for (i = 0; i < length; i++)
{
if (nsKeycodes[i].keysym == keysym)
{
return(nsKeycodes[i].vkCode);
}
}
return((int)0);
}
//////////////////////////////////////////////////////////////////////////
/* static */ PRBool
nsKeyCode::KeyCodeIsModifier(KeyCode aKeyCode)
{
if (aKeyCode == XK_Shift_L ||
aKeyCode == XK_Shift_R ||
aKeyCode == XK_Control_L ||
aKeyCode == XK_Control_R ||
aKeyCode == XK_Caps_Lock ||
aKeyCode == XK_Shift_Lock ||
aKeyCode == XK_Meta_L ||
aKeyCode == XK_Meta_R ||
aKeyCode == XK_Alt_L ||
aKeyCode == XK_Alt_R)
{
return PR_TRUE;
}
return PR_FALSE;
}
//////////////////////////////////////////////////////////////////////////
/* static */ KeySym
nsKeyCode::ConvertKeyCodeToKeySym(Display * aDisplay, KeyCode aKeyCode)
{
KeySym keysym = 0;
keysym = XKeycodeToKeysym(aDisplay, aKeyCode, 0);
return keysym;
}
//////////////////////////////////////////////////////////////////////////

View File

@ -1,56 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsKeyCode_h
#define __nsKeyCode_h
#include <X11/X.h>
#include <X11/Xlib.h>
#include "prtypes.h"
struct nsKeyCode
{
static PRInt32 ConvertKeySymToVirtualKey(KeySym aKeySym);
static PRBool KeyCodeIsModifier(KeyCode aKeyCode);
static KeySym ConvertKeyCodeToKeySym(Display *aDisplay,
KeyCode aKeyCode);
};
#endif // __nsKeyCode_h

View File

@ -1,384 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsLookAndFeel.h"
#include "nsWidget.h"
nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
{
PR_LOG(XlibWidgetsLM, PR_LOG_DEBUG, ("nsLookAndFeel::nsLookAndFeel()\n"));
}
nsLookAndFeel::~nsLookAndFeel()
{
PR_LOG(XlibWidgetsLM, PR_LOG_DEBUG, ("nsLookAndFeel::~nsLookAndFeel()\n"));
}
nsresult nsLookAndFeel::NativeGetColor(const nsColorID aID, nscolor &aColor)
{
PR_LOG(XlibWidgetsLM, PR_LOG_DEBUG, ("nsLookAndFeel::NativeGetColor()\n"));
nsresult res = NS_OK;
aColor = 0;
switch (aID) {
case eColor_WindowBackground:
aColor = NS_RGB(0xcc, 0xcc, 0xcc);
break;
case eColor_WindowForeground:
aColor = NS_RGB(0x00, 0x00, 0x00);
break;
case eColor_WidgetBackground:
aColor = NS_RGB(0xcc, 0xcc, 0xcc);
break;
case eColor_WidgetForeground:
aColor = NS_RGB(0x00, 0x00, 0x00);
break;
case eColor_WidgetSelectBackground:
aColor = NS_RGB(0x00, 0x00, 0x9c);
break;
case eColor_WidgetSelectForeground:
aColor = NS_RGB(0xff, 0xff, 0xff);
break;
case eColor_Widget3DHighlight:
aColor = NS_RGB(0x99,0x99,0x99);
break;
case eColor_Widget3DShadow:
aColor = NS_RGB(0x40,0x40,0x40);
break;
case eColor_TextBackground:
aColor = NS_RGB(0xff, 0xff, 0xff);
break;
case eColor_TextForeground:
aColor = NS_RGB(0x00, 0x00, 0x00);
break;
case eColor_TextSelectBackground:
case eColor_IMESelectedRawTextBackground:
case eColor_IMESelectedConvertedTextBackground:
aColor = NS_RGB(0x00, 0x00, 0x9c);
break;
case eColor_TextSelectForeground:
case eColor_IMESelectedRawTextForeground:
case eColor_IMESelectedConvertedTextForeground:
aColor = NS_RGB(0xff, 0xff, 0xff);
break;
case eColor_IMERawInputBackground:
case eColor_IMEConvertedTextBackground:
aColor = NS_TRANSPARENT;
break;
case eColor_IMERawInputForeground:
case eColor_IMEConvertedTextForeground:
aColor = NS_SAME_AS_FOREGROUND_COLOR;
break;
case eColor_IMERawInputUnderline:
case eColor_IMEConvertedTextUnderline:
aColor = NS_SAME_AS_FOREGROUND_COLOR;
break;
case eColor_IMESelectedRawTextUnderline:
case eColor_IMESelectedConvertedTextUnderline:
aColor = NS_TRANSPARENT;
break;
// css2 http://www.w3.org/TR/REC-CSS2/ui.html#system-colors
case eColor_activeborder:
aColor = NS_RGB(0x00, 0x00, 0x00);
break;
case eColor_activecaption:
aColor = NS_RGB(0xcc, 0xcc, 0xcc);
break;
case eColor_appworkspace:
aColor = NS_RGB(0xcc, 0xcc, 0xcc);
break;
case eColor_background:
aColor = NS_RGB(0xcc, 0xcc, 0xcc);
break;
case eColor_captiontext:
aColor = NS_RGB(0x00, 0x00, 0x00);
break;
case eColor_graytext:
aColor = NS_RGB(0x80, 0x80, 0x80);
break;
case eColor_highlight:
case eColor__moz_menuhover:
aColor = NS_RGB(0x00, 0x00, 0x9c);
break;
case eColor_highlighttext:
case eColor__moz_menuhovertext:
aColor = NS_RGB(0xff, 0xff, 0xff);
break;
case eColor_inactiveborder:
aColor = NS_RGB(0xcc, 0xcc, 0xcc);
break;
case eColor_inactivecaption:
aColor = NS_RGB(0x80, 0x80, 0x80);
break;
case eColor_inactivecaptiontext:
aColor = NS_RGB(0xff, 0xff, 0xff);
break;
case eColor_infobackground:
aColor = NS_RGB(0xcc, 0xcc, 0xcc);
break;
case eColor_infotext:
aColor = NS_RGB(0x00, 0x00, 0x00);
break;
case eColor_menu:
aColor = NS_RGB(0xcc, 0xcc, 0xcc);
break;
case eColor_menutext:
aColor = NS_RGB(0x00, 0x00, 0x00);
break;
case eColor_scrollbar:
aColor = NS_RGB(0xcc, 0xcc, 0xcc);
break;
case eColor_threedface:
// 3-D face color
case eColor_buttonface:
case eColor__moz_buttonhoverface:
// 3-D face color
case eColor_threedlightshadow:
// 3-D inner highlight color
aColor = NS_RGB(0xcc, 0xcc, 0xcc);
break;
case eColor_buttonhighlight:
// 3-D highlight color
case eColor_threedhighlight:
// 3-D outer highlight color
aColor = NS_RGB(0xff, 0xff, 0xff);
break;
case eColor_buttontext:
case eColor__moz_buttonhovertext:
aColor = NS_RGB(0x00, 0x00, 0x00);
break;
case eColor_buttonshadow:
// 3-D shadow color
case eColor_threedshadow:
// 3-D inner shadow color
aColor = NS_RGB(0x66, 0x66, 0x66);
break;
case eColor_threeddarkshadow:
// 3-D outer shadow color
aColor = NS_RGB(0x00, 0x00, 0x00);
break;
case eColor_window:
case eColor_windowframe:
aColor = NS_RGB(0xcc, 0xcc, 0xcc);
break;
case eColor_windowtext:
aColor = NS_RGB(0x00, 0x00, 0x00);
break;
case eColor__moz_field:
aColor = NS_RGB(0xff, 0xff, 0xff);
break;
case eColor__moz_fieldtext:
aColor = NS_RGB(0x00, 0x00, 0x00);
break;
case eColor__moz_dialog:
case eColor__moz_cellhighlight:
aColor = NS_RGB(0xcc, 0xcc, 0xcc);
break;
case eColor__moz_dialogtext:
case eColor__moz_cellhighlighttext:
aColor = NS_RGB(0x00, 0x00, 0x00);
break;
case eColor__moz_buttondefault:
// default button border color
aColor = NS_RGB(0x00, 0x00, 0x00);
break;
default:
/* default color is BLACK */
aColor = 0;
res = NS_ERROR_FAILURE;
break;
}
return NS_OK;
}
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricID aID, PRInt32 & aMetric)
{
PR_LOG(XlibWidgetsLM, PR_LOG_DEBUG, ("nsLookAndFeel::GetMetric()\n"));
// XXX These are not complete!
nsresult res = nsXPLookAndFeel::GetMetric(aID, aMetric);
if (NS_SUCCEEDED(res))
return res;
res = NS_OK;
switch (aID) {
case eMetric_WindowTitleHeight:
aMetric = 20;
break;
case eMetric_WindowBorderWidth:
aMetric = 1;
break;
case eMetric_WindowBorderHeight:
aMetric = 1;
break;
case eMetric_Widget3DBorder:
aMetric = 1;
break;
case eMetric_TextFieldHeight:
aMetric = 24;
break;
case eMetric_ButtonHorizontalInsidePaddingNavQuirks:
aMetric = 10;
break;
case eMetric_ButtonHorizontalInsidePaddingOffsetNavQuirks:
aMetric = 8;
break;
case eMetric_CheckboxSize:
aMetric = 15;
break;
case eMetric_RadioboxSize:
aMetric = 15;
break;
case eMetric_TextHorizontalInsideMinimumPadding:
aMetric = 3;
break;
case eMetric_TextVerticalInsidePadding:
aMetric = 0;
break;
case eMetric_TextShouldUseVerticalInsidePadding:
aMetric = 0;
break;
case eMetric_TextShouldUseHorizontalInsideMinimumPadding:
aMetric = 1;
break;
case eMetric_ListShouldUseHorizontalInsideMinimumPadding:
aMetric = 0;
break;
case eMetric_ListHorizontalInsideMinimumPadding:
aMetric = 3;
break;
case eMetric_ListShouldUseVerticalInsidePadding:
aMetric = 0;
break;
case eMetric_ListVerticalInsidePadding:
aMetric = 0;
break;
case eMetric_CaretBlinkTime:
aMetric = 500;
break;
case eMetric_CaretWidth:
aMetric = 1;
break;
case eMetric_ShowCaretDuringSelection:
aMetric = 0;
break;
case eMetric_SelectTextfieldsOnKeyFocus:
// Select textfield content when focused by kbd
// used by nsEventStateManager::sTextfieldSelectModel
aMetric = 1;
break;
case eMetric_SubmenuDelay:
aMetric = 200;
break;
case eMetric_TreeOpenDelay:
aMetric = 1000;
break;
case eMetric_TreeCloseDelay:
aMetric = 1000;
break;
case eMetric_TreeLazyScrollDelay:
aMetric = 150;
break;
case eMetric_TreeScrollDelay:
aMetric = 100;
break;
case eMetric_TreeScrollLinesMax:
aMetric = 3;
break;
default:
aMetric = 0;
res = NS_ERROR_FAILURE;
}
return res;
}
NS_IMETHODIMP nsLookAndFeel::GetMetric(const nsMetricFloatID aID, float & aMetric)
{
PR_LOG(XlibWidgetsLM, PR_LOG_DEBUG, ("nsLookAndFeel::GetMetric()\n"));
// XXX this is not complete
nsresult res = nsXPLookAndFeel::GetMetric(aID, aMetric);
if (NS_SUCCEEDED(res))
return res;
res = NS_OK;
switch (aID) {
case eMetricFloat_TextFieldVerticalInsidePadding:
aMetric = 0.25f;
break;
case eMetricFloat_TextFieldHorizontalInsidePadding:
aMetric = 0.95f;
break;
case eMetricFloat_TextAreaVerticalInsidePadding:
aMetric = 0.40f;
break;
case eMetricFloat_TextAreaHorizontalInsidePadding:
aMetric = 0.40f;
break;
case eMetricFloat_ListVerticalInsidePadding:
aMetric = 0.10f;
break;
case eMetricFloat_ListHorizontalInsidePadding:
aMetric = 0.40f;
break;
case eMetricFloat_ButtonVerticalInsidePadding:
aMetric = 0.25f;
break;
case eMetricFloat_ButtonHorizontalInsidePadding:
aMetric = 0.25f;
break;
case eMetricFloat_IMEUnderlineRelativeSize:
aMetric = 1.0f;
break;
default:
aMetric = -1.0;
res = NS_ERROR_FAILURE;
}
return res;
}

View File

@ -1,53 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsLookAndFeel
#define __nsLookAndFeel
#include "nsXPLookAndFeel.h"
class nsLookAndFeel: public nsXPLookAndFeel {
public:
nsLookAndFeel();
virtual ~nsLookAndFeel();
nsresult NativeGetColor(const nsColorID aID, nscolor &aColor);
NS_IMETHOD GetMetric(const nsMetricID aID, PRInt32 & aMetric);
NS_IMETHOD GetMetric(const nsMetricFloatID aID, float & aMetric);
};
#endif

View File

@ -1,127 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Hartshorn <peter@igelaus.com.au>
* Ken Faulkner <faulkner@igelaus.com.au>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsScreenManagerXlib.h"
#include "nsScreenXlib.h"
nsScreenManagerXlib :: nsScreenManagerXlib ( )
{
// nothing else to do. I guess we could cache a bunch of information
// here, but we want to ask the device at runtime in case anything
// has changed.
}
nsScreenManagerXlib :: ~nsScreenManagerXlib()
{
// nothing to see here.
}
// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenManagerXlib, nsIScreenManager)
//
// CreateNewScreenObject
//
// Utility routine. Creates a new screen object from the given device handle
//
// NOTE: For this "single-monitor" impl, we just always return the cached primary
// screen. This should change when a multi-monitor impl is done.
//
nsIScreen*
nsScreenManagerXlib :: CreateNewScreenObject ( )
{
nsIScreen* retval = nsnull;
if ( !mCachedMainScreen )
mCachedMainScreen = new nsScreenXlib ( );
NS_IF_ADDREF(retval = mCachedMainScreen.get());
return retval;
}
//
// ScreenForRect
//
// Returns the screen that contains the rectangle. If the rect overlaps
// multiple screens, it picks the screen with the greatest area of intersection.
//
// The coordinates are in pixels (not twips) and in screen coordinates.
//
NS_IMETHODIMP
nsScreenManagerXlib :: ScreenForRect ( PRInt32 /*inLeft*/, PRInt32 /*inTop*/, PRInt32 /*inWidth*/,
PRInt32 /*inHeight*/, nsIScreen **outScreen )
{
GetPrimaryScreen ( outScreen );
return NS_OK;
} // ScreenForRect
//
// GetPrimaryScreen
//
// The screen with the menubar/taskbar. This shouldn't be needed very
// often.
//
NS_IMETHODIMP
nsScreenManagerXlib :: GetPrimaryScreen(nsIScreen * *aPrimaryScreen)
{
*aPrimaryScreen = CreateNewScreenObject(); // addrefs
return NS_OK;
} // GetPrimaryScreen
//
// GetNumberOfScreens
//
// Returns how many physical screens are available.
//
NS_IMETHODIMP
nsScreenManagerXlib :: GetNumberOfScreens(PRUint32 *aNumberOfScreens)
{
*aNumberOfScreens = 1;
return NS_OK;
} // GetNumberOfScreens

View File

@ -1,67 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Hartshorn <peter@igelaus.com.au>
* Ken Faulkner <faulkner@igelaus.com.au>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsScreenManagerXlib_h___
#define nsScreenManagerXlib_h___
#include "nsIScreenManager.h"
#include "nsIScreen.h"
#include "nsCOMPtr.h"
//------------------------------------------------------------------------
class nsScreenManagerXlib : public nsIScreenManager
{
public:
nsScreenManagerXlib ( );
virtual ~nsScreenManagerXlib();
NS_DECL_ISUPPORTS
NS_DECL_NSISCREENMANAGER
private:
nsIScreen* CreateNewScreenObject ( ) ;
// cache the primary screen object to avoid memory allocation every time
nsCOMPtr<nsIScreen> mCachedMainScreen;
};
#endif // nsScreenManagerXlib_h___

View File

@ -1,117 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Hartshorn <peter@igelaus.com.au>
* Ken Faulkner <faulkner@igelaus.com.au>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsScreenXlib.h"
#include "xlibrgb.h"
#include <stdlib.h>
nsScreenXlib :: nsScreenXlib ( )
{
// nothing else to do. I guess we could cache a bunch of information
// here, but we want to ask the device at runtime in case anything
// has changed.
}
nsScreenXlib :: ~nsScreenXlib()
{
// nothing to see here.
}
// addref, release, QI
NS_IMPL_ISUPPORTS1(nsScreenXlib, nsIScreen)
NS_IMETHODIMP
nsScreenXlib :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{
XlibRgbHandle *xrh;
if (!(xrh = xxlib_find_handle(XXLIBRGB_DEFAULT_HANDLE)))
abort();
*outTop = 0;
*outLeft = 0;
*outWidth = XDisplayWidth(xxlib_rgb_get_display(xrh), 0);
*outHeight = XDisplayHeight(xxlib_rgb_get_display(xrh), 0);
return NS_OK;
} // GetRect
NS_IMETHODIMP
nsScreenXlib :: GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
{
XlibRgbHandle *xrh;
if (!(xrh = xxlib_find_handle(XXLIBRGB_DEFAULT_HANDLE)))
abort();
*outTop = 0;
*outLeft = 0;
*outWidth = XDisplayWidth(xxlib_rgb_get_display(xrh), 0);
*outHeight = XDisplayHeight(xxlib_rgb_get_display(xrh), 0);
return NS_OK;
} // GetAvailRect
NS_IMETHODIMP
nsScreenXlib :: GetPixelDepth(PRInt32 *aPixelDepth)
{
XlibRgbHandle *xrh;
if (!(xrh = xxlib_find_handle(XXLIBRGB_DEFAULT_HANDLE)))
abort();
*aPixelDepth = xxlib_rgb_get_depth(xrh);
return NS_OK;
} // GetPixelDepth
NS_IMETHODIMP
nsScreenXlib :: GetColorDepth(PRInt32 *aColorDepth)
{
return GetPixelDepth ( aColorDepth );
} // GetColorDepth

View File

@ -1,60 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Peter Hartshorn <peter@igelaus.com.au>
* Ken Faulkner <faulkner@igelaus.com.au>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsScreenXlib_h___
#define nsScreenXlib_h___
#include "nsIScreen.h"
//------------------------------------------------------------------------
class nsScreenXlib : public nsIScreen
{
public:
nsScreenXlib ( );
virtual ~nsScreenXlib();
NS_DECL_ISUPPORTS
NS_DECL_NSISCREEN
private:
};
#endif // nsScreenXlib_h___

View File

@ -1,111 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
* Peter Hartshorn <peter@igelaus.com.au>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nscore.h"
#include "plstr.h"
#include "prlink.h"
#include "nsSound.h"
#include "nsAppShell.h"
#include "nsIURL.h"
#include "nsNetUtil.h"
#include "nsCOMPtr.h"
#include <stdio.h>
#include <unistd.h>
NS_IMPL_THREADSAFE_ISUPPORTS2(nsSound, nsISound, nsIStreamLoaderObserver)
////////////////////////////////////////////////////////////////////////
nsSound::nsSound()
{
}
nsSound::~nsSound()
{
}
NS_IMETHODIMP nsSound::Init()
{
#ifdef DEBUG_faulkner
fprintf(stderr, "\n////////// nsSound::Init() in xlib called //////////\n");
#endif /* DEBUG_faulkner */
return NS_OK;
}
NS_IMETHODIMP nsSound::OnStreamComplete(nsIStreamLoader *aLoader,
nsISupports *context,
nsresult aStatus,
PRUint32 stringLen,
const PRUint8 *string)
{
#ifdef DEBUG_faulkner
fprintf(stderr, "\n////////// nsSound::Init() in xlib called //////////\n");
#endif /* DEBUG_faulkner */
return NS_OK;
}
NS_METHOD nsSound::Beep()
{
#ifdef DEBUG_faulkner
fprintf(stderr, "\n////////// nsSound::Beep() in xlib called //////////\n");
#endif /* DEBUG_faulkner */
XBell(nsAppShell::mDisplay, 80);
return NS_OK;
}
NS_METHOD nsSound::Play(nsIURL *aURL)
{
#ifdef DEBUG_faulkner
fprintf(stderr, "\n////////// nsSound::Play() in xlib called //////////\n");
#endif /* DEBUG_faulkner */
return NS_OK;
}
NS_IMETHODIMP nsSound::PlaySystemSound(const nsAString &aSoundAlias)
{
return Beep();
}

View File

@ -1,61 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Stuart Parmenter <pavlov@netscape.com>
* Peter Hartshorn <peter@igelaus.com.au>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsSound_h__
#define __nsSound_h__
#include "nsISound.h"
#include "nsIStreamLoader.h"
class nsSound : public nsISound,
public nsIStreamLoaderObserver
{
public:
nsSound();
virtual ~nsSound();
NS_DECL_ISUPPORTS
NS_DECL_NSISOUND
NS_DECL_NSISTREAMLOADEROBSERVER
};
#endif /* __nsSound_h__ */

Some files were not shown because too many files have changed in this diff Show More