graphics_xlib.h (2393B)
1 /* 2 * Copyright (c) 2022-2024 lumidify <nobody@lumidify.org> 3 * 4 * Permission to use, copy, modify, and/or distribute this software for any 5 * purpose with or without fee is hereby granted, provided that the above 6 * copyright notice and this permission notice appear in all copies. 7 * 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 */ 16 17 #ifndef LTK_GRAPHICS_XLIB_H 18 #define LTK_GRAPHICS_XLIB_H 19 20 /* FIXME: make this a setting somewhere sensible */ 21 #define USE_XLIB_GRAPHICS 1 22 23 #if USE_PANGO == 1 24 #undef USE_XFT 25 #define USE_XFT 1 26 #endif 27 28 #include <X11/X.h> 29 #include <X11/Xlib.h> 30 #include <X11/extensions/Xdbe.h> 31 32 #if USE_XFT == 1 33 #include <X11/Xft/Xft.h> 34 #endif 35 36 #include "rect.h" 37 #include "array.h" 38 #include "graphics.h" 39 40 struct ltk_moninfo { 41 int x, y; 42 int width, height; 43 int mwidth, mheight; 44 unsigned int dpi; 45 }; 46 47 LTK_ARRAY_INIT_STRUCT_DECL(moninfo, struct ltk_moninfo) 48 49 /* FIXME: figure out which of these items might make more 50 sense in ltk_renderwindow */ 51 struct ltk_renderdata { 52 Display *dpy; 53 Visual *vis; 54 ltk_array(moninfo) *monitors; 55 Colormap cm; 56 Atom wm_delete_msg; 57 Window root_window; 58 int screen; 59 int depth; 60 int xkb_event_type; 61 int xrandr_event_type; 62 /* double buffering enabled */ 63 char db_enabled; 64 char xkb_supported; 65 char xrandr_supported; 66 }; 67 68 struct ltk_renderwindow { 69 struct ltk_renderdata *renderdata; 70 unsigned int dpi; 71 GC gc; 72 Window xwindow; 73 XdbeBackBuffer back_buf; 74 Drawable drawable; 75 XIM xim; 76 XIC xic; 77 XPoint spot; 78 XVaNestedList spotlist; 79 ltk_rect rect; 80 }; 81 82 /* FIXME: only generate draw if needed */ 83 struct ltk_surface { 84 int w, h; 85 ltk_renderwindow *window; 86 Drawable d; 87 #if USE_XFT == 1 88 XftDraw *xftdraw; 89 #endif 90 char resizable; 91 }; 92 93 int ltk_recalc_renderwindow_dpi(ltk_renderwindow *window); 94 95 struct ltk_color { 96 XColor xcolor; 97 #if USE_XFT == 1 98 XftColor xftcolor; 99 #endif 100 }; 101 102 #endif /* LTK_GRAPHICS_XLIB_H */