890c40f6f11e2f87ca273575676b6d855e2742be
[blender.git] / intern / ghost / intern / GHOST_WindowX11.cpp
1 /*
2  * $Id$
3  * ***** BEGIN GPL LICENSE BLOCK *****
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
20  * All rights reserved.
21  *
22  * The Original Code is: all of this file.
23  *
24  * Contributor(s): none yet.
25  *
26  * ***** END GPL LICENSE BLOCK *****
27  */
28
29 /** \file ghost/intern/GHOST_WindowX11.cpp
30  *  \ingroup GHOST
31  */
32
33
34 #include "GHOST_WindowX11.h"
35 #include "GHOST_SystemX11.h"
36 #include "STR_String.h"
37 #include "GHOST_Debug.h"
38
39 // For standard X11 cursors
40 #include <X11/cursorfont.h>
41 #include <X11/Xatom.h>
42
43 #if defined(__sun__) || defined( __sun ) || defined (__sparc) || defined (__sparc__) || defined (_AIX)
44 #include <strings.h>
45 #endif
46
47 #include <cstring>
48 #include <cstdio>
49
50 #include <algorithm>
51 #include <string>
52
53 // For obscure full screen mode stuuf
54 // lifted verbatim from blut.
55
56 typedef struct {
57         long flags;
58         long functions;
59         long decorations;
60         long input_mode;
61 } MotifWmHints;
62
63 #define MWM_HINTS_DECORATIONS         (1L << 1)
64
65
66 // #define GHOST_X11_GRAB
67
68 /*
69  * A Client can't change the window property, that is
70  * the work of the window manager. In case, we send
71  * a ClientMessage to the RootWindow with the property
72  * and the Action (WM-spec define this):
73  */
74 #define _NET_WM_STATE_REMOVE 0
75 #define _NET_WM_STATE_ADD 1
76 #define _NET_WM_STATE_TOGGLE 2
77
78 /*
79 import bpy
80 I = bpy.data.images['blender.png'] # the 48x48 icon
81
82 # Write to a file that can be 
83 # used within static unsigned char BLENDER_ICON_48x48x24[] = {...}
84 f = open('/myicon.txt', 'w')
85 for j in xrange(48):
86         for k in xrange(48):
87                 v = I.getPixelI(j,47-k)
88                 v.pop()
89                 for p in v:
90                         f.write(str(hex(p))+',')
91
92         f.write('\n')
93 */
94
95 // See the python script above to regenerate the 48x48 icon within blender
96 #define BLENDER_ICON_WIDTH 48
97 #define BLENDER_ICON_HEIGHT 48
98 static unsigned char BLENDER_ICON_48x48x24[] = {
99 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
100 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x4f,0x2a,0xd,0xa7,0x5b,0x1f,0xb8,0x66,0x22,0x6c,0x3b,0x14,0x5,0x3,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
101 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x6f,0x3a,0x13,0xea,0x7f,0x2c,0xee,0x7e,0x2b,0xee,0x7e,0x2b,0xef,0x85,0x2e,0x5f,0x35,0x12,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
102 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x43,0x22,0xb,0xed,0x7f,0x2c,0xed,0x7c,0x2b,0xee,0x7f,0x2c,0xee,0x80,0x2c,0xee,0x80,0x2c,0xa8,0x5f,0x20,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
103 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x2e,0x16,0x6,0xd0,0x6f,0x26,0xed,0x7b,0x2a,0xed,0x7d,0x2b,0xee,0x7f,0x2c,0xee,0x80,0x2c,0xee,0x82,0x2d,0x9a,0x57,0x1d,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
104 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x17,0xb,0x4,0xb9,0x60,0x21,0xed,0x7a,0x2a,0xed,0x7b,0x2a,0xed,0x7e,0x2b,0xee,0x7f,0x2c,0xee,0x7f,0x2c,0xee,0x86,0x2e,0x4e,0x2b,0xe,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
105 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x1,0x0,0x0,0x96,0x4d,0x19,0xee,0x7a,0x2a,0xed,0x79,0x2a,0xed,0x7c,0x2b,0xed,0x7e,0x2b,0xed,0x7e,0x2b,0xef,0x83,0x2d,0x98,0x55,0x1c,0x3,0x1,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
106 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x20,0xf,0x5,0x4b,0x27,0xe,0x21,0x11,0x5,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x67,0x34,0x11,0xed,0x7b,0x2a,0xec,0x79,0x29,0xed,0x7b,0x2a,0xed,0x7c,0x2b,0xed,0x7d,0x2b,0xee,0x7f,0x2c,0xbb,0x69,0x24,0x11,0x9,0x3,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
107 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x38,0x1c,0x9,0xc9,0x6d,0x2c,0xf1,0x86,0x36,0xd7,0x79,0x2a,0x22,0x12,0x5,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x3b,0x1d,0x9,0xe0,0x74,0x27,0xed,0x7a,0x2a,0xed,0x7c,0x2a,0xed,0x7d,0x2b,0xed,0x7d,0x2b,0xed,0x7d,0x2b,0xdc,0x7a,0x2a,0x1e,0xf,0x5,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
108 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xa6,0x56,0x23,0xee,0x83,0x3b,0xed,0x7d,0x2c,0xf0,0x85,0x2e,0x75,0x43,0x17,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x25,0x12,0x5,0xc9,0x68,0x24,0xed,0x7b,0x2a,0xed,0x7d,0x2b,0xed,0x7e,0x2b,0xee,0x7e,0x2c,0xed,0x7d,0x2b,0xe3,0x7d,0x2b,0x3b,0x1f,0xa,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
109 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x1c,0xd,0x4,0xd9,0x74,0x35,0xee,0x83,0x3a,0xee,0x7f,0x2b,0xf0,0x86,0x2e,0x83,0x4d,0x1a,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xa,0x5,0x1,0xa1,0x54,0x1c,0xee,0x7e,0x2c,0xed,0x7e,0x2c,0xed,0x7f,0x2c,0xed,0x80,0x2c,0xed,0x7f,0x2b,0xec,0x81,0x2d,0x60,0x33,0x11,0x1,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
110 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x24,0x11,0x5,0xe0,0x7a,0x38,0xee,0x84,0x3a,0xee,0x82,0x2c,0xf0,0x88,0x2f,0x82,0x4d,0x1a,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x6f,0x39,0x13,0xef,0x82,0x30,0xed,0x82,0x2f,0xee,0x82,0x2e,0xee,0x82,0x2d,0xee,0x81,0x2c,0xf0,0x83,0x2d,0x88,0x49,0x18,0x3,0x2,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
111 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x24,0x11,0x5,0xe0,0x7c,0x3a,0xee,0x86,0x3b,0xee,0x84,0x2d,0xf1,0x8b,0x30,0x82,0x4d,0x1a,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0x54,0x2b,0xf,0xe9,0x80,0x30,0xee,0x87,0x33,0xef,0x88,0x32,0xef,0x88,0x30,0xee,0x85,0x2f,0xef,0x83,0x2e,0xae,0x5f,0x20,0x4,0x2,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
112 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x24,0x11,0x5,0xe0,0x7e,0x3d,0xef,0x8a,0x3d,0xef,0x88,0x2e,0xf1,0x8d,0x31,0x81,0x4d,0x1a,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0x29,0x15,0x7,0xd2,0x74,0x2d,0xf0,0x8b,0x36,0xf0,0x8d,0x35,0xef,0x8d,0x35,0xef,0x8b,0x33,0xef,0x88,0x30,0xc4,0x6d,0x26,0x18,0xc,0x4,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
113 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x24,0x11,0x5,0xe1,0x80,0x3f,0xf0,0x8d,0x3f,0xef,0x8a,0x2f,0xf1,0x8f,0x32,0x81,0x4e,0x1a,0x0,0x0,0x0,0x0,0x0,0x0,0x9,0x3,0x0,0xb1,0x61,0x26,0xf1,0x8e,0x3a,0xf1,0x90,0x3a,0xf0,0x90,0x38,0xf0,0x90,0x36,0xef,0x8e,0x35,0xd3,0x7a,0x2c,0x22,0x11,0x6,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
114 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x24,0x12,0x5,0xe1,0x83,0x42,0xf0,0x90,0x42,0xf0,0x8d,0x30,0xf2,0x92,0x33,0x80,0x4e,0x1b,0x0,0x0,0x0,0x3,0x2,0x0,0x81,0x45,0x1b,0xf1,0x90,0x3e,0xf1,0x94,0x3d,0xf1,0x95,0x3c,0xf0,0x94,0x3b,0xf0,0x92,0x39,0xf0,0x90,0x35,0xd0,0x7b,0x2b,0xc2,0x6e,0x26,0xbe,0x6c,0x25,0x94,0x54,0x1c,0x5b,0x33,0x11,0x1a,0xe,0x4,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
115 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x25,0x14,0x6,0xe2,0x86,0x44,0xf1,0x94,0x45,0xf0,0x90,0x31,0xf2,0x94,0x33,0x80,0x4e,0x1b,0x0,0x0,0x0,0x60,0x34,0x14,0xed,0x8c,0x3e,0xf0,0x96,0x42,0xf1,0x97,0x40,0xf1,0x95,0x3f,0xf0,0x91,0x39,0xef,0x8e,0x33,0xef,0x8d,0x31,0xf0,0x8d,0x31,0xef,0x8c,0x30,0xef,0x8c,0x30,0xf0,0x8d,0x31,0xf1,0x8e,0x31,0xe1,0x85,0x2e,0x92,0x55,0x1d,0x25,0x14,0x7,0x1,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
116 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x26,0x14,0x6,0xe2,0x89,0x46,0xf2,0x97,0x47,0xf1,0x92,0x32,0xf2,0x96,0x34,0x80,0x4e,0x1a,0x32,0x1a,0xa,0xe3,0x87,0x3d,0xf1,0x97,0x45,0xf1,0x98,0x44,0xf1,0x95,0x41,0xf0,0x90,0x39,0xef,0x8d,0x30,0xef,0x8f,0x31,0xf0,0x90,0x32,0xf0,0x92,0x33,0xf1,0x93,0x33,0xf1,0x94,0x34,0xf1,0x94,0x34,0xf0,0x93,0x34,0xf0,0x91,0x32,0xf1,0x91,0x33,0xe2,0x8a,0x30,0x6b,0x3f,0x15,0x1,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
117 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x26,0x14,0x6,0xe3,0x8b,0x49,0xf2,0x9a,0x49,0xf1,0x93,0x32,0xf2,0x98,0x35,0x8f,0x57,0x1d,0xcf,0x7c,0x38,0xf2,0x99,0x48,0xf1,0x98,0x47,0xf1,0x96,0x44,0xf0,0x90,0x39,0xef,0x8d,0x31,0xf0,0x90,0x31,0xf0,0x92,0x33,0xf1,0x94,0x33,0xf1,0x96,0x35,0xf1,0x98,0x35,0xf1,0x9a,0x36,0xf1,0x9c,0x37,0xf2,0x9d,0x37,0xf2,0x9c,0x37,0xf2,0x99,0x36,0xf0,0x94,0x34,0xf3,0x97,0x35,0x9f,0x60,0x21,0x13,0xb,0x3,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
118 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x26,0x14,0x6,0xe3,0x8d,0x4b,0xf2,0x9b,0x4c,0xf1,0x93,0x32,0xf1,0x97,0x35,0xea,0x98,0x43,0xf2,0x9d,0x4d,0xf1,0x9a,0x4b,0xf1,0x99,0x49,0xf0,0x93,0x3d,0xf0,0x8d,0x30,0xf0,0x90,0x32,0xf0,0x92,0x32,0xf0,0x94,0x34,0xf1,0x96,0x34,0xf1,0x98,0x36,0xf1,0x9a,0x36,0xf2,0x9c,0x38,0xf2,0x9f,0x38,0xf2,0xa2,0x39,0xf3,0xa2,0x39,0xf3,0xa2,0x39,0xf2,0x9f,0x38,0xf1,0x99,0x35,0xf2,0x97,0x35,0xba,0x74,0x29,0x13,0xb,0x4,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
119 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x26,0x14,0x6,0xe4,0x8e,0x4d,0xf2,0x9d,0x4e,0xf1,0x93,0x32,0xf2,0x9d,0x3f,0xf3,0xa4,0x54,0xf2,0x9d,0x50,0xf1,0x9b,0x4d,0xf2,0x98,0x46,0xef,0x8d,0x31,0xf0,0x8f,0x31,0xf0,0x91,0x32,0xf0,0x93,0x32,0xf1,0x94,0x32,0xf1,0x95,0x32,0xf1,0x98,0x34,0xf1,0x9b,0x36,0xf2,0x9e,0x38,0xf2,0xa1,0x39,0xf2,0xa4,0x3a,0xf3,0xa6,0x3b,0xf4,0xa8,0x3c,0xf3,0xa7,0x3c,0xf3,0xa4,0x3a,0xf2,0x9c,0x37,0xf2,0x99,0x36,0xa9,0x69,0x25,0x2,0x1,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
120 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x26,0x14,0x6,0xe4,0x90,0x50,0xf2,0x9e,0x51,0xf1,0x95,0x35,0xf4,0xa6,0x54,0xf3,0xa2,0x55,0xf2,0x9e,0x51,0xf2,0x9c,0x4e,0xf0,0x8f,0x35,0xf0,0x8e,0x31,0xf0,0x90,0x32,0xf3,0xa5,0x56,0xf7,0xc4,0x8e,0xfa,0xd8,0xb6,0xfb,0xdf,0xc2,0xfa,0xd8,0xb2,0xf7,0xc4,0x89,0xf4,0xae,0x59,0xf2,0xa1,0x38,0xf3,0xa5,0x3b,0xf4,0xa8,0x3c,0xf4,0xab,0x3d,0xf4,0xac,0x3e,0xf4,0xab,0x3d,0xf3,0xa7,0x3b,0xf2,0x9e,0x38,0xf4,0x9e,0x38,0x6f,0x45,0x17,0x1,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
121 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x19,0xc,0x5,0x63,0x36,0x18,0x3f,0x20,0x9,0x2,0x1,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x26,0x14,0x6,0xe4,0x91,0x52,0xf3,0xa2,0x55,0xf2,0x9d,0x43,0xf4,0xa7,0x5b,0xf3,0xa2,0x57,0xf3,0xa0,0x55,0xf1,0x97,0x43,0xf0,0x8d,0x30,0xf2,0x9d,0x4c,0xfa,0xda,0xbc,0xfe,0xfb,0xf7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfb,0xf6,0xfa,0xdc,0xb5,0xf4,0xae,0x4e,0xf4,0xa9,0x3c,0xf4,0xac,0x3d,0xf4,0xae,0x3f,0xf4,0xaf,0x3f,0xf4,0xad,0x3f,0xf3,0xa8,0x3d,0xf2,0x9d,0x38,0xe2,0x94,0x34,0x23,0x14,0x6,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
122 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x11,0x8,0x3,0x9e,0x62,0x39,0xf2,0x91,0x4e,0xe7,0x79,0x29,0x48,0x25,0xc,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0x27,0x13,0x6,0xe5,0x93,0x54,0xf3,0xa7,0x59,0xf4,0xa6,0x56,0xf4,0xa7,0x5d,0xf3,0xa4,0x59,0xf3,0xa2,0x57,0xf1,0x90,0x36,0xf4,0xa7,0x5d,0xfe,0xf4,0xeb,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0xf2,0xe3,0xf6,0xb8,0x5f,0xf4,0xac,0x3e,0xf4,0xaf,0x3f,0xf4,0xb1,0x40,0xf4,0xb2,0x40,0xf5,0xaf,0x3f,0xf3,0xa6,0x3c,0xf3,0x9f,0x38,0x90,0x5d,0x21,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
123 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x3d,0x1f,0xf,0xed,0x9c,0x6a,0xef,0x8b,0x4a,0xec,0x78,0x29,0xe4,0x79,0x2a,0x29,0x15,0x7,0x0,0x0,0x0,0xff,0x0,0xff,0x28,0x14,0x6,0xe6,0x97,0x57,0xf5,0xad,0x63,0xf5,0xac,0x62,0xf4,0xa8,0x5f,0xf4,0xa6,0x5c,0xf3,0xa0,0x53,0xf4,0xa9,0x64,0xfe,0xf8,0xf4,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfe,0xff,0xf2,0xf7,0xfa,0xed,0xf4,0xf8,0xfd,0xfe,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xf7,0xed,0xf5,0xb5,0x53,0xf5,0xb0,0x3f,0xf5,0xb3,0x41,0xf5,0xb4,0x42,0xf5,0xb3,0x41,0xf4,0xad,0x3f,0xf3,0xa1,0x39,0xe4,0x98,0x37,0x1d,0x11,0x5,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
124 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x43,0x23,0x10,0xf2,0xa1,0x70,0xf1,0x99,0x61,0xec,0x78,0x2a,0xed,0x7b,0x2a,0xc4,0x69,0x23,0x15,0xa,0x3,0x0,0x0,0x0,0x1d,0xf,0x5,0xe7,0x9b,0x5b,0xf5,0xb1,0x68,0xf5,0xad,0x65,0xf4,0xaa,0x62,0xf4,0xa8,0x5f,0xf3,0xa4,0x59,0xfd,0xec,0xde,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0xfd,0xfe,0xc3,0xda,0xe9,0x5c,0x9a,0xc5,0x2a,0x7b,0xb4,0x17,0x6f,0xae,0x36,0x81,0xb8,0x91,0xbb,0xd9,0xf0,0xf6,0xfa,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0xe7,0xc7,0xf5,0xb2,0x43,0xf6,0xb3,0x41,0xf5,0xb5,0x43,0xf5,0xb6,0x43,0xf5,0xb3,0x42,0xf4,0xa8,0x3c,0xf4,0xa2,0x3a,0x66,0x41,0x17,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
125 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x22,0x10,0x7,0xd6,0x88,0x5b,0xf2,0xa5,0x76,0xee,0x84,0x3f,0xed,0x7a,0x2a,0xee,0x80,0x2c,0xa5,0x59,0x1e,0x7,0x3,0x1,0x19,0xd,0x4,0xe7,0x9e,0x5e,0xf6,0xb2,0x6b,0xf5,0xae,0x67,0xf5,0xac,0x65,0xf4,0xa9,0x61,0xf8,0xcc,0xa1,0xff,0xff,0xfe,0xff,0xff,0xff,0xfd,0xfe,0xfe,0x97,0xbf,0xdb,0x33,0x83,0xbb,0x24,0x7e,0xb9,0x3,0x6a,0xae,0x0,0x66,0xab,0x0,0x64,0xa9,0x1,0x63,0xa9,0x3c,0x87,0xbd,0xee,0xf5,0xf9,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfd,0xf8,0xc7,0x76,0xf6,0xb4,0x41,0xf5,0xb7,0x43,0xf6,0xb8,0x44,0xf6,0xb6,0x43,0xf5,0xae,0x3f,0xf3,0xa2,0x3a,0xac,0x71,0x29,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
126 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x52,0x2c,0x16,0xf0,0xa1,0x71,0xf2,0xa2,0x6f,0xed,0x7e,0x32,0xed,0x7e,0x2b,0xef,0x82,0x2d,0x8a,0x49,0x18,0x1b,0xe,0x4,0xe7,0xa2,0x61,0xf6,0xb3,0x6e,0xf6,0xb0,0x6a,0xf5,0xae,0x67,0xf5,0xab,0x64,0xfe,0xf4,0xeb,0xff,0xff,0xff,0xff,0xff,0xff,0xb4,0xd1,0xe5,0x3e,0x8d,0xc3,0x37,0x8e,0xc5,0x16,0x7a,0xb9,0x0,0x6b,0xaf,0x0,0x68,0xac,0x0,0x65,0xaa,0x0,0x65,0xab,0x0,0x66,0xac,0x4d,0x93,0xc4,0xf8,0xfb,0xfd,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0xe7,0xc5,0xf6,0xb3,0x40,0xf6,0xb7,0x43,0xf6,0xb9,0x44,0xf6,0xb8,0x45,0xf5,0xb2,0x41,0xf3,0xa5,0x3b,0xe2,0x98,0x37,0x3,0x1,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
127 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x86,0x4e,0x2e,0xf3,0xa6,0x77,0xf1,0x9e,0x66,0xed,0x7e,0x2d,0xee,0x82,0x2c,0xf0,0x85,0x2d,0x7e,0x47,0x17,0xe8,0xa6,0x64,0xf6,0xb5,0x70,0xf6,0xb2,0x6d,0xf5,0xb0,0x6a,0xf7,0xbb,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xf9,0xfb,0xfd,0x5b,0x9c,0xca,0x42,0x96,0xcb,0x3c,0x93,0xc9,0x9,0x73,0xb6,0x0,0x6b,0xb0,0x0,0x69,0xad,0x0,0x66,0xab,0x0,0x66,0xab,0x0,0x67,0xad,0x4,0x6a,0xaf,0xbb,0xd7,0xe9,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xf8,0xee,0xf6,0xb9,0x4f,0xf6,0xb7,0x44,0xf6,0xba,0x45,0xf6,0xba,0x45,0xf5,0xb5,0x43,0xf4,0xa8,0x3d,0xf5,0xa7,0x3d,0x1b,0xf,0x4,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
128 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x11,0x8,0x3,0xb0,0x6d,0x45,0xf4,0xaa,0x7b,0xf1,0x9a,0x5b,0xee,0x82,0x2d,0xef,0x86,0x2e,0xee,0x91,0x36,0xf5,0xb5,0x70,0xf6,0xb7,0x73,0xf6,0xb4,0x70,0xf5,0xb1,0x6c,0xf9,0xcc,0xa1,0xff,0xff,0xff,0xff,0xff,0xff,0xd1,0xe2,0xef,0x4b,0x97,0xca,0x47,0x9a,0xce,0x3f,0x95,0xcb,0x3,0x71,0xb5,0x0,0x6c,0xb0,0x0,0x69,0xae,0x0,0x67,0xac,0x0,0x66,0xac,0x0,0x67,0xad,0x0,0x69,0xaf,0x66,0xa5,0xcf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0xfa,0xf8,0xc3,0x67,0xf6,0xb8,0x44,0xf6,0xba,0x45,0xf6,0xbb,0x46,0xf6,0xb7,0x44,0xf4,0xab,0x3e,0xf8,0xab,0x3f,0x2a,0x19,0x8,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
129 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x2b,0x15,0x9,0xd4,0x8a,0x5c,0xf4,0xac,0x7c,0xf1,0x98,0x54,0xee,0x85,0x2e,0xf1,0x93,0x38,0xf6,0xba,0x75,0xf6,0xb9,0x75,0xf6,0xb6,0x72,0xf6,0xb3,0x6f,0xfa,0xd5,0xb1,0xff,0xff,0xff,0xff,0xff,0xff,0xb0,0xcf,0xe5,0x51,0x9e,0xcf,0x4b,0x9d,0xd0,0x43,0x97,0xcc,0x3,0x71,0xb5,0x0,0x6d,0xb1,0x0,0x6a,0xae,0x0,0x67,0xac,0x0,0x67,0xad,0x0,0x68,0xae,0x0,0x6a,0xb0,0x3b,0x8c,0xc2,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xf9,0xc9,0x77,0xf6,0xb8,0x44,0xf6,0xba,0x45,0xf6,0xbc,0x46,0xf6,0xb8,0x44,0xf4,0xad,0x3f,0xf8,0xac,0x3f,0x2a,0x1a,0x8,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
130 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x47,0x26,0x12,0xee,0xa3,0x72,0xf4,0xae,0x7b,0xf1,0x97,0x4e,0xf1,0x92,0x38,0xf6,0xbb,0x78,0xf6,0xbb,0x78,0xf6,0xb7,0x75,0xf6,0xb5,0x71,0xfa,0xd6,0xb2,0xff,0xff,0xff,0xff,0xff,0xff,0xad,0xcd,0xe4,0x54,0xa0,0xd1,0x4e,0xa0,0xd1,0x48,0x9b,0xce,0xb,0x76,0xb8,0x0,0x6d,0xb2,0x0,0x6a,0xaf,0x0,0x68,0xad,0x0,0x68,0xad,0x0,0x69,0xae,0x0,0x6b,0xb1,0x36,0x89,0xc1,0xfe,0xfe,0xff,0xff,0xff,0xff,0xff,0xfe,0xfe,0xf9,0xc9,0x76,0xf6,0xb9,0x44,0xf6,0xbb,0x46,0xf6,0xbc,0x47,0xf6,0xb9,0x44,0xf4,0xad,0x3f,0xf8,0xad,0x40,0x2a,0x1a,0x8,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
131 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x70,0x42,0x26,0xf4,0xad,0x7b,0xf5,0xb1,0x7d,0xf3,0x9f,0x50,0xf7,0xbc,0x7b,0xf7,0xbc,0x7b,0xf6,0xb9,0x78,0xf6,0xb7,0x74,0xf9,0xd0,0xa6,0xff,0xff,0xff,0xff,0xff,0xff,0xc3,0xda,0xeb,0x56,0xa0,0xd0,0x51,0xa1,0xd2,0x4a,0x9c,0xcf,0x20,0x82,0xbf,0x0,0x6e,0xb2,0x0,0x6b,0xb0,0x0,0x68,0xae,0x0,0x68,0xae,0x0,0x69,0xaf,0x0,0x6b,0xb1,0x50,0x98,0xc9,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0xf9,0xf8,0xc3,0x66,0xf6,0xb9,0x45,0xf7,0xbb,0x46,0xf6,0xbc,0x47,0xf6,0xb8,0x45,0xf4,0xad,0x3f,0xf8,0xac,0x3f,0x2a,0x19,0x7,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
132 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xc,0x5,0x0,0xa5,0x67,0x40,0xf5,0xb1,0x7f,0xf5,0xb7,0x7e,0xf7,0xbf,0x80,0xf7,0xbe,0x7d,0xf7,0xbb,0x7b,0xf6,0xb9,0x78,0xf8,0xc2,0x8b,0xff,0xff,0xff,0xff,0xff,0xff,0xee,0xf5,0xf9,0x5b,0xa0,0xce,0x53,0xa2,0xd2,0x4c,0x9e,0xd0,0x3c,0x93,0xc8,0x6,0x71,0xb4,0x0,0x6c,0xb0,0x0,0x69,0xae,0x0,0x69,0xae,0x0,0x6a,0xaf,0x0,0x6b,0xb1,0x9b,0xc5,0xe0,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xf7,0xec,0xf6,0xba,0x4e,0xf6,0xb9,0x45,0xf7,0xbb,0x46,0xf6,0xbc,0x47,0xf5,0xb7,0x44,0xf4,0xab,0x3e,0xf5,0xa8,0x3e,0x18,0xd,0x4,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
133 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x1f,0x10,0x7,0xc9,0x84,0x56,0xf5,0xb5,0x81,0xf7,0xbf,0x82,0xf8,0xc0,0x80,0xf7,0xbd,0x7d,0xf7,0xba,0x7a,0xf6,0xb8,0x77,0xfe,0xf5,0xec,0xff,0xff,0xff,0xff,0xff,0xff,0x9a,0xc2,0xdf,0x55,0x9f,0xd0,0x4e,0x9f,0xd0,0x47,0x99,0xcc,0x2a,0x87,0xc1,0x3,0x6d,0xb1,0x0,0x69,0xaf,0x0,0x6a,0xaf,0x0,0x6a,0xb0,0x27,0x80,0xbc,0xec,0xf4,0xf9,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0xe5,0xbf,0xf6,0xb6,0x42,0xf6,0xba,0x46,0xf7,0xbb,0x46,0xf7,0xbb,0x47,0xf5,0xb5,0x43,0xf3,0xa8,0x3d,0xdd,0x97,0x37,0x2,0x1,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
134 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x32,0x1a,0xb,0xe4,0x9d,0x6a,0xf7,0xbd,0x84,0xf8,0xc1,0x83,0xf8,0xbe,0x80,0xf7,0xbd,0x7d,0xf7,0xba,0x79,0xfa,0xd9,0xb6,0xff,0xff,0xff,0xff,0xff,0xff,0xf0,0xf6,0xfa,0x74,0xac,0xd4,0x4f,0x9b,0xcd,0x48,0x99,0xcc,0x41,0x94,0xc8,0x2c,0x85,0xbe,0xb,0x70,0xb3,0x1,0x6a,0xb0,0xb,0x6e,0xb2,0xbf,0xd9,0xeb,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfd,0xf8,0xc8,0x74,0xf6,0xb7,0x44,0xf6,0xba,0x46,0xf7,0xbb,0x46,0xf7,0xb9,0x46,0xf6,0xb2,0x42,0xf4,0xa7,0x3d,0xa6,0x70,0x29,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
135 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x4f,0x2e,0x18,0xef,0xaf,0x78,0xf8,0xc1,0x85,0xf8,0xc0,0x82,0xf7,0xbe,0x7f,0xf7,0xbc,0x7d,0xf7,0xbe,0x81,0xfe,0xf3,0xe8,0xff,0xff,0xff,0xff,0xff,0xff,0xf2,0xf7,0xfa,0x91,0xbd,0xdb,0x4f,0x97,0xc8,0x40,0x8e,0xc3,0x37,0x8a,0xc0,0x34,0x88,0xbf,0x57,0x9c,0xca,0xcc,0xe1,0xef,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0xe4,0xbf,0xf5,0xb6,0x45,0xf6,0xb8,0x45,0xf6,0xba,0x46,0xf7,0xba,0x46,0xf6,0xb7,0x45,0xf5,0xad,0x3f,0xf4,0xa9,0x40,0x5c,0x3d,0x18,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
136 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x85,0x55,0x31,0xf7,0xbd,0x84,0xf8,0xc2,0x85,0xf8,0xc0,0x82,0xf7,0xbe,0x80,0xf7,0xbc,0x7d,0xf9,0xcb,0x99,0xfe,0xf9,0xf4,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0xfe,0xfe,0xe5,0xef,0xf6,0xc1,0xda,0xeb,0xba,0xd5,0xe9,0xd8,0xe8,0xf2,0xf9,0xfb,0xfd,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xf3,0xe4,0xf6,0xb9,0x51,0xf5,0xb5,0x43,0xf6,0xb8,0x45,0xf6,0xb9,0x46,0xf6,0xb8,0x46,0xf6,0xb3,0x43,0xf4,0xa7,0x3e,0xdf,0x9d,0x43,0x17,0xd,0x4,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
137 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x14,0xa,0x4,0xb2,0x7b,0x4b,0xf8,0xc2,0x88,0xf8,0xc1,0x85,0xf7,0xbf,0x82,0xf7,0xbe,0x80,0xf7,0xbd,0x7d,0xf9,0xca,0x97,0xfe,0xf9,0xf4,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfd,0xf2,0xe1,0xf7,0xbc,0x5d,0xf5,0xb3,0x42,0xf5,0xb6,0x44,0xf5,0xb7,0x45,0xf6,0xb8,0x45,0xf6,0xb5,0x44,0xf5,0xad,0x40,0xf6,0xae,0x4c,0x88,0x5d,0x27,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
138 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x1d,0x10,0x6,0xdb,0xa0,0x68,0xf8,0xc3,0x88,0xf7,0xc1,0x85,0xf7,0xc0,0x82,0xf7,0xbf,0x80,0xf7,0xbe,0x7e,0xf8,0xc4,0x88,0xfc,0xe6,0xcc,0xfe,0xfb,0xf7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfe,0xfa,0xf3,0xfa,0xda,0xa9,0xf5,0xb3,0x4a,0xf5,0xb2,0x42,0xf5,0xb3,0x43,0xf5,0xb6,0x44,0xf5,0xb7,0x45,0xf5,0xb5,0x44,0xf5,0xb0,0x42,0xf5,0xad,0x4d,0xdd,0x9e,0x4a,0x19,0xf,0x5,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
139 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x50,0x33,0x19,0xec,0xb4,0x7a,0xf8,0xc2,0x87,0xf7,0xc1,0x85,0xf7,0xc1,0x83,0xf7,0xc0,0x80,0xf7,0xc0,0x7f,0xf7,0xc0,0x7c,0xf7,0xc2,0x7e,0xf8,0xcc,0x92,0xfa,0xda,0xb0,0xfb,0xdf,0xb9,0xfa,0xd9,0xad,0xf7,0xc8,0x84,0xf5,0xb4,0x54,0xf4,0xad,0x3f,0xf4,0xaf,0x41,0xf5,0xb2,0x42,0xf5,0xb4,0x43,0xf5,0xb5,0x44,0xf5,0xb4,0x44,0xf5,0xb2,0x46,0xf5,0xb2,0x54,0xf5,0xb4,0x5a,0x5e,0x3e,0x1a,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
140 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x71,0x4b,0x29,0xf8,0xc0,0x86,0xf7,0xc3,0x87,0xf7,0xc2,0x85,0xf7,0xc1,0x83,0xf7,0xc2,0x82,0xf7,0xc2,0x7f,0xf7,0xc2,0x7e,0xf6,0xc0,0x76,0xf4,0xb4,0x59,0xf3,0xa8,0x3e,0xf3,0xa7,0x39,0xf3,0xa9,0x3d,0xf4,0xab,0x3e,0xf4,0xad,0x40,0xf4,0xb0,0x41,0xf4,0xb2,0x42,0xf5,0xb2,0x42,0xf5,0xb3,0x45,0xf6,0xb7,0x54,0xf6,0xb7,0x60,0xf6,0xb5,0x5f,0x9d,0x6b,0x31,0x2,0x1,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
141 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x8b,0x5f,0x36,0xf9,0xc1,0x87,0xf7,0xc3,0x88,0xf8,0xc3,0x86,0xf7,0xc3,0x84,0xf8,0xc3,0x81,0xf7,0xc4,0x80,0xf7,0xc4,0x7e,0xf7,0xc4,0x7d,0xf7,0xc3,0x7a,0xf6,0xbd,0x6c,0xf5,0xb7,0x5c,0xf5,0xb5,0x54,0xf5,0xb4,0x50,0xf5,0xb6,0x52,0xf6,0xb9,0x58,0xf6,0xbd,0x62,0xf7,0xbf,0x6a,0xf6,0xba,0x66,0xf6,0xb6,0x63,0xab,0x78,0x39,0xa,0x6,0x2,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
142 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x83,0x58,0x32,0xf0,0xb9,0x7f,0xf7,0xc3,0x88,0xf7,0xc3,0x86,0xf8,0xc4,0x84,0xf7,0xc5,0x82,0xf7,0xc5,0x80,0xf7,0xc5,0x7f,0xf8,0xc5,0x7d,0xf7,0xc4,0x7b,0xf7,0xc4,0x79,0xf7,0xc4,0x78,0xf7,0xc3,0x76,0xf7,0xc3,0x74,0xf7,0xc2,0x71,0xf6,0xbe,0x6d,0xf6,0xba,0x6a,0xf4,0xb6,0x65,0x8a,0x5e,0x2c,0xc,0x7,0x3,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
143 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x4f,0x33,0x1a,0xd2,0x99,0x60,0xf8,0xc4,0x89,0xf8,0xc3,0x86,0xf8,0xc4,0x84,0xf7,0xc5,0x82,0xf7,0xc5,0x80,0xf7,0xc5,0x7f,0xf7,0xc4,0x7e,0xf7,0xc4,0x7b,0xf7,0xc3,0x79,0xf7,0xc2,0x77,0xf6,0xc0,0x74,0xf6,0xbd,0x71,0xf6,0xbb,0x6e,0xe1,0xa4,0x59,0x5c,0x3d,0x1b,0x1,0x1,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
144 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xe,0x6,0x0,0x72,0x4b,0x28,0xd0,0x9a,0x62,0xf7,0xbf,0x80,0xf8,0xc4,0x85,0xf7,0xc3,0x82,0xf7,0xc3,0x80,0xf7,0xc3,0x7e,0xf7,0xc1,0x7c,0xf6,0xc0,0x7a,0xf7,0xbf,0x78,0xf8,0xbc,0x72,0xde,0xa2,0x5d,0x80,0x57,0x2b,0x13,0xb,0x4,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
145 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x19,0xe,0x5,0x44,0x2c,0x15,0x81,0x59,0x32,0xb2,0x80,0x4c,0xcb,0x95,0x5b,0xd2,0x9c,0x5f,0xcd,0x97,0x5a,0xb9,0x86,0x4d,0x8b,0x61,0x34,0x4a,0x30,0x17,0x15,0xc,0x5,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
146 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0x0,0x0,0x0,0x1,0x0,0x0,0x3,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,
147 };
148
149
150 GLXContext GHOST_WindowX11::s_firstContext = NULL;
151
152 GHOST_WindowX11::
153 GHOST_WindowX11(
154         GHOST_SystemX11 *system,
155         Display * display,
156         const STR_String& title, 
157         GHOST_TInt32 left,
158         GHOST_TInt32 top,
159         GHOST_TUns32 width,     
160         GHOST_TUns32 height,
161         GHOST_TWindowState state,
162         const GHOST_TEmbedderWindowID parentWindow,
163         GHOST_TDrawingContextType type,
164         const bool stereoVisual,
165         const GHOST_TUns16 numOfAASamples
166 ) :
167         GHOST_Window(title,left,top,width,height,state,type,stereoVisual,numOfAASamples),
168         m_context(NULL),
169         m_display(display),
170         m_normal_state(GHOST_kWindowStateNormal),
171         m_system (system),
172         m_valid_setup (false),
173         m_invalid_window(false),
174         m_empty_cursor(None),
175         m_custom_cursor(None)
176 {
177         
178         // Set up the minimum atrributes that we require and see if
179         // X can find us a visual matching those requirements.
180
181         int attributes[40], i, samples;
182         Atom atoms[2];
183         int natom;
184         int glxVersionMajor, glxVersionMinor; // As in GLX major.minor
185         
186         /* initialize incase X11 fails to load */
187         memset(&m_xtablet, 0, sizeof(m_xtablet));
188         m_visual= NULL;
189
190         if (!glXQueryVersion(m_display, &glxVersionMajor, &glxVersionMinor)) {
191                 printf("%s:%d: X11 glXQueryVersion() failed, verify working openGL system!\n", __FILE__, __LINE__);
192                 
193                 /* exit if this is the first window */
194                 if(s_firstContext==NULL) {
195                         printf("initial window could not find the GLX extension, exit!\n");
196                         exit(1);
197                 }
198
199                 return;
200         }
201
202         /* Find the display with highest samples, starting at level requested */
203         for (samples = m_numOfAASamples; samples >= 0; samples--) {
204                 i = 0; /* Reusing attributes array, so reset counter */
205
206                 if(m_stereoVisual)
207                         attributes[i++] = GLX_STEREO;
208
209                 attributes[i++] = GLX_RGBA;
210                 attributes[i++] = GLX_DOUBLEBUFFER;
211                 attributes[i++] = GLX_RED_SIZE;   attributes[i++] = 1;
212                 attributes[i++] = GLX_BLUE_SIZE;  attributes[i++] = 1;
213                 attributes[i++] = GLX_GREEN_SIZE; attributes[i++] = 1;
214                 attributes[i++] = GLX_DEPTH_SIZE; attributes[i++] = 1;
215                 /* GLX >= 1.4 required for multi-sample */
216                 if(samples && (glxVersionMajor >= 1) && (glxVersionMinor >= 4)) {
217                         attributes[i++] = GLX_SAMPLE_BUFFERS; attributes[i++] = 1;
218                         attributes[i++] = GLX_SAMPLES; attributes[i++] = samples;
219                 }
220                 attributes[i] = None;
221
222                 m_visual = glXChooseVisual(m_display, DefaultScreen(m_display), attributes);
223
224                 /* Any sample level or even zero, which means oversampling disabled, is good
225                    but we need a valid visual to continue */
226                 if (m_visual == NULL) {
227                         if (samples == 0) {
228                                 /* All options exhausted, cannot continue */
229                                 printf("%s:%d: X11 glXChooseVisual() failed, verify working openGL system!\n", __FILE__, __LINE__);
230                                 
231                                 if(s_firstContext==NULL) {
232                                         printf("initial window could not find the GLX extension, exit!\n");
233                                         exit(1);
234                                 }
235                                 
236                                 return;
237                         }
238                 } else {
239                         if (m_numOfAASamples && (m_numOfAASamples > samples)) {
240                                 printf("%s:%d: oversampling requested %i but using %i samples\n", __FILE__, __LINE__, m_numOfAASamples, samples);
241                         }
242                         break;
243                 }
244         }
245
246         // Create a bunch of attributes needed to create an X window.
247
248
249         // First create a colormap for the window and visual. 
250         // This seems pretty much a legacy feature as we are in rgba mode anyway.
251
252         XSetWindowAttributes xattributes;
253         memset(&xattributes, 0, sizeof(xattributes));
254
255         xattributes.colormap= XCreateColormap(
256                 m_display, 
257                 RootWindow(m_display, m_visual->screen),
258                 m_visual->visual,
259                 AllocNone
260         );
261
262         xattributes.border_pixel= 0;
263
264         // Specify which events we are interested in hearing.   
265
266         xattributes.event_mask= 
267                 ExposureMask | StructureNotifyMask | 
268                 KeyPressMask | KeyReleaseMask |
269                 EnterWindowMask | LeaveWindowMask |
270                 ButtonPressMask | ButtonReleaseMask |
271                 PointerMotionMask | FocusChangeMask | PropertyChangeMask;
272
273         // create the window!
274
275         ;
276         if (parentWindow == 0) {
277                 m_window = 
278                         XCreateWindow(
279                                 m_display, 
280                                 RootWindow(m_display, m_visual->screen), 
281                                 left,
282                                 top,
283                                 width,
284                                 height,
285                                 0, // no border.
286                                 m_visual->depth,
287                                 InputOutput, 
288                                 m_visual->visual,
289                                 CWBorderPixel|CWColormap|CWEventMask, 
290                                 &xattributes
291                         );
292         } else {
293
294                 Window root_return;
295                 int x_return,y_return;
296                 unsigned int w_return,h_return,border_w_return,depth_return;
297                 
298                 XGetGeometry(m_display, parentWindow, &root_return, &x_return, &y_return,
299                         &w_return, &h_return, &border_w_return, &depth_return );
300
301                 left = 0;
302                 top = 0;
303                 width = w_return;
304                 height = h_return;
305
306
307                 m_window = XCreateWindow(
308                                 m_display, 
309                                 parentWindow,  // reparent against embedder 
310                                 left,
311                                 top,
312                                 width,
313                                 height,
314                                 0, // no border.
315                                 m_visual->depth,
316                                 InputOutput, 
317                                 m_visual->visual,
318                                 CWBorderPixel|CWColormap|CWEventMask, 
319                                 &xattributes
320                         );
321
322                 XSelectInput(m_display , parentWindow, SubstructureNotifyMask);
323                 
324         }       
325         
326         /*
327          * One of the problem with WM-spec is that can't set a property
328          * to a window that isn't mapped. That is why we can't "just
329          * call setState" here.
330          *
331          * To fix this, we first need know that the window is really
332          * map waiting for the MapNotify event.
333          *
334          * So, m_post_init indicate that we need wait for the MapNotify
335          * event and then set the Window state to the m_post_state.
336          */
337         if ((state != GHOST_kWindowStateNormal) && (state != GHOST_kWindowStateMinimized)) {
338                 m_post_init = True;
339                 m_post_state = state;
340         }
341         else {
342                 m_post_init = False;
343                 m_post_state = GHOST_kWindowStateNormal;
344         }
345         
346         // Create some hints for the window manager on how
347         // we want this window treated.
348
349         XSizeHints * xsizehints = XAllocSizeHints();
350         xsizehints->flags = PPosition | PSize | PMinSize | PMaxSize;
351         xsizehints->x = left;
352         xsizehints->y = top;
353         xsizehints->width = width;
354         xsizehints->height = height;
355         xsizehints->min_width= 320;     // size hints, could be made apart of the ghost api
356         xsizehints->min_height= 240;    // limits are also arbitrary, but should not allow 1x1 window
357         xsizehints->max_width= 65535;
358         xsizehints->max_height= 65535;
359         XSetWMNormalHints(m_display, m_window, xsizehints);
360         XFree(xsizehints);
361
362         XClassHint * xclasshint = XAllocClassHint();
363         int len = title.Length() +1 ;
364         char *wmclass = (char *)malloc(sizeof(char) * len);
365         strncpy(wmclass, (const char*)title, sizeof(char) * len);
366         xclasshint->res_name = wmclass;
367         xclasshint->res_class = wmclass;
368         XSetClassHint(m_display, m_window, xclasshint);
369         free(wmclass);
370         XFree(xclasshint);
371
372         /* The basic for a good ICCCM "work" */
373         if (m_system->m_wm_protocols) {
374                 natom= 0;
375
376                 if (m_system->m_delete_window_atom) {
377                         atoms[natom]= m_system->m_delete_window_atom;
378                         natom++;
379                 }
380
381                 if (m_system->m_wm_take_focus) {
382                         atoms[natom]= m_system->m_wm_take_focus;
383                         natom++;
384                 }
385
386                 if (natom) {
387                         /* printf("Register atoms: %d\n", natom); */
388                         XSetWMProtocols(m_display, m_window, atoms, natom);
389                 }
390         }
391
392         // Set the window icon
393         XWMHints *xwmhints = XAllocWMHints();
394         XImage *x_image, *mask_image;
395         Pixmap icon_pixmap, mask_pixmap;
396         icon_pixmap = XCreatePixmap(display, m_window, BLENDER_ICON_WIDTH, BLENDER_ICON_HEIGHT, 24);
397         mask_pixmap = XCreatePixmap(display, m_window, BLENDER_ICON_WIDTH, BLENDER_ICON_HEIGHT, 1);
398         GC gc_icon = XCreateGC(display, icon_pixmap, 0, NULL);
399         GC gc_mask = XCreateGC(display, mask_pixmap, 0, NULL);
400         
401         x_image = XCreateImage( display, m_visual->visual, 24, ZPixmap, 0, NULL, BLENDER_ICON_WIDTH, BLENDER_ICON_HEIGHT, 32, 0 );
402         mask_image = XCreateImage( display, m_visual->visual, 1, ZPixmap, 0, NULL,  BLENDER_ICON_WIDTH, BLENDER_ICON_HEIGHT, 8, 0);
403         
404         x_image->data = (char *)malloc(x_image->bytes_per_line * BLENDER_ICON_HEIGHT);
405         mask_image->data = (char *)malloc( mask_image->bytes_per_line * BLENDER_ICON_HEIGHT);
406         
407         /* copy the BLENDER_ICON_48x48x24 into the XImage */
408         unsigned char *col = BLENDER_ICON_48x48x24;
409         int px, py;
410         for (px=0; px<BLENDER_ICON_WIDTH; px++) {
411                 for (py=0; py<BLENDER_ICON_HEIGHT; py++, col+=3) {
412                         /* mask out pink */
413                         if (col[0]==255 && col[1] == 0 && col[2]== 255) {
414                                 XPutPixel(mask_image, px, py, 0 );
415                         } else {
416                                 XPutPixel(x_image, px, py, (col[0]<<16)+(col[1]<<8)+col[2] );
417                                 XPutPixel(mask_image, px, py, 1 );
418                         }
419                 }
420         }
421         
422         XPutImage(display, icon_pixmap, gc_icon, x_image, 0, 0, 0, 0, BLENDER_ICON_WIDTH, BLENDER_ICON_HEIGHT);
423         XPutImage(display, mask_pixmap, gc_mask, mask_image, 0, 0, 0, 0, BLENDER_ICON_WIDTH, BLENDER_ICON_HEIGHT);
424         
425         // Now the pixmap is ok to assign to the window as a hint
426         xwmhints->icon_pixmap = icon_pixmap;
427         xwmhints->icon_mask = mask_pixmap;
428         XFreeGC (display, gc_icon);
429         XFreeGC (display, gc_mask);
430         XDestroyImage( x_image ); /* frees x_image->data too */
431         XDestroyImage( mask_image );
432         
433         xwmhints->initial_state = NormalState;
434         xwmhints->input= True;
435         xwmhints->flags= InputHint|IconPixmapHint|IconMaskHint|StateHint;
436         XSetWMHints(display, m_window, xwmhints );
437         XFree(xwmhints);
438         // done setting the icon
439
440         setTitle(title);
441
442         initXInputDevices();
443
444         // now set up the rendering context.
445         if (installDrawingContext(type) == GHOST_kSuccess) {
446                 m_valid_setup = true;
447                 GHOST_PRINT("Created window\n");
448         }
449
450         XMapWindow(m_display, m_window);
451         GHOST_PRINT("Mapped window\n");
452
453         XFlush(m_display);
454 }
455
456 /* 
457         Dummy function to get around IO Handler exiting if device invalid
458         Basically it will not crash blender now if you have a X device that 
459         is configured but not plugged in.
460
461 */
462 static int ApplicationErrorHandler(Display *display, XErrorEvent *theEvent) {
463         fprintf(stderr, "Ignoring Xlib error: error code %d request code %d\n",
464                 theEvent->error_code, theEvent->request_code) ;
465
466         /* No exit! - but keep lint happy */
467         return 0 ;
468 }
469
470 /* These C functions are copied from Wine 1.1.13's wintab.c */
471 #define BOOL int
472 #define TRUE 1
473 #define FALSE 0
474
475 static bool match_token(const char *haystack, const char *needle)
476 {
477         const char *p, *q;
478         for (p = haystack; *p; )
479         {
480                 while (*p && isspace(*p))
481                         p++;
482                 if (! *p)
483                         break;
484
485                 for (q = needle; *q && *p && tolower(*p) == tolower(*q); q++)
486                         p++;
487                 if (! *q && (isspace(*p) || !*p))
488                         return TRUE;
489
490                 while (*p && ! isspace(*p))
491                         p++;
492         }
493         return FALSE;
494 }
495
496 /*      Determining if an X device is a Tablet style device is an imperfect science.
497 **  We rely on common conventions around device names as well as the type reported
498 **  by Wacom tablets.  This code will likely need to be expanded for alternate tablet types
499 **
500 **      Wintab refers to any device that interacts with the tablet as a cursor,
501 **  (stylus, eraser, tablet mouse, airbrush, etc)
502 **  this is not to be confused with wacom x11 configuration "cursor" device.
503 **  Wacoms x11 config "cursor" refers to its device slot (which we mirror with
504 **  our gSysCursors) for puck like devices (tablet mice essentially).
505 */
506 #if 0 // unused
507 static BOOL is_tablet_cursor(const char *name, const char *type)
508 {
509         int i;
510         static const char *tablet_cursor_whitelist[] = {
511                 "wacom",
512                 "wizardpen",
513                 "acecad",
514                 "tablet",
515                 "cursor",
516                 "stylus",
517                 "eraser",
518                 "pad",
519                 NULL
520         };
521
522         for (i=0; tablet_cursor_whitelist[i] != NULL; i++) {
523                 if (name && match_token(name, tablet_cursor_whitelist[i]))
524                         return TRUE;
525                 if (type && match_token(type, tablet_cursor_whitelist[i]))
526                         return TRUE;
527         }
528         return FALSE;
529 }
530 #endif
531 static BOOL is_stylus(const char *name, const char *type)
532 {
533         int i;
534         static const char* tablet_stylus_whitelist[] = {
535                 "stylus",
536                 "wizardpen",
537                 "acecad",
538                 NULL
539         };
540
541         for (i=0; tablet_stylus_whitelist[i] != NULL; i++) {
542                 if (name && match_token(name, tablet_stylus_whitelist[i]))
543                         return TRUE;
544                 if (type && match_token(type, tablet_stylus_whitelist[i]))
545                         return TRUE;
546         }
547
548         return FALSE;
549 }
550
551 static BOOL is_eraser(const char *name, const char *type)
552 {
553         if (name && match_token(name, "eraser"))
554                 return TRUE;
555         if (type && match_token(type, "eraser"))
556                 return TRUE;
557         return FALSE;
558 }
559 #undef BOOL
560 #undef TRUE
561 #undef FALSE
562 /* end code copied from wine */
563
564 void GHOST_WindowX11::initXInputDevices()
565 {
566         static XErrorHandler old_handler = (XErrorHandler) 0 ;
567         XExtensionVersion *version = XGetExtensionVersion(m_display, INAME);
568
569         if(version && (version != (XExtensionVersion*)NoSuchExtension)) {
570                 if(version->present) {
571                         int device_count;
572                         XDeviceInfo* device_info = XListInputDevices(m_display, &device_count);
573                         m_xtablet.StylusDevice = NULL;
574                         m_xtablet.EraserDevice = NULL;
575                         m_xtablet.CommonData.Active= GHOST_kTabletModeNone;
576
577                         /* Install our error handler to override Xlib's termination behavior */
578                         old_handler = XSetErrorHandler(ApplicationErrorHandler) ;
579
580                         for(int i=0; i<device_count; ++i) {
581                                 char *device_type = device_info[i].type ? XGetAtomName(m_display, device_info[i].type) : NULL;
582                                 
583 //                              printf("Tablet type:'%s', name:'%s', index:%d\n", device_type, device_info[i].name, i);
584
585
586                                 if(m_xtablet.StylusDevice==NULL && is_stylus(device_info[i].name, device_type)) {
587 //                                      printf("\tfound stylus\n");
588                                         m_xtablet.StylusID= device_info[i].id;
589                                         m_xtablet.StylusDevice = XOpenDevice(m_display, m_xtablet.StylusID);
590
591                                         if (m_xtablet.StylusDevice != NULL) {
592                                                 /* Find how many pressure levels tablet has */
593                                                 XAnyClassPtr ici = device_info[i].inputclassinfo;
594                                                 for(int j=0; j<m_xtablet.StylusDevice->num_classes; ++j) {
595                                                         if(ici->c_class==ValuatorClass) {
596 //                                                              printf("\t\tfound ValuatorClass\n");
597                                                                 XValuatorInfo* xvi = (XValuatorInfo*)ici;
598                                                                 m_xtablet.PressureLevels = xvi->axes[2].max_value;
599                                                         
600                                                                 /* this is assuming that the tablet has the same tilt resolution in both
601                                                                  * positive and negative directions. It would be rather weird if it didn't.. */
602                                                                 m_xtablet.XtiltLevels = xvi->axes[3].max_value;
603                                                                 m_xtablet.YtiltLevels = xvi->axes[4].max_value;
604                                                                 break;
605                                                         }
606                                                 
607                                                         ici = (XAnyClassPtr)(((char *)ici) + ici->length);
608                                                 }
609                                         } else {
610                                                 m_xtablet.StylusID= 0;
611                                         }
612                                 }
613                                 else if(m_xtablet.EraserDevice==NULL && is_eraser(device_info[i].name, device_type)) {
614 //                                      printf("\tfound eraser\n");
615                                         m_xtablet.EraserID= device_info[i].id;
616                                         m_xtablet.EraserDevice = XOpenDevice(m_display, m_xtablet.EraserID);
617                                         if (m_xtablet.EraserDevice == NULL) m_xtablet.EraserID= 0;
618                                 }
619
620                                 if(device_type) {
621                                         XFree((void*)device_type);
622                                 }
623                         }
624
625                         /* Restore handler */
626                         (void) XSetErrorHandler(old_handler) ;
627
628                         XFreeDeviceList(device_info);
629
630
631                         XEventClass xevents[10], ev;
632                         int dcount = 0;
633
634                         if(m_xtablet.StylusDevice) {
635                                 DeviceMotionNotify(m_xtablet.StylusDevice, m_xtablet.MotionEvent, ev);
636                                 if(ev) xevents[dcount++] = ev;
637                                 ProximityIn(m_xtablet.StylusDevice, m_xtablet.ProxInEvent, ev);
638                                 if(ev) xevents[dcount++] = ev;
639                                 ProximityOut(m_xtablet.StylusDevice, m_xtablet.ProxOutEvent, ev);
640                                 if(ev) xevents[dcount++] = ev;
641                         }
642                         if(m_xtablet.EraserDevice) {
643                                 DeviceMotionNotify(m_xtablet.EraserDevice, m_xtablet.MotionEvent, ev);
644                                 if(ev) xevents[dcount++] = ev;
645                                 ProximityIn(m_xtablet.EraserDevice, m_xtablet.ProxInEvent, ev);
646                                 if(ev) xevents[dcount++] = ev;
647                                 ProximityOut(m_xtablet.EraserDevice, m_xtablet.ProxOutEvent, ev);
648                                 if(ev) xevents[dcount++] = ev;
649                         }
650
651                         XSelectExtensionEvent(m_display, m_window, xevents, dcount);
652                 }
653                 XFree(version);
654         }
655 }       
656
657
658         Window 
659 GHOST_WindowX11::
660 getXWindow(
661 ){
662         return m_window;
663 }
664
665         bool 
666 GHOST_WindowX11::
667 getValid(
668 ) const {
669         return m_valid_setup;
670 }
671
672         void 
673 GHOST_WindowX11::
674 setTitle(
675         const STR_String& title
676 ){
677         Atom name = XInternAtom(m_display, "_NET_WM_NAME", 0);
678         Atom utf8str = XInternAtom(m_display, "UTF8_STRING", 0);
679         XChangeProperty(m_display, m_window,
680                         name, utf8str, 8, PropModeReplace,
681                         (const unsigned char*) title.ReadPtr(),
682                         title.Length());
683
684 // This should convert to valid x11 string
685 //  and getTitle would need matching change
686         XStoreName(m_display,m_window,title);
687
688         XFlush(m_display);
689 }
690
691         void 
692 GHOST_WindowX11::
693 getTitle(
694         STR_String& title
695 ) const {
696         char *name = NULL;
697         
698         XFetchName(m_display,m_window,&name);
699         title= name?name:"untitled";
700         XFree(name);
701 }
702         
703         void 
704 GHOST_WindowX11::
705 getWindowBounds(
706         GHOST_Rect& bounds
707 ) const {
708                 // Getting the window bounds under X11 is not
709                 // really supported (nor should it be desired).
710         getClientBounds(bounds);
711 }
712
713         void 
714 GHOST_WindowX11::
715 getClientBounds(
716         GHOST_Rect& bounds
717 ) const {
718         Window root_return;
719         int x_return,y_return;
720         unsigned int w_return,h_return,border_w_return,depth_return;
721         GHOST_TInt32 screen_x, screen_y;
722         
723         XGetGeometry(m_display,m_window,&root_return,&x_return,&y_return,
724                 &w_return,&h_return,&border_w_return,&depth_return);
725
726         clientToScreen(0, 0, screen_x, screen_y);
727         
728         bounds.m_l = screen_x;
729         bounds.m_r = bounds.m_l + w_return;
730         bounds.m_t = screen_y;
731         bounds.m_b = bounds.m_t + h_return;
732
733 }
734
735         GHOST_TSuccess 
736 GHOST_WindowX11::
737 setClientWidth(
738         GHOST_TUns32 width
739 ){      
740         XWindowChanges values;
741         unsigned int value_mask= CWWidth;               
742         values.width = width;
743         XConfigureWindow(m_display,m_window,value_mask,&values);
744
745         return GHOST_kSuccess;
746 }
747
748         GHOST_TSuccess 
749 GHOST_WindowX11::
750 setClientHeight(
751         GHOST_TUns32 height
752 ){
753         XWindowChanges values;
754         unsigned int value_mask= CWHeight;              
755         values.height = height;
756         XConfigureWindow(m_display,m_window,value_mask,&values);
757         return GHOST_kSuccess;
758
759 }
760
761         GHOST_TSuccess 
762 GHOST_WindowX11::
763 setClientSize(
764         GHOST_TUns32 width,
765         GHOST_TUns32 height
766 ){
767         XWindowChanges values;
768         unsigned int value_mask= CWWidth | CWHeight;            
769         values.width = width;
770         values.height = height;
771         XConfigureWindow(m_display,m_window,value_mask,&values);
772         return GHOST_kSuccess;
773
774 }       
775
776         void 
777 GHOST_WindowX11::
778 screenToClient(
779         GHOST_TInt32 inX,
780         GHOST_TInt32 inY,
781         GHOST_TInt32& outX,
782         GHOST_TInt32& outY
783 ) const {
784         // This is correct!
785
786         int ax,ay;
787         Window temp;
788
789         XTranslateCoordinates(
790                         m_display,
791                         RootWindow(m_display, m_visual->screen),
792                         m_window,
793                         inX,
794                         inY,
795                         &ax,
796                         &ay,
797                         &temp
798                 );
799         outX = ax;
800         outY = ay;
801 }
802                  
803         void 
804 GHOST_WindowX11::
805 clientToScreen(
806         GHOST_TInt32 inX,
807         GHOST_TInt32 inY,
808         GHOST_TInt32& outX,
809         GHOST_TInt32& outY
810 ) const {
811         int ax,ay;
812         Window temp;
813
814         XTranslateCoordinates(
815                         m_display,
816                         m_window,
817                         RootWindow(m_display, m_visual->screen),
818                         inX,
819                         inY,
820                         &ax,
821                         &ay,
822                         &temp
823                 );
824         outX = ax;
825         outY = ay;
826 }
827
828 void GHOST_WindowX11::icccmSetState(int state)
829 {
830         XEvent xev;
831
832         if (state != IconicState)
833                 return;
834
835         xev.xclient.type = ClientMessage;
836         xev.xclient.serial = 0;
837         xev.xclient.send_event = True;
838         xev.xclient.display = m_display;
839         xev.xclient.window = m_window;
840         xev.xclient.format = 32;
841         xev.xclient.message_type = m_system->m_wm_change_state;
842         xev.xclient.data.l[0] = state;
843         XSendEvent (m_display, RootWindow(m_display, DefaultScreen(m_display)),
844                 False, SubstructureNotifyMask | SubstructureRedirectMask, &xev);
845 }
846
847 int GHOST_WindowX11::icccmGetState(void) const
848 {
849         unsigned char *prop_ret;
850         unsigned long bytes_after, num_ret;
851         Atom type_ret;
852         int format_ret, st;
853
854         prop_ret = NULL;
855         st = XGetWindowProperty(m_display, m_window, m_system->m_wm_state, 0,
856                         0x7fffffff, False, m_system->m_wm_state, &type_ret,
857                         &format_ret, &num_ret, &bytes_after, &prop_ret);
858
859         if ((st == Success) && (prop_ret) && (num_ret == 2))
860                 st = prop_ret[0];
861         else
862                 st = NormalState;
863
864         if (prop_ret)
865                 XFree(prop_ret);
866         return (st);
867 }
868
869 void GHOST_WindowX11::netwmMaximized(bool set)
870 {
871         XEvent xev;
872
873         xev.xclient.type = ClientMessage;
874         xev.xclient.serial = 0;
875         xev.xclient.send_event = True;
876         xev.xclient.window = m_window;
877         xev.xclient.message_type = m_system->m_net_state;
878         xev.xclient.format = 32;
879
880         if (set == True)
881                 xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
882         else
883                 xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
884
885         xev.xclient.data.l[1] = m_system->m_net_max_horz;
886         xev.xclient.data.l[2] = m_system->m_net_max_vert;
887         xev.xclient.data.l[3] = 0;
888         xev.xclient.data.l[4] = 0;
889         XSendEvent(m_display, RootWindow(m_display, DefaultScreen(m_display)),
890                 False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
891 }
892
893 bool GHOST_WindowX11::netwmIsMaximized(void) const
894 {
895         unsigned char *prop_ret;
896         unsigned long bytes_after, num_ret, i;
897         Atom type_ret;
898         bool st;
899         int format_ret, ret, count;
900
901         prop_ret = NULL;
902         st = False;
903         ret = XGetWindowProperty(m_display, m_window, m_system->m_net_state, 0,
904                         0x7fffffff, False, XA_ATOM, &type_ret, &format_ret,
905                         &num_ret, &bytes_after, &prop_ret);
906         if ((ret == Success) && (prop_ret) && (format_ret == 32)) {
907                 count = 0;
908                 for (i = 0; i < num_ret; i++) {
909                         if (((unsigned long *) prop_ret)[i] == m_system->m_net_max_horz)
910                                 count++;
911                         if (((unsigned long *) prop_ret)[i] == m_system->m_net_max_vert)
912                                 count++;
913                         if (count == 2) {
914                                 st = True;
915                                 break;
916                         }
917                 }
918         }
919
920         if (prop_ret)
921                 XFree(prop_ret);
922         return (st);
923 }
924
925 void GHOST_WindowX11::netwmFullScreen(bool set)
926 {
927         XEvent xev;
928
929         xev.xclient.type = ClientMessage;
930         xev.xclient.serial = 0;
931         xev.xclient.send_event = True;
932         xev.xclient.window = m_window;
933         xev.xclient.message_type = m_system->m_net_state;
934         xev.xclient.format = 32;
935
936         if (set == True)
937                 xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
938         else
939                 xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
940
941         xev.xclient.data.l[1] = m_system->m_net_fullscreen;
942         xev.xclient.data.l[2] = 0;
943         xev.xclient.data.l[3] = 0;
944         xev.xclient.data.l[4] = 0;
945         XSendEvent(m_display, RootWindow(m_display, DefaultScreen(m_display)),
946                 False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
947 }
948
949 bool GHOST_WindowX11::netwmIsFullScreen(void) const
950 {
951         unsigned char *prop_ret;
952         unsigned long bytes_after, num_ret, i;
953         Atom type_ret;
954         bool st;
955         int format_ret, ret;
956
957         prop_ret = NULL;
958         st = False;
959         ret = XGetWindowProperty(m_display, m_window, m_system->m_net_state, 0,
960                         0x7fffffff, False, XA_ATOM, &type_ret, &format_ret,
961                         &num_ret, &bytes_after, &prop_ret);
962         if ((ret == Success) && (prop_ret) && (format_ret == 32)) {
963                 for (i = 0; i < num_ret; i++) {
964                         if (((unsigned long *) prop_ret)[i] == m_system->m_net_fullscreen) {
965                                 st = True;
966                                 break;
967                         }
968                 }
969         }
970
971         if (prop_ret)
972                 XFree(prop_ret);
973         return (st);
974 }
975
976 void GHOST_WindowX11::motifFullScreen(bool set)
977 {
978         MotifWmHints hints;
979
980         hints.flags = MWM_HINTS_DECORATIONS;
981         if (set == True)
982                 hints.decorations = 0;
983         else
984                 hints.decorations = 1;
985
986         XChangeProperty(m_display, m_window, m_system->m_motif,
987                         m_system->m_motif, 32, PropModeReplace,
988                         (unsigned char *) &hints, 4);
989 }
990
991 bool GHOST_WindowX11::motifIsFullScreen(void) const
992 {
993         unsigned char *prop_ret;
994         unsigned long bytes_after, num_ret;
995         MotifWmHints *hints;
996         Atom type_ret;
997         bool state;
998         int format_ret, st;
999
1000         prop_ret = NULL;
1001         state = False;
1002         st = XGetWindowProperty(m_display, m_window, m_system->m_motif, 0,
1003                                 0x7fffffff, False, m_system->m_motif,
1004                                 &type_ret, &format_ret, &num_ret,
1005                                 &bytes_after, &prop_ret);
1006         if ((st == Success) && (prop_ret)) {
1007                 hints = (MotifWmHints *) prop_ret;
1008                 if (hints->flags & MWM_HINTS_DECORATIONS) {
1009                         if (!hints->decorations)
1010                                 state = True;
1011                 }
1012         }
1013
1014         if (prop_ret)
1015                 XFree(prop_ret);
1016         return (state);
1017 }
1018
1019 GHOST_TWindowState GHOST_WindowX11::getState() const
1020 {
1021         GHOST_TWindowState state_ret;
1022         int state;
1023
1024         state_ret = GHOST_kWindowStateNormal;
1025         state = icccmGetState();
1026         /*
1027          * In the Iconic and Withdrawn state, the window
1028          * is unmaped, so only need return a Minimized state.
1029          */
1030         if ((state == IconicState) || (state == WithdrawnState))
1031                 state_ret = GHOST_kWindowStateMinimized;
1032         else if (netwmIsMaximized() == True)
1033                 state_ret = GHOST_kWindowStateMaximized;
1034         else if (netwmIsFullScreen() == True)
1035                 state_ret = GHOST_kWindowStateFullScreen;
1036         else if (motifIsFullScreen() == True)
1037                 state_ret = GHOST_kWindowStateFullScreen;
1038         return (state_ret);
1039 }
1040
1041 GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
1042 {
1043         GHOST_TWindowState cur_state;
1044         bool is_max, is_full, is_motif_full;
1045
1046         cur_state = getState();
1047         if (state == (int)cur_state)
1048                 return GHOST_kSuccess;
1049
1050         if (cur_state != GHOST_kWindowStateMinimized) {
1051                 /*
1052                  * The window don't have this property's
1053                  * if it's not mapped.
1054                  */
1055                 is_max = netwmIsMaximized();
1056                 is_full = netwmIsFullScreen();
1057         }
1058         else {
1059                 is_max = False;
1060                 is_full = False;
1061         }
1062
1063         is_motif_full = motifIsFullScreen();
1064
1065         if (state == GHOST_kWindowStateNormal)
1066                 state = m_normal_state;
1067
1068         if (state == GHOST_kWindowStateNormal) {
1069                 if (is_max == True)
1070                         netwmMaximized(False);
1071                 if (is_full == True)
1072                         netwmFullScreen(False);
1073                 if (is_motif_full == True)
1074                         motifFullScreen(False);
1075                 icccmSetState(NormalState);
1076                 return (GHOST_kSuccess);
1077         }
1078
1079         if (state == GHOST_kWindowStateFullScreen) {
1080                 /*
1081                  * We can't change to full screen if the window
1082                  * isn't mapped.
1083                  */
1084                 if (cur_state == GHOST_kWindowStateMinimized)
1085                         return (GHOST_kFailure);
1086
1087                 m_normal_state = cur_state;
1088
1089                 if (is_max == True)
1090                         netwmMaximized(False);
1091                 if (is_full == False)
1092                         netwmFullScreen(True);
1093                 if (is_motif_full == False)
1094                         motifFullScreen(True);
1095                 return (GHOST_kSuccess);
1096         }
1097
1098         if (state == GHOST_kWindowStateMaximized) {
1099                 /*
1100                  * We can't change to Maximized if the window
1101                  * isn't mapped.
1102                  */
1103                 if (cur_state == GHOST_kWindowStateMinimized)
1104                         return (GHOST_kFailure);
1105
1106                 if (is_full == True)
1107                         netwmFullScreen(False);
1108                 if (is_motif_full == True)
1109                         motifFullScreen(False);
1110                 if (is_max == False)
1111                         netwmMaximized(True);
1112                 return (GHOST_kSuccess);
1113         }
1114
1115         if (state == GHOST_kWindowStateMinimized) {
1116                 /*
1117                  * The window manager need save the current state of
1118                  * the window (maximized, full screen, etc).
1119                  */
1120                 icccmSetState(IconicState);
1121                 return (GHOST_kSuccess);
1122         }
1123
1124         return (GHOST_kFailure);
1125 }
1126
1127 #include <iostream>
1128 using namespace std;
1129
1130         GHOST_TSuccess 
1131 GHOST_WindowX11::
1132 setOrder(
1133         GHOST_TWindowOrder order
1134 ){
1135         if (order == GHOST_kWindowOrderTop) {
1136                 XWindowAttributes attr;   
1137                 Atom atom;
1138
1139                 /* We use both XRaiseWindow and _NET_ACTIVE_WINDOW, since some
1140                    window managers ignore the former (e.g. kwin from kde) and others
1141                    don't implement the latter (e.g. fluxbox pre 0.9.9) */
1142
1143                 XRaiseWindow(m_display, m_window);
1144
1145                 atom = XInternAtom(m_display, "_NET_ACTIVE_WINDOW", True);
1146
1147                 if (atom != None) {
1148                         Window root;
1149                         XEvent xev;
1150                         long eventmask;
1151
1152                         xev.xclient.type = ClientMessage;
1153                         xev.xclient.serial = 0;
1154                         xev.xclient.send_event = True;
1155                         xev.xclient.window = m_window;
1156                         xev.xclient.message_type = atom;
1157
1158                         xev.xclient.format = 32;
1159                         xev.xclient.data.l[0] = 1;
1160                         xev.xclient.data.l[1] = CurrentTime;
1161                         xev.xclient.data.l[2] = m_window;
1162                         xev.xclient.data.l[3] = 0;
1163                         xev.xclient.data.l[4] = 0;
1164
1165                         root = RootWindow(m_display, m_visual->screen),
1166                         eventmask = SubstructureRedirectMask | SubstructureNotifyMask;
1167
1168                         XSendEvent(m_display, root, False, eventmask, &xev);
1169                 }
1170
1171                 XGetWindowAttributes(m_display, m_window, &attr);
1172
1173                 /* iconized windows give bad match error */
1174                 if (attr.map_state == IsViewable)
1175                         XSetInputFocus(m_display, m_window, RevertToPointerRoot,
1176                                                  CurrentTime);
1177                 XFlush(m_display);
1178         } else if (order == GHOST_kWindowOrderBottom) {
1179                 XLowerWindow(m_display,m_window);
1180                 XFlush(m_display);
1181         } else {
1182                 return GHOST_kFailure;
1183         }
1184         
1185         return GHOST_kSuccess;
1186 }
1187
1188         GHOST_TSuccess 
1189 GHOST_WindowX11::
1190 swapBuffers(
1191 ){
1192         if (getDrawingContextType() == GHOST_kDrawingContextTypeOpenGL) {
1193                 glXSwapBuffers(m_display,m_window);
1194                 return GHOST_kSuccess;
1195         } else {
1196                 return GHOST_kFailure;
1197         }
1198 }
1199
1200         GHOST_TSuccess 
1201 GHOST_WindowX11::
1202 activateDrawingContext(
1203 ){
1204         if (m_context !=NULL) {
1205                 glXMakeCurrent(m_display, m_window,m_context);                                          
1206                 return GHOST_kSuccess;
1207         } 
1208         return GHOST_kFailure;
1209 }
1210
1211         GHOST_TSuccess 
1212 GHOST_WindowX11::
1213 invalidate(
1214 ){
1215         
1216         // So the idea of this function is to generate an expose event
1217         // for the window.
1218         // Unfortunately X does not handle expose events for you and 
1219         // it is the client's job to refresh the dirty part of the window.
1220         // We need to queue up invalidate calls and generate GHOST events 
1221         // for them in the system.
1222
1223         // We implement this by setting a boolean in this class to concatenate 
1224         // all such calls into a single event for this window.
1225
1226         // At the same time we queue the dirty windows in the system class
1227         // and generate events for them at the next processEvents call.
1228
1229         if (m_invalid_window == false) {
1230                 m_system->addDirtyWindow(this);
1231                 m_invalid_window = true;
1232         } 
1233  
1234         return GHOST_kSuccess;
1235 }
1236
1237 /**
1238  * called by the X11 system implementation when expose events
1239  * for the window have been pushed onto the GHOST queue
1240  */
1241  
1242         void
1243 GHOST_WindowX11::
1244 validate(
1245 ){
1246         m_invalid_window = false;
1247 }       
1248  
1249  
1250 /**
1251  * Destructor.
1252  * Closes the window and disposes resources allocated.
1253  */
1254
1255 GHOST_WindowX11::
1256 ~GHOST_WindowX11(
1257 ){
1258         static Atom Primary_atom, Clipboard_atom;
1259         Window p_owner, c_owner;
1260         /*Change the owner of the Atoms to None if we are the owner*/
1261         Primary_atom = XInternAtom(m_display, "PRIMARY", False);
1262         Clipboard_atom = XInternAtom(m_display, "CLIPBOARD", False);
1263         
1264         p_owner = XGetSelectionOwner(m_display, Primary_atom);
1265         c_owner = XGetSelectionOwner(m_display, Clipboard_atom);
1266         
1267         std::map<unsigned int, Cursor>::iterator it = m_standard_cursors.begin();
1268         for (; it != m_standard_cursors.end(); it++) {
1269                 XFreeCursor(m_display, it->second);
1270         }
1271
1272         if (m_empty_cursor) {
1273                 XFreeCursor(m_display, m_empty_cursor);
1274         }
1275         if (m_custom_cursor) {
1276                 XFreeCursor(m_display, m_custom_cursor);
1277         }
1278         
1279         /* close tablet devices */
1280         if(m_xtablet.StylusDevice)
1281                 XCloseDevice(m_display, m_xtablet.StylusDevice);
1282         
1283         if(m_xtablet.EraserDevice)
1284                 XCloseDevice(m_display, m_xtablet.EraserDevice);
1285         
1286         if (m_context != s_firstContext) {
1287                 glXDestroyContext(m_display, m_context);
1288         }
1289         
1290         if (p_owner == m_window) {
1291                 XSetSelectionOwner(m_display, Primary_atom, None, CurrentTime);
1292         }
1293         if (c_owner == m_window) {
1294                 XSetSelectionOwner(m_display, Clipboard_atom, None, CurrentTime);
1295         }
1296         
1297         XDestroyWindow(m_display, m_window);
1298         XFree(m_visual);
1299 }
1300
1301
1302
1303
1304 /**
1305  * Tries to install a rendering context in this window.
1306  * @param type  The type of rendering context installed.
1307  * @return Indication as to whether installation has succeeded.
1308  */
1309         GHOST_TSuccess 
1310 GHOST_WindowX11::
1311 installDrawingContext(
1312         GHOST_TDrawingContextType type
1313 ){
1314         // only support openGL for now.
1315         GHOST_TSuccess success;
1316         switch (type) {
1317         case GHOST_kDrawingContextTypeOpenGL:
1318                 m_context = glXCreateContext(m_display, m_visual, s_firstContext, True);
1319                 if (m_context !=NULL) {
1320                         if (!s_firstContext) {
1321                                 s_firstContext = m_context;
1322                         }
1323                         glXMakeCurrent(m_display, m_window,m_context);                                          
1324                         success = GHOST_kSuccess;
1325                 } else {
1326                         success = GHOST_kFailure;
1327                 }
1328
1329                 break;
1330
1331         case GHOST_kDrawingContextTypeNone:
1332                 success = GHOST_kSuccess;
1333                 break;
1334
1335         default:
1336                 success = GHOST_kFailure;
1337         }
1338         return success;
1339 }
1340
1341
1342
1343 /**
1344  * Removes the current drawing context.
1345  * @return Indication as to whether removal has succeeded.
1346  */
1347         GHOST_TSuccess 
1348 GHOST_WindowX11::
1349 removeDrawingContext(
1350 ){
1351         GHOST_TSuccess success;
1352
1353         if (m_context != NULL) {
1354                 glXDestroyContext(m_display, m_context);
1355                 success = GHOST_kSuccess;
1356         } else {
1357                 success = GHOST_kFailure;
1358         }
1359         return success; 
1360 }
1361
1362
1363         Cursor
1364 GHOST_WindowX11::
1365 getStandardCursor(
1366         GHOST_TStandardCursor g_cursor
1367 ){
1368         unsigned int xcursor_id;
1369
1370 #define GtoX(gcurs, xcurs)      case gcurs: xcursor_id = xcurs
1371         switch (g_cursor) {
1372         GtoX(GHOST_kStandardCursorRightArrow, XC_arrow); break;
1373         GtoX(GHOST_kStandardCursorLeftArrow, XC_top_left_arrow); break;
1374         GtoX(GHOST_kStandardCursorInfo, XC_hand1); break;
1375         GtoX(GHOST_kStandardCursorDestroy, XC_pirate); break;
1376         GtoX(GHOST_kStandardCursorHelp, XC_question_arrow); break; 
1377         GtoX(GHOST_kStandardCursorCycle, XC_exchange); break;
1378         GtoX(GHOST_kStandardCursorSpray, XC_spraycan); break;
1379         GtoX(GHOST_kStandardCursorWait, XC_watch); break;
1380         GtoX(GHOST_kStandardCursorText, XC_xterm); break;
1381         GtoX(GHOST_kStandardCursorCrosshair, XC_crosshair); break;
1382         GtoX(GHOST_kStandardCursorUpDown, XC_sb_v_double_arrow); break;
1383         GtoX(GHOST_kStandardCursorLeftRight, XC_sb_h_double_arrow); break;
1384         GtoX(GHOST_kStandardCursorTopSide, XC_top_side); break;
1385         GtoX(GHOST_kStandardCursorBottomSide, XC_bottom_side); break;
1386         GtoX(GHOST_kStandardCursorLeftSide, XC_left_side); break;
1387         GtoX(GHOST_kStandardCursorRightSide, XC_right_side); break;
1388         GtoX(GHOST_kStandardCursorTopLeftCorner, XC_top_left_corner); break;
1389         GtoX(GHOST_kStandardCursorTopRightCorner, XC_top_right_corner); break;
1390         GtoX(GHOST_kStandardCursorBottomRightCorner, XC_bottom_right_corner); break;
1391         GtoX(GHOST_kStandardCursorBottomLeftCorner, XC_bottom_left_corner); break;
1392         GtoX(GHOST_kStandardCursorPencil, XC_pencil); break;
1393         GtoX(GHOST_kStandardCursorCopy, XC_arrow); break;
1394         default:
1395                 xcursor_id = 0;
1396         }
1397 #undef GtoX
1398
1399         if (xcursor_id) {
1400                 Cursor xcursor = m_standard_cursors[xcursor_id];
1401                 
1402                 if (!xcursor) {
1403                         xcursor = XCreateFontCursor(m_display, xcursor_id);
1404
1405                         m_standard_cursors[xcursor_id] = xcursor;
1406                 }
1407                 
1408                 return xcursor;
1409         } else {
1410                 return None;
1411         }
1412 }
1413
1414         Cursor 
1415 GHOST_WindowX11::
1416 getEmptyCursor(
1417 ) {
1418         if (!m_empty_cursor) {
1419                 Pixmap blank;
1420                 XColor dummy;
1421                 char data[1] = {0};
1422                         
1423                 /* make a blank cursor */
1424                 blank = XCreateBitmapFromData (
1425                         m_display, 
1426                         RootWindow(m_display,DefaultScreen(m_display)),
1427                         data, 1, 1
1428                 );
1429
1430                 m_empty_cursor = XCreatePixmapCursor(m_display, blank, blank, &dummy, &dummy, 0, 0);
1431                 XFreePixmap(m_display, blank);
1432         }
1433
1434         return m_empty_cursor;
1435 }
1436
1437         GHOST_TSuccess
1438 GHOST_WindowX11::
1439 setWindowCursorVisibility(
1440         bool visible
1441 ){
1442         Cursor xcursor;
1443         
1444         if (visible) {
1445                 xcursor = getStandardCursor( getCursorShape() );
1446         } else {
1447                 xcursor = getEmptyCursor();
1448         }
1449
1450         XDefineCursor(m_display, m_window, xcursor);
1451         XFlush(m_display);
1452         
1453         return GHOST_kSuccess;
1454 }
1455
1456         GHOST_TSuccess
1457 GHOST_WindowX11::
1458 setWindowCursorGrab(
1459         GHOST_TGrabCursorMode mode
1460 ){
1461         if(mode != GHOST_kGrabDisable) {
1462                 if(mode != GHOST_kGrabNormal) {
1463                         m_system->getCursorPosition(m_cursorGrabInitPos[0], m_cursorGrabInitPos[1]);
1464                         setCursorGrabAccum(0, 0);
1465
1466                         if(mode == GHOST_kGrabHide)
1467                                 setWindowCursorVisibility(false);
1468
1469                 }
1470 #ifdef GHOST_X11_GRAB
1471                 XGrabPointer(m_display, m_window, False, ButtonPressMask| ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
1472 #endif
1473         }
1474         else {
1475                 if (m_cursorGrab==GHOST_kGrabHide) {
1476                         m_system->setCursorPosition(m_cursorGrabInitPos[0], m_cursorGrabInitPos[1]);
1477                         setWindowCursorVisibility(true);
1478                 }
1479
1480                 if(m_cursorGrab != GHOST_kGrabNormal) {
1481                         /* use to generate a mouse move event, otherwise the last event
1482                          * blender gets can be outside the screen causing menus not to show
1483                          * properly unless the user moves the mouse */
1484                         XWarpPointer(m_display,None,None,0,0,0,0,0,0);
1485                 }
1486
1487                 /* Almost works without but important otherwise the mouse GHOST location can be incorrect on exit */
1488                 setCursorGrabAccum(0, 0);
1489                 m_cursorGrabBounds.m_l= m_cursorGrabBounds.m_r= -1; /* disable */
1490 #ifdef GHOST_X11_GRAB
1491                 XUngrabPointer(m_display, CurrentTime);
1492 #endif
1493         }
1494
1495         XFlush(m_display);
1496         
1497         return GHOST_kSuccess;
1498 }
1499
1500         GHOST_TSuccess
1501 GHOST_WindowX11::
1502 setWindowCursorShape(
1503         GHOST_TStandardCursor shape
1504 ){
1505         Cursor xcursor = getStandardCursor( shape );
1506         
1507         XDefineCursor(m_display, m_window, xcursor);
1508         XFlush(m_display);
1509
1510         return GHOST_kSuccess;
1511 }
1512
1513         GHOST_TSuccess
1514 GHOST_WindowX11::
1515 setWindowCustomCursorShape(
1516         GHOST_TUns8 bitmap[16][2], 
1517         GHOST_TUns8 mask[16][2], 
1518         int hotX, 
1519         int hotY
1520 ){
1521
1522 setWindowCustomCursorShape((GHOST_TUns8*)bitmap, (GHOST_TUns8*)mask, 
1523                                                                         16, 16, hotX, hotY, 0, 1);
1524         return GHOST_kSuccess;
1525 }
1526
1527         GHOST_TSuccess
1528 GHOST_WindowX11::
1529 setWindowCustomCursorShape(     
1530         GHOST_TUns8 *bitmap, 
1531         GHOST_TUns8 *mask, 
1532         int sizex, 
1533         int sizey, 
1534         int hotX, 
1535         int hotY, 
1536         int fg_color, 
1537         int bg_color
1538 ){
1539         Colormap colormap= DefaultColormap(m_display, DefaultScreen(m_display));
1540         Pixmap bitmap_pix, mask_pix;
1541         XColor fg, bg;
1542         
1543         if(XAllocNamedColor(m_display, colormap, "White", &fg, &fg) == 0) return GHOST_kFailure;
1544         if(XAllocNamedColor(m_display, colormap, "Black", &bg, &bg) == 0) return GHOST_kFailure;
1545
1546         if (m_custom_cursor) {
1547                 XFreeCursor(m_display, m_custom_cursor);
1548         }
1549
1550         bitmap_pix = XCreateBitmapFromData(m_display, m_window, (char*) bitmap, sizex, sizey);
1551         mask_pix = XCreateBitmapFromData(m_display, m_window, (char*) mask, sizex, sizey);
1552                 
1553         m_custom_cursor = XCreatePixmapCursor(m_display, bitmap_pix, mask_pix, &fg, &bg, hotX, hotY);
1554         XDefineCursor(m_display, m_window, m_custom_cursor);
1555         XFlush(m_display);
1556         
1557         XFreePixmap(m_display, bitmap_pix);
1558         XFreePixmap(m_display, mask_pix);
1559
1560     XFreeColors(m_display, colormap, &fg.pixel, 1, 0L);
1561     XFreeColors(m_display, colormap, &bg.pixel, 1, 0L);
1562
1563         return GHOST_kSuccess;
1564 }
1565
1566 /*
1567
1568 void glutCustomCursor(char *data1, char *data2, int size)
1569 {
1570         Pixmap source, mask;
1571         Cursor cursor;
1572         XColor fg, bg;
1573         
1574         if(XAllocNamedColor(__glutDisplay, DefaultColormap(__glutDisplay, __glutScreen),
1575                 "White", &fg, &fg) == 0) return;
1576         if(XAllocNamedColor(__glutDisplay, DefaultColormap(__glutDisplay, __glutScreen),
1577                 "Red", &bg, &bg) == 0) return;
1578
1579
1580         source= XCreateBitmapFromData(__glutDisplay, xdraw, data2, size, size);
1581         mask= XCreateBitmapFromData(__glutDisplay, xdraw, data1, size, size);
1582                 
1583         cursor= XCreatePixmapCursor(__glutDisplay, source, mask, &fg, &bg, 7, 7);
1584                 
1585         XFreePixmap(__glutDisplay, source);
1586         XFreePixmap(__glutDisplay, mask);
1587                 
1588         XDefineCursor(__glutDisplay, xdraw, cursor);
1589 }
1590
1591 */