]>
git.saurik.com Git - wxWidgets.git/blob - src/x11/nanox.c
4 * Replacements for some comomon Xlib functions
11 #include "wx/x11/nanox/X11/Xlib.h"
13 /* Expands to some compatibility functions (see XtoNX.h) */
17 Colormap
DefaultColormapOfScreen(Screen
* /* screen */)
19 static GR_PALETTE
* s_globalColormap
= 0;
20 static bool s_init
= FALSE
;
24 s_globalColormap
= (GR_PALETTE
*) malloc(sizeof(GR_PALETTE
));
26 GrGetSystemPalette(s_globalColormap
);
30 return s_globalColormap
;
33 int XSetGraphicsExposures( Display
* /* display */, GC
/* gc */, Bool
/* graphics_exposures */)
38 int XWarpPointer( Display
* /* display */, Window
/* srcW */, Window
/* srcW */,
39 int /* srcX */, int /* srcY */,
40 unsigned int /* srcWidth */,
41 unsigned int /* srcHeight */,
44 GrMoveCursor(destX
, destY
);
48 int XSetInputFocus(Display
* /* display */, Window focus
, int /* revert_to */, Time
/* time */)
54 int XGetInputFocus(Display
* /* display */, Window
* /* focus_return */, int* /* revert_to_return */)
56 * focus_return
= GrGetFocus();
57 * revert_to_return
= 0;
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 */)
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.
73 int XUngrabPointer(Display
/* display */, Time
/* time */)
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
)
82 GrCopyArea(dest
, gc
, dest_x
, dest_y
,
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 */)
92 GrCopyArea(dest
, gc
, dest_x
, dest_y
,
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*/
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 */
147 Status
XGetWindowAttributes(Display
* display
, Window w
,
148 XWindowAttributes
* window_attributes_return
)
151 GrGetWindowInfo(w
, & info
);
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
;
179 static XErrorHandler
* g_ErrorHandler
= NULL
;
181 static void DefaultNanoXErrorHandler(GR_EVENT_ERROR
* ep
)
185 XErrorEvent errEvent
;
186 errEvent
.type
= ep
->type
;
187 errEvent
.display
= wxGlobalDisplay();
188 errEvent
.resourceid
= ep
->id
;
190 errEvent
.error_code
= ep
->code
;
191 errEvent
.request_code
= 0;
192 errEvent
.minor_code
= 0;
193 (*g_ErrorHandler
)(wxGlobalDisplay(), & errEvent
);
197 XErrorHandler
XSetErrorHandler (XErrorHandler handler
)
199 XErrorHandler oldHandler
= g_ErrorHandler
;
200 g_errorHandler
= handler
;
204 Screen
*XScreenOfDisplay(Display
* /* display */,
205 int /* screen_number */)
207 static Screen s_screen
;
208 /* TODO: fill in the members. See Xlib.h */
212 int DisplayWidth(Display
* /* display */, int /* screen */)
214 return _display
.display_width
;
217 int DisplayHeight(Display
* /* display */, int /* screen */)
219 return _display
.display_height
;
222 int DefaultDepth(Display
* /* display */, int /* screen */)
224 return _display
.display_bpp
;
227 int XAllocColor(Display
* /* display */, Colormap
/* cmap */,
231 GrFindColor(color
, & pixel
);
235 int XParseColor(Display
* /* display */, Colormap
/* cmap */,
236 const char* cname
, XColor
* color
)