Atlas - SDL_x11toolkit.h

Home / ext / SDL / src / video / x11 Lines: 1 | Size: 8171 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1/* 2 Simple DirectMedia Layer 3 Copyright (C) 1997-2025 Sam Lantinga <[email protected]> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20*/ 21#include "SDL_internal.h" 22 23#ifndef SDL_x11toolkit_h_ 24#define SDL_x11toolkit_h_ 25 26#include "../../SDL_list.h" 27#include "SDL_x11video.h" 28#include "SDL_x11dyn.h" 29#include "SDL_x11settings.h" 30#include "SDL_x11toolkit.h" 31#include "xsettings-client.h" 32#ifdef HAVE_FRIBIDI_H 33#include "../../core/unix/SDL_fribidi.h" 34#endif 35#ifdef HAVE_LIBTHAI_H 36#include "../../core/unix/SDL_libthai.h" 37#endif 38 39#ifdef SDL_VIDEO_DRIVER_X11 40 41/* Various predefined paddings */ 42#define SDL_TOOLKIT_X11_ELEMENT_PADDING 4 43#define SDL_TOOLKIT_X11_ELEMENT_PADDING_2 12 44#define SDL_TOOLKIT_X11_ELEMENT_PADDING_3 8 45#define SDL_TOOLKIT_X11_ELEMENT_PADDING_4 16 46#define SDL_TOOLKIT_X11_ELEMENT_PADDING_5 3 47 48typedef enum SDL_ToolkitChildModeX11 49{ 50 SDL_TOOLKIT_WINDOW_MODE_X11_DIALOG, 51 SDL_TOOLKIT_WINDOW_MODE_X11_CHILD, /* For embedding into a normal SDL_Window */ 52 SDL_TOOLKIT_WINDOW_MODE_X11_MENU, 53 SDL_TOOLKIT_WINDOW_MODE_X11_TOOLTIP 54} SDL_ToolkitWindowModeX11; 55 56typedef enum SDL_ToolkitThaiEncodingX11 57{ 58 SDL_TOOLKIT_THAI_ENCODING_X11_NONE, 59 SDL_TOOLKIT_THAI_ENCODING_X11_TIS, /* -0 */ 60 SDL_TOOLKIT_THAI_ENCODING_X11_TIS_WIN, /* -2 */ 61 SDL_TOOLKIT_THAI_ENCODING_X11_TIS_MAC, /* -1 */ 62 SDL_TOOLKIT_THAI_ENCODING_X11_8859, 63 SDL_TOOLKIT_THAI_ENCODING_X11_UNICODE 64} SDL_ToolkitThaiEncodingX11; 65 66typedef enum SDL_ToolkitThaiFontX11 67{ 68 SDL_TOOLKIT_THAI_FONT_X11_OFFSET, 69 SDL_TOOLKIT_THAI_FONT_X11_CELL 70} SDL_ToolkitThaiFontX11; 71 72typedef struct SDL_ToolkitWindowX11 73{ 74 /* Locale */ 75 char *origlocale; 76 77 /* Mode */ 78 SDL_ToolkitWindowModeX11 mode; 79 80 /* Display */ 81 Display *display; 82 int screen; 83 bool display_close; 84 85 /* Parent */ 86 SDL_VideoDevice *parent_device; 87 SDL_Window *parent; 88 struct SDL_ToolkitWindowX11 *tk_parent; 89 90 /* Window */ 91 Window window; 92 Drawable drawable; 93#ifndef NO_SHARED_MEMORY 94 XImage *image; 95 XShmSegmentInfo shm_info; 96 int shm_bytes_per_line; 97#endif 98 99 /* Visuals and drawing */ 100 Visual *visual; 101 XVisualInfo vi; 102 Colormap cmap; 103 GC ctx; 104 int depth; 105 bool pixmap; 106 107 /* X11 extensions */ 108#ifdef SDL_VIDEO_DRIVER_X11_XDBE 109 XdbeBackBuffer buf; 110 bool xdbe; // Whether Xdbe is present or not 111#endif 112#ifdef SDL_VIDEO_DRIVER_X11_XRANDR 113 bool xrandr; // Whether Xrandr is present or not 114#endif 115#ifndef NO_SHARED_MEMORY 116 bool shm; 117 Bool shm_pixmap; 118#endif 119 bool utf8; 120 /* Atoms */ 121 Atom wm_protocols; 122 Atom wm_delete_message; 123 124 /* Window and pixmap sizes */ 125 int window_width; // Window width. 126 int window_height; // Window height. 127 int pixmap_width; 128 int pixmap_height; 129 int window_x; 130 int window_y; 131 132 /* XSettings and scaling */ 133 XSettingsClient *xsettings; 134 bool xsettings_first_time; 135 int iscale; 136 float scale; 137 138 /* Font */ 139 XFontSet font_set; // for UTF-8 systems 140 XFontStruct *font_struct; // Latin1 (ASCII) fallback. 141 SDL_ToolkitThaiEncodingX11 thai_encoding; 142 SDL_ToolkitThaiFontX11 thai_font; 143 144 /* Control colors */ 145 const SDL_MessageBoxColor *color_hints; 146 XColor xcolor[SDL_MESSAGEBOX_COLOR_COUNT]; 147 XColor xcolor_bevel_l1; 148 XColor xcolor_bevel_l2; 149 XColor xcolor_bevel_d; 150 XColor xcolor_pressed; 151 XColor xcolor_disabled_text; 152 153 /* Control list */ 154 bool has_focus; 155 struct SDL_ToolkitControlX11 *focused_control; 156 struct SDL_ToolkitControlX11 *fiddled_control; 157 struct SDL_ToolkitControlX11 **controls; 158 size_t controls_sz; 159 struct SDL_ToolkitControlX11 **dyn_controls; 160 size_t dyn_controls_sz; 161 162 /* User callbacks */ 163 void *cb_data; 164 void (*cb_on_scale_change)(struct SDL_ToolkitWindowX11 *, void *); 165 166 /* Popup windows */ 167 SDL_ListNode *popup_windows; 168 169 /* Event loop */ 170 XEvent *e; 171 struct SDL_ToolkitControlX11 *previous_control; 172 struct SDL_ToolkitControlX11 *key_control_esc; 173 struct SDL_ToolkitControlX11 *key_control_enter; 174 KeySym last_key_pressed; 175 int ev_i; 176 float ev_scale; 177 float ev_iscale; 178 bool draw; 179 bool close; 180 long event_mask; 181 182#ifdef HAVE_FRIBIDI_H 183 /* BIDI engine */ 184 SDL_FriBidi *fribidi; 185 bool do_shaping; 186#endif 187 188#ifdef HAVE_LIBTHAI_H 189 SDL_LibThai *th; 190#endif 191 192 bool flip_interface; 193} SDL_ToolkitWindowX11; 194 195typedef enum SDL_ToolkitControlStateX11 196{ 197 SDL_TOOLKIT_CONTROL_STATE_X11_NORMAL, 198 SDL_TOOLKIT_CONTROL_STATE_X11_HOVER, 199 SDL_TOOLKIT_CONTROL_STATE_X11_PRESSED, /* Key/Button Up */ 200 SDL_TOOLKIT_CONTROL_STATE_X11_PRESSED_HELD, /* Key/Button Down */ 201 SDL_TOOLKIT_CONTROL_STATE_X11_DISABLED 202} SDL_ToolkitControlStateX11; 203 204typedef struct SDL_ToolkitControlX11 205{ 206 SDL_ToolkitWindowX11 *window; 207 SDL_ToolkitControlStateX11 state; 208 SDL_Rect rect; 209 bool selected; 210 bool dynamic; 211 bool is_default_enter; 212 bool is_default_esc; 213 bool do_size; 214 215 /* User data */ 216 void *data; 217 218 /* Virtual functions */ 219 void (*func_draw)(struct SDL_ToolkitControlX11 *); 220 void (*func_calc_size)(struct SDL_ToolkitControlX11 *); 221 void (*func_on_scale_change)(struct SDL_ToolkitControlX11 *); 222 void (*func_on_state_change)(struct SDL_ToolkitControlX11 *); 223 void (*func_free)(struct SDL_ToolkitControlX11 *); 224} SDL_ToolkitControlX11; 225 226typedef struct SDL_ToolkitMenuItemX11 227{ 228 const char *utf8; 229 bool checkbox; 230 bool checked; 231 bool disabled; 232 void *cb_data; 233 void (*cb)(struct SDL_ToolkitMenuItemX11 *, void *); 234 SDL_ListNode *sub_menu; 235 236 /* Internal use */ 237 SDL_Rect utf8_rect; 238 SDL_Rect hover_rect; 239 SDL_Rect check_rect; 240 SDL_ToolkitControlStateX11 state; 241 int arrow_x; 242 int arrow_y; 243 bool reverse_arrows; 244} SDL_ToolkitMenuItemX11; 245 246/* WINDOW FUNCTIONS */ 247extern SDL_ToolkitWindowX11 *X11Toolkit_CreateWindowStruct(SDL_Window *parent, SDL_ToolkitWindowX11 *tkparent, SDL_ToolkitWindowModeX11 mode, const SDL_MessageBoxColor *colorhints, bool create_new_display); 248extern bool X11Toolkit_CreateWindowRes(SDL_ToolkitWindowX11 *data, int w, int h, int cx, int cy, char *title); 249extern void X11Toolkit_DoWindowEventLoop(SDL_ToolkitWindowX11 *data); 250extern void X11Toolkit_ResizeWindow(SDL_ToolkitWindowX11 *data, int w, int h); 251extern void X11Toolkit_DestroyWindow(SDL_ToolkitWindowX11 *data); 252extern void X11Toolkit_SignalWindowClose(SDL_ToolkitWindowX11 *data); 253 254/* GENERIC CONTROL FUNCTIONS */ 255extern bool X11Toolkit_NotifyControlOfSizeChange(SDL_ToolkitControlX11 *control); 256 257/* ICON CONTROL FUNCTIONS */ 258extern SDL_ToolkitControlX11 *X11Toolkit_CreateIconControl(SDL_ToolkitWindowX11 *window, SDL_MessageBoxFlags flags); 259 260/* LABEL CONTROL FUNCTIONS */ 261extern SDL_ToolkitControlX11 *X11Toolkit_CreateLabelControl(SDL_ToolkitWindowX11 *window, char *utf8); 262extern int X11Toolkit_GetLabelControlFirstLineHeight(SDL_ToolkitControlX11 *control); 263 264/* BUTTON CONTROL FUNCTIONS */ 265extern SDL_ToolkitControlX11 *X11Toolkit_CreateButtonControl(SDL_ToolkitWindowX11 *window, const SDL_MessageBoxButtonData *data); 266extern void X11Toolkit_RegisterCallbackForButtonControl(SDL_ToolkitControlX11 *control, void *data, void (*cb)(struct SDL_ToolkitControlX11 *, void *)); 267extern const SDL_MessageBoxButtonData *X11Toolkit_GetButtonControlData(SDL_ToolkitControlX11 *control); 268 269#endif // SDL_VIDEO_DRIVER_X11 270 271#endif // SDL_x11toolkit_h_ 272
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.