~ubuntu-branches/ubuntu/intrepid/xserver-xgl/intrepid

« back to all changes in this revision

Viewing changes to hw/xnest/Cursor.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthew Garrett
  • Date: 2006-02-13 14:21:43 UTC
  • Revision ID: james.westby@ubuntu.com-20060213142143-mad6z9xzem7hzxz9
Tags: upstream-7.0.0
ImportĀ upstreamĀ versionĀ 7.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Xorg: Cursor.c,v 1.3 2000/08/17 19:53:28 cpqbld Exp $ */
 
2
/*
 
3
 
 
4
Copyright 1993 by Davor Matic
 
5
 
 
6
Permission to use, copy, modify, distribute, and sell this software
 
7
and its documentation for any purpose is hereby granted without fee,
 
8
provided that the above copyright notice appear in all copies and that
 
9
both that copyright notice and this permission notice appear in
 
10
supporting documentation.  Davor Matic makes no representations about
 
11
the suitability of this software for any purpose.  It is provided "as
 
12
is" without express or implied warranty.
 
13
 
 
14
*/
 
15
/* $XFree86: xc/programs/Xserver/hw/xnest/Cursor.c,v 1.3 2002/11/23 19:27:50 tsi Exp $ */
 
16
 
 
17
#ifdef HAVE_XNEST_CONFIG_H
 
18
#include <xnest-config.h>
 
19
#endif
 
20
 
 
21
#include <X11/X.h>
 
22
#include <X11/Xproto.h>
 
23
#include "screenint.h"
 
24
#include "input.h"
 
25
#include "misc.h"
 
26
#include "cursor.h"
 
27
#include "cursorstr.h"
 
28
#include "scrnintstr.h"
 
29
#include "servermd.h"
 
30
 
 
31
#include "Xnest.h"
 
32
 
 
33
#include "Display.h"
 
34
#include "Screen.h"
 
35
#include "XNCursor.h"
 
36
#include "Visual.h"
 
37
#include "Keyboard.h"
 
38
#include "Args.h"
 
39
 
 
40
Bool
 
41
xnestRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
 
42
{
 
43
  XImage *ximage;
 
44
  Pixmap source, mask;
 
45
  XColor fg_color, bg_color;
 
46
  unsigned long valuemask;
 
47
  XGCValues values;
 
48
 
 
49
  valuemask = GCFunction | 
 
50
              GCPlaneMask | 
 
51
              GCForeground |
 
52
              GCBackground |
 
53
              GCClipMask;
 
54
 
 
55
  values.function = GXcopy;
 
56
  values.plane_mask = AllPlanes;
 
57
  values.foreground = 1L;
 
58
  values.background = 0L;
 
59
  values.clip_mask = None;
 
60
 
 
61
  XChangeGC(xnestDisplay, xnestBitmapGC, valuemask, &values);
 
62
 
 
63
  source = XCreatePixmap(xnestDisplay, 
 
64
                         xnestDefaultWindows[pScreen->myNum],
 
65
                         pCursor->bits->width,
 
66
                         pCursor->bits->height,
 
67
                         1);
 
68
  
 
69
  mask   = XCreatePixmap(xnestDisplay, 
 
70
                         xnestDefaultWindows[pScreen->myNum],
 
71
                         pCursor->bits->width,
 
72
                         pCursor->bits->height,
 
73
                         1);
 
74
  
 
75
  ximage = XCreateImage(xnestDisplay, 
 
76
                        xnestDefaultVisual(pScreen),
 
77
                        1, XYBitmap, 0, 
 
78
                        (char *)pCursor->bits->source,
 
79
                        pCursor->bits->width,
 
80
                        pCursor->bits->height,
 
81
                        BitmapPad(xnestDisplay), 0);
 
82
  
 
83
  XPutImage(xnestDisplay, source, xnestBitmapGC, ximage,
 
84
            0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height);
 
85
  
 
86
  XFree(ximage);
 
87
  
 
88
  ximage = XCreateImage(xnestDisplay, 
 
89
                        xnestDefaultVisual(pScreen),
 
90
                        1, XYBitmap, 0, 
 
91
                        (char *)pCursor->bits->mask,
 
92
                        pCursor->bits->width,
 
93
                        pCursor->bits->height,
 
94
                        BitmapPad(xnestDisplay), 0);
 
95
  
 
96
  XPutImage(xnestDisplay, mask, xnestBitmapGC, ximage,
 
97
            0, 0, 0, 0, pCursor->bits->width, pCursor->bits->height);
 
98
  
 
99
  XFree(ximage);
 
100
  
 
101
  fg_color.red = pCursor->foreRed;
 
102
  fg_color.green = pCursor->foreGreen;
 
103
  fg_color.blue = pCursor->foreBlue;
 
104
  
 
105
  bg_color.red = pCursor->backRed;
 
106
  bg_color.green = pCursor->backGreen;
 
107
  bg_color.blue = pCursor->backBlue;
 
108
 
 
109
  pCursor->devPriv[pScreen->myNum] = (pointer)xalloc(sizeof(xnestPrivCursor));
 
110
  xnestCursorPriv(pCursor, pScreen)->cursor = 
 
111
    XCreatePixmapCursor(xnestDisplay, source, mask, &fg_color, &bg_color,
 
112
                        pCursor->bits->xhot, pCursor->bits->yhot);
 
113
  
 
114
  XFreePixmap(xnestDisplay, source);
 
115
  XFreePixmap(xnestDisplay, mask);
 
116
  
 
117
  return True;
 
118
}
 
119
 
 
120
Bool
 
121
xnestUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor)
 
122
{
 
123
  XFreeCursor(xnestDisplay, xnestCursor(pCursor, pScreen));
 
124
  xfree(xnestCursorPriv(pCursor, pScreen));
 
125
  return True;
 
126
}
 
127
 
 
128
void
 
129
xnestRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor, Bool displayed)
 
130
{
 
131
  XColor fg_color, bg_color;
 
132
  
 
133
  fg_color.red = pCursor->foreRed;
 
134
  fg_color.green = pCursor->foreGreen;
 
135
  fg_color.blue = pCursor->foreBlue;
 
136
  
 
137
  bg_color.red = pCursor->backRed;
 
138
  bg_color.green = pCursor->backGreen;
 
139
  bg_color.blue = pCursor->backBlue;
 
140
  
 
141
  XRecolorCursor(xnestDisplay, 
 
142
                 xnestCursor(pCursor, pScreen),
 
143
                 &fg_color, &bg_color);
 
144
}
 
145
 
 
146
void xnestSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
 
147
{
 
148
    if (pCursor)
 
149
    {
 
150
        XDefineCursor(xnestDisplay, 
 
151
                      xnestDefaultWindows[pScreen->myNum], 
 
152
                      xnestCursor(pCursor, pScreen));
 
153
    }
 
154
}
 
155
 
 
156
void
 
157
xnestMoveCursor (ScreenPtr pScreen, int x, int y)
 
158
{
 
159
}