1 /* grTk4.c -
2  *
3  * Copyright 2003 Open Circuit Design, Inc., for MultiGiG Ltd.
4  *
5  * This file contains functions to manage the graphics tablet associated
6  * with the X display.
7  *
8  */
9 
10 #include <signal.h>
11 #include <stdio.h>
12 #include <X11/Xlib.h>
13 
14 #include "tcltk/tclmagic.h"
15 #include "utils/magic.h"
16 #include "utils/magsgtty.h"
17 #include "textio/textio.h"
18 #include "utils/geometry.h"
19 #include "windows/windows.h"
20 #include "graphics/graphics.h"
21 #include "graphics/graphicsInt.h"
22 #include "textio/txcommands.h"
23 #include "grTkInt.h"
24 #include "grTkCommon.h"
25 
26 
27 /*---------------------------------------------------------
28  * GrTkDisableTablet:
29  *	Turns off the cursor.
30  *
31  * Results:	None.
32  *
33  * Side Effects:    None.
34  *---------------------------------------------------------
35  */
36 
37 void
GrTkDisableTablet()38 GrTkDisableTablet ()
39 {
40 }
41 
42 
43 /*---------------------------------------------------------
44  * GrTkEnableTablet:
45  *	This routine enables the graphics tablet.
46  *
47  * Results:
48  *   	None.
49  *
50  * Side Effects:
51  *	Simply turn on the crosshair.
52  *---------------------------------------------------------
53  */
54 
55 void
GrTkEnableTablet()56 GrTkEnableTablet ()
57 {
58 }
59 
60 
61 /*
62  * ----------------------------------------------------------------------------
63  * grtkGetCursorPos:
64  * 	Read the cursor position in magic coordinates.
65  *
66  * Results:
67  *	TRUE is returned if the coordinates were succesfully read, FALSE
68  *	otherwise.
69  *
70  * Side effects:
71  *	The parameter is filled in with the cursor position, in the form of
72  *	a point in screen coordinates.
73  * ----------------------------------------------------------------------------
74  */
75 
76 bool
grtkGetCursorPos(mw,p)77 grtkGetCursorPos (mw, p)
78     MagWindow *mw;
79     Point *p;		/* point to be filled in with screen coordinates */
80 {
81     int x, y, x1, y1;
82     unsigned int buttons;
83     Window win1, win2;
84 
85     if (mw == NULL) mw = grCurrent.mw;
86 
87     XQueryPointer(grXdpy, Tk_WindowId((Tk_Window)mw->w_grdata),
88 		  &win1, &win2, &x1, &y1,
89 		  &x, &y, &buttons);
90     p->p_x = x;
91     p->p_y = grXtransY(mw, y);
92 
93     return TRUE;
94 }
95 
96 /*
97  * ----------------------------------------------------------------------------
98  * grtkGetCursorRootPos:
99  * 	Read the cursor position in screen root coordinates.
100  *
101  * Results:
102  *	TRUE is returned if the coordinates were succesfully read, FALSE
103  *	otherwise.
104  *
105  * Side effects:
106  *	The parameter is filled in with the cursor position, in the form of
107  *	a point in screen coordinates.
108  * ----------------------------------------------------------------------------
109  */
110 
111 bool
grtkGetCursorRootPos(mw,p)112 grtkGetCursorRootPos (mw, p)
113     MagWindow *mw;
114     Point *p;		/* point to be filled in with root coordinates */
115 {
116     int x, y, x1, y1;
117     unsigned int buttons;
118     Window win1, win2;
119 
120     if (mw == NULL) mw = grCurrent.mw;
121 
122     XQueryPointer(grXdpy, Tk_WindowId((Tk_Window)mw->w_grdata),
123 		  &win1, &win2, &x1, &y1,
124 		  &x, &y, &buttons);
125     p->p_x = x1;
126     p->p_y = y1;
127 
128     return TRUE;
129 }
130