Update of /cvsroot/java-game-lib/LWJGL/src/native/linux
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28739/src/native/linux
Modified Files:
Window.h org_lwjgl_input_Mouse.c org_lwjgl_opengl_Display.c
Log Message:
Linux: removed getWindowWidth/Height from native side
Index: Window.h
===================================================================
RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/Window.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- Window.h 21 Nov 2005 13:22:52 -0000 1.27
+++ Window.h 22 Nov 2005 10:32:17 -0000 1.28
@@ -66,16 +66,6 @@
extern bool shouldGrab(void);
/*
- * get the current window width
- */
- extern int getWindowWidth(void);
-
- /*
- * get the current window height
- */
- extern int getWindowHeight(void);
-
- /*
* get the current display
*/
extern Display *getDisplay(void);
Index: org_lwjgl_opengl_Display.c
===================================================================
RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_opengl_Display.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- org_lwjgl_opengl_Display.c 21 Nov 2005 21:59:11 -0000 1.38
+++ org_lwjgl_opengl_Display.c 22 Nov 2005 10:32:17 -0000 1.39
@@ -445,14 +445,6 @@
return current_win;
}
-int getWindowWidth(void) {
- return current_width;
-}
-
-int getWindowHeight(void) {
- return current_height;
-}
-
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nUpdate
(JNIEnv *env, jclass clazz, jint extension, jint window_mode, jobject saved_gamma, jobject current_gamma, jobject saved_mode)
{
Index: org_lwjgl_input_Mouse.c
===================================================================
RCS file: /cvsroot/java-game-lib/LWJGL/src/native/linux/org_lwjgl_input_Mouse.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- org_lwjgl_input_Mouse.c 22 Nov 2005 09:32:15 -0000 1.39
+++ org_lwjgl_input_Mouse.c 22 Nov 2005 10:32:17 -0000 1.40
@@ -84,7 +84,9 @@
}
static int transformY(int y) {
- return getWindowHeight() - 1 - y;
+ XWindowAttributes window_attributes;
+ XGetWindowAttributes(getDisplay(), getCurrentWindow(), &window_attributes);
+ return window_attributes.height - 1 - y;
}
static void setCursorPos(int x, int y) {
@@ -280,22 +282,28 @@
return v1 < v2 ? v1 : v2;
}
-static void doHandlePointerMotion(Window root_window, int root_x, int root_y, int win_x, int win_y) {
+static void doHandlePointerMotion(Window root_window, Window window, int root_x, int root_y, int win_x, int win_y) {
setCursorPos(win_x, win_y);
if (!pointer_grabbed || !shouldGrab())
return;
// find the window position in root coordinates
+ XWindowAttributes window_attributes;
+ XGetWindowAttributes(getDisplay(), root_window, &window_attributes);
+ int root_window_width = window_attributes.width;
+ int root_window_height = window_attributes.height;
+ XGetWindowAttributes(getDisplay(), window, &window_attributes);
+ int window_width = window_attributes.width;
+ int window_height = window_attributes.height;
+
int win_left = root_x - win_x;
int win_top = root_y - win_y;
- int win_right = win_left + getWindowWidth();
- int win_bottom = win_top + getWindowHeight();
+ int win_right = win_left + window_width;
+ int win_bottom = win_top + window_height;
// cap the window position to the screen dimensions
int border_left = max(0, win_left);
int border_top = max(0, win_top);
- XWindowAttributes root_attributes;
- XGetWindowAttributes(getDisplay(), root_window, &root_attributes);
- int border_right = min(root_attributes.width, win_right);
- int border_bottom = min(root_attributes.height, win_bottom);
+ int border_right = min(root_window_width, win_right);
+ int border_bottom = min(root_window_height, win_bottom);
// determine whether the cursor is outside the bounds
bool outside_limits = root_x < border_left + POINTER_WARP_BORDER || root_y < border_top + POINTER_WARP_BORDER ||
root_x > border_right - POINTER_WARP_BORDER || root_y > border_bottom - POINTER_WARP_BORDER;
@@ -308,7 +316,7 @@
}
void handlePointerMotion(XMotionEvent *event) {
- doHandlePointerMotion(event->root, event->x_root, event->y_root, event->x, event->y);
+ doHandlePointerMotion(event->root, event->window, event->x_root, event->y_root, event->x, event->y);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_LinuxDisplay_nPollMouse(JNIEnv * env, jclass clazz, jobject coord_buffer_obj, jobject button_buffer_obj) {
@@ -355,5 +363,5 @@
setGrab(window_mode, new_grab == JNI_TRUE ? true : false);
reset();
XQueryPointer(getDisplay(), getCurrentWindow(), &root_return, &child_return, &root_x, &root_y, &win_x, &win_y, &mask_return);
- doHandlePointerMotion(root_return, root_x, root_y, win_x, win_y);
+ doHandlePointerMotion(root_return, getCurrentWindow(), root_x, root_y, win_x, win_y);
}
|