Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2007-10-05 18:22:41 +0000
committerAndrew Niefer2007-10-05 18:22:41 +0000
commit2cb8cc250a06e04d4e237eb33b60a2a07ec8d9e6 (patch)
tree379901e355918ff45335fdc49324d5870b9f34fd /bundles/org.eclipse.equinox.executable/library/motif
parent4e3aa09c05ebda8375c36b7c0aed0312fc787520 (diff)
downloadrt.equinox.framework-2cb8cc250a06e04d4e237eb33b60a2a07ec8d9e6.tar.gz
rt.equinox.framework-2cb8cc250a06e04d4e237eb33b60a2a07ec8d9e6.tar.xz
rt.equinox.framework-2cb8cc250a06e04d4e237eb33b60a2a07ec8d9e6.zip
bug 201414
Diffstat (limited to 'bundles/org.eclipse.equinox.executable/library/motif')
-rw-r--r--bundles/org.eclipse.equinox.executable/library/motif/NgImage.c95
-rw-r--r--bundles/org.eclipse.equinox.executable/library/motif/NgImage.h17
-rw-r--r--bundles/org.eclipse.equinox.executable/library/motif/eclipseMotif.c102
-rw-r--r--bundles/org.eclipse.equinox.executable/library/motif/eclipseMotif.h93
-rw-r--r--bundles/org.eclipse.equinox.executable/library/motif/eclipseMotifCommon.c117
-rw-r--r--bundles/org.eclipse.equinox.executable/library/motif/eclipseMotifInit.c144
-rw-r--r--bundles/org.eclipse.equinox.executable/library/motif/make_aix.mak7
-rw-r--r--bundles/org.eclipse.equinox.executable/library/motif/make_linux.mak8
-rw-r--r--bundles/org.eclipse.equinox.executable/library/motif/make_solaris.mak6
9 files changed, 460 insertions, 129 deletions
diff --git a/bundles/org.eclipse.equinox.executable/library/motif/NgImage.c b/bundles/org.eclipse.equinox.executable/library/motif/NgImage.c
index 04ffbe701..bd2abf2dd 100644
--- a/bundles/org.eclipse.equinox.executable/library/motif/NgImage.c
+++ b/bundles/org.eclipse.equinox.executable/library/motif/NgImage.c
@@ -13,13 +13,73 @@
#include "NgImageData.h"
#include "NgImage.h"
#include "NgWinBMPFileFormat.h"
+#include <dlfcn.h>
+struct NG_PTRS ng;
+
+#define FN_TABLE_ENTRY(fn) { (void**)&ng.fn, #fn }
+typedef struct {
+ void ** fnPtr;
+ char * fnName;
+} FN_TABLE;
+static FN_TABLE x11Functions[] = { FN_TABLE_ENTRY(XCreateGC),
+ FN_TABLE_ENTRY(XCreateImage),
+ FN_TABLE_ENTRY(XCreatePixmap),
+ FN_TABLE_ENTRY(XDefaultColormap),
+ FN_TABLE_ENTRY(XDefaultDepthOfScreen),
+ FN_TABLE_ENTRY(XDefaultRootWindow),
+ FN_TABLE_ENTRY(XDefaultScreen),
+ FN_TABLE_ENTRY(XDefaultScreenOfDisplay),
+ FN_TABLE_ENTRY(XDefaultVisual),
+ FN_TABLE_ENTRY(XFreeGC),
+ FN_TABLE_ENTRY(XFreePixmap),
+ FN_TABLE_ENTRY(XPutImage),
+ FN_TABLE_ENTRY(XQueryColor),
+ { NULL, NULL }
+ };
+
+static FN_TABLE xtFunctions[] = { FN_TABLE_ENTRY(XtMalloc), {NULL, NULL} };
+
+int NGImageInit() {
+ int i = 0;
+ void * fn;
+#ifdef AIX
+ void * x11Lib = dlopen(X11_LIB, RTLD_LAZY | RTLD_MEMBER);
+ void * xtLib = dlopen(XT_LIB, RTLD_LAZY | RTLD_MEMBER);
+#else
+ void * x11Lib = dlopen(X11_LIB, RTLD_LAZY);
+ void * xtLib = dlopen(XT_LIB, RTLD_LAZY);
+#endif
+ /* initialize ptr struct to 0's */
+ memset(&ng, 0, sizeof(struct NG_PTRS));
+
+
+ if (x11Lib == NULL || xtLib == NULL)
+ return -1;
+
+ for (i = 0; x11Functions[i].fnName != NULL; i++) {
+ fn = dlsym(x11Lib, x11Functions[i].fnName);
+ if (fn != 0)
+ *(x11Functions[i].fnPtr) = fn;
+ else
+ return -1;
+ }
+
+ for (i = 0; xtFunctions[i].fnName != NULL; i++) {
+ fn = dlsym(xtLib, xtFunctions[i].fnName);
+ if (fn != 0)
+ *(xtFunctions[i].fnPtr) = fn;
+ else
+ return -1;
+ }
+ return 0;
+}
/**
* Return the nbr of entries in the default color palette
*/
int getNbrColorsXPalette(Display *xDisplay)
{
- Visual *visual = XDefaultVisual (xDisplay, XDefaultScreen(xDisplay));
+ Visual *visual = ng.XDefaultVisual (xDisplay, ng.XDefaultScreen(xDisplay));
return visual->map_entries;
}
@@ -32,11 +92,11 @@ ng_err_t getXPalette (Display *xDisplay, int numColors, char* palette)
XColor color;
int i;
int index = 0;
- int colormap = XDefaultColormap (xDisplay, XDefaultScreen(xDisplay));
+ int colormap = ng.XDefaultColormap (xDisplay, ng.XDefaultScreen(xDisplay));
for (i = 0; i < numColors; i++)
{
color.pixel = i;
- XQueryColor (xDisplay, colormap, &color);
+ ng.XQueryColor (xDisplay, colormap, &color);
palette[index++] = ((color.red >> 8) & 0xFF);
palette[index++] = ((color.green >> 8) & 0xFF);
palette[index++] = ((color.blue >> 8) & 0xFF);
@@ -69,7 +129,7 @@ ng_err_t putImage(ng_bitmap_image_t *image, int srcX, int srcY, int srcWidth, in
numColors = getNbrColorsXPalette (xDisplay);
if (numColors == 0)
return NgError (ERR_NG, "Error pseudo-color mode detected, no colors available");
- numColors = 1 << XDefaultDepthOfScreen (XDefaultScreenOfDisplay (xDisplay));
+ numColors = 1 << ng.XDefaultDepthOfScreen (ng.XDefaultScreenOfDisplay (xDisplay));
screenDirect = 0;
} else
{
@@ -79,11 +139,11 @@ ng_err_t putImage(ng_bitmap_image_t *image, int srcX, int srcY, int srcWidth, in
screenDirect = 1;
}
- xImagePtr = XCreateImage(xDisplay, visual, screenDepth, ZPixmap, 0, 0, srcWidth, srcHeight, 32, 0);
+ xImagePtr = ng.XCreateImage(xDisplay, visual, screenDepth, ZPixmap, 0, 0, srcWidth, srcHeight, 32, 0);
if (xImagePtr == NULL) return NgError (ERR_NG, "Error XCreateImage failed");
bufSize = xImagePtr->bytes_per_line * srcHeight;
- xImagePtr->data = (char*) XtMalloc (bufSize);
+ xImagePtr->data = (char*) ng.XtMalloc (bufSize);
sbpp = NgBitmapImageBytesPerRow(image);
dbpp = xImagePtr->bytes_per_line;
@@ -104,11 +164,11 @@ ng_err_t putImage(ng_bitmap_image_t *image, int srcX, int srcY, int srcWidth, in
NgFree (palette);
}
- tempGC = XCreateGC (xDisplay, drawable, 0, NULL);
- XPutImage(xDisplay, drawable, tempGC, xImagePtr, 0, 0, 0, 0, srcWidth, srcHeight);
+ tempGC = ng.XCreateGC (xDisplay, drawable, 0, NULL);
+ ng.XPutImage(xDisplay, drawable, tempGC, xImagePtr, 0, 0, 0, 0, srcWidth, srcHeight);
XDestroyImage (xImagePtr);
- XFreeGC (xDisplay, tempGC);
+ ng.XFreeGC (xDisplay, tempGC);
return ERR_OK;
}
@@ -118,8 +178,8 @@ ng_err_t init(ng_bitmap_image_t *image, Display *xDisplay, int screenDepth, int
int width = (int)NgBitmapImageWidth(image);
int height = (int)NgBitmapImageHeight(image);
- Visual *visual = XDefaultVisual(xDisplay, XDefaultScreen(xDisplay));
- *pixmap = XCreatePixmap(xDisplay, drawable, width, height, screenDepth);
+ Visual *visual = ng.XDefaultVisual(xDisplay, ng.XDefaultScreen(xDisplay));
+ *pixmap = ng.XCreatePixmap(xDisplay, drawable, width, height, screenDepth);
if (*pixmap == 0)
{
return NgError (ERR_NG, "Error XCreatePixmap failed");
@@ -127,7 +187,7 @@ ng_err_t init(ng_bitmap_image_t *image, Display *xDisplay, int screenDepth, int
err = putImage(image, 0, 0, width, height, 0, 0, xDisplay, visual, screenDepth, *pixmap);
if (err != ERR_OK)
{
- XFreePixmap (xDisplay, *pixmap);
+ ng.XFreePixmap (xDisplay, *pixmap);
return NgError (err, "Error putImage failed");
}
@@ -145,15 +205,20 @@ ng_err_t init(ng_bitmap_image_t *image, Display *xDisplay, int screenDepth, int
* returned value: the pixmap newly created if successful. 0 otherwise.
*/
Pixmap loadBMPImage (Display *display, Screen *screen, char *bmpPathname) {
- Window drawable = XDefaultRootWindow (display);
+ Window drawable;
ng_stream_t in;
ng_bitmap_image_t image;
ng_err_t err = ERR_OK;
- int screenDepth = XDefaultDepthOfScreen (screen);
+ int screenDepth;
Pixmap pixmap;
+ /* this must be called before any X functions are used */
+ NGImageInit();
NgInit();
-
+
+ drawable = ng.XDefaultRootWindow (display);
+ screenDepth = ng.XDefaultDepthOfScreen (screen);
+
if (NgStreamInit (&in, bmpPathname) != ERR_OK)
{
NgError (ERR_NG, "Error can't open BMP file");
diff --git a/bundles/org.eclipse.equinox.executable/library/motif/NgImage.h b/bundles/org.eclipse.equinox.executable/library/motif/NgImage.h
index 9f1b1320a..c9c711d9d 100644
--- a/bundles/org.eclipse.equinox.executable/library/motif/NgImage.h
+++ b/bundles/org.eclipse.equinox.executable/library/motif/NgImage.h
@@ -17,6 +17,23 @@
#include <X11/Xos.h>
#include <X11/Intrinsic.h>
+struct NG_PTRS {
+ GC (*XCreateGC) (Display*, Drawable, unsigned long, XGCValues*);
+ XImage * (*XCreateImage) (Display*, Visual*, unsigned int, int, int, char*, unsigned int, unsigned int, int, int);
+ Pixmap (*XCreatePixmap) (Display*, Drawable, unsigned int, unsigned int, unsigned int);
+ Colormap (*XDefaultColormap) (Display*, int);
+ int (*XDefaultDepthOfScreen)(Screen*);
+ Window (*XDefaultRootWindow) (Display*);
+ int (*XDefaultScreen) (Display*);
+ Screen * (*XDefaultScreenOfDisplay)(Display*);
+ Visual * (*XDefaultVisual) (Display*, int);
+ int (*XFreeGC) (Display*, GC);
+ int (*XFreePixmap) (Display*, Pixmap);
+ int (*XPutImage) (Display*, Drawable, GC, XImage*, int, int, int, int, unsigned int, unsigned int);
+ int (*XQueryColor) (Display*, Colormap, XColor*);
+ char * (*XtMalloc) (Cardinal);
+};
+
/**
* loadBMPImage
* Create a pixmap representing the given BMP file, for the specified display and screen.
diff --git a/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotif.c b/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotif.c
index c3cda9ce7..d962b6a4f 100644
--- a/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotif.c
+++ b/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotif.c
@@ -14,17 +14,11 @@
/* UNIX/Motif specific logic for displaying the splash screen. */
#include "eclipseCommon.h"
#include "eclipseMozilla.h"
+#include "eclipseMotif.h"
#include "eclipseOS.h"
#include "eclipseUtil.h"
#include "NgImage.h"
-#include <Xm/XmAll.h>
-#include <X11/X.h>
-#include <X11/Xlib.h>
-#include <X11/IntrinsicP.h>
-#include <X11/Intrinsic.h>
-#include <X11/Shell.h>
-
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
@@ -94,9 +88,13 @@ int showSplash( const char* featureImage )
if (initialArgv == NULL)
initialArgc = 0;
- initWindowSystem(&initialArgc, initialArgv, 1);
- xDisplay = XtDisplay(topWindow);
- screen = XDefaultScreenOfDisplay( xDisplay );
+
+ if (initWindowSystem(&initialArgc, initialArgv, 1) != 0) {
+ return -1;
+ }
+
+ xDisplay = motif_XtDisplay(topWindow);
+ screen = motif.XDefaultScreenOfDisplay( xDisplay );
if (featureImage != NULL)
{
splashPixmap = loadBMPImage(xDisplay, screen, (char*)featureImage);
@@ -105,7 +103,7 @@ int showSplash( const char* featureImage )
if (splashPixmap == 0)
return ENOENT;
- XGetGeometry (xDisplay, splashPixmap, &root, &x, &y, &width, &height, &border, &depth);
+ motif.XGetGeometry (xDisplay, splashPixmap, &root, &x, &y, &width, &height, &border, &depth);
/* make sure we never pass more than 20 args */
args = malloc(10 * sizeof(Arg));
@@ -113,50 +111,50 @@ int showSplash( const char* featureImage )
nArgs = 0;
/* Note that XtSetArg is a macro, and the 1st argument will be evaluated twice
* so increment nArgs on its own */
- XtSetArg(args[nArgs], XmNmwmDecorations, 0); nArgs++;
- XtSetArg(args[nArgs], XmNtitle, getOfficialName()); nArgs++;
- XtSetArg(args[nArgs], XmNwidth, width); nArgs++;
- XtSetArg(args[nArgs], XmNheight, height); nArgs++;
- shellHandle = XtAppCreateShell(getOfficialName(), "", applicationShellWidgetClass, xDisplay, args, nArgs);
- XtAddCallback(shellHandle, XmNdestroyCallback, (XtCallbackProc) takeDownSplashCB, NULL);
+ motif_XtSetArg(args[nArgs], XmNmwmDecorations, 0); nArgs++;
+ motif_XtSetArg(args[nArgs], XmNtitle, getOfficialName()); nArgs++;
+ motif_XtSetArg(args[nArgs], XmNwidth, width); nArgs++;
+ motif_XtSetArg(args[nArgs], XmNheight, height); nArgs++;
+ shellHandle = motif.XtAppCreateShell(getOfficialName(), "", *motif.applicationShellWidgetClass, xDisplay, args, nArgs);
+ motif.XtAddCallback(shellHandle, XmNdestroyCallback, (XtCallbackProc) takeDownSplashCB, NULL);
nArgs = 0;
- XtSetArg(args[nArgs++], XmNancestorSensitive, 1);
- scrolledHandle = XmCreateMainWindow(shellHandle, NULL, args, nArgs);
+ motif_XtSetArg(args[nArgs++], XmNancestorSensitive, 1);
+ scrolledHandle = motif.XmCreateMainWindow(shellHandle, NULL, args, nArgs);
if(scrolledHandle == 0)
return -1;
- XtManageChild(scrolledHandle);
+ motif.XtManageChild(scrolledHandle);
nArgs = 0;
- XtSetArg(args[nArgs], XmNancestorSensitive, 1); nArgs++;
- XtSetArg(args[nArgs], XmNborderWidth, 0); nArgs++;
- /*XtSetArg(args[nArgs], XmNbackground, 0xFF00FF); nArgs++; */
- XtSetArg(args[nArgs], XmNmarginWidth, 0); nArgs++;
- XtSetArg(args[nArgs], XmNmarginHeight, 0); nArgs++;
- XtSetArg(args[nArgs], XmNresizePolicy, XmRESIZE_NONE); nArgs++;
- XtSetArg(args[nArgs], XmNtraversalOn, 1); nArgs++;
- drawingHandle = XmCreateDrawingArea(scrolledHandle, NULL, args, nArgs);
+ motif_XtSetArg(args[nArgs], XmNancestorSensitive, 1); nArgs++;
+ motif_XtSetArg(args[nArgs], XmNborderWidth, 0); nArgs++;
+ /*motif_XtSetArg(args[nArgs], XmNbackground, 0xFF00FF); nArgs++; */
+ motif_XtSetArg(args[nArgs], XmNmarginWidth, 0); nArgs++;
+ motif_XtSetArg(args[nArgs], XmNmarginHeight, 0); nArgs++;
+ motif_XtSetArg(args[nArgs], XmNresizePolicy, XmRESIZE_NONE); nArgs++;
+ motif_XtSetArg(args[nArgs], XmNtraversalOn, 1); nArgs++;
+ drawingHandle = motif.XmCreateDrawingArea(scrolledHandle, NULL, args, nArgs);
if(drawingHandle == 0)
return -1;
- XtManageChild(drawingHandle);
+ motif.XtManageChild(drawingHandle);
nArgs = 0;
- XtSetArg(args[nArgs], XmNlabelType, XmPIXMAP); nArgs++;
- XtSetArg(args[nArgs], XmNlabelPixmap, splashPixmap);nArgs++;
- XtSetArg(args[nArgs], XmNwidth, width); nArgs++;
- XtSetArg(args[nArgs], XmNheight, height); nArgs++;
- XtSetArg(args[nArgs], XmNmarginWidth, 0); nArgs++;
- XtSetArg(args[nArgs], XmNmarginHeight, 0); nArgs++;
- image = XmCreateLabelGadget ( drawingHandle, "", args, nArgs );
- XtManageChild( image );
+ motif_XtSetArg(args[nArgs], XmNlabelType, XmPIXMAP); nArgs++;
+ motif_XtSetArg(args[nArgs], XmNlabelPixmap, splashPixmap); nArgs++;
+ motif_XtSetArg(args[nArgs], XmNwidth, width); nArgs++;
+ motif_XtSetArg(args[nArgs], XmNheight, height); nArgs++;
+ motif_XtSetArg(args[nArgs], XmNmarginWidth, 0); nArgs++;
+ motif_XtSetArg(args[nArgs], XmNmarginHeight, 0); nArgs++;
+ image = motif.XmCreateLabelGadget ( drawingHandle, "", args, nArgs );
+ motif.XtManageChild( image );
- XtRealizeWidget(shellHandle);
- XtSetMappedWhenManaged(shellHandle, 1);
+ motif.XtRealizeWidget(shellHandle);
+ motif.XtSetMappedWhenManaged(shellHandle, 1);
- if(XtIsTopLevelShell(shellHandle))
- XtMapWidget(shellHandle);
+ if(motif_XtIsTopLevelShell(shellHandle))
+ motif_XtMapWidget(shellHandle);
else
- XtPopup(shellHandle, XtGrabNone);
+ motif.XtPopup(shellHandle, XtGrabNone);
/* Centre the splash screen and display it. */
centreShell( shellHandle, drawingHandle );
@@ -202,10 +200,10 @@ jlong getSplashHandle() {
void dispatchMessages() {
XtInputMask mask;
- if (appContext != NULL) {
+ if (appContext != NULL && motif.XtAppPending != 0) {
/* Process any outstanding messages */
- while ((mask = XtAppPending(appContext)) != 0) {
- XtAppProcessEvent(appContext, mask);
+ while ((mask = motif.XtAppPending(appContext)) != 0) {
+ motif.XtAppProcessEvent(appContext, mask);
}
}
}
@@ -214,7 +212,7 @@ void takeDownSplash()
{
if (shellHandle != 0)
{
- XtDestroyWidget( shellHandle );
+ motif.XtDestroyWidget( shellHandle );
/*XFlush( XtDisplay( shellHandle ) );*/
shellHandle = NULL;
}
@@ -287,6 +285,18 @@ int launchJavaVM( char* args[] )
fixEnvForMozilla();
#endif /* MOZILLA_FIX */
+ {
+ /* put the root of eclipse on the LD_LIBRARY_PATH */
+ char * ldPath = (char*)getenv(_T_ECLIPSE("LD_LIBRARY_PATH"));
+ char * root = getProgramDir();
+ if (root != NULL) {
+ char * newPath = malloc((strlen(root) + strlen(ldPath) + 2) * sizeof(char));
+ sprintf(newPath, "%s%c%s", root, pathSeparator, ldPath);
+ setenv("LD_LIBRARY_PATH", newPath, 1);
+ free(newPath);
+ }
+ }
+
/* Create a child process for the JVM. */
jvmProcess = fork();
if (jvmProcess == 0)
diff --git a/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotif.h b/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotif.h
new file mode 100644
index 000000000..92fa13d3a
--- /dev/null
+++ b/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotif.h
@@ -0,0 +1,93 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#ifndef ECLIPSE_MOTIF_H
+#define ECLIPSE_MOTIF_H
+
+#include <Xm/XmAll.h>
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/IntrinsicP.h>
+#include <X11/Intrinsic.h>
+#include <X11/Shell.h>
+
+#ifndef NO_XINERAMA_EXTENSIONS
+#include <X11/extensions/Xinerama.h>
+#endif
+
+struct MOTIF_PTRS {
+#ifndef NO_XINERAMA_EXTENSIONS
+ Bool (*XineramaIsActive) (Display*);
+ XineramaScreenInfo* (*XineramaQueryScreens) (Display*, int*);
+#endif
+ Widget (*XmCreateDrawingArea) (Widget, String, ArgList, Cardinal);
+ Widget (*XmCreateLabelGadget) (Widget, char *, Arg *, Cardinal);
+ Widget (*XmCreateMainWindow) (Widget, char *, ArgList, Cardinal);
+ Widget (*XmCreateMessageDialog)(Widget, String, ArgList, Cardinal);
+ Widget (*XmMessageBoxGetChild) (Widget, unsigned char);
+ void (*XmStringFree) (XmString);
+ XmString (*XmStringGenerate) (XtPointer, XmStringTag, XmTextType, XmStringTag);
+
+ void (*XtAddCallback) (Widget, String, XtCallbackProc, XtPointer);
+ Widget (*XtAppCreateShell) (String, String, WidgetClass, Display*, ArgList, Cardinal);
+ void (*XtAppNextEvent) (XtAppContext, XEvent*);
+ XtInputMask (*XtAppPending) (XtAppContext);
+ void (*XtAppProcessEvent) (XtAppContext, XtInputMask);
+ void (*XtDestroyWidget) (Widget);
+ Boolean (*XtDispatchEvent) (XEvent*);
+ void (*XtGetValues) (Widget, ArgList, Cardinal);
+ Widget (*XtInitialize) (String, String, XrmOptionDescRec*, Cardinal, int*, char**);
+ Boolean (*XtIsManaged) (Widget);
+ void (*XtManageChild) (Widget);
+ int (*XtMapWidget) (Widget);
+ void (*XtPopup) (Widget, XtGrabKind);
+ void (*XtRealizeWidget) (Widget);
+ Widget (*XtSetLanguageProc) (XtAppContext, XtLanguageProc, XtPointer);
+ void (*XtSetMappedWhenManaged)(Widget, Boolean);
+ void (*XtSetValues) (Widget, ArgList, Cardinal);
+ void (*XtUnmanageChild) (Widget);
+ XtAppContext (*XtWidgetToApplicationContext) (Widget);
+ Window (*XtWindowOfObject) (Widget);
+
+ Screen * (*XDefaultScreenOfDisplay)(Display*);
+ int (*XFree) (void*);
+ int (*XFlush) (Display*);
+ Status (*XGetGeometry) (Display*, Drawable, Window*, int*, int*, unsigned int*, unsigned int*, unsigned int*, unsigned int*);
+ int (*XMapWindow) (Display*, Window);
+
+ char * _XmStrings;
+ char * XtShellStrings;
+ char * XtStrings;
+ WidgetClass *applicationShellWidgetClass;
+};
+
+extern struct MOTIF_PTRS motif;
+
+#define motif_XtDisplay XtDisplay
+#define motif_XtSetArg XtSetArg
+#define motif_XtWindow XtWindow
+#define motif_XtIsTopLevelShell XtIsTopLevelShell
+#define motif_XtIsRealized(object) (motif.XtWindowOfObject(object) != None)
+#define motif_XtMapWidget(widget) motif.XMapWindow(XtDisplay(widget), XtWindow(widget))
+
+#define _XmStrings motif._XmStrings
+#define XtShellStrings motif.XtShellStrings
+#define XtStrings motif.XtStrings
+
+/* macro resolves to { (void**)&motif.foo, "foo" }, use it to initialize FN_TABLEs */
+#define FN_TABLE_ENTRY(fn) { (void**)&motif.fn, #fn }
+typedef struct {
+ void ** fnPtr;
+ char * fnName;
+} FN_TABLE;
+
+extern int loadMotif();
+#endif
diff --git a/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotifCommon.c b/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotifCommon.c
index b9a50d02c..998f53cb1 100644
--- a/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotifCommon.c
+++ b/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotifCommon.c
@@ -12,20 +12,11 @@
#include "eclipseCommon.h"
#include "eclipseOS.h"
+#include "eclipseMotif.h"
#include <locale.h>
#include <dlfcn.h>
#include <stdlib.h>
-#include <Xm/XmAll.h>
-#include <X11/X.h>
-#include <X11/Xlib.h>
-#include <X11/IntrinsicP.h>
-#include <X11/Intrinsic.h>
-#include <X11/Shell.h>
-
-#ifndef NO_XINERAMA_EXTENSIONS
-#include <X11/extensions/Xinerama.h>
-#endif
#define ECLIPSE_ICON 401
@@ -33,7 +24,6 @@ char dirSeparator = '/';
char pathSeparator = ':';
void centreShell( Widget widget, Widget expose );
-void initWindowSystem( int* pArgc, _TCHAR* argv[], int showSplash );
/* Global Variables */
XtAppContext appContext = 0;
@@ -55,53 +45,52 @@ void displayMessage( char* title, char* message )
int nArgs;
XEvent event;
- /* If there is no associated display, just print the error and return. */
+ /* If there is no associated display, or we fail to initialize Xt, just print the error and return. */
displayName = getenv("DISPLAY");
- if (displayName == NULL || strlen(displayName) == 0)
+ if ( displayName == NULL || strlen(displayName) == 0 ||
+ (topWindow == 0 && initWindowSystem( &saveArgc, saveArgv, 1 ) != 0) )
{
- printf( "%s: %s\n", title, message );
return;
}
-
- /* If Xt has not been initialized yet, do it now. */
- if (topWindow == 0)
- {
- initWindowSystem( &saveArgc, saveArgv, 1 );
- }
-
- msg = XmStringGenerate( message, NULL, XmCHARSET_TEXT, NULL );
+ msg = motif.XmStringGenerate( message, NULL, XmCHARSET_TEXT, NULL );
- /* Output a simple message box. */
+ /* Output a simple message box. */
nArgs = 0;
- XtSetArg( arg[ nArgs ], XmNdialogType, XmDIALOG_MESSAGE ); nArgs++;
- XtSetArg( arg[ nArgs ], XmNtitle, title ); nArgs++;
- XtSetArg( arg[ nArgs ], XmNmessageString, msg ); nArgs++;
- msgBox = XmCreateMessageDialog( topWindow, getOfficialName(), arg, nArgs );
- XtUnmanageChild( XmMessageBoxGetChild( msgBox, XmDIALOG_CANCEL_BUTTON ) );
- XtUnmanageChild( XmMessageBoxGetChild( msgBox, XmDIALOG_HELP_BUTTON ) );
- XtManageChild( msgBox );
+
+ motif_XtSetArg( arg[ nArgs ], XmNdialogType, XmDIALOG_MESSAGE ); nArgs++;
+ motif_XtSetArg( arg[ nArgs ], XmNtitle, title ); nArgs++;
+ motif_XtSetArg( arg[ nArgs ], XmNmessageString, msg ); nArgs++;
+ msgBox = motif.XmCreateMessageDialog( topWindow, getOfficialName(), arg, nArgs );
+
+ motif.XtUnmanageChild( motif.XmMessageBoxGetChild( msgBox, XmDIALOG_CANCEL_BUTTON ) );
+ motif.XtUnmanageChild( motif.XmMessageBoxGetChild( msgBox, XmDIALOG_HELP_BUTTON ) );
+ motif.XtManageChild( msgBox );
centreShell( msgBox, msgBox );
- if (msg != 0) XmStringFree (msg);
+ if (msg != 0) motif.XmStringFree (msg);
/* Wait for the OK button to be pressed. */
- while (XtIsRealized( msgBox ) && XtIsManaged( msgBox ))
+ while (motif_XtIsRealized( msgBox ) && motif.XtIsManaged( msgBox ))
{
- XtAppNextEvent( appContext, &event );
- XtDispatchEvent( &event );
+ motif.XtAppNextEvent( appContext, &event );
+ motif.XtDispatchEvent( &event );
}
- XtDestroyWidget( msgBox );
+ motif.XtDestroyWidget( msgBox );
}
/* Initialize Window System
*
* Initialize the Xt and Xlib.
*/
-void initWindowSystem( int* pArgc, char* argv[], int showSplash )
+int initWindowSystem( int* pArgc, char* argv[], int showSplash )
{
Arg arg[20];
if(motifInitialized == 1)
- return;
+ return 0;
+
+ if (loadMotif() != 0)
+ return -1;
+
/* Save the arguments in case displayMessage() is called in the main launcher. */
if (saveArgv == 0)
{
@@ -110,14 +99,20 @@ void initWindowSystem( int* pArgc, char* argv[], int showSplash )
}
/* Create the top level shell that will not be used other than
- to initialize the application. */
+ to initialize the application.
+ */
+#ifdef AIX
topWindow = XtInitialize(NULL, getOfficialName(), NULL, 0, pArgc, argv);
- appContext = XtWidgetToApplicationContext(topWindow);
- XtSetLanguageProc (appContext, NULL, NULL);
- XtSetArg( arg[ 0 ], XmNmappedWhenManaged, False );
- XtSetValues( topWindow, arg, 1 );
- XtRealizeWidget( topWindow );
+#else
+ topWindow = motif.XtInitialize(NULL, getOfficialName(), NULL, 0, pArgc, argv);
+#endif
+ appContext = motif.XtWidgetToApplicationContext(topWindow);
+ motif.XtSetLanguageProc (appContext, NULL, NULL);
+ motif_XtSetArg( arg[ 0 ], XmNmappedWhenManaged, False );
+ motif.XtSetValues( topWindow, arg, 1 );
+ motif.XtRealizeWidget( topWindow );
motifInitialized = 1;
+ return 0;
}
/* Centre the shell on the screen. */
@@ -140,27 +135,27 @@ void centreShell( Widget widget, Widget expose )
#endif
/* Realize the shell to calculate its width/height. */
- XtRealizeWidget( widget );
+ motif.XtRealizeWidget( widget );
/* Get the desired dimensions of the shell. */
nArgs = 0;
- XtSetArg( arg[ nArgs ], XmNwidth, &width ); nArgs++;
- XtSetArg( arg[ nArgs ], XmNheight, &height ); nArgs++;
- XtSetArg( arg[ nArgs ], XmNscreen, &screen ); nArgs++;
- XtGetValues( widget, arg, nArgs );
+ motif_XtSetArg( arg[ nArgs ], XmNwidth, &width ); nArgs++;
+ motif_XtSetArg( arg[ nArgs ], XmNheight, &height ); nArgs++;
+ motif_XtSetArg( arg[ nArgs ], XmNscreen, &screen ); nArgs++;
+ motif.XtGetValues( widget, arg, nArgs );
screenWidth = screen->width;
screenHeight = screen->height;
#ifndef NO_XINERAMA_EXTENSIONS
- display = XtDisplay( widget );
- if (XineramaIsActive( display )) {
- info = XineramaQueryScreens( display, &monitorCount );
+ display = motif_XtDisplay( widget );
+ if (motif.XineramaIsActive != 0 && motif.XineramaIsActive( display )) {
+ info = motif.XineramaQueryScreens( display, &monitorCount );
if (info != 0) {
if (monitorCount > 1) {
screenWidth = info->width;
screenHeight = info->height;
}
- XFree (info);
+ motif.XFree (info);
}
}
#endif
@@ -171,28 +166,28 @@ void centreShell( Widget widget, Widget expose )
/* Set the new shell position and display it. */
nArgs = 0;
- XtSetArg( arg[ nArgs ], XmNx, x ); nArgs++;
- XtSetArg( arg[ nArgs ], XmNy, y ); nArgs++;
- XtSetValues( widget, arg, nArgs );
- XtMapWidget( widget );
+ motif_XtSetArg( arg[ nArgs ], XmNx, x ); nArgs++;
+ motif_XtSetArg( arg[ nArgs ], XmNy, y ); nArgs++;
+ motif.XtSetValues( widget, arg, nArgs );
+ motif_XtMapWidget( widget );
/* Wait for an expose event on the desired widget. This wait loop is required when
* the startVM command fails and the message box is created before the splash
* window is displayed. Without this wait, the message box sometimes appears
* under the splash window and the user cannot see it.
*/
- context = XtWidgetToApplicationContext( widget );
+ context = motif.XtWidgetToApplicationContext( widget );
waiting = True;
while (waiting)
{
- XtAppNextEvent( context, &event );
- if (event.xany.type == Expose && event.xany.window == XtWindow( expose ))
+ motif.XtAppNextEvent( context, &event );
+ if (event.xany.type == Expose && event.xany.window == motif_XtWindow( expose ))
{
waiting = False;
}
- XtDispatchEvent( &event );
+ motif.XtDispatchEvent( &event );
}
- XFlush( XtDisplay( widget ) );
+ motif.XFlush( motif_XtDisplay( widget ) );
}
/* Load the specified shared library
diff --git a/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotifInit.c b/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotifInit.c
new file mode 100644
index 000000000..794342221
--- /dev/null
+++ b/bundles/org.eclipse.equinox.executable/library/motif/eclipseMotifInit.c
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2007 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+#include "eclipseMotif.h"
+#include "eclipseCommon.h"
+#include <dlfcn.h>
+#include <stdlib.h>
+
+struct MOTIF_PTRS motif;
+
+/* need to undef these so the FN_TABLE works ok */
+#undef _XmStrings
+#undef XtShellStrings
+#undef XtStrings
+
+/* functions from libXm */
+static FN_TABLE xmFunctions[] = { FN_TABLE_ENTRY(XmCreateDrawingArea),
+ FN_TABLE_ENTRY(XmCreateLabelGadget),
+ FN_TABLE_ENTRY(XmCreateMainWindow),
+ FN_TABLE_ENTRY(XmCreateMessageDialog),
+ FN_TABLE_ENTRY(XmMessageBoxGetChild),
+ FN_TABLE_ENTRY(XmStringFree),
+ FN_TABLE_ENTRY(XmStringGenerate),
+ FN_TABLE_ENTRY(_XmStrings), /* not a function */
+ { NULL, NULL }
+ };
+
+/* functions from libXt */
+static FN_TABLE xtFunctions[] = { FN_TABLE_ENTRY(XtAddCallback),
+ FN_TABLE_ENTRY(XtAppCreateShell),
+ FN_TABLE_ENTRY(XtAppNextEvent),
+ FN_TABLE_ENTRY(XtAppPending),
+ FN_TABLE_ENTRY(XtAppProcessEvent),
+ FN_TABLE_ENTRY(XtDestroyWidget),
+ FN_TABLE_ENTRY(XtDispatchEvent),
+ FN_TABLE_ENTRY(XtGetValues),
+#ifndef AIX
+ FN_TABLE_ENTRY(XtInitialize),
+#endif
+ FN_TABLE_ENTRY(XtIsManaged),
+ FN_TABLE_ENTRY(XtManageChild),
+ FN_TABLE_ENTRY(XtMapWidget),
+ FN_TABLE_ENTRY(XtPopup),
+ FN_TABLE_ENTRY(XtRealizeWidget),
+ FN_TABLE_ENTRY(XtSetLanguageProc),
+ FN_TABLE_ENTRY(XtSetMappedWhenManaged),
+ FN_TABLE_ENTRY(XtSetValues),
+ FN_TABLE_ENTRY(XtUnmanageChild),
+ FN_TABLE_ENTRY(XtWidgetToApplicationContext),
+ FN_TABLE_ENTRY(XtWindowOfObject),
+ FN_TABLE_ENTRY(XtShellStrings), /* not a function */
+ FN_TABLE_ENTRY(XtStrings), /* not a function */
+ FN_TABLE_ENTRY(applicationShellWidgetClass), /* not a function */
+ { NULL, NULL }
+ };
+
+/* functions from libX11 */
+static FN_TABLE x11Functions[] = { FN_TABLE_ENTRY(XDefaultScreenOfDisplay),
+ FN_TABLE_ENTRY(XFree),
+ FN_TABLE_ENTRY(XFlush),
+ FN_TABLE_ENTRY(XGetGeometry),
+ FN_TABLE_ENTRY(XMapWindow),
+ { NULL, NULL }
+ };
+
+#ifndef NO_XINERAMA_EXTENSIONS
+static FN_TABLE xinFunctions[] = { FN_TABLE_ENTRY(XineramaIsActive),
+ FN_TABLE_ENTRY(XineramaQueryScreens),
+ { NULL, NULL }
+ };
+#endif
+
+static int loadMotifSymbols( void * library, FN_TABLE * table) {
+ int i = 0;
+ void * fn;
+ for (i = 0; table[i].fnName != NULL; i++) {
+ fn = findSymbol(library, table[i].fnName);
+ if (fn != 0) {
+ *(table[i].fnPtr) = fn;
+ } else {
+ *(table[i].fnPtr) = 0;
+ return -1;
+ }
+ }
+ return 0;
+}
+
+int loadMotif() {
+ void * xmLib = NULL, *xtLib = NULL, *x11Lib = NULL, *xinLib = NULL;
+ char * path = getProgramDir();
+ int dlFlags = RTLD_LAZY;
+
+ /* initialize ptr struct to 0's */
+ memset(&motif, 0, sizeof(struct MOTIF_PTRS));
+
+#ifndef AIX
+ if (path != NULL) {
+ /* look for libXm first in the root of eclipse */
+ char * lib = malloc((strlen(path) + strlen(_T_ECLIPSE(XM_LIB)) + 2) * sizeof(char));
+ sprintf( lib, "%s%c%s", path, dirSeparator, XM_LIB);
+ xmLib = dlopen(lib, dlFlags);
+ free(lib);
+ }
+#else
+ dlFlags |= RTLD_MEMBER;
+#endif
+
+ if (xmLib == NULL) {
+ xmLib = dlopen(XM_LIB, dlFlags);
+ }
+
+ if (xmLib == NULL) {
+ /* bail now, don't load the others, libXm must be loaded first, so leave things for
+ * swt to do later */
+ return -1;
+ }
+
+ xtLib = dlopen(XT_LIB, dlFlags);
+ x11Lib = dlopen(X11_LIB, dlFlags);
+
+ /* printf("XmLib: %s: %x\nXtLib: %s: %x\nX11Lib:%s, %x\n", XM_LIB, xmLib, XT_LIB, xtLib, X11_LIB, x11Lib);*/
+#ifndef NO_XINERAMA_EXTENSIONS
+ /* don't fail without Xinerama */
+ xinLib = dlopen(XIN_LIB, dlFlags);
+ if (xinLib != NULL)
+ loadMotifSymbols(xinLib, xinFunctions);
+#endif
+ if( xtLib == NULL || x11Lib == NULL)
+ return -1;
+
+ if (loadMotifSymbols(xmLib, xmFunctions) != 0) return -1;
+ if (loadMotifSymbols(xtLib, xtFunctions) != 0) return -1;
+ if (loadMotifSymbols(x11Lib, x11Functions) != 0) return -1;
+
+ return 0;
+}
diff --git a/bundles/org.eclipse.equinox.executable/library/motif/make_aix.mak b/bundles/org.eclipse.equinox.executable/library/motif/make_aix.mak
index 4801f4157..4ec36125f 100644
--- a/bundles/org.eclipse.equinox.executable/library/motif/make_aix.mak
+++ b/bundles/org.eclipse.equinox.executable/library/motif/make_aix.mak
@@ -29,13 +29,15 @@ PROGRAM_LIBRARY=eclipse_$(LIB_VERSION).so
CC = cc_r
# Define the object modules to be compiled and flags.
MAIN_OBJS = eclipseMain.o
-COMMON_OBJS = eclipseConfig.o eclipseCommon.o eclipseMotifCommon.o
+COMMON_OBJS = eclipseConfig.o eclipseCommon.o eclipseMotifCommon.o eclipseMotifInit.o
DLL_OBJS = eclipse.o eclipseMotif.o eclipseUtil.o eclipseJNI.o eclipseShm.o eclipseNix.o\
NgCommon.o NgImage.o NgImageData.o NgWinBMPFileFormat.o
EXEC = $(PROGRAM_OUTPUT)
DLL = $(PROGRAM_LIBRARY)
-LIBS = -L$(MOTIF_HOME)/lib -lXm -lXt -lX11
+LIBS = -L$(MOTIF_HOME)/lib -ldl -lXm -lXt -lX11
+MOTIF_LIBS = -DXM_LIB="\"libXm.a(shr_32.o)\"" -DXT_LIB="\"libXt.a(shr4.o)\"" -DX11_LIB="\"libX11.a(shr4.o)\""
+#MOTIF_LIBS = -DXM_LIB="NULL" -DXT_LIB="NULL" -DX11_LIB="NULL"
LFLAGS = -G -bnoentry -bexpall -lm -lc_r -lC_r
CFLAGS = -O -s \
-DMOTIF \
@@ -43,6 +45,7 @@ CFLAGS = -O -s \
-DDEFAULT_OS="\"$(DEFAULT_OS)\"" \
-DDEFAULT_OS_ARCH="\"$(DEFAULT_OS_ARCH)\"" \
-DDEFAULT_WS="\"$(DEFAULT_WS)\"" \
+ $(MOTIF_LIBS) \
-DDEFAULT_JAVA_EXEC \
-DAIX \
-I./ \
diff --git a/bundles/org.eclipse.equinox.executable/library/motif/make_linux.mak b/bundles/org.eclipse.equinox.executable/library/motif/make_linux.mak
index 668ee436e..740a75986 100644
--- a/bundles/org.eclipse.equinox.executable/library/motif/make_linux.mak
+++ b/bundles/org.eclipse.equinox.executable/library/motif/make_linux.mak
@@ -36,21 +36,23 @@ endif
# Define the object modules to be compiled and flags.
CC=gcc
MAIN_OBJS = eclipseMain.o
-COMMON_OBJS = eclipseConfig.o eclipseCommon.o eclipseMotifCommon.o
+COMMON_OBJS = eclipseConfig.o eclipseCommon.o eclipseMotifCommon.o eclipseMotifInit.o
DLL_OBJS = eclipse.o eclipseMotif.o eclipseUtil.o eclipseJNI.o eclipseMozilla.o eclipseShm.o eclipseNix.o \
NgCommon.o NgImage.o NgImageData.o NgWinBMPFileFormat.o
EXEC = $(PROGRAM_OUTPUT)
DLL = $(PROGRAM_LIBRARY)
-LIBS = -Xlinker -rpath -Xlinker . -L$(MOTIF_HOME)/lib -L$(X11_HOME)/lib -lXm -lXt -lX11 -lXinerama -lpthread
+LIBS = -Xlinker -rpath -Xlinker . -L$(MOTIF_HOME)/lib -L$(X11_HOME)/lib -lpthread -ldl
+MOTIF_LIBS = -DXM_LIB="\"libXm.so.2\"" -DXT_LIB="\"libXt.so.6\"" -DX11_LIB="\"libX11.so.6\"" -DXIN_LIB="\"libXinerama.so.1\""
LFLAGS = -shared -fpic -Wl,--export-dynamic
-CFLAGS = -O -s -Wall \
+CFLAGS = -g -s -Wall \
-DLINUX \
-DMOTIF \
-DMOZILLA_FIX \
-DDEFAULT_OS="\"$(DEFAULT_OS)\"" \
-DDEFAULT_OS_ARCH="\"$(DEFAULT_OS_ARCH)\"" \
-DDEFAULT_WS="\"$(DEFAULT_WS)\"" \
+ $(MOTIF_LIBS) \
-D$(DEFAULT_JAVA)\
-fPIC \
-I./ \
diff --git a/bundles/org.eclipse.equinox.executable/library/motif/make_solaris.mak b/bundles/org.eclipse.equinox.executable/library/motif/make_solaris.mak
index d9be492bb..fad1e84a5 100644
--- a/bundles/org.eclipse.equinox.executable/library/motif/make_solaris.mak
+++ b/bundles/org.eclipse.equinox.executable/library/motif/make_solaris.mak
@@ -31,7 +31,7 @@ PROGRAM_LIBRARY=eclipse_$(LIB_VERSION).so
# Define the object modules to be compiled and flags.
MAIN_OBJS = eclipseMain.o
-COMMON_OBJS = eclipseConfig.o eclipseCommon.o eclipseMotifCommon.o
+COMMON_OBJS = eclipseConfig.o eclipseCommon.o eclipseMotifCommon.o eclipseMotifInit.o
DLL_OBJS = eclipse.o eclipseMotif.o eclipseUtil.o eclipseJNI.o eclipseShm.o eclipseNix.o\
NgCommon.o NgImage.o NgImageData.o NgWinBMPFileFormat.o
PICFLAG = -K PIC
@@ -41,7 +41,8 @@ OPTFLAG = -O -s
EXEC = $(PROGRAM_OUTPUT)
DLL = $(PROGRAM_LIBRARY)
-LIBS = -L$(MOTIF_HOME)/lib -L$(X11_HOME)/lib -lXm -lXt -lX11 -lintl -lthread -ldl -lc
+LIBS = -L$(MOTIF_HOME)/lib -L$(X11_HOME)/lib -lintl -lthread -ldl -lc
+MOTIF_LIBS = -DXM_LIB="\"libXm.so.4\"" -DXT_LIB="\"libXt.so.4\"" -DX11_LIB="\"libX11.so.4\"" -DXIN_LIB="\"libXinerama.so.1\""
#LFLAGS = -shared -Wl,--export-dynamic
LFLAGS = -G
CFLAGS =$(OPTFLAG) \
@@ -52,6 +53,7 @@ CFLAGS =$(OPTFLAG) \
-DDEFAULT_OS="\"$(DEFAULT_OS)\"" \
-DDEFAULT_OS_ARCH="\"$(DEFAULT_OS_ARCH)\"" \
-DDEFAULT_WS="\"$(DEFAULT_WS)\"" \
+ $(MOTIF_LIBS) \
-I./ \
-I../ \
-I$(MOTIF_HOME)/include \

Back to the top