From 4b98c873da45e02dbe538d386bff7555499c8178 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sat, 21 Aug 2004 00:18:20 +0000 Subject: [PATCH] Made Xcursor library static linked instead of dynamically loaded --- src/native/configure.in | 3 +- src/native/linux/Makefile.am | 6 +- src/native/linux/extxcursor.cpp | 99 --------------------- src/native/linux/extxcursor.h | 83 ----------------- src/native/linux/org_lwjgl_input_Cursor.cpp | 5 +- src/native/linux/org_lwjgl_input_Mouse.cpp | 20 +++-- 6 files changed, 22 insertions(+), 194 deletions(-) delete mode 100644 src/native/linux/extxcursor.cpp delete mode 100644 src/native/linux/extxcursor.h diff --git a/src/native/configure.in b/src/native/configure.in index ff438021..b867badf 100644 --- a/src/native/configure.in +++ b/src/native/configure.in @@ -28,8 +28,9 @@ case "$host_os" in bsdi* | linux* | solaris*) AC_PATH_XTRA AC_LIBTOOL_DLOPEN _BUILD_FLAGS="-pthread -D_X11 $X_CFLAGS" + LDFLAGS="-Wl,-static,-lXcursor,-lXrender,-call_shared" AC_CHECK_HEADERS([AL/altypes.h AL/alctypes.h],, AC_MSG_ERROR([OpenAL headers required])) - NATIVE_BUILD_DIR=linux + NATIVE_BUILD_DIR=linux CXXFLAGS="$CXXFLAGS -Wall $_BUILD_FLAGS" CFLAGS="$CFLAGS -Wall $_BUILD_FLAGS" LIBS="$LIBS $X_LIBS" diff --git a/src/native/linux/Makefile.am b/src/native/linux/Makefile.am index 284ff00d..e6ba446a 100644 --- a/src/native/linux/Makefile.am +++ b/src/native/linux/Makefile.am @@ -1,6 +1,8 @@ noinst_LTLIBRARIES = libnative.la libnative_la_SOURCES = $(NATIVE) +#libnative_la_LIBADD = -lXrender -lXcursor +#libnative_la_LDFLAGS = -Wl,-static,-lXcursor,-lXrender,-call_shared INCLUDES = -I../common NATIVE = \ @@ -12,6 +14,6 @@ NATIVE = \ org_lwjgl_opengl_Display.cpp \ org_lwjgl_opengl_Pbuffer.cpp \ display.cpp \ - extgl_glx.cpp \ - extxcursor.cpp + extgl_glx.cpp +# extxcursor.cpp diff --git a/src/native/linux/extxcursor.cpp b/src/native/linux/extxcursor.cpp deleted file mode 100644 index 4b927fc8..00000000 --- a/src/native/linux/extxcursor.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2002-2004 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include "extxcursor.h" -#include "common_tools.h" - -static void * xcursor_handle = NULL; -static const char *xcursor_lib_name = "libXcursor.so.1"; -static bool load_success; - -XcursorSupportsARGBPROC XcursorSupportsARGB = NULL; -XcursorSupportsAnimPROC XcursorSupportsAnim = NULL; -XcursorImageCreatePROC XcursorImageCreate = NULL; -XcursorImageDestroyPROC XcursorImageDestroy = NULL; -XcursorImagesCreatePROC XcursorImagesCreate = NULL; -XcursorImagesDestroyPROC XcursorImagesDestroy = NULL; -XcursorImagesLoadCursorPROC XcursorImagesLoadCursor = NULL; - -static void * loadHandle(const char * func_name) { - void * func_pointer = dlsym(xcursor_handle, func_name); - if (func_pointer == NULL) { - load_success = false; - return NULL; - } - return func_pointer; -} - -static bool loadFunctionPointers(void) { - load_success = true; - XcursorSupportsARGB = (XcursorSupportsARGBPROC)loadHandle("XcursorSupportsARGB"); - XcursorSupportsAnim = (XcursorSupportsAnimPROC)loadHandle("XcursorSupportsAnim"); - XcursorImageCreate = (XcursorImageCreatePROC)loadHandle("XcursorImageCreate"); - XcursorImageDestroy = (XcursorImageDestroyPROC)loadHandle("XcursorImageDestroy"); - XcursorImagesCreate = (XcursorImagesCreatePROC)loadHandle("XcursorImagesCreate"); - XcursorImagesDestroy = (XcursorImagesDestroyPROC)loadHandle("XcursorImagesDestroy"); - XcursorImagesLoadCursor = (XcursorImagesLoadCursorPROC)loadHandle("XcursorImagesLoadCursor"); - return load_success; -} - -bool loadXcursor(void) { - load_success = false; - xcursor_handle = dlopen(xcursor_lib_name, RTLD_GLOBAL | RTLD_LAZY); - if (xcursor_handle == NULL) { - printfDebug("Could not load %s: %s\n", xcursor_lib_name, dlerror()); - return load_success; - } - loadFunctionPointers(); - return load_success; -} - -bool isXcursorLoaded(void) { - return load_success; -} - -void closeXcursor(void) { - if (load_success) { - load_success = false; - dlclose(xcursor_handle); - xcursor_handle = NULL; - XcursorSupportsARGB = NULL; - XcursorSupportsAnim = NULL; - XcursorImageCreate = NULL; - XcursorImageDestroy = NULL; - XcursorImagesCreate = NULL; - XcursorImagesDestroy = NULL; - XcursorImagesLoadCursor = NULL; - } -} diff --git a/src/native/linux/extxcursor.h b/src/native/linux/extxcursor.h deleted file mode 100644 index c389bd98..00000000 --- a/src/native/linux/extxcursor.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2002-2004 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#define XcursorTrue 1 -#define XcursorFalse 0 - -typedef int XcursorBool; - -typedef int XcursorBool; -typedef unsigned int XcursorUInt; - -typedef XcursorUInt XcursorDim; -typedef XcursorUInt XcursorPixel; - -typedef struct _XcursorImage { - XcursorUInt version; /* version of the image data */ - XcursorDim size; /* nominal size for matching */ - XcursorDim width; /* actual width */ - XcursorDim height; /* actual height */ - XcursorDim xhot; /* hot spot x (must be inside image) */ - XcursorDim yhot; /* hot spot y (must be inside image) */ - XcursorUInt delay; /* animation delay to next frame (ms) */ - XcursorPixel *pixels; /* pointer to pixels */ -} XcursorImage; - -/* - * Other data structures exposed by the library API - */ -typedef struct _XcursorImages { - int nimage; /* number of images */ - XcursorImage **images; /* array of XcursorImage pointers */ -} XcursorImages; - -typedef XcursorBool (* XcursorSupportsARGBPROC ) (Display *dpy); -typedef XcursorBool (* XcursorSupportsAnimPROC ) (Display *dpy); -typedef XcursorImage * (* XcursorImageCreatePROC) (int width, int height); -typedef void (* XcursorImageDestroyPROC) (XcursorImage *image); -typedef XcursorImages * (* XcursorImagesCreatePROC) (int size); -typedef void (* XcursorImagesDestroyPROC) (XcursorImages *images); -typedef Cursor (* XcursorImagesLoadCursorPROC) (Display *dpy, const XcursorImages *images); - -extern XcursorSupportsARGBPROC XcursorSupportsARGB; -extern XcursorSupportsAnimPROC XcursorSupportsAnim; -extern XcursorImageCreatePROC XcursorImageCreate; -extern XcursorImageDestroyPROC XcursorImageDestroy; -extern XcursorImagesCreatePROC XcursorImagesCreate; -extern XcursorImagesDestroyPROC XcursorImagesDestroy; -extern XcursorImagesLoadCursorPROC XcursorImagesLoadCursor; - -bool loadXcursor(void); -bool isXcursorLoaded(void); -void closeXcursor(void); diff --git a/src/native/linux/org_lwjgl_input_Cursor.cpp b/src/native/linux/org_lwjgl_input_Cursor.cpp index 902c13be..5db3a7e9 100644 --- a/src/native/linux/org_lwjgl_input_Cursor.cpp +++ b/src/native/linux/org_lwjgl_input_Cursor.cpp @@ -39,8 +39,11 @@ * @version $Revision$ */ +#include +#include +#include #include "org_lwjgl_input_Cursor.h" -#include "extxcursor.h" +//#include "extxcursor.h" #include "Window.h" #include "common_tools.h" diff --git a/src/native/linux/org_lwjgl_input_Mouse.cpp b/src/native/linux/org_lwjgl_input_Mouse.cpp index 835e0b6c..c225840b 100644 --- a/src/native/linux/org_lwjgl_input_Mouse.cpp +++ b/src/native/linux/org_lwjgl_input_Mouse.cpp @@ -48,7 +48,8 @@ #include "Window.h" #include "common_tools.h" #include "org_lwjgl_input_Mouse.h" -#include "extxcursor.h" +#include +//#include "extxcursor.h" #define NUM_BUTTONS 3 @@ -139,8 +140,12 @@ static void grabPointer(void) { if (result == GrabSuccess) { pointer_grabbed = true; // make sure we have a centered window - if (isFullscreen()) - XF86VidModeSetViewPort(getDisplay(), getCurrentScreen(), 0, 0); + if (isFullscreen()) { + XWindowAttributes win_attribs; + XGetWindowAttributes(getDisplay(), getCurrentWindow(), &win_attribs); +// XF86VidModeSetViewPort(getDisplay(), getCurrentScreen(), 0, 0); + XF86VidModeSetViewPort(getDisplay(), getCurrentScreen(), win_attribs.x, win_attribs.y); + } XFlush(getDisplay()); } } @@ -191,8 +196,8 @@ static void warpPointer(void) { JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps (JNIEnv *env, jclass clazz) { int caps = 0; - if (!isXcursorLoaded()) - return caps; +/* if (!isXcursorLoaded()) + return caps;*/ XcursorBool argb_supported = XcursorSupportsARGB(getDisplay()); XcursorBool anim_supported = XcursorSupportsAnim(getDisplay()); if (argb_supported) @@ -205,7 +210,6 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_input_Mouse_nGetNativeCursorCaps JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nSetNativeCursor(JNIEnv *env, jclass clazz, jobject cursor_handle) { if (cursor_handle != NULL) { Cursor *cursor = (Cursor *)env->GetDirectBufferAddress(cursor_handle); -// Cursor cursor = (Cursor)cursor_handle; current_cursor = *cursor; } else current_cursor = None; @@ -259,14 +263,14 @@ JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nCreate buffer_enabled = false; updatePointerGrab(); initEventQueue(&event_queue); - loadXcursor(); +// loadXcursor(); doWarpPointer(); } JNIEXPORT void JNICALL Java_org_lwjgl_input_Mouse_nDestroy (JNIEnv * env, jclass clazz) { - closeXcursor(); +// closeXcursor(); ungrabPointer(); XFreeCursor(getDisplay(), blank_cursor); created = false;