- this is very very old, and the linux mouse is working quite well now

This commit is contained in:
Bryce Denney 2002-11-20 03:50:07 +00:00
parent e0b4cb6421
commit 1ef6479c6f

View File

@ -1,147 +0,0 @@
Index: gui/x.cc
===================================================================
RCS file: /cvsroot/bochs/bochs/gui/x.cc,v
retrieving revision 1.13
diff -u -r1.13 x.cc
--- gui/x.cc 2001/06/23 03:18:14 1.13
+++ gui/x.cc 2001/06/23 03:57:38
@@ -75,8 +75,8 @@
static int warp_dy = 0;
static void warp_cursor(int dx, int dy);
-static void disable_cursor();
-static void enable_cursor();
+static void trap_x_pointer();
+static void release_x_pointer();
struct {
Pixmap bmap;
@@ -525,16 +525,16 @@
{
BX_INFO (("mouse_enabled=%d, x11 specific code", val?1:0));
if (val) {
- BX_INFO(("[x] Mouse on"));
- mouse_enable_x = current_x;
- mouse_enable_y = current_y;
- disable_cursor();
- // Move the cursor to a 'safe' place
- warp_cursor(warp_home_x-current_x, warp_home_y-current_y);
+ BX_INFO(("[x] Mouse on\n"));
+ mouse_enable_x = current_x;
+ mouse_enable_y = current_y;
+ trap_x_pointer();
+ // Move the cursor to a 'safe' place
+ warp_cursor(warp_home_x-current_x, warp_home_y-current_y);
} else {
- BX_INFO(("[x] Mouse off"));
- enable_cursor();
- warp_cursor(mouse_enable_x-current_x, mouse_enable_y-current_y);
+ BX_INFO(("[x] Mouse off\n"));
+ release_x_pointer();
+ warp_cursor(mouse_enable_x-current_x, mouse_enable_y-current_y);
}
}
@@ -628,10 +628,10 @@
mouse_update = 0;
break;
case Button2:
- BX_DEBUG(("XXX: button2"));
+ BX_DEBUG(("XXX: button2"));
- // (mch) Hack for easier mouse handling (toggle mouse enable)
- toggle_mouse_enable();
+ // (mch) Hack for easier mouse handling (toggle mouse enable)
+ toggle_mouse_enable();
//mouse_button_state |= ;
//send_keyboard_mouse_status();
@@ -703,22 +703,32 @@
pointer_event = (XPointerMovedEvent *) &report;
current_x = pointer_event->x;
current_y = pointer_event->y;
- mouse_update = 1;
-//BX_INFO(("xxx: motionNotify x,y=(%d,%d)", current_x, current_y));
+ /*
+ If both the conditions below are zero, this motion event is an echo from
+ the call to "WarpPointer()", so we just swallow it...
+ (i.e. don't update the emulation)
+ */
+ if ((warp_home_x-current_x) || (warp_home_y-current_y))
+ mouse_update = 1;
+//BX_INFO(("xxx: motionNotify x,y=(%d,%d)\n", current_x, current_y));
break;
case EnterNotify:
enter_event = (XEnterWindowEvent *) &report;
- prev_x = current_x = enter_event->x;
- prev_y = current_y = enter_event->y;
-//BX_INFO(("xxx: enterNotify x,y=(%d,%d)", current_x, current_y));
+ mouse_enable_x = prev_x = current_x = enter_event->x;
+ mouse_enable_y = prev_y = current_y = enter_event->y;
+ trap_x_pointer();
+ // Move the cursor to a 'safe' place
+ warp_cursor(warp_home_x-current_x, warp_home_y-current_y);
+//BX_INFO(("xxx: enterNotify x,y=(%d,%d)\n", current_x, current_y));
break;
case LeaveNotify:
leave_event = (XLeaveWindowEvent *) &report;
prev_x = current_x = -1;
prev_y = current_y = -1;
-//BX_INFO(("xxx: LeaveNotify x,y set to -1"));
+//BX_INFO(("xxx: LeaveNotify x,y set to -1\n"));
+// This _won't_ happen, because we use WarpPointer to "trap" the pointer
break;
case MapNotify:
@@ -748,9 +758,8 @@
void
send_keyboard_mouse_status(void)
{
- BX_DEBUG(("XXX: prev=(%d,%d) curr=(%d,%d)",
- prev_x, prev_y, current_x, current_y));
-
+//BX_DEBUG(("XXX: prev=(%d,%d) curr=(%d,%d)\n",
+// prev_x, prev_y, current_x, current_y));
if ( (prev_x!=-1) && (current_x!=-1) && (prev_y!=-1) && (current_y!=-1)) {
int dx, dy;
@@ -763,6 +772,9 @@
bx_devices.keyboard->mouse_motion( dx, dy, mouse_button_state);
//if (warped) {
// prev_x = current_x = -1;
+
+ BX_DEBUG(("send_kbd_mse_status: warp_(%3d,%3d) d(%3d,%3d) c(%3d,%3d) p(%3d,%3d)\n", warp_dx, warp_dy, dx, dy, current_x, current_y, prev_x, prev_y ));
+
// prev_y = current_y = -1;
// }
//else {
@@ -1251,14 +1263,15 @@
static void warp_cursor (int dx, int dy)
{
- if (bx_options.Omouse_enabled->get ()) {
+ if ((bx_options.Omouse_enabled->get ()) && ((dx != 0) || (dy != 0))) {
warp_dx = dx;
warp_dy = dy;
XWarpPointer(bx_x_display, None, None, 0, 0, 0, 0, dx, dy);
}
}
-static void disable_cursor ()
+// "Trap" the X-Windows pointer by defining a local pointer for this window
+static void trap_x_pointer ()
{
static Cursor cursor;
static unsigned cursor_created = 0;
@@ -1302,7 +1315,8 @@
XDefineCursor(bx_x_display, win, cursor);
}
-static void enable_cursor ()
+// Release the X-Windows mouse pointer by undefining the local one.
+static void release_x_pointer ()
{
XUndefineCursor(bx_x_display, win);
}