summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hw/xscreen/xs-color.c123
-rw-r--r--hw/xscreen/xs-visual.c86
-rw-r--r--hw/xscreen/xs-visual.h5
3 files changed, 214 insertions, 0 deletions
diff --git a/hw/xscreen/xs-color.c b/hw/xscreen/xs-color.c
new file mode 100644
index 000000000..3d8a6b380
--- /dev/null
+++ b/hw/xscreen/xs-color.c
@@ -0,0 +1,123 @@
+#include <X11/Xmd.h>
+#include <X11/XCB/xcb.h>
+#include <X11/XCB/xproto.h>
+#include <X11/XCB/xcb_aux.h>
+#include "scrnintstr.h"
+#include "window.h"
+#include "windowstr.h"
+#include "colormapst.h"
+#include "resource.h"
+
+#include "xs-globals.h"
+#include "xs-visual.h"
+#include "xs-color.h"
+
+static ColormapPtr xsInstalledMap;
+
+/**
+ * Creates a colormap on the backing server.
+ * FIXME: Do I need to actually initialize the values in it?
+ * Xnest does, Xdmx doesn't seem to.
+ **/
+Bool xsCreateColormap(ColormapPtr pCmap)
+{
+ XCBVISUALID vid;
+ VisualPtr pVis;
+
+ pVis = pCmap->pVisual;
+ pCmap->devPriv = xalloc(sizeof(XscreenPrivColormap));
+ XS_CMAP_PRIV(pCmap)->colormap = XCBCOLORMAPNew(xsConnection);
+ vid = xsGetVisual(pVis)->visual_id;
+ XCBCreateColormap(xsConnection,
+ (pVis->class & DynamicClass) ? XCBColormapAllocAll : XCBColormapAllocNone,
+ XS_CMAP_PRIV(pCmap)->colormap,
+ xsBackingRoot.window,
+ vid);
+}
+
+/**
+ * Frees a colormap on the backing server and deallocates it's privates.
+ **/
+void xsDestroyColormap(ColormapPtr pCmap)
+{
+ XCBFreeColormap(xsConnection, XS_CMAP_PRIV(pCmap)->colormap);
+ xfree(pCmap->devPriv);
+}
+
+
+void xsSetInstalledColormapWindows(ScreenPtr pScreen)
+{
+ /*FIXME. Actually implement something here.*/
+}
+
+void xsDirectUninstallColormaps(ScreenPtr pScreen)
+{
+ int i, n;
+ XCBCOLORMAP pCmapIDs[MAXCMAPS];
+
+ /*do I want this? What does it do?
+ if (!xsDoDirectColormaps)
+ return;
+ */
+ n = (*pScreen->ListInstalledColormaps)(pScreen, (XID*)pCmapIDs);
+
+ for (i = 0; i < n; i++) {
+ ColormapPtr pCmap;
+
+ pCmap = (ColormapPtr)LookupIDByType(pCmapIDs[i].xid, RT_COLORMAP);
+ if (pCmap)
+ XCBUninstallColormap(xsConnection, XS_CMAP_PRIV(pCmap)->colormap);
+ }
+}
+void xsInstallColormap(ColormapPtr pCmap)
+{
+ int index;
+
+ if(pCmap != xsInstalledMap)
+ {
+ xsDirectUninstallColormaps(pCmap->pScreen);
+
+ /* Uninstall pInstalledMap. Notify all interested parties. */
+ if(xsInstalledMap != (ColormapPtr)None)
+ WalkTree(pCmap->pScreen, TellLostMap, (pointer)&xsInstalledMap->mid);
+
+ xsInstalledMap = pCmap;
+ WalkTree(pCmap->pScreen, TellGainedMap, (pointer)&pCmap->mid);
+
+ xsSetInstalledColormapWindows(pCmap->pScreen);
+ //xsDirectInstallColormaps(pCmap->pScreen);
+ }
+}
+
+void xsUninstallColormap(ColormapPtr pCmap)
+{
+ int index;
+
+ if(pCmap == xsInstalledMap)
+ {
+ if (pCmap->mid != pCmap->pScreen->defColormap)
+ {
+ xsInstalledMap = (ColormapPtr)LookupIDByType(pCmap->pScreen->defColormap,
+ RT_COLORMAP);
+ (*pCmap->pScreen->InstallColormap)(xsInstalledMap);
+ }
+ }
+}
+
+void xsStoreColors(ColormapPtr pCmap, int nColors, XCBCOLORITEM *pColors)
+{
+}
+
+void xsResolveColor(CARD16 *r, CARD16 *g, CARD16 *b, VisualPtr pVisual)
+{
+}
+
+int xsListInstalledColormaps(ScreenPtr pScreen, XCBCOLORMAP *pCmapIDs)
+{
+ if (xsInstalledMap) {
+ pCmapIDs->xid = xsInstalledMap->mid;
+ return 1;
+ }
+ else
+ return 0;
+}
diff --git a/hw/xscreen/xs-visual.c b/hw/xscreen/xs-visual.c
new file mode 100644
index 000000000..9152caae0
--- /dev/null
+++ b/hw/xscreen/xs-visual.c
@@ -0,0 +1,86 @@
+/* $Xorg: Visual.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
+/*
+
+ Copyright 1993 by Davor Matic
+
+ Permission to use, copy, modify, distribute, and sell this software
+ and its documentation for any purpose is hereby granted without fee,
+ provided that the above copyright notice appear in all copies and that
+ both that copyright notice and this permission notice appear in
+ supporting documentation. Davor Matic makes no representations about
+ the suitability of this software for any purpose. It is provided "as
+ is" without express or implied warranty.
+
+*/
+/* $XFree86$ */
+
+#ifdef HAVE_XNEST_CONFIG_H
+#include <xs-config.h>
+#endif
+
+#include <X11/Xmd.h>
+#include <X11/XCB/xcb.h>
+#include <X11/XCB/xproto.h>
+#include "scrnintstr.h"
+#include "dix.h"
+#include "mi.h"
+#include "mibstore.h"
+
+static int num_visuals = 0;
+static XCBVISUALTYPE *visuals;
+static CARD8 *depths;
+
+void xsInitVisuals()
+{
+ /*initialize the visuals*/
+}
+
+XCBVISUALTYPE *xsGetVisual(VisualPtr pVisual)
+{
+ int i;
+
+ for (i = 0; i < num_visuals; i++)
+ if (pVisual->class == visuals[i]._class &&
+ pVisual->bitsPerRGBValue == visuals[i].bits_per_rgb_value &&
+ pVisual->ColormapEntries == visuals[i].colormap_entries &&
+ pVisual->nplanes == depths[i] &&
+ pVisual->redMask == visuals[i].red_mask &&
+ pVisual->greenMask == visuals[i].green_mask &&
+ pVisual->blueMask == visuals[i].blue_mask)
+ return &visuals[i];
+
+ return NULL;
+}
+
+XCBVISUALTYPE *visualFromID(ScreenPtr pScreen, XCBVISUALID visual)
+{
+ int i;
+
+ for (i = 0; i < pScreen->numVisuals; i++)
+ if (pScreen->visuals[i].vid == visual.id)
+ return xsGetVisual(&pScreen->visuals[i]);
+
+ return NULL;
+}
+
+XCBVISUALTYPE *xsGetDefaultVisual(ScreenPtr pScreen)
+{
+ XCBVISUALID v;
+
+ v.id = pScreen->rootVisual;
+ return visualFromID(pScreen, v);
+}
+
+/*
+XCBCOLORMAP xsDefaultVisualColormap(XCBVISUALTYPE *visual)
+{
+ int i;
+ XCBCOLORMAP noneCmap = { 0 };
+
+ for (i = 0; i < num_visuals; i++)
+ if (&visuals[i] == visual)
+ return xsDefaultColormaps[i];
+
+ return noneCmap;
+}
+*/
diff --git a/hw/xscreen/xs-visual.h b/hw/xscreen/xs-visual.h
new file mode 100644
index 000000000..7976ec3ce
--- /dev/null
+++ b/hw/xscreen/xs-visual.h
@@ -0,0 +1,5 @@
+
+XCBVISUALTYPE *xsGetVisual(VisualPtr pVisual);
+XCBVISUALTYPE *xsGetVisualFromID(ScreenPtr pScreen, XCBVISUALID visual);
+XCBVISUALTYPE *xsGetDefaultVisual(ScreenPtr pScreen);
+XCBCOLORMAP xsDefaultVisualColormap(XCBVISUALTYPE *visual);