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