aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Weisse <[email protected]>2007-05-12 15:02:18 +0000
committerCarsten Weisse <[email protected]>2007-05-12 15:02:18 +0000
commita873d42c6e3a540cf8468737d5a7243f4e68ebef (patch)
tree986ba901f8a314819410fe27d97cca642d5465f0
parent24dbc3ecbe14a051618e260288ba167c37223424 (diff)
bugfix: center the mouse correct, now really ;-)
-rw-r--r--src/jake2/sys/JOGLKBD.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/jake2/sys/JOGLKBD.java b/src/jake2/sys/JOGLKBD.java
index 59b3361..e5c86a3 100644
--- a/src/jake2/sys/JOGLKBD.java
+++ b/src/jake2/sys/JOGLKBD.java
@@ -56,6 +56,8 @@ final public class JOGLKBD extends KBD
if (IN.mouse_active) {
mx = (((MouseEvent)event.ev).getX() - win_w2) * 2;
my = (((MouseEvent)event.ev).getY() - win_h2) * 2;
+ System.out
+ .println(mx + " " + my);
} else {
mx = 0;
my = 0;
@@ -88,18 +90,21 @@ final public class JOGLKBD extends KBD
Component c = ((ComponentEvent)event.ev).getComponent();
win_x = 0;
win_y = 0;
- win_w2 = c.getWidth() / 2;
- win_h2 = c.getHeight() / 2;
+ win_w2 = (c.getWidth() + 1) / 2;
+ win_h2 = (c.getHeight() + 1) / 2;
+ int left = 0; int top = 0;
while (c != null) {
if (c instanceof Container) {
Insets insets = ((Container)c).getInsets();
- win_x += insets.left;
- win_y += insets.top;
+ left += insets.left;
+ top += insets.top;
}
win_x += c.getX();
win_y += c.getY();
c = c.getParent();
}
+ win_x += left; win_y += top;
+ win_w2 -= (left + 1) / 2; win_h2 -= (top + 1) / 2;
break;
}
}