Line |
Branch |
Exec |
Source |
1 |
|
|
/* GATE PROJECT LICENSE: |
2 |
|
|
+----------------------------------------------------------------------------+ |
3 |
|
|
| Copyright(c) 2018-2025, Stefan Meislinger <sm@opengate.at> | |
4 |
|
|
| All rights reserved. | |
5 |
|
|
| | |
6 |
|
|
| Redistribution and use in source and binary forms, with or without | |
7 |
|
|
| modification, are permitted provided that the following conditions are met:| |
8 |
|
|
| | |
9 |
|
|
| 1. Redistributions of source code must retain the above copyright notice, | |
10 |
|
|
| this list of conditions and the following disclaimer. | |
11 |
|
|
| 2. Redistributions in binary form must reproduce the above copyright | |
12 |
|
|
| notice, this list of conditions and the following disclaimer in the | |
13 |
|
|
| documentation and/or other materials provided with the distribution. | |
14 |
|
|
| | |
15 |
|
|
| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"| |
16 |
|
|
| AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
17 |
|
|
| IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
18 |
|
|
| ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
19 |
|
|
| LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
20 |
|
|
| CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
21 |
|
|
| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
22 |
|
|
| INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
23 |
|
|
| CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
24 |
|
|
| ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | |
25 |
|
|
| THE POSSIBILITY OF SUCH DAMAGE. | |
26 |
|
|
+----------------------------------------------------------------------------+ |
27 |
|
|
*/ |
28 |
|
|
|
29 |
|
|
#ifndef GATE_PLATFORM_LINUX_PROCFS_H_INCLUDED |
30 |
|
|
#define GATE_PLATFORM_LINUX_PROCFS_H_INCLUDED |
31 |
|
|
|
32 |
|
|
#include "gate/gatetypes.h" |
33 |
|
|
|
34 |
|
|
#ifdef GATE_SYS_POSIX |
35 |
|
|
|
36 |
|
|
#include "gate/inputs.h" |
37 |
|
|
#include "gate/strings.h" |
38 |
|
|
#include "gate/libraries.h" |
39 |
|
|
#include "gate/results.h" |
40 |
|
|
|
41 |
|
|
#ifndef XUTIL_DEFINE_FUNCTIONS |
42 |
|
|
#define XUTIL_DEFINE_FUNCTIONS |
43 |
|
|
#endif |
44 |
|
|
#include <X11/Xlib.h> |
45 |
|
|
#include <X11/Xutil.h> |
46 |
|
|
#include <X11/keysym.h> |
47 |
|
|
#include <X11/Xatom.h> |
48 |
|
|
|
49 |
|
|
typedef struct gate_xlib |
50 |
|
|
{ |
51 |
|
|
Display* (*XOpenDisplay) (const char* display_name); |
52 |
|
|
Window (*XDefaultRootWindow) (Display* display); |
53 |
|
|
int (*XCloseDisplay) (Display* display); |
54 |
|
|
Window (*XCreateWindow) (Display* display, Window parent, int x, int y, unsigned int width, unsigned int height, unsigned int border_width, int depth, unsigned int clazz, Visual* visual, unsigned long valuemask, XSetWindowAttributes* attributes); |
55 |
|
|
Atom (*XInternAtom) (Display* display, const char* atom_name, Bool only_if_exists); |
56 |
|
|
int (*XChangeProperty) (Display* display, Window w, Atom property, Atom type, int format, int mode, const unsigned char* data, int nelements); |
57 |
|
|
int (*XSetWMHints) (Display* display, Window w, XWMHints* wm_hints); |
58 |
|
|
int (*XMapWindow) (Display* display, Window w); |
59 |
|
|
int (*XStoreName) (Display* display, Window w, const char* window_name); |
60 |
|
|
int (*XPending) (Display* display); |
61 |
|
|
int (*XNextEvent) (Display* display, XEvent* event_return); |
62 |
|
|
int (*XDestroyWindow) (Display* display, Window w); |
63 |
|
|
Bool (*XCheckWindowEvent) (Display* display, Window w, long event_mask, XEvent* event_return); |
64 |
|
|
int (*XGetInputFocus) (Display* display, Window* focus_return, int* revert_to_return); |
65 |
|
|
KeyCode (*XKeysymToKeycode) (Display* display, KeySym keysym); |
66 |
|
|
KeySym (*XStringToKeysym) (const char* str); |
67 |
|
|
Status (*XSendEvent) (Display* display, Window w, Bool propagate, long event_mask, XEvent* event_send); |
68 |
|
|
Status (*XGetWindowAttributes) (Display* display, Window w, XWindowAttributes* window_attributes_return); |
69 |
|
|
int (*XFlush) (Display* display); |
70 |
|
|
int (*XDefaultScreen) (Display*); |
71 |
|
|
Colormap (*XDefaultColormap) (Display*, int); |
72 |
|
|
int (*XQueryColor) (Display*, Colormap, XColor*); |
73 |
|
|
int (*XResizeWindow) (Display* display, Window w, unsigned int width, unsigned int height); |
74 |
|
|
Bool (*XCheckMaskEvent) (Display* display, long event_mask, XEvent* event_return); |
75 |
|
|
KeySym (*XLookupKeysym) (XKeyEvent* key_event, int index); |
76 |
|
|
int (*XSelectInput) (Display* display, Window w, long event_mask); |
77 |
|
|
Status (*XMatchVisualInfo) (Display* display, int screen, int depth, int clazz, XVisualInfo* vinfo_return); |
78 |
|
|
Colormap (*XCreateColormap) (Display* display, Window w, Visual* visual, int alloc); |
79 |
|
|
void (*XSetWMProtocols) (Display* display, Window w, Atom* protocols, int count); |
80 |
|
|
/********/ |
81 |
|
|
Status (*XInitThreads) (void); |
82 |
|
|
int (*XDefaultDepth) (Display* display, int screen_number); |
83 |
|
|
Visual* (*XDefaultVisual) (Display* display, int screen_number); |
84 |
|
|
int (*XBitmapPad) (Display* display); |
85 |
|
|
Window (*XRootWindow) (Display* display, int screen_number); |
86 |
|
|
Bool (*XTranslateCoordinates)(Display* display, Window src_w, Window dest_w, int src_x, int src_y, int* dest_x_return, int* dest_y_return, Window* child_return); |
87 |
|
|
int (*XConnectionNumber) (Display* display); |
88 |
|
|
int (*XMoveResizeWindow) (Display* display, Window w, int x, int y, unsigned int width, unsigned int height); |
89 |
|
|
int (*XSetInputFocus) (Display* display, Window focus, int revert_to, Time time); |
90 |
|
|
int (*XUnmapWindow) (Display* display, Window w); |
91 |
|
|
|
92 |
|
|
int (*XSetGraphicsExposures)(Display* display, GC gc, Bool graphics_exposures); |
93 |
|
|
Pixmap (*XCreatePixmap) (Display* display, Drawable d, unsigned int width, unsigned int height, unsigned int depth); |
94 |
|
|
int (*XFreePixmap) (Display* display, Pixmap pixmap); |
95 |
|
|
GC (*XCreateGC) (Display* display, Drawable d, unsigned long valuemask, XGCValues* values); |
96 |
|
|
int (*XFreeGC) (Display* display, GC gc); |
97 |
|
|
XImage* (*XCreateImage) (Display* display, Visual* visual, unsigned int depth, int format, int offset, char* data, unsigned int width, unsigned int height, int bitmap_pad, int bytes_per_line); |
98 |
|
|
XImage* (*XGetImage) (Display* display, Drawable d, int x, int y, unsigned int width, unsigned int height, unsigned long plane_mask, int format); |
99 |
|
|
int (*XPutImage) (Display* display, Drawable d, GC gc, XImage* image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height); |
100 |
|
|
int (*XDestroyImage) (XImage* ximage); |
101 |
|
|
|
102 |
|
|
Status (*XAllocColor) (Display* display, Colormap colormap, XColor* screen_in_out); |
103 |
|
|
unsigned long(*XBlackPixel) (Display* display, int screen_number); |
104 |
|
|
unsigned long(*XWhitePixel) (Display* display, int screen_number); |
105 |
|
|
int (*XSetForeground) (Display* display, GC gc, unsigned long foreground); |
106 |
|
|
unsigned long(*XGetPixel) (XImage* ximage, int x, int y); |
107 |
|
|
int (*XPutPixel) (XImage* ximage, int x, int y, unsigned long pixel); |
108 |
|
|
int (*XDrawPoint) (Display* display, Drawable d, GC gc, int x, int y); |
109 |
|
|
int (*XDrawLine) (Display* display, Drawable d, GC gc, int x1, int y1, int x2, int y2); |
110 |
|
|
int (*XDrawLines) (Display* display, Drawable d, GC gc, XPoint* points, int npoints, int mode); |
111 |
|
|
int (*XFillPolygon) (Display* display, Drawable d, GC gc, XPoint* points, int npoints, int shape, int mode); |
112 |
|
|
int (*XDrawRectangle) (Display* display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height); |
113 |
|
|
int (*XFillRectangle) (Display* display, Drawable d, GC gc, int x, int y, unsigned int width, unsigned int height); |
114 |
|
|
|
115 |
|
|
Font (*XLoadFont) (Display* display, char const* name); |
116 |
|
|
int (*XSetFont) (Display* display, GC gc, Font font); |
117 |
|
|
char** (*XListFonts) (Display* display, char const* pattern, int maxnames, int* actual_count_return); |
118 |
|
|
int (*XFreeFontNames) (char** list); |
119 |
|
|
int (*XDrawString) (Display* display, Drawable d, GC gc, int x, int y, char const* string, int length); |
120 |
|
|
int (*XFreeFontInfo) (char** names, XFontStruct* free_info, int actual_count); |
121 |
|
|
XFontStruct*(*XQueryFont) (Display* display, XID font_ID); |
122 |
|
|
int (*XTextWidth) (XFontStruct* font_struct, char const* string, int count); |
123 |
|
|
int (*XUnloadFont) (Display* display, Font font); |
124 |
|
|
Cursor (*XCreateFontCursor) (Display* display, unsigned int shape); |
125 |
|
|
int (*XDefineCursor) (Display* display, Window w, Cursor cursor); |
126 |
|
|
int (*XUndefineCursor) (Display* display, Window w); |
127 |
|
|
int (*XFreeCursor) (Display* display, Cursor cursor); |
128 |
|
|
Bool (*XQueryPointer) (Display* display, Window w, Window* root_return, Window* child_return, int* root_x_return, int* root_y_return, int* win_x_return, int* win_y_return, unsigned int* mask_return); |
129 |
|
|
int (*XWarpPointer) (Display* display, Window src_w, Window dest_w, int src_x, int src_y, unsigned int src_width, unsigned int src_height, int dest_x, int dest_y); |
130 |
|
|
|
131 |
|
|
} gate_xlib_t; |
132 |
|
|
|
133 |
|
|
static gate_xlib_t xlib = GATE_INIT_EMPTY; |
134 |
|
|
static gate_bool_t volatile xlib_loaded = false; |
135 |
|
|
|
136 |
|
✗ |
static gate_result_t gate_xlib_load_functions() |
137 |
|
|
{ |
138 |
|
|
static gate_string_t xlib_lib_name = GATE_STRING_INIT_STATIC("libX11.so"); |
139 |
|
✗ |
gate_result_t ret = GATE_RESULT_FAILED; |
140 |
|
|
static gate_library_t xlib_lib = NULL; |
141 |
|
|
|
142 |
|
|
do |
143 |
|
|
{ |
144 |
|
✗ |
if (xlib_loaded) |
145 |
|
|
{ |
146 |
|
✗ |
ret = GATE_RESULT_OK; |
147 |
|
✗ |
break; |
148 |
|
|
} |
149 |
|
|
|
150 |
|
✗ |
if (xlib_lib == NULL) |
151 |
|
|
{ |
152 |
|
✗ |
ret = gate_library_open(&xlib_lib_name, &xlib_lib, GATE_LIBRARY_FLAG_DEFAULT); |
153 |
|
✗ |
GATE_BREAK_IF_FAILED(ret); |
154 |
|
|
} |
155 |
|
|
|
156 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XOpenDisplay", &xlib.XOpenDisplay)); |
157 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XDefaultRootWindow", &xlib.XDefaultRootWindow)); |
158 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XCloseDisplay", &xlib.XCloseDisplay)); |
159 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XCreateWindow", &xlib.XCreateWindow)); |
160 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XInternAtom", &xlib.XInternAtom)); |
161 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XChangeProperty", &xlib.XChangeProperty)); |
162 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XSetWMHints", &xlib.XSetWMHints)); |
163 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XMapWindow", &xlib.XMapWindow)); |
164 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XStoreName", &xlib.XStoreName)); |
165 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XPending", &xlib.XPending)); |
166 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XNextEvent", &xlib.XNextEvent)); |
167 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XDestroyWindow", &xlib.XDestroyWindow)); |
168 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XCheckWindowEvent", &xlib.XCheckWindowEvent)); |
169 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XGetInputFocus", &xlib.XGetInputFocus)); |
170 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XKeysymToKeycode", &xlib.XKeysymToKeycode)); |
171 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XStringToKeysym", &xlib.XStringToKeysym)); |
172 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XSendEvent", &xlib.XSendEvent)); |
173 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XGetWindowAttributes", &xlib.XGetWindowAttributes)); |
174 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XFlush", &xlib.XFlush)); |
175 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XDefaultScreen", &xlib.XDefaultScreen)); |
176 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XDefaultColormap", &xlib.XDefaultColormap)); |
177 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XQueryColor", &xlib.XQueryColor)); |
178 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XResizeWindow", &xlib.XResizeWindow)); |
179 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XCheckMaskEvent", &xlib.XCheckMaskEvent)); |
180 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XLookupKeysym", &xlib.XLookupKeysym)); |
181 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XSelectInput", &xlib.XSelectInput)); |
182 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XMatchVisualInfo", &xlib.XMatchVisualInfo)); |
183 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XCreateColormap", &xlib.XCreateColormap)); |
184 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XSetWMProtocols", &xlib.XSetWMProtocols)); |
185 |
|
|
|
186 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XInitThreads", &xlib.XInitThreads)); |
187 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XDefaultDepth", &xlib.XDefaultDepth)); |
188 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XDefaultVisual", &xlib.XDefaultVisual)); |
189 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XBitmapPad", &xlib.XBitmapPad)); |
190 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XRootWindow", &xlib.XRootWindow)); |
191 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XTranslateCoordinates", &xlib.XTranslateCoordinates)); |
192 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XConnectionNumber", &xlib.XConnectionNumber)); |
193 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XMoveResizeWindow", &xlib.XMoveResizeWindow)); |
194 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XSetInputFocus", &xlib.XSetInputFocus)); |
195 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XUnmapWindow", &xlib.XUnmapWindow)); |
196 |
|
|
|
197 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XSetGraphicsExposures", &xlib.XSetGraphicsExposures)); |
198 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XCreatePixmap", &xlib.XCreatePixmap)); |
199 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XFreePixmap", &xlib.XFreePixmap)); |
200 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XCreateGC", &xlib.XCreateGC)); |
201 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XFreeGC", &xlib.XFreeGC)); |
202 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XCreateImage", &xlib.XCreateImage)); |
203 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XGetImage", &xlib.XGetImage)); |
204 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XPutImage", &xlib.XPutImage)); |
205 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XDestroyImage", &xlib.XDestroyImage)); |
206 |
|
|
|
207 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XAllocColor", &xlib.XAllocColor)); |
208 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XBlackPixel", &xlib.XBlackPixel)); |
209 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XWhitePixel", &xlib.XWhitePixel)); |
210 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XSetForeground", &xlib.XSetForeground)); |
211 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XGetPixel", &xlib.XGetPixel)); |
212 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XPutPixel", &xlib.XPutPixel)); |
213 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XDrawPoint", &xlib.XDrawPoint)); |
214 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XDrawLine", &xlib.XDrawLine)); |
215 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XDrawLines", &xlib.XDrawLines)); |
216 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XFillPolygon", &xlib.XFillPolygon)); |
217 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XDrawRectangle", &xlib.XDrawRectangle)); |
218 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XFillRectangle", &xlib.XFillRectangle)); |
219 |
|
|
|
220 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XLoadFont", &xlib.XLoadFont)); |
221 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XSetFont", &xlib.XSetFont)); |
222 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XListFonts", &xlib.XListFonts)); |
223 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XFreeFontNames", &xlib.XFreeFontNames)); |
224 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XDrawString", &xlib.XDrawString)); |
225 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XFreeFontInfo", &xlib.XFreeFontInfo)); |
226 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XQueryFont", &xlib.XQueryFont)); |
227 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XTextWidth", &xlib.XTextWidth)); |
228 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XUnloadFont", &xlib.XUnloadFont)); |
229 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XCreateFontCursor", &xlib.XCreateFontCursor)); |
230 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XDefineCursor", &xlib.XDefineCursor)); |
231 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XUndefineCursor", &xlib.XUndefineCursor)); |
232 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XFreeCursor", &xlib.XFreeCursor)); |
233 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XQueryPointer", &xlib.XQueryPointer)); |
234 |
|
✗ |
GATE_BREAK_IF_FAILED(ret = gate_library_get_function_name(xlib_lib, "XWarpPointer", &xlib.XWarpPointer)); |
235 |
|
|
|
236 |
|
✗ |
xlib_loaded = true; |
237 |
|
✗ |
ret = GATE_RESULT_OK; |
238 |
|
|
} while (0); |
239 |
|
✗ |
return ret; |
240 |
|
|
} |
241 |
|
|
|
242 |
|
|
|
243 |
|
|
|
244 |
|
|
struct gate_xlib_keysym_mapping |
245 |
|
|
{ |
246 |
|
|
gate_input_keycode_t keycode; |
247 |
|
|
KeySym keysym; |
248 |
|
|
}; |
249 |
|
|
|
250 |
|
|
static struct gate_xlib_keysym_mapping const gate_xlib_keysym_mappings[] = |
251 |
|
|
{ |
252 |
|
|
{ GATE_KBD_KEY_CTRL, XK_Control_L }, |
253 |
|
|
{ GATE_KBD_KEY_CTRL, XK_Control_R }, |
254 |
|
|
{ GATE_KBD_KEY_MENU, XK_Alt_L }, |
255 |
|
|
{ GATE_KBD_KEY_MENU, XK_Alt_R }, |
256 |
|
|
{ GATE_KBD_KEY_SHIFT, XK_Shift_L }, |
257 |
|
|
{ GATE_KBD_KEY_SHIFT, XK_Shift_R }, |
258 |
|
|
{ GATE_KBD_KEY_ADD, XK_plus }, |
259 |
|
|
{ GATE_KBD_KEY_SUBTRACT, XK_minus }, |
260 |
|
|
{ GATE_KBD_KEY_TAB, XK_Tab }, |
261 |
|
|
/*{ GATE_KBD_KEY_CAPSLOCK, XK_Caps_Lock },*/ |
262 |
|
|
{ GATE_KBD_KEY_BACKSPACE, XK_BackSpace }, |
263 |
|
|
{ GATE_KBD_KEY_RETURN, XK_Return }, |
264 |
|
|
{ GATE_KBD_KEY_RETURN, XK_KP_Enter }, |
265 |
|
|
{ GATE_KBD_KEY_ESCAPE, XK_Escape }, |
266 |
|
|
{ GATE_KBD_KEY_INSERT, XK_Insert }, |
267 |
|
|
{ GATE_KBD_KEY_DELETE, XK_Delete }, |
268 |
|
|
{ GATE_KBD_KEY_HOME, XK_Home }, |
269 |
|
|
{ GATE_KBD_KEY_END, XK_End }, |
270 |
|
|
{ GATE_KBD_KEY_PGUP, XK_Page_Up }, |
271 |
|
|
{ GATE_KBD_KEY_PGDOWN, XK_Page_Down }, |
272 |
|
|
{ GATE_KBD_KEY_LEFT, XK_Left }, |
273 |
|
|
{ GATE_KBD_KEY_UP, XK_Up }, |
274 |
|
|
{ GATE_KBD_KEY_RIGHT, XK_Right }, |
275 |
|
|
{ GATE_KBD_KEY_DOWN, XK_Down }, |
276 |
|
|
{ GATE_KBD_KEY_PRINT, XK_Print }, |
277 |
|
|
/* { GATE_KBD_KEY_BREAK, XK_Break },*/ |
278 |
|
|
{ GATE_KBD_KEY_SCROLLLOCK, XK_Scroll_Lock }, |
279 |
|
|
{ GATE_KBD_KEY_NUMLOCK, XK_Num_Lock }, |
280 |
|
|
{ GATE_KBD_KEY_F1, XK_F1 }, { GATE_KBD_KEY_F2, XK_F2 }, { GATE_KBD_KEY_F3, XK_F3 }, |
281 |
|
|
{ GATE_KBD_KEY_F4, XK_F4 }, { GATE_KBD_KEY_F5, XK_F5 }, { GATE_KBD_KEY_F6, XK_F6 }, |
282 |
|
|
{ GATE_KBD_KEY_F7, XK_F7 }, { GATE_KBD_KEY_F8, XK_F8 }, { GATE_KBD_KEY_F9, XK_F9 }, |
283 |
|
|
{ GATE_KBD_KEY_F10, XK_F10 }, { GATE_KBD_KEY_F11, XK_F11 }, { GATE_KBD_KEY_F12, XK_F12 }, |
284 |
|
|
{ GATE_KBD_KEY_SPACEBAR, XK_space }, |
285 |
|
|
{ GATE_KBD_KEY_BRACE_LEFT, XK_braceleft }, |
286 |
|
|
{ GATE_KBD_KEY_BRACE_RIGHT, XK_braceright }, |
287 |
|
|
{ GATE_KBD_KEY_A, XK_A }, { GATE_KBD_KEY_B, XK_B }, { GATE_KBD_KEY_C, XK_C }, |
288 |
|
|
{ GATE_KBD_KEY_D, XK_D }, { GATE_KBD_KEY_E, XK_E }, { GATE_KBD_KEY_F, XK_F }, |
289 |
|
|
{ GATE_KBD_KEY_G, XK_G }, { GATE_KBD_KEY_H, XK_H }, { GATE_KBD_KEY_I, XK_I }, |
290 |
|
|
{ GATE_KBD_KEY_J, XK_J }, { GATE_KBD_KEY_K, XK_K }, { GATE_KBD_KEY_L, XK_L }, |
291 |
|
|
{ GATE_KBD_KEY_M, XK_M }, { GATE_KBD_KEY_N, XK_N }, { GATE_KBD_KEY_O, XK_O }, |
292 |
|
|
{ GATE_KBD_KEY_P, XK_P }, { GATE_KBD_KEY_Q, XK_Q }, { GATE_KBD_KEY_R, XK_R }, |
293 |
|
|
{ GATE_KBD_KEY_S, XK_S }, { GATE_KBD_KEY_T, XK_T }, { GATE_KBD_KEY_U, XK_U }, |
294 |
|
|
{ GATE_KBD_KEY_V, XK_V }, { GATE_KBD_KEY_W, XK_W }, { GATE_KBD_KEY_X, XK_X }, |
295 |
|
|
{ GATE_KBD_KEY_Y, XK_Y }, { GATE_KBD_KEY_Z, XK_Z }, { GATE_KBD_KEY_0, XK_0 }, |
296 |
|
|
{ GATE_KBD_KEY_1, XK_1 }, { GATE_KBD_KEY_2, XK_2 }, { GATE_KBD_KEY_3, XK_3 }, |
297 |
|
|
{ GATE_KBD_KEY_4, XK_4 }, { GATE_KBD_KEY_5, XK_5 }, { GATE_KBD_KEY_6, XK_6 }, |
298 |
|
|
{ GATE_KBD_KEY_7, XK_7 }, { GATE_KBD_KEY_8, XK_8 }, { GATE_KBD_KEY_9, XK_9 } |
299 |
|
|
}; |
300 |
|
|
|
301 |
|
|
static gate_size_t const gate_xlib_keysym_mappings_count = sizeof(gate_xlib_keysym_mappings) / sizeof(gate_xlib_keysym_mappings[0]); |
302 |
|
|
|
303 |
|
✗ |
static gate_bool_t gate_xlib_convert_keysym(KeySym key_sym, gate_input_keycode_t* key_code) |
304 |
|
|
{ |
305 |
|
|
gate_size_t index; |
306 |
|
✗ |
for (index = 0; index != gate_xlib_keysym_mappings_count; ++index) |
307 |
|
|
{ |
308 |
|
✗ |
if (gate_xlib_keysym_mappings[index].keysym == key_sym) |
309 |
|
|
{ |
310 |
|
✗ |
*key_code = gate_xlib_keysym_mappings[index].keycode; |
311 |
|
✗ |
return true; |
312 |
|
|
} |
313 |
|
|
} |
314 |
|
✗ |
return false; |
315 |
|
|
} |
316 |
|
|
|
317 |
|
✗ |
static gate_bool_t gate_xlib_resolve_keysym(gate_input_keycode_t key_code, KeySym* key_sym) |
318 |
|
|
{ |
319 |
|
|
gate_size_t index; |
320 |
|
✗ |
for (index = 0; index != gate_xlib_keysym_mappings_count; ++index) |
321 |
|
|
{ |
322 |
|
✗ |
if (gate_xlib_keysym_mappings[index].keysym == key_code) |
323 |
|
|
{ |
324 |
|
✗ |
*key_sym = gate_xlib_keysym_mappings[index].keysym; |
325 |
|
✗ |
return true; |
326 |
|
|
} |
327 |
|
|
} |
328 |
|
✗ |
return false; |
329 |
|
|
} |
330 |
|
|
|
331 |
|
|
#endif |
332 |
|
|
|
333 |
|
|
#endif |
334 |
|
|
|