[RFA] libgui/src/tkWarpPointer.c for cygwin

Keith Seitz keiths@cygnus.com
Wed May 2 13:12:00 GMT 2001


Hi,

I am working on making the Insight testsuite work (better?), and I wanted
to make sure (as much as possible) that we are able to run the same tests
on Cygwin and unix.

For some tests, it is necessary to warp the pointer. This patch simply
implements this functionality on Windows, too.

Keith

src/libgui/ChangeLog:
2001-05-01  Keith Seitz  <keiths@cygnus.com>

	* src/tkWarpPointer.c (WarpPointer): Implement for windows.

Patch:
Index: src/tkWarpPointer.c
===================================================================
RCS file: /cvs/cvsfiles/devo/libgui/src/tkWarpPointer.c,v
retrieving revision 1.2
diff -p -r1.2 tkWarpPointer.c
*** tkWarpPointer.c	1999/01/28 01:18:27	1.2
--- tkWarpPointer.c	2001/05/02 20:11:06
***************
*** 24,32 ****
  *
  *
  * ---------------------------------------------------------------------------*/
- #ifndef _WIN32
-
  #include "tk.h"

  int
  WarpPointer (clientData, interp, objc, objv)
--- 24,34 ----
  *
  *
  * ---------------------------------------------------------------------------*/
  #include "tk.h"
+ #ifdef _WIN32
+ #include <windows.h>
+ #include <winuser.h>
+ #endif

  int
  WarpPointer (clientData, interp, objc, objv)
*************** WarpPointer (clientData, interp, objc, o
*** 36,47 ****
      Tcl_Obj *CONST objv[];
  {
      Tk_Window tkwin;
-     Window win;
      int x, y;
      char *str;

      if (objc != 4) {
!       Tcl_WrongNumArgs(interp, 1, objv, "x y widgetId");
        return TCL_ERROR;
      }

--- 38,48 ----
      Tcl_Obj *CONST objv[];
  {
      Tk_Window tkwin;
      int x, y;
      char *str;

      if (objc != 4) {
!       Tcl_WrongNumArgs(interp, 1, objv, "widgetId x y");
        return TCL_ERROR;
      }

*************** WarpPointer (clientData, interp, objc, o
*** 53,61 ****
  			 Tk_MainWindow (interp));
      if (tkwin == NULL)
        return TCL_ERROR;

-     win = Tk_WindowId(tkwin);
-     XWarpPointer(Tk_Display(tkwin), None, win, 0, 0, 0, 0, x, y);
      return TCL_OK;
  }

--- 54,71 ----
  			 Tk_MainWindow (interp));
      if (tkwin == NULL)
        return TCL_ERROR;
+
+     {
+ #ifdef _WIN32
+       int wx, wy;
+       Tk_GetRootCoords (tkwin, &wx, &wy);
+       SetCursorPos@8 (wx + x, wy + y);
+ #else
+       Window win = Tk_WindowId(tkwin);
+       XWarpPointer(Tk_Display(tkwin), None, win, 0, 0, 0, 0, x, y);
+ #endif
+     }

      return TCL_OK;
  }

*************** cyg_create_warp_pointer_command (Tcl_Int
*** 66,70 ****
      return TCL_ERROR;
    return TCL_OK;
  }
-
- #endif /* !_WIN32 */
--- 76,78 ----



More information about the Insight mailing list