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