xserver/hw/xnest/Cursor.c
2006-06-29 23:45:18 -05:00

177 lines
5.4 KiB
C

/* $Xorg: Cursor.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: xc/programs/Xserver/hw/xnest/Cursor.c,v 1.3 2002/11/23 19:27:50 tsi Exp $ */
#ifdef HAVE_XNEST_CONFIG_H
#include <xnest-config.h>
#endif
#include <X11/Xmd.h>
#include <X11/XCB/xcb.h>
#include <X11/XCB/xcb_aux.h>
#include <X11/XCB/xproto.h>
#include <X11/XCB/xcb_image.h>
#include "screenint.h"
#include "input.h"
#include "misc.h"
#include "cursor.h"
#include "cursorstr.h"
#include "scrnintstr.h"
#include "servermd.h"
#include "Xnest.h"
#include "Display.h"
#include "Screen.h"
#include "XNCursor.h"
#include "Visual.h"
#include "Keyboard.h"
#include "Args.h"
Bool xnestRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
{
/*do we really want to realize the pointer here?*/
XCBPIXMAP source, mask;
int pad;
int size;
int bpp;
int i;
XCBCURSOR c;
unsigned long valuemask;
XCBParamsGC values;
valuemask = XCBGCFunction |
XCBGCPlaneMask |
XCBGCForeground |
XCBGCBackground |
XCBGCClipMask;
values.function = GXcopy;
values.plane_mask = AllPlanes;
values.foreground = 1L;
values.background = 0L;
values.mask = None;
XCBAuxChangeGC(xnestConnection, xnestBitmapGC, valuemask, &values);
source = XCBPIXMAPNew(xnestConnection);
mask = XCBPIXMAPNew(xnestConnection);
XCBCreatePixmap(xnestConnection,
xnestDefaultDepth,
source,
(XCBDRAWABLE)xnestDefaultWindows[pScreen->myNum],
pCursor->bits->width,
pCursor->bits->height);
XCBCreatePixmap(xnestConnection,
xnestDefaultDepth,
mask,
(XCBDRAWABLE)xnestDefaultWindows[pScreen->myNum],
pCursor->bits->width,
pCursor->bits->height);
for (i=0; i<xnestNumPixmapFormats; i++) {
if (xnestPixmapFormats[i].depth == 1) {
pad = xnestPixmapFormats[i].scanline_pad;
bpp = xnestPixmapFormats[i].bits_per_pixel;
break;
}
}
/*not sure if this is right*/
size = (((bpp * pCursor->bits->width + pad - 1) & -pad) >> 3) * pCursor->bits->height;
XCBPutImage(xnestConnection,
XCBImageFormatXYBitmap,
(XCBDRAWABLE)source,
xnestBitmapGC,
pCursor->bits->width,
pCursor->bits->height,
0,0, /*dst_x, dst_y*/
pad,
1, /*depth*/
size, /*length..correct??*/
pCursor->bits->source); /*bits*/
XCBPutImage(xnestConnection,
XCBImageFormatXYBitmap,
(XCBDRAWABLE)mask,
xnestBitmapGC,
pCursor->bits->width,
pCursor->bits->height,
0,0, /*dst_x, dst_y*/
pad,
1, /*depth*/
size, /*length..correct??*/
pCursor->bits->mask); /*bits*/
pCursor->devPriv[pScreen->myNum] = (pointer)xalloc(sizeof(xnestPrivCursor));
c = XCBCURSORNew(xnestConnection);
xnestCursorPriv(pCursor, pScreen)->cursor = c.xid;
XCBCreateCursor(xnestConnection,
c,
source,
mask,
pCursor->foreRed,
pCursor->foreGreen,
pCursor->foreBlue,
pCursor->backRed,
pCursor->backGreen,
pCursor->backBlue,
pCursor->bits->xhot,
pCursor->bits->yhot);
XCBFreePixmap(xnestConnection, source);
XCBFreePixmap(xnestConnection, mask);
return True;
}
Bool xnestUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
{
XCBCURSOR c;
c.xid = xnestCursor(pCursor, pScreen);
XCBFreeCursor(xnestConnection, c);
xfree(xnestCursorPriv(pCursor, pScreen));
return True;
}
void xnestRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor, Bool displayed)
{
XCBCURSOR c;
c.xid = xnestCursor(pCursor, pScreen);
XCBRecolorCursor(xnestConnection,
c,
pCursor->foreRed,
pCursor->foreGreen,
pCursor->foreBlue,
pCursor->backRed,
pCursor->backGreen,
pCursor->backBlue);
}
void xnestSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
{
XCBParamsCW params;
if (pCursor)
{
params.cursor = xnestCursor(pCursor, pScreen);
XCBAuxChangeWindowAttributes(xnestConnection,
xnestDefaultWindows[pScreen->myNum],
XCBCWCursor,
&params);
}
}
void xnestMoveCursor (ScreenPtr pScreen, int x, int y)
{
}