Made Xcursor library static linked instead of dynamically loaded
This commit is contained in:
parent
c3fb7cc5c8
commit
4b98c873da
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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 <stdio.h>
|
||||
#include <dlfcn.h>
|
||||
#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;
|
||||
}
|
||||
}
|
|
@ -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 <X11/Xlib.h>
|
||||
|
||||
#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);
|
|
@ -39,8 +39,11 @@
|
|||
* @version $Revision$
|
||||
*/
|
||||
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
#include "org_lwjgl_input_Cursor.h"
|
||||
#include "extxcursor.h"
|
||||
//#include "extxcursor.h"
|
||||
#include "Window.h"
|
||||
#include "common_tools.h"
|
||||
|
||||
|
|
|
@ -48,7 +48,8 @@
|
|||
#include "Window.h"
|
||||
#include "common_tools.h"
|
||||
#include "org_lwjgl_input_Mouse.h"
|
||||
#include "extxcursor.h"
|
||||
#include <X11/Xcursor/Xcursor.h>
|
||||
//#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;
|
||||
|
|
Loading…
Reference in New Issue