]> git.saurik.com Git - wxWidgets.git/blob - src/x11/nanox.c
Removed bizarre test code of which I have no recollection...
[wxWidgets.git] / src / x11 / nanox.c
1 /*
2 * nanox.c
3 *
4 * Replacements for some comomon Xlib functions
5 */
6
7 #include "wx/setup.h"
8
9 #if wxUSE_NANOX
10
11 #include "wx/x11/nanox/X11/Xlib.h"
12
13 /* Expands to some compatibility functions (see XtoNX.h) */
14
15 STATIC_FUNCTIONS
16
17 Colormap DefaultColormapOfScreen(Screen* /* screen */)
18 {
19 static GR_PALETTE* s_globalColormap = 0;
20 static bool s_init = FALSE;
21
22 if (!s_init)
23 {
24 s_globalColormap = (GR_PALETTE*) malloc(sizeof(GR_PALETTE));
25
26 GrGetSystemPalette(s_globalColormap);
27 s_init = TRUE;
28 }
29
30 return s_globalColormap;
31 }
32
33 int XSetGraphicsExposures( Display* /* display */, GC /* gc */, Bool /* graphics_exposures */)
34 {
35 return Success ;
36 }
37
38 int XWarpPointer( Display* /* display */, Window /* srcW */, Window /* srcW */,
39 int /* srcX */, int /* srcY */,
40 unsigned int /* srcWidth */,
41 unsigned int /* srcHeight */,
42 int destX, int destY)
43 {
44 GrMoveCursor(destX, destY);
45 return Success;
46 }
47
48 int XSetInputFocus(Display* /* display */, Window focus, int /* revert_to */, Time /* time */)
49 {
50 GrSetFocus(focus);
51 return Success;
52 }
53
54 int XGetInputFocus(Display* /* display */, Window* /* focus_return */, int* /* revert_to_return */)
55 {
56 * focus_return = GrGetFocus();
57 * revert_to_return = 0;
58 return Success;
59 }
60
61 int XGrabPointer(Display* /* display */, Window /* grab_window */,
62 Bool /* owner_events */, unsigned int /* event_mask */,
63 int /* pointer_mode */, int /* keyboard_mode */,
64 Window /* confine_to */, Cursor /* cursor */, Time /* time */)
65 {
66 /* According to comments in srvevent.c in Nano-X, the pointer
67 * is implicitly grabbed when a mouse button is down.
68 * We may be able to simulate this further in the event loop.
69 */
70 return Success;
71 }
72
73 int XUngrabPointer(Display /* display */, Time /* time */)
74 {
75 return Success;
76 }
77
78 int XCopyArea(Display* /* display */, Drawable src, Drawable dest, GC gc,
79 int src_x, int src_y, unsigned int width, unsigned int height,
80 int dest_x, int dest_y)
81 {
82 GrCopyArea(dest, gc, dest_x, dest_y,
83 width, height, src,
84 src_x, src_y, 0);
85 return Success;
86 }
87
88 int XCopyPlane(Display* /* display */, Drawable src, Drawable dest, GC gc,
89 int src_x, int src_y, unsigned int width, unsigned int height,
90 int dest_x, int dest_y, unsigned long /* plane */)
91 {
92 GrCopyArea(dest, gc, dest_x, dest_y,
93 width, height, src,
94 src_x, src_y, 0);
95 return Success;
96 }
97
98 #if 0
99 typedef struct {
100 GR_WINDOW_ID wid; /* window id (or 0 if no such window) */
101 GR_WINDOW_ID parent; /* parent window id */
102 GR_WINDOW_ID child; /* first child window id (or 0) */
103 GR_WINDOW_ID sibling; /* next sibling window id (or 0) */
104 GR_BOOL inputonly; /* TRUE if window is input only */
105 GR_BOOL mapped; /* TRUE if window is mapped */
106 GR_COUNT unmapcount; /* reasons why window is unmapped */
107 GR_COORD x; /* absolute x position of window */
108 GR_COORD y; /* absolute y position of window */
109 GR_SIZE width; /* width of window */
110 GR_SIZE height; /* height of window */
111 GR_SIZE bordersize; /* size of border */
112 GR_COLOR bordercolor; /* color of border */
113 GR_COLOR background; /* background color */
114 GR_EVENT_MASK eventmask; /* current event mask for this client */
115 GR_WM_PROPS props; /* window properties */
116 GR_CURSOR_ID cursor; /* cursor id*/
117 unsigned long processid; /* process id of owner*/
118 } GR_WINDOW_INFO;
119
120 typedef struct {
121 int x, y; /* location of window */
122 int width, height; /* width and height of window */
123 int border_width; /* border width of window */
124 int depth; /* depth of window */
125 Visual *visual; /* the associated visual structure */
126 Window root; /* root of screen containing window */
127 int class; /* InputOutput, InputOnly*/
128 int bit_gravity; /* one of the bit gravity values */
129 int win_gravity; /* one of the window gravity values */
130 int backing_store; /* NotUseful, WhenMapped, Always */
131 unsigned long backing_planes;/* planes to be preserved if possible */
132 unsigned long backing_pixel;/* value to be used when restoring planes */
133 Bool save_under; /* boolean, should bits under be saved? */
134 Colormap colormap; /* color map to be associated with window */
135 Bool map_installed; /* boolean, is color map currently installed*/
136 int map_state; /* IsUnmapped, IsUnviewable, IsViewable */
137 long all_event_masks; /* set of events all people have interest in*/
138 long your_event_mask; /* my event mask */
139 long do_not_propagate_mask;/* set of events that should not propagate */
140 Bool override_redirect; /* boolean value for override-redirect */
141 Screen *screen; /* back pointer to correct screen */
142 } XWindowAttributes;
143
144 #endif
145
146
147 Status XGetWindowAttributes(Display* display, Window w,
148 XWindowAttributes* window_attributes_return)
149 {
150 GR_WINDOW_INFO info;
151 GrGetWindowInfo(w, & info);
152
153 window_attributes->x = info.x;
154 window_attributes->y = info.y;
155 window_attributes->width = info.width;
156 window_attributes->height = info.height;
157 window_attributes->border_width = info.bordersize;
158 window_attributes->depth = 0;
159 window_attributes->visual = NULL;
160 window_attributes->root = 0;
161 window_attributes->class = info.inputonly ? InputOnly : InputOutput ;
162 window_attributes->bit_gravity = 0;
163 window_attributes->win_gravity = 0;
164 window_attributes->backing_store = 0;
165 window_attributes->backing_planes = 0;
166 window_attributes->backing_pixel = 0;
167 window_attributes->save_under = FALSE;
168 window_attributes->colormap = DefaultColormapOfScreen(0);
169 window_attributes->map_installed = FALSE;
170 window_attributes->map_state = info.mapped ? IsViewable : IsUnmapped ;
171 window_attributes->all_event_masks = 0;
172 window_attributes->do_not_propagate_mask = 0;
173 window_attributes->override_redirect = FALSE;
174 window_attributes->screen = NULL;
175
176 return 1;
177 }
178
179 static XErrorHandler* g_ErrorHandler = NULL;
180
181 static void DefaultNanoXErrorHandler(GR_EVENT_ERROR* ep)
182 {
183 if (g_ErrorHandler)
184 {
185 XErrorEvent errEvent;
186 errEvent.type = ep->type;
187 errEvent.display = wxGlobalDisplay();
188 errEvent.resourceid = ep->id;
189 errEvent.serial = 0;
190 errEvent.error_code = ep->code;
191 errEvent.request_code = 0;
192 errEvent.minor_code = 0;
193 (*g_ErrorHandler)(wxGlobalDisplay(), & errEvent);
194 }
195 }
196
197 XErrorHandler XSetErrorHandler (XErrorHandler handler)
198 {
199 XErrorHandler oldHandler = g_ErrorHandler;
200 g_errorHandler = handler;
201 return oldHandler;
202 }
203
204 Screen *XScreenOfDisplay(Display* /* display */,
205 int /* screen_number */)
206 {
207 static Screen s_screen;
208 /* TODO: fill in the members. See Xlib.h */
209 return & s_screen;
210 }
211
212 int DisplayWidth(Display* /* display */, int /* screen */)
213 {
214 return _display.display_width;
215 }
216
217 int DisplayHeight(Display* /* display */, int /* screen */)
218 {
219 return _display.display_height;
220 }
221
222 int DefaultDepth(Display* /* display */, int /* screen */)
223 {
224 return _display.display_bpp;
225 }
226
227 int XAllocColor(Display* /* display */, Colormap /* cmap */,
228 XColor* color)
229 {
230 GR_PIXELVAL pixel;
231 GrFindColor(color, & pixel);
232 return pixel;
233 }
234
235 int XParseColor(Display* /* display */, Colormap /* cmap */,
236 const char* cname, XColor* color)
237 {
238 /* TODO */
239 return 0;
240 }
241
242 #endif
243 /* wxUSE_NANOX */