xserver/hw/xnest/xcb.c

75 lines
1.7 KiB
C

/* SPDX-License-Identifier: MIT OR X11
*
* Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
*/
#include <dix-config.h>
#include <xcb/xcb.h>
#include <xcb/xcb_icccm.h>
#include <X11/X.h>
#include <X11/Xdefs.h>
#include <X11/Xproto.h>
#include "include/gc.h"
#include "Xnest.h"
#include "xnest-xcb.h"
#include "XNGC.h"
#include "Display.h"
struct xnest_upstream_info xnestUpstreamInfo = { 0 };
void xnest_upstream_setup(void) {
xnestUpstreamInfo.screenId = DefaultScreen(xnestDisplay);
/* retrieve setup data for our screen */
xnestUpstreamInfo.conn = XGetXCBConnection(xnestDisplay);
xnestUpstreamInfo.setup = xcb_get_setup(xnestUpstreamInfo.conn);
xcb_screen_iterator_t iter = xcb_setup_roots_iterator (xnestUpstreamInfo.setup);
for (int i = 0; i < xnestUpstreamInfo.screenId; ++i)
xcb_screen_next (&iter);
xnestUpstreamInfo.screenInfo = iter.data;
}
/* retrieve upstream GC XID for our xserver GC */
uint32_t xnest_upstream_gc(GCPtr pGC) {
if (pGC == NULL) return 0;
xnestPrivGC *priv = dixLookupPrivate(&(pGC)->devPrivates, xnestGCPrivateKey);
if (priv == NULL) return 0;
return priv->gc;
}
const char WM_COLORMAP_WINDOWS[] = "WM_COLORMAP_WINDOWS";
void xnest_wm_colormap_windows(
xcb_connection_t *conn,
xcb_window_t w,
xcb_window_t *windows,
int count)
{
xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(
conn,
xcb_intern_atom(
conn, 0,
sizeof(WM_COLORMAP_WINDOWS)-1,
WM_COLORMAP_WINDOWS),
NULL);
if (!reply)
return;
xcb_icccm_set_wm_colormap_windows_checked(
conn,
w,
reply->atom,
count,
(xcb_window_t*)windows);
free(reply);
}