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