This is the mail archive of the insight@sources.redhat.com mailing list for the Insight project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

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


At 01:12 PM 5/2/01 -0700, Keith Seitz wrote:
>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
>+     }

I hate #ifdef's like this, I would prefer there to be two files, one for 
windows and one for unix, with an implementation for either.

However, assuming that nothing else in libgui is implemented that way, I 
guess this is ok.

The second question I have is why do you need "SetCursorPos@8"? Assuming 
you are including winuser.h, you should be able to use "SetCursorPos", and 
either a macro will fix this, or the linker will. I don't think requiring 
the "@8" or "@16" or whatever for Windows API calls is very nice.


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

Syd Polk		spolk@redhat.com
Engineering Manager	+1 408 543 9430
Red Hat, Inc.




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]