~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/lib/Xmu/DrawLogo.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Xorg: DrawLogo.c,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */
 
2
 
 
3
/*
 
4
 
 
5
Copyright 1988, 1998  The Open Group
 
6
 
 
7
Permission to use, copy, modify, distribute, and sell this software and its
 
8
documentation for any purpose is hereby granted without fee, provided that
 
9
the above copyright notice appear in all copies and that both that
 
10
copyright notice and this permission notice appear in supporting
 
11
documentation.
 
12
 
 
13
The above copyright notice and this permission notice shall be included in
 
14
all copies or substantial portions of the Software.
 
15
 
 
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
 
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
 
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
22
 
 
23
Except as contained in this notice, the name of The Open Group shall not be
 
24
used in advertising or otherwise to promote the sale, use or other dealings
 
25
in this Software without prior written authorization from The Open Group.
 
26
 
 
27
*/
 
28
/* $XFree86: xc/lib/Xmu/DrawLogo.c,v 1.8 2001/12/14 19:55:41 dawes Exp $ */
 
29
 
 
30
#include <X11/Xlib.h>  
 
31
#include <X11/Xmu/Drawing.h>
 
32
 
 
33
/*
 
34
 *  Draw the "official" X Window System Logo, designed by Danny Chong
 
35
 *
 
36
 *  Written by Ollie Jones, Apollo Computer
 
37
 *
 
38
 *  Does some fancy stuff to make the logo look acceptable even
 
39
 *  if it is tiny.  Also makes the various linear elements of
 
40
 *  the logo line up as well as possible considering rasterization.
 
41
 */
 
42
void
 
43
XmuDrawLogo(Display *dpy, Drawable drawable, GC gcFore, GC gcBack,
 
44
            int x, int y, unsigned int width, unsigned int height)
 
45
{
 
46
    unsigned int size;
 
47
    int thin, gap, d31;
 
48
    XPoint poly[4];
 
49
 
 
50
    XFillRectangle(dpy, drawable, gcBack, x, y, width, height);
 
51
 
 
52
    /* for now, do a centered even-sized square, at least for now */
 
53
    size = width;
 
54
    if (height < width)
 
55
         size = height;
 
56
    size &= ~1;
 
57
    x += (width - size) >> 1;
 
58
    y += (height - size) >> 1;
 
59
 
 
60
/*    
 
61
 * Draw what will be the thin strokes.
 
62
 *
 
63
 *           ----- 
 
64
 *          /    /
 
65
 *         /    /
 
66
 *        /    /
 
67
 *       /    /
 
68
 *      /____/
 
69
 *           d
 
70
 *
 
71
 * Point d is 9/44 (~1/5) of the way across.
 
72
 */
 
73
 
 
74
    thin = (size / 11);
 
75
    if (thin < 1) thin = 1;
 
76
    gap = (thin+3) / 4;
 
77
    d31 = thin + thin + gap;
 
78
    poly[0].x = x + size;              poly[0].y = y;
 
79
    poly[1].x = x + size-d31;          poly[1].y = y;
 
80
    poly[2].x = x + 0;                 poly[2].y = y + size;
 
81
    poly[3].x = x + d31;               poly[3].y = y + size;
 
82
    XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin);
 
83
 
 
84
/*    
 
85
 * Erase area not needed for lower thin stroke.
 
86
 *
 
87
 *           ------ 
 
88
 *          /     /
 
89
 *         /  __ /
 
90
 *        /  /  /
 
91
 *       /  /  /
 
92
 *      /__/__/
 
93
 */
 
94
 
 
95
    poly[0].x = x + d31/2;                       poly[0].y = y + size;
 
96
    poly[1].x = x + size / 2;                    poly[1].y = y + size/2;
 
97
    poly[2].x = x + (size/2)+(d31-(d31/2));      poly[2].y = y + size/2;
 
98
    poly[3].x = x + d31;                         poly[3].y = y + size;
 
99
    XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
 
100
 
 
101
/*    
 
102
 * Erase area not needed for upper thin stroke.
 
103
 *
 
104
 *           ------ 
 
105
 *          /  /  /
 
106
 *         /--/  /
 
107
 *        /     /
 
108
 *       /     /
 
109
 *      /_____/
 
110
 */
 
111
 
 
112
    poly[0].x = x + size - d31/2;                poly[0].y = y;
 
113
    poly[1].x = x + size / 2;                    poly[1].y = y + size/2;
 
114
    poly[2].x = x + (size/2)-(d31-(d31/2));      poly[2].y = y + size/2;
 
115
    poly[3].x = x + size - d31;                  poly[3].y = y;
 
116
    XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
 
117
 
 
118
/*
 
119
 * Draw thick stroke.
 
120
 * Point b is 1/4 of the way across.
 
121
 *
 
122
 *      b
 
123
 * -----
 
124
 * \    \
 
125
 *  \    \
 
126
 *   \    \
 
127
 *    \    \
 
128
 *     \____\
 
129
 */
 
130
 
 
131
    poly[0].x = x;                     poly[0].y = y;
 
132
    poly[1].x = x + size/4;            poly[1].y = y;
 
133
    poly[2].x = x + size;              poly[2].y = y + size;
 
134
    poly[3].x = x + size - size/4;     poly[3].y = y + size;
 
135
    XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin);
 
136
 
 
137
/*    
 
138
 * Erase to create gap.
 
139
 *
 
140
 *          /
 
141
 *         /
 
142
 *        /
 
143
 *       /
 
144
 *      /
 
145
 */
 
146
 
 
147
    poly[0].x = x + size- thin;        poly[0].y = y;
 
148
    poly[1].x = x + size-( thin+gap);  poly[1].y = y;
 
149
    poly[2].x = x + thin;              poly[2].y = y + size;
 
150
    poly[3].x = x + thin + gap;        poly[3].y = y + size;
 
151
    XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin);
 
152
}