/* SPDX-License-Identifier: MIT OR X11 * * Copyright © 2024 Enrico Weigelt, metux IT consult */ #ifndef __XNEST__XCB_H #define __XNEST__XCB_H #include #include "include/list.h" #include "include/scrnintstr.h" struct xnest_event_queue { struct xorg_list entry; xcb_generic_event_t *event; }; struct xnest_screen_info { /* the FRAME window isn't the ROOT window - it's where the ROOT window is created into: on startup the core will call xnestCreateWindow() with pWin->parent == NULL, which means we're creating the screen's ROOT window. This approach makes several things easier, eg. embedding Xnest into another application, or maybe even adding some control widgets (eg. scroll bars) */ xcb_window_t upstream_frame_window; /* the SAVER window also is child of the FRAME. It's only mapped while the screen saver is active, and then overlapping our ROOT window. */ xcb_window_t upstream_saver_window; }; struct xnest_upstream_info { xcb_connection_t *conn; int screenId; const xcb_screen_t *screenInfo; const xcb_setup_t *setup; struct xnest_event_queue eventQueue; xcb_gc_t bitmapGC; uint32_t eventMask; }; extern struct xnest_screen_info xnestScreens[MAXSCREENS]; extern struct xnest_upstream_info xnestUpstreamInfo; static inline struct xnest_screen_info *xnest_screen_by_id(int idx) { return &xnestScreens[idx]; } static inline struct xnest_screen_info *xnest_screen_priv(ScreenPtr pScreen) { return xnest_screen_by_id(pScreen->myNum); // should use devPrivates } /* connect to upstream X server */ Bool xnest_upstream_setup(const char* displayName); /* retrieve upstream GC XID for our xserver GC */ uint32_t xnest_upstream_gc(GCPtr pGC); typedef struct { xcb_visualtype_t *upstreamVisual; xcb_depth_t *upstreamDepth; xcb_colormap_t upstreamCMap; uint32_t ourXID; VisualPtr ourVisual; } xnest_visual_t; extern xnest_visual_t *xnestVisualMap; extern int xnestNumVisualMap; void xnest_wm_colormap_windows(xcb_connection_t *conn, xcb_window_t w, xcb_window_t *windows, int count); uint32_t xnest_create_bitmap_from_data(xcb_connection_t *conn, uint32_t drawable, const char *data, uint32_t width, uint32_t height); uint32_t xnest_create_pixmap_from_bitmap_data(xcb_connection_t *conn, uint32_t drawable, const char *data, uint32_t width, uint32_t height, uint32_t fg, uint32_t bg, uint16_t depth); void xnest_set_command(xcb_connection_t *conn, xcb_window_t window, char ** argv, int argc); void xnest_xkb_init(xcb_connection_t *conn); int xnest_xkb_device_id(xcb_connection_t *conn); xcb_get_keyboard_mapping_reply_t *xnest_get_keyboard_mapping(xcb_connection_t *conn, int min_keycode, int count); void xnest_get_pointer_control(xcb_connection_t *conn, int *acc_num, int *acc_den, int *threshold); xRectangle xnest_get_geometry(xcb_connection_t *conn, uint32_t window); int xnest_parse_geometry(const char *string, xRectangle *geometry); uint32_t xnest_visual_map_to_upstream(VisualID visual); uint32_t xnest_upstream_visual_to_cmap(uint32_t visual); uint32_t xnest_visual_to_upstream_cmap(uint32_t visual); typedef struct { xcb_query_font_reply_t *font_reply; xcb_font_t font_id; xcb_charinfo_t *chars; uint16_t chars_len; } xnestPrivFont; int xnest_text_width (xnestPrivFont *font, const char *string, int count); int xnest_text_width_16 (xnestPrivFont *font, const uint16_t *string, int count); xcb_atom_t xnest_intern_atom(xcb_connection_t *conn, const char* name); void xnest_upstream_set_property( struct xnest_upstream_info *upstream, xcb_window_t window, const char* property, const char* type, int state, uint32_t format, uint32_t size, void *data); void xnest_property_state_callback(CallbackListPtr *pcbl, void *closure, void *calldata); #endif /* __XNEST__XCB_H */