2001-06-01 22:53:17 +04:00
|
|
|
Index: gui/x.cc
|
|
|
|
===================================================================
|
|
|
|
RCS file: /cvsroot/bochs/bochs/gui/x.cc,v
|
2001-06-23 07:59:49 +04:00
|
|
|
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;
|
2001-06-01 22:53:17 +04:00
|
|
|
|
2001-06-23 07:59:49 +04:00
|
|
|
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();
|
2001-06-01 22:53:17 +04:00
|
|
|
|
2001-06-23 07:59:49 +04:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2001-06-01 22:53:17 +04:00
|
|
|
|
2001-06-23 07:59:49 +04:00
|
|
|
@@ -628,10 +628,10 @@
|
2001-06-01 22:53:17 +04:00
|
|
|
mouse_update = 0;
|
2001-06-23 07:59:49 +04:00
|
|
|
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();
|
2001-06-01 22:53:17 +04:00
|
|
|
|
2001-06-23 07:59:49 +04:00
|
|
|
//mouse_button_state |= ;
|
|
|
|
//send_keyboard_mouse_status();
|
|
|
|
@@ -703,22 +703,32 @@
|
2001-06-01 22:53:17 +04:00
|
|
|
pointer_event = (XPointerMovedEvent *) &report;
|
2001-06-23 07:59:49 +04:00
|
|
|
current_x = pointer_event->x;
|
|
|
|
current_y = pointer_event->y;
|
2001-06-01 22:53:17 +04:00
|
|
|
- mouse_update = 1;
|
2001-06-23 07:59:49 +04:00
|
|
|
-//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));
|
2001-06-01 22:53:17 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case EnterNotify:
|
|
|
|
enter_event = (XEnterWindowEvent *) &report;
|
|
|
|
- prev_x = current_x = enter_event->x;
|
|
|
|
- prev_y = current_y = enter_event->y;
|
2001-06-23 07:59:49 +04:00
|
|
|
-//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));
|
2001-06-01 22:53:17 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case LeaveNotify:
|
|
|
|
leave_event = (XLeaveWindowEvent *) &report;
|
2001-06-23 07:59:49 +04:00
|
|
|
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
|
2001-06-01 22:53:17 +04:00
|
|
|
break;
|
|
|
|
|
2001-06-23 07:59:49 +04:00
|
|
|
case MapNotify:
|
|
|
|
@@ -748,9 +758,8 @@
|
2001-06-01 22:53:17 +04:00
|
|
|
void
|
|
|
|
send_keyboard_mouse_status(void)
|
|
|
|
{
|
|
|
|
- BX_DEBUG(("XXX: prev=(%d,%d) curr=(%d,%d)",
|
|
|
|
- prev_x, prev_y, current_x, current_y));
|
|
|
|
-
|
2001-06-23 07:59:49 +04:00
|
|
|
+//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;
|
2001-06-01 22:53:17 +04:00
|
|
|
+
|
2001-06-23 07:59:49 +04:00
|
|
|
+ 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 ));
|
2001-06-01 22:53:17 +04:00
|
|
|
+
|
2001-06-23 07:59:49 +04:00
|
|
|
// 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);
|
|
|
|
}
|
2001-06-01 22:53:17 +04:00
|
|
|
}
|
|
|
|
|
2001-06-23 07:59:49 +04:00
|
|
|
-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);
|
|
|
|
}
|