patch from skejoe for gcc 4.3 compatibility
[blender-staging.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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, 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 #include <cstdio>
39
40 #if defined(__sun__) || defined( __sun ) || defined (__sparc) || defined (__sparc__)
41 #include <strings.h>
42 #endif
43
44
45 // For obscure full screen mode stuuf
46 // lifted verbatim from blut.
47
48 typedef struct {
49         long flags;
50         long functions;
51         long decorations;
52         long input_mode;
53 } MotifWmHints;
54
55 #define MWM_HINTS_DECORATIONS         (1L << 1)
56
57 /*
58  * A Client can't change the window property, that is
59  * the work of the window manager. In case, we send
60  * a ClientMessage to the RootWindow with the property
61  * and the Action (WM-spec define this):
62  */
63 #define _NET_WM_STATE_REMOVE 0
64 #define _NET_WM_STATE_ADD 1
65 #define _NET_WM_STATE_TOGGLE 2
66
67 /*
68 import bpy
69 I = bpy.data.images['blender.png'] # the 48x48 icon
70
71 # Write to a file that can be 
72 # used within static unsigned char BLENDER_ICON_48x48x24[] = {...}
73 f = open('/myicon.txt', 'w')
74 for j in xrange(48):
75         for k in xrange(48):
76                 v = I.getPixelI(j,47-k)
77                 v.pop()
78                 for p in v:
79                         f.write(str(hex(p))+',')
80
81         f.write('\n')
82 */
83
84 // See the python script above to regenerate the 48x48 icon within blender
85 #define BLENDER_ICON_WIDTH 48
86 #define BLENDER_ICON_HEIGHT 48
87 static unsigned char BLENDER_ICON_48x48x24[] = {
88 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
89 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
90 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
91 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
92 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
93 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
94 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
95 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
96 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
97 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
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,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,
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,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,
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,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,
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,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,
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,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,
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,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,
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,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,
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,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,
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,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,
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,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,
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,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,
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,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,
110 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,
111 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,
112 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,
113 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,
114 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,
115 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,
116 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,
117 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,
118 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,
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,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,
120 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
121 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
122 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
123 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
124 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
125 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
126 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
127 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
128 0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
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,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,
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,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,
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,0xff,0x0,0xff,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,
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,0xff,0x0,0xff,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,
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,0xff,0x0,0xff,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,
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,0xff,0x0,0xff,0xff,0x0,0xff,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,
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,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,0xff,0x0,0xff,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,
136 };
137
138
139 GLXContext GHOST_WindowX11::s_firstContext = NULL;
140
141 GHOST_WindowX11::
142 GHOST_WindowX11(
143         GHOST_SystemX11 *system,
144         Display * display,
145         const STR_String& title, 
146         GHOST_TInt32 left,
147         GHOST_TInt32 top,
148         GHOST_TUns32 width,     
149         GHOST_TUns32 height,
150         GHOST_TWindowState state,
151         GHOST_TDrawingContextType type,
152         const bool stereoVisual
153 ) :
154         GHOST_Window(title,left,top,width,height,state,type,stereoVisual),
155         m_context(NULL),
156         m_display(display),
157         m_system (system),
158         m_valid_setup (false),
159         m_invalid_window(false),
160         m_empty_cursor(None),
161         m_custom_cursor(None)
162 {
163         
164         // Set up the minimum atrributes that we require and see if
165         // X can find us a visual matching those requirements.
166
167         int attributes[40], i = 0;
168         
169         
170         if(m_stereoVisual)
171                 attributes[i++] = GLX_STEREO;
172
173         attributes[i++] = GLX_RGBA;
174         attributes[i++] = GLX_DOUBLEBUFFER;     
175         attributes[i++] = GLX_RED_SIZE;   attributes[i++] = 1;
176         attributes[i++] = GLX_BLUE_SIZE;  attributes[i++] = 1;
177         attributes[i++] = GLX_GREEN_SIZE; attributes[i++] = 1;
178         attributes[i++] = GLX_DEPTH_SIZE; attributes[i++] = 1;
179         attributes[i] = None;
180         
181         m_visual = glXChooseVisual(m_display, DefaultScreen(m_display), attributes);
182
183         if (m_visual == NULL) {
184                 // barf : no visual meeting these requirements could be found.
185                 printf("%s:%d: X11 glxChooseVisual() failed for OpenGL, verify working openGL system!\n", __FILE__, __LINE__);
186                 return;
187         }
188
189         // Create a bunch of attributes needed to create an X window.
190
191
192         // First create a colormap for the window and visual. 
193         // This seems pretty much a legacy feature as we are in rgba mode anyway.
194
195         XSetWindowAttributes xattributes;
196         memset(&xattributes, 0, sizeof(xattributes));
197
198         xattributes.colormap= XCreateColormap(
199                 m_display, 
200                 RootWindow(m_display, m_visual->screen),
201                 m_visual->visual,
202                 AllocNone
203         );
204
205         xattributes.border_pixel= 0;
206
207         // Specify which events we are interested in hearing.   
208
209         xattributes.event_mask= 
210                 ExposureMask | StructureNotifyMask | 
211                 KeyPressMask | KeyReleaseMask |
212                 EnterWindowMask | LeaveWindowMask |
213                 ButtonPressMask | ButtonReleaseMask |
214                 PointerMotionMask | FocusChangeMask;
215
216         // create the window!
217
218         m_window = 
219                 XCreateWindow(
220                         m_display, 
221                         RootWindow(m_display, m_visual->screen), 
222                         left,
223                         top,
224                         width,
225                         height,
226                         0, // no border.
227                         m_visual->depth,
228                         InputOutput, 
229                         m_visual->visual,
230                         CWBorderPixel|CWColormap|CWEventMask, 
231                         &xattributes
232                 );
233         
234         /*
235          * One of the problem with WM-spec is that can't set a property
236          * to a window that isn't mapped. That is why we can't "just
237          * call setState" here.
238          *
239          * To fix this, we first need know that the window is really
240          * map waiting for the MapNotify event.
241          *
242          * So, m_post_init indicate that we need wait for the MapNotify
243          * event and then set the Window state to the m_post_state.
244          */
245         if ((state != GHOST_kWindowStateNormal) && (state != GHOST_kWindowStateMinimized)) {
246                 m_post_init = True;
247                 m_post_state = state;
248         }
249         else {
250                 m_post_init = False;
251                 m_post_state = GHOST_kWindowStateNormal;
252         }
253         
254         // Create some hints for the window manager on how
255         // we want this window treated. 
256
257         XSizeHints * xsizehints = XAllocSizeHints();
258         xsizehints->flags = USPosition | USSize;
259         xsizehints->x = left;
260         xsizehints->y = top;
261         xsizehints->width = width;
262         xsizehints->height = height;
263         XSetWMNormalHints(m_display, m_window, xsizehints);
264         XFree(xsizehints);
265
266         XClassHint * xclasshint = XAllocClassHint();
267         int len = title.Length() +1 ;
268         char *wmclass = (char *)malloc(sizeof(char) * len);
269         strncpy(wmclass, (const char*)title, sizeof(char) * len);
270         xclasshint->res_name = wmclass;
271         xclasshint->res_class = wmclass;
272         XSetClassHint(m_display, m_window, xclasshint);
273         free(wmclass);
274         XFree(xclasshint);
275
276
277         // Set the window icon
278         XWMHints *xwmhints = XAllocWMHints();
279         XImage *x_image, *mask_image;
280         Pixmap icon_pixmap, mask_pixmap;
281         icon_pixmap = XCreatePixmap(display, m_window, BLENDER_ICON_WIDTH, BLENDER_ICON_HEIGHT, 24);
282         mask_pixmap = XCreatePixmap(display, m_window, BLENDER_ICON_WIDTH, BLENDER_ICON_HEIGHT, 1);
283         GC gc_icon = XCreateGC(display, icon_pixmap, 0, NULL);
284         GC gc_mask = XCreateGC(display, mask_pixmap, 0, NULL);
285         
286         x_image = XCreateImage( display, m_visual->visual, 24, ZPixmap, 0, NULL, BLENDER_ICON_WIDTH, BLENDER_ICON_HEIGHT, 32, 0 );
287         mask_image = XCreateImage( display, m_visual->visual, 1, ZPixmap, 0, NULL,  BLENDER_ICON_WIDTH, BLENDER_ICON_HEIGHT, 8, 0);
288         
289         x_image->data = (char *)malloc(x_image->bytes_per_line * BLENDER_ICON_HEIGHT);
290         mask_image->data = (char *)malloc( mask_image->bytes_per_line * BLENDER_ICON_HEIGHT);
291         
292         /* copy the BLENDER_ICON_48x48x24 into the XImage */
293         unsigned char *col = BLENDER_ICON_48x48x24;
294         int px, py;
295         for (px=0; px<BLENDER_ICON_WIDTH; px++) {
296                 for (py=0; py<BLENDER_ICON_HEIGHT; py++, col+=3) {
297                         /* mask out pink */
298                         if (col[0]==255 && col[1] == 0 && col[2]== 255) {
299                                 XPutPixel(mask_image, px, py, 0 );
300                         } else {
301                                 XPutPixel(x_image, px, py, (col[0]<<16)+(col[1]<<8)+col[2] );
302                                 XPutPixel(mask_image, px, py, 1 );
303                         }
304                 }
305         }
306         
307         XPutImage(display, icon_pixmap, gc_icon, x_image, 0, 0, 0, 0, BLENDER_ICON_WIDTH, BLENDER_ICON_HEIGHT);
308         XPutImage(display, mask_pixmap, gc_mask, mask_image, 0, 0, 0, 0, BLENDER_ICON_WIDTH, BLENDER_ICON_HEIGHT);
309         
310         // Now the pixmap is ok to assign to the window as a hint
311         xwmhints->icon_pixmap = icon_pixmap;
312         xwmhints->icon_mask = mask_pixmap;
313         XFreeGC (display, gc_icon);
314         XFreeGC (display, gc_mask);
315         XDestroyImage( x_image ); /* frees x_image->data too */
316         XDestroyImage( mask_image );
317         
318         xwmhints->initial_state = NormalState;
319         xwmhints->flags         = IconPixmapHint|IconMaskHint|StateHint;
320         XSetWMHints(display, m_window, xwmhints );
321         XFree(xwmhints);
322         // done setting the icon
323         
324
325         setTitle(title);
326
327         initXInputDevices();
328
329         // now set up the rendering context.
330         if (installDrawingContext(type) == GHOST_kSuccess) {
331                 m_valid_setup = true;
332                 GHOST_PRINT("Created window\n");
333         }
334
335         XMapWindow(m_display, m_window);
336         GHOST_PRINT("Mapped window\n");
337
338         XFlush(m_display);
339 }
340
341 /* 
342         Dummy function to get around IO Handler exiting if device invalid
343         Basically it will not crash blender now if you have a X device that 
344         is configured but not plugged in.
345
346 */
347 static int ApplicationErrorHandler(Display *display, XErrorEvent *theEvent) {
348         fprintf(stderr, "Ignoring Xlib error: error code %d request code %d\n",
349                 theEvent->error_code, theEvent->request_code) ;
350
351         /* No exit! - but keep lint happy */
352         return 0 ;
353 }
354
355 void GHOST_WindowX11::initXInputDevices()
356 {
357         static XErrorHandler old_handler = (XErrorHandler) 0 ;
358         XExtensionVersion *version = XGetExtensionVersion(m_display, INAME);
359
360         if(version && (version != (XExtensionVersion*)NoSuchExtension)) {
361                 if(version->present) {
362                         int device_count;
363                         XDeviceInfo* device_info = XListInputDevices(m_display, &device_count);
364                         m_xtablet.StylusDevice = 0;
365                         m_xtablet.EraserDevice = 0;
366                         m_xtablet.CommonData.Active= 0;
367
368                         /* Install our error handler to override Xlib's termination behavior */
369                         old_handler = XSetErrorHandler(ApplicationErrorHandler) ;
370
371                         for(int i=0; i<device_count; ++i) {
372                                 if(!strcasecmp(device_info[i].name, "stylus")) {
373                                         m_xtablet.StylusID= device_info[i].id;
374                                         m_xtablet.StylusDevice = XOpenDevice(m_display, m_xtablet.StylusID);
375
376                                         if (m_xtablet.StylusDevice != NULL) {
377                                                 /* Find how many pressure levels tablet has */
378                                                 XAnyClassPtr ici = device_info[i].inputclassinfo;
379                                                 for(int j=0; j<m_xtablet.StylusDevice->num_classes; ++j) {
380                                                         if(ici->c_class==ValuatorClass) {
381                                                                 XValuatorInfo* xvi = (XValuatorInfo*)ici;
382                                                                 m_xtablet.PressureLevels = xvi->axes[2].max_value;
383                                                         
384                                                                 /* this is assuming that the tablet has the same tilt resolution in both
385                                                                  * positive and negative directions. It would be rather weird if it didn't.. */
386                                                                 m_xtablet.XtiltLevels = xvi->axes[3].max_value;
387                                                                 m_xtablet.YtiltLevels = xvi->axes[4].max_value;
388                                                                 break;
389                                                         }
390                                                 
391                                                         ici = (XAnyClassPtr)(((char *)ici) + ici->length);
392                                                 }
393                                         } else {
394                                                 m_xtablet.StylusID= 0;
395                                         }
396                                 }
397                                 if(!strcasecmp(device_info[i].name, "eraser")) {
398                                         m_xtablet.EraserID= device_info[i].id;
399                                         m_xtablet.EraserDevice = XOpenDevice(m_display, m_xtablet.EraserID);
400                                         if (m_xtablet.EraserDevice == NULL) m_xtablet.EraserID= 0;
401                                 }
402                         }
403
404                         /* Restore handler */
405                         (void) XSetErrorHandler(old_handler) ;
406
407                         XFreeDeviceList(device_info);
408
409
410                         XEventClass xevents[10], ev;
411                         int dcount = 0;
412
413                         if(m_xtablet.StylusDevice) {
414                                 DeviceMotionNotify(m_xtablet.StylusDevice, m_xtablet.MotionEvent, ev);
415                                 if(ev) xevents[dcount++] = ev;
416                                 ProximityIn(m_xtablet.StylusDevice, m_xtablet.ProxInEvent, ev);
417                                 if(ev) xevents[dcount++] = ev;
418                                 ProximityOut(m_xtablet.StylusDevice, m_xtablet.ProxOutEvent, ev);
419                                 if(ev) xevents[dcount++] = ev;
420                         }
421                         if(m_xtablet.EraserDevice) {
422                                 DeviceMotionNotify(m_xtablet.EraserDevice, m_xtablet.MotionEvent, ev);
423                                 if(ev) xevents[dcount++] = ev;
424                                 ProximityIn(m_xtablet.EraserDevice, m_xtablet.ProxInEvent, ev);
425                                 if(ev) xevents[dcount++] = ev;
426                                 ProximityOut(m_xtablet.EraserDevice, m_xtablet.ProxOutEvent, ev);
427                                 if(ev) xevents[dcount++] = ev;
428                         }
429
430                         XSelectExtensionEvent(m_display, m_window, xevents, dcount);
431                 }
432                 XFree(version);
433         }
434 }       
435
436
437         Window 
438 GHOST_WindowX11::
439 getXWindow(
440 ){
441         return m_window;
442 }       
443
444         bool 
445 GHOST_WindowX11::
446 getValid(
447 ) const {
448         return m_valid_setup;
449 }
450
451         void 
452 GHOST_WindowX11::
453 setTitle(
454         const STR_String& title
455 ){
456         XStoreName(m_display,m_window,title);
457         XFlush(m_display);
458 }
459
460         void 
461 GHOST_WindowX11::
462 getTitle(
463         STR_String& title
464 ) const {
465         char *name = NULL;
466         
467         XFetchName(m_display,m_window,&name);
468         title= name?name:"untitled";
469         XFree(name);
470 }
471         
472         void 
473 GHOST_WindowX11::
474 getWindowBounds(
475         GHOST_Rect& bounds
476 ) const {
477                 // Getting the window bounds under X11 is not
478                 // really supported (nor should it be desired).
479         getClientBounds(bounds);
480 }
481
482         void 
483 GHOST_WindowX11::
484 getClientBounds(
485         GHOST_Rect& bounds
486 ) const {
487         Window root_return;
488         int x_return,y_return;
489         unsigned int w_return,h_return,border_w_return,depth_return;
490         GHOST_TInt32 screen_x, screen_y;
491         
492         XGetGeometry(m_display,m_window,&root_return,&x_return,&y_return,
493                 &w_return,&h_return,&border_w_return,&depth_return);
494
495         clientToScreen(0, 0, screen_x, screen_y);
496         
497         bounds.m_l = screen_x;
498         bounds.m_r = bounds.m_l + w_return;
499         bounds.m_t = screen_y;
500         bounds.m_b = bounds.m_t + h_return;
501
502 }
503
504         GHOST_TSuccess 
505 GHOST_WindowX11::
506 setClientWidth(
507         GHOST_TUns32 width
508 ){      
509         XWindowChanges values;
510         unsigned int value_mask= CWWidth;               
511         values.width = width;
512         XConfigureWindow(m_display,m_window,value_mask,&values);
513
514         return GHOST_kSuccess;
515 }
516
517         GHOST_TSuccess 
518 GHOST_WindowX11::
519 setClientHeight(
520         GHOST_TUns32 height
521 ){
522         XWindowChanges values;
523         unsigned int value_mask= CWHeight;              
524         values.height = height;
525         XConfigureWindow(m_display,m_window,value_mask,&values);
526         return GHOST_kSuccess;
527
528 }
529
530         GHOST_TSuccess 
531 GHOST_WindowX11::
532 setClientSize(
533         GHOST_TUns32 width,
534         GHOST_TUns32 height
535 ){
536         XWindowChanges values;
537         unsigned int value_mask= CWWidth | CWHeight;            
538         values.width = width;
539         values.height = height;
540         XConfigureWindow(m_display,m_window,value_mask,&values);
541         return GHOST_kSuccess;
542
543 }       
544
545         void 
546 GHOST_WindowX11::
547 screenToClient(
548         GHOST_TInt32 inX,
549         GHOST_TInt32 inY,
550         GHOST_TInt32& outX,
551         GHOST_TInt32& outY
552 ) const {
553         // This is correct!
554
555         int ax,ay;
556         Window temp;
557
558         XTranslateCoordinates(
559                         m_display,
560                         RootWindow(m_display, m_visual->screen),
561                         m_window,
562                         inX,
563                         inY,
564                         &ax,
565                         &ay,
566                         &temp
567                 );
568         outX = ax;
569         outY = ay;
570 }
571                  
572         void 
573 GHOST_WindowX11::
574 clientToScreen(
575         GHOST_TInt32 inX,
576         GHOST_TInt32 inY,
577         GHOST_TInt32& outX,
578         GHOST_TInt32& outY
579 ) const {
580         int ax,ay;
581         Window temp;
582
583         XTranslateCoordinates(
584                         m_display,
585                         m_window,
586                         RootWindow(m_display, m_visual->screen),
587                         inX,
588                         inY,
589                         &ax,
590                         &ay,
591                         &temp
592                 );
593         outX = ax;
594         outY = ay;
595 }
596
597 void GHOST_WindowX11::icccmSetState(int state)
598 {
599         XEvent xev;
600
601         if (state != IconicState)
602                 return;
603
604         xev.xclient.type = ClientMessage;
605         xev.xclient.serial = 0;
606         xev.xclient.send_event = True;
607         xev.xclient.display = m_display;
608         xev.xclient.window = m_window;
609         xev.xclient.format = 32;
610         xev.xclient.message_type = m_system->m_wm_change_state;
611         xev.xclient.data.l[0] = state;
612         XSendEvent (m_display, RootWindow(m_display, DefaultScreen(m_display)),
613                 False, SubstructureNotifyMask | SubstructureRedirectMask, &xev);
614 }
615
616 int GHOST_WindowX11::icccmGetState(void) const
617 {
618         unsigned char *prop_ret;
619         unsigned long bytes_after, num_ret;
620         Atom type_ret;
621         int format_ret, st;
622
623         prop_ret = NULL;
624         st = XGetWindowProperty(m_display, m_window, m_system->m_wm_state, 0,
625                         0x7fffffff, False, m_system->m_wm_state, &type_ret,
626                         &format_ret, &num_ret, &bytes_after, &prop_ret);
627
628         if ((st == Success) && (prop_ret) && (num_ret == 2))
629                 st = prop_ret[0];
630         else
631                 st = NormalState;
632
633         if (prop_ret)
634                 XFree(prop_ret);
635         return (st);
636 }
637
638 void GHOST_WindowX11::netwmMaximized(bool set)
639 {
640         XEvent xev;
641
642         xev.xclient.type = ClientMessage;
643         xev.xclient.serial = 0;
644         xev.xclient.send_event = True;
645         xev.xclient.window = m_window;
646         xev.xclient.message_type = m_system->m_net_state;
647         xev.xclient.format = 32;
648
649         if (set == True)
650                 xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
651         else
652                 xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
653
654         xev.xclient.data.l[1] = m_system->m_net_max_horz;
655         xev.xclient.data.l[2] = m_system->m_net_max_vert;
656         xev.xclient.data.l[3] = 0;
657         xev.xclient.data.l[4] = 0;
658         XSendEvent(m_display, RootWindow(m_display, DefaultScreen(m_display)),
659                 False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
660 }
661
662 bool GHOST_WindowX11::netwmIsMaximized(void) const
663 {
664         unsigned char *prop_ret;
665         unsigned long bytes_after, num_ret;
666         Atom type_ret;
667         bool st;
668         int format_ret, count, i;
669
670         prop_ret = NULL;
671         st = False;
672         i = XGetWindowProperty(m_display, m_window, m_system->m_net_state, 0,
673                         0x7fffffff, False, XA_ATOM, &type_ret, &format_ret,
674                         &num_ret, &bytes_after, &prop_ret);
675         if ((i == Success) && (prop_ret) && (format_ret == 32)) {
676                 count = 0;
677                 for (i = 0; i < num_ret; i++) {
678                         if (((unsigned long *) prop_ret)[i] == m_system->m_net_max_horz)
679                                 count++;
680                         if (((unsigned long *) prop_ret)[i] == m_system->m_net_max_vert)
681                                 count++;
682                         if (count == 2) {
683                                 st = True;
684                                 break;
685                         }
686                 }
687         }
688
689         if (prop_ret)
690                 XFree(prop_ret);
691         return (st);
692 }
693
694 void GHOST_WindowX11::netwmFullScreen(bool set)
695 {
696         XEvent xev;
697
698         xev.xclient.type = ClientMessage;
699         xev.xclient.serial = 0;
700         xev.xclient.send_event = True;
701         xev.xclient.window = m_window;
702         xev.xclient.message_type = m_system->m_net_state;
703         xev.xclient.format = 32;
704
705         if (set == True)
706                 xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
707         else
708                 xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
709
710         xev.xclient.data.l[1] = m_system->m_net_fullscreen;
711         xev.xclient.data.l[2] = 0;
712         xev.xclient.data.l[3] = 0;
713         xev.xclient.data.l[4] = 0;
714         XSendEvent(m_display, RootWindow(m_display, DefaultScreen(m_display)),
715                 False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
716 }
717
718 bool GHOST_WindowX11::netwmIsFullScreen(void) const
719 {
720         unsigned char *prop_ret;
721         unsigned long bytes_after, num_ret;
722         Atom type_ret;
723         bool st;
724         int format_ret, i;
725
726         prop_ret = NULL;
727         st = False;
728         i = XGetWindowProperty(m_display, m_window, m_system->m_net_state, 0,
729                         0x7fffffff, False, XA_ATOM, &type_ret, &format_ret,
730                         &num_ret, &bytes_after, &prop_ret);
731         if ((i == Success) && (prop_ret) && (format_ret == 32)) {
732                 for (i = 0; i < num_ret; i++) {
733                         if (((unsigned long *) prop_ret)[i] == m_system->m_net_fullscreen) {
734                                 st = True;
735                                 break;
736                         }
737                 }
738         }
739
740         if (prop_ret)
741                 XFree(prop_ret);
742         return (st);
743 }
744
745 void GHOST_WindowX11::motifFullScreen(bool set)
746 {
747         MotifWmHints hints;
748
749         hints.flags = MWM_HINTS_DECORATIONS;
750         if (set == True)
751                 hints.decorations = 0;
752         else
753                 hints.decorations = 1;
754
755         XChangeProperty(m_display, m_window, m_system->m_motif,
756                         m_system->m_motif, 32, PropModeReplace,
757                         (unsigned char *) &hints, 4);
758 }
759
760 bool GHOST_WindowX11::motifIsFullScreen(void) const
761 {
762         unsigned char *prop_ret;
763         unsigned long bytes_after, num_ret;
764         MotifWmHints *hints;
765         Atom type_ret;
766         bool state;
767         int format_ret, st;
768
769         prop_ret = NULL;
770         state = False;
771         st = XGetWindowProperty(m_display, m_window, m_system->m_motif, 0,
772                                 0x7fffffff, False, m_system->m_motif,
773                                 &type_ret, &format_ret, &num_ret,
774                                 &bytes_after, &prop_ret);
775         if ((st == Success) && (prop_ret)) {
776                 hints = (MotifWmHints *) prop_ret;
777                 if (hints->flags & MWM_HINTS_DECORATIONS) {
778                         if (!hints->decorations)
779                                 state = True;
780                 }
781         }
782
783         if (prop_ret)
784                 XFree(prop_ret);
785         return (state);
786 }
787
788 GHOST_TWindowState GHOST_WindowX11::getState() const
789 {
790         GHOST_TWindowState state_ret;
791         int state;
792
793         state_ret = GHOST_kWindowStateNormal;
794         state = icccmGetState();
795         /*
796          * In the Iconic and Withdrawn state, the window
797          * is unmaped, so only need return a Minimized state.
798          */
799         if ((state == IconicState) || (state == WithdrawnState))
800                 state_ret = GHOST_kWindowStateMinimized;
801         else if (netwmIsMaximized() == True)
802                 state_ret = GHOST_kWindowStateMaximized;
803         else if (netwmIsFullScreen() == True)
804                 state_ret = GHOST_kWindowStateFullScreen;
805         else if (motifIsFullScreen() == True)
806                 state_ret = GHOST_kWindowStateFullScreen;
807         return (state_ret);
808 }
809
810 GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
811 {
812         GHOST_TWindowState cur_state;
813         bool is_max, is_full, is_motif_full;
814         int icccm_state;
815
816         cur_state = getState();
817         if (state == (int)cur_state)
818                 return GHOST_kSuccess;
819
820         if (cur_state != GHOST_kWindowStateMinimized) {
821                 /*
822                  * The window don't have this property's
823                  * if it's not mapped.
824                  */
825                 is_max = netwmIsMaximized();
826                 is_full = netwmIsFullScreen();
827         }
828         else {
829                 is_max = False;
830                 is_full = False;
831         }
832
833         is_motif_full = motifIsFullScreen();
834
835         if (state == GHOST_kWindowStateNormal) {
836                 if (is_max == True)
837                         netwmMaximized(False);
838                 if (is_full == True)
839                         netwmFullScreen(False);
840                 if (is_motif_full == True)
841                         motifFullScreen(False);
842                 icccmSetState(NormalState);
843                 return (GHOST_kSuccess);
844         }
845
846         if (state == GHOST_kWindowStateFullScreen) {
847                 /*
848                  * We can't change to full screen if the window
849                  * isn't mapped.
850                  */
851                 if (cur_state == GHOST_kWindowStateMinimized)
852                         return (GHOST_kFailure);
853
854                 if (is_max == True)
855                         netwmMaximized(False);
856                 if (is_full == False)
857                         netwmFullScreen(True);
858                 if (is_motif_full == False)
859                         motifFullScreen(True);
860                 return (GHOST_kSuccess);
861         }
862
863         if (state == GHOST_kWindowStateMaximized) {
864                 /*
865                  * We can't change to Maximized if the window
866                  * isn't mapped.
867                  */
868                 if (cur_state == GHOST_kWindowStateMinimized)
869                         return (GHOST_kFailure);
870
871                 if (is_full == True)
872                         netwmFullScreen(False);
873                 if (is_motif_full == True)
874                         motifFullScreen(False);
875                 if (is_max == False)
876                         netwmMaximized(True);
877                 return (GHOST_kSuccess);
878         }
879
880         if (state == GHOST_kWindowStateMinimized) {
881                 /*
882                  * The window manager need save the current state of
883                  * the window (maximized, full screen, etc).
884                  */
885                 icccmSetState(IconicState);
886                 return (GHOST_kSuccess);
887         }
888
889         return (GHOST_kFailure);
890 }
891
892 #include <iostream>
893 using namespace std;
894
895         GHOST_TSuccess 
896 GHOST_WindowX11::
897 setOrder(
898         GHOST_TWindowOrder order
899 ){
900         if (order == GHOST_kWindowOrderTop) {
901                 XWindowAttributes attr;   
902                 Atom atom;
903
904                 /* We use both XRaiseWindow and _NET_ACTIVE_WINDOW, since some
905                    window managers ignore the former (e.g. kwin from kde) and others
906                    don't implement the latter (e.g. fluxbox pre 0.9.9) */
907
908                 XRaiseWindow(m_display, m_window);
909
910                 atom = XInternAtom(m_display, "_NET_ACTIVE_WINDOW", True);
911
912                 if (atom != None) {
913                         Window root;
914                         XEvent xev;
915                         long eventmask;
916
917                         xev.xclient.type = ClientMessage;
918                         xev.xclient.serial = 0;
919                         xev.xclient.send_event = True;
920                         xev.xclient.window = m_window;
921                         xev.xclient.message_type = atom;
922
923                         xev.xclient.format = 32;
924                         xev.xclient.data.l[0] = 0;
925                         xev.xclient.data.l[1] = 0;
926                         xev.xclient.data.l[2] = 0;
927                         xev.xclient.data.l[3] = 0;
928                         xev.xclient.data.l[4] = 0;
929
930                         root = RootWindow(m_display, m_visual->screen),
931                         eventmask = SubstructureRedirectMask | SubstructureNotifyMask;
932
933                         XSendEvent(m_display, root, False, eventmask, &xev);
934                 }
935
936                 XGetWindowAttributes(m_display, m_window, &attr);
937
938                 /* iconized windows give bad match error */
939                 if (attr.map_state == IsViewable)
940                         XSetInputFocus(m_display, m_window, RevertToPointerRoot,
941                                                  CurrentTime);
942                 XFlush(m_display);
943         } else if (order == GHOST_kWindowOrderBottom) {
944                 XLowerWindow(m_display,m_window);
945                 XFlush(m_display);
946         } else {
947                 return GHOST_kFailure;
948         }
949         
950         return GHOST_kSuccess;
951 }
952
953         GHOST_TSuccess 
954 GHOST_WindowX11::
955 swapBuffers(
956 ){
957         if (getDrawingContextType() == GHOST_kDrawingContextTypeOpenGL) {
958                 glXSwapBuffers(m_display,m_window);
959                 return GHOST_kSuccess;
960         } else {
961                 return GHOST_kFailure;
962         }
963 }
964
965         GHOST_TSuccess 
966 GHOST_WindowX11::
967 activateDrawingContext(
968 ){
969         if (m_context !=NULL) {
970                 glXMakeCurrent(m_display, m_window,m_context);                                          
971                 return GHOST_kSuccess;
972         } 
973         return GHOST_kFailure;
974 }
975
976         GHOST_TSuccess 
977 GHOST_WindowX11::
978 invalidate(
979 ){
980         
981         // So the idea of this function is to generate an expose event
982         // for the window.
983         // Unfortunately X does not handle expose events for you and 
984         // it is the client's job to refresh the dirty part of the window.
985         // We need to queue up invalidate calls and generate GHOST events 
986         // for them in the system.
987
988         // We implement this by setting a boolean in this class to concatenate 
989         // all such calls into a single event for this window.
990
991         // At the same time we queue the dirty windows in the system class
992         // and generate events for them at the next processEvents call.
993
994         if (m_invalid_window == false) {
995                 m_system->addDirtyWindow(this);
996                 m_invalid_window = true;
997         } 
998  
999         return GHOST_kSuccess;
1000 }
1001
1002 /**
1003  * called by the X11 system implementation when expose events
1004  * for the window have been pushed onto the GHOST queue
1005  */
1006  
1007         void
1008 GHOST_WindowX11::
1009 validate(
1010 ){
1011         m_invalid_window = false;
1012 }       
1013  
1014  
1015 /**
1016  * Destructor.
1017  * Closes the window and disposes resources allocated.
1018  */
1019
1020 GHOST_WindowX11::
1021 ~GHOST_WindowX11(
1022 ){
1023         std::map<unsigned int, Cursor>::iterator it = m_standard_cursors.begin();
1024         for (; it != m_standard_cursors.end(); it++) {
1025                 XFreeCursor(m_display, it->second);
1026         }
1027
1028         if (m_empty_cursor) {
1029                 XFreeCursor(m_display, m_empty_cursor);
1030         }
1031         if (m_custom_cursor) {
1032                 XFreeCursor(m_display, m_custom_cursor);
1033         }
1034         
1035         if (m_context) {
1036                 if (m_context == s_firstContext) {
1037                         s_firstContext = NULL;
1038                 }
1039                 glXDestroyContext(m_display, m_context);
1040         }
1041         XDestroyWindow(m_display, m_window);
1042         XFree(m_visual);
1043 }
1044
1045
1046
1047
1048 /**
1049  * Tries to install a rendering context in this window.
1050  * @param type  The type of rendering context installed.
1051  * @return Indication as to whether installation has succeeded.
1052  */
1053         GHOST_TSuccess 
1054 GHOST_WindowX11::
1055 installDrawingContext(
1056         GHOST_TDrawingContextType type
1057 ){
1058         // only support openGL for now.
1059         GHOST_TSuccess success;
1060         switch (type) {
1061         case GHOST_kDrawingContextTypeOpenGL:
1062                 m_context = glXCreateContext(m_display, m_visual, s_firstContext, True);
1063                 if (m_context !=NULL) {
1064                         if (!s_firstContext) {
1065                                 s_firstContext = m_context;
1066                         }
1067                         glXMakeCurrent(m_display, m_window,m_context);                                          
1068                         success = GHOST_kSuccess;
1069                 } else {
1070                         success = GHOST_kFailure;
1071                 }
1072
1073                 break;
1074
1075         case GHOST_kDrawingContextTypeNone:
1076                 success = GHOST_kSuccess;
1077                 break;
1078
1079         default:
1080                 success = GHOST_kFailure;
1081         }
1082         return success;
1083 }
1084
1085
1086
1087 /**
1088  * Removes the current drawing context.
1089  * @return Indication as to whether removal has succeeded.
1090  */
1091         GHOST_TSuccess 
1092 GHOST_WindowX11::
1093 removeDrawingContext(
1094 ){
1095         GHOST_TSuccess success;
1096
1097         if (m_context != NULL) {
1098                 glXDestroyContext(m_display, m_context);
1099                 success = GHOST_kSuccess;
1100         } else {
1101                 success = GHOST_kFailure;
1102         }
1103         return success; 
1104 }
1105
1106
1107         Cursor
1108 GHOST_WindowX11::
1109 getStandardCursor(
1110         GHOST_TStandardCursor g_cursor
1111 ){
1112         unsigned int xcursor_id;
1113
1114 #define GtoX(gcurs, xcurs)      case gcurs: xcursor_id = xcurs
1115         switch (g_cursor) {
1116         GtoX(GHOST_kStandardCursorRightArrow, XC_arrow); break;
1117         GtoX(GHOST_kStandardCursorLeftArrow, XC_top_left_arrow); break;
1118         GtoX(GHOST_kStandardCursorInfo, XC_hand1); break;
1119         GtoX(GHOST_kStandardCursorDestroy, XC_pirate); break;
1120         GtoX(GHOST_kStandardCursorHelp, XC_question_arrow); break; 
1121         GtoX(GHOST_kStandardCursorCycle, XC_exchange); break;
1122         GtoX(GHOST_kStandardCursorSpray, XC_spraycan); break;
1123         GtoX(GHOST_kStandardCursorWait, XC_watch); break;
1124         GtoX(GHOST_kStandardCursorText, XC_xterm); break;
1125         GtoX(GHOST_kStandardCursorCrosshair, XC_crosshair); break;
1126         GtoX(GHOST_kStandardCursorUpDown, XC_sb_v_double_arrow); break;
1127         GtoX(GHOST_kStandardCursorLeftRight, XC_sb_h_double_arrow); break;
1128         GtoX(GHOST_kStandardCursorTopSide, XC_top_side); break;
1129         GtoX(GHOST_kStandardCursorBottomSide, XC_bottom_side); break;
1130         GtoX(GHOST_kStandardCursorLeftSide, XC_left_side); break;
1131         GtoX(GHOST_kStandardCursorRightSide, XC_right_side); break;
1132         GtoX(GHOST_kStandardCursorTopLeftCorner, XC_top_left_corner); break;
1133         GtoX(GHOST_kStandardCursorTopRightCorner, XC_top_right_corner); break;
1134         GtoX(GHOST_kStandardCursorBottomRightCorner, XC_bottom_right_corner); break;
1135         GtoX(GHOST_kStandardCursorBottomLeftCorner, XC_bottom_left_corner); break;
1136         GtoX(GHOST_kStandardCursorPencil, XC_pencil); break;
1137         default:
1138                 xcursor_id = 0;
1139         }
1140 #undef GtoX
1141
1142         if (xcursor_id) {
1143                 Cursor xcursor = m_standard_cursors[xcursor_id];
1144                 
1145                 if (!xcursor) {
1146                         xcursor = XCreateFontCursor(m_display, xcursor_id);
1147
1148                         m_standard_cursors[xcursor_id] = xcursor;
1149                 }
1150                 
1151                 return xcursor;
1152         } else {
1153                 return None;
1154         }
1155 }
1156
1157         Cursor 
1158 GHOST_WindowX11::
1159 getEmptyCursor(
1160 ) {
1161         if (!m_empty_cursor) {
1162                 Pixmap blank;
1163                 XColor dummy;
1164                 char data[1] = {0};
1165                         
1166                 /* make a blank cursor */
1167                 blank = XCreateBitmapFromData (
1168                         m_display, 
1169                         RootWindow(m_display,DefaultScreen(m_display)),
1170                         data, 1, 1
1171                 );
1172
1173                 m_empty_cursor = XCreatePixmapCursor(m_display, blank, blank, &dummy, &dummy, 0, 0);
1174                 XFreePixmap(m_display, blank);
1175         }
1176
1177         return m_empty_cursor;
1178 }
1179
1180         GHOST_TSuccess
1181 GHOST_WindowX11::
1182 setWindowCursorVisibility(
1183         bool visible
1184 ){
1185         Cursor xcursor;
1186         
1187         if (visible) {
1188                 xcursor = getStandardCursor( getCursorShape() );
1189         } else {
1190                 xcursor = getEmptyCursor();
1191         }
1192
1193         XDefineCursor(m_display, m_window, xcursor);
1194         XFlush(m_display);
1195         
1196         return GHOST_kSuccess;
1197 }
1198
1199         GHOST_TSuccess
1200 GHOST_WindowX11::
1201 setWindowCursorShape(
1202         GHOST_TStandardCursor shape
1203 ){
1204         Cursor xcursor = getStandardCursor( shape );
1205         
1206         XDefineCursor(m_display, m_window, xcursor);
1207         XFlush(m_display);
1208
1209         return GHOST_kSuccess;
1210 }
1211
1212         GHOST_TSuccess
1213 GHOST_WindowX11::
1214 setWindowCustomCursorShape(
1215         GHOST_TUns8 bitmap[16][2], 
1216         GHOST_TUns8 mask[16][2], 
1217         int hotX, 
1218         int hotY
1219 ){
1220
1221 setWindowCustomCursorShape((GHOST_TUns8*)bitmap, (GHOST_TUns8*)mask, 
1222                                                                         16, 16, hotX, hotY, 0, 1);
1223         return GHOST_kSuccess;
1224 }
1225
1226         GHOST_TSuccess
1227 GHOST_WindowX11::
1228 setWindowCustomCursorShape(     
1229         GHOST_TUns8 *bitmap, 
1230         GHOST_TUns8 *mask, 
1231         int sizex, 
1232         int sizey, 
1233         int hotX, 
1234         int hotY, 
1235         int fg_color, 
1236         int bg_color
1237 ){
1238         Pixmap bitmap_pix, mask_pix;
1239         XColor fg, bg;
1240         
1241         if(XAllocNamedColor(m_display, DefaultColormap(m_display, DefaultScreen(m_display)),
1242                 "White", &fg, &fg) == 0) return GHOST_kFailure;
1243         if(XAllocNamedColor(m_display, DefaultColormap(m_display, DefaultScreen(m_display)),
1244                 "Black", &bg, &bg) == 0) return GHOST_kFailure;
1245
1246         if (m_custom_cursor) {
1247                 XFreeCursor(m_display, m_custom_cursor);
1248         }
1249
1250         bitmap_pix = XCreateBitmapFromData(m_display, m_window, (char*) bitmap, sizex, sizey);
1251         mask_pix = XCreateBitmapFromData(m_display, m_window, (char*) mask, sizex, sizey);
1252                 
1253         m_custom_cursor = XCreatePixmapCursor(m_display, bitmap_pix, mask_pix, &fg, &bg, hotX, hotY);
1254         XDefineCursor(m_display, m_window, m_custom_cursor);
1255         XFlush(m_display);
1256         
1257         XFreePixmap(m_display, bitmap_pix);
1258         XFreePixmap(m_display, mask_pix);
1259
1260         return GHOST_kSuccess;
1261 }
1262
1263 /*
1264
1265 void glutCustomCursor(char *data1, char *data2, int size)
1266 {
1267         Pixmap source, mask;
1268         Cursor cursor;
1269         XColor fg, bg;
1270         
1271         if(XAllocNamedColor(__glutDisplay, DefaultColormap(__glutDisplay, __glutScreen),
1272                 "White", &fg, &fg) == 0) return;
1273         if(XAllocNamedColor(__glutDisplay, DefaultColormap(__glutDisplay, __glutScreen),
1274                 "Red", &bg, &bg) == 0) return;
1275
1276
1277         source= XCreateBitmapFromData(__glutDisplay, xdraw, data2, size, size);
1278         mask= XCreateBitmapFromData(__glutDisplay, xdraw, data1, size, size);
1279                 
1280         cursor= XCreatePixmapCursor(__glutDisplay, source, mask, &fg, &bg, 7, 7);
1281                 
1282         XFreePixmap(__glutDisplay, source);
1283         XFreePixmap(__glutDisplay, mask);
1284                 
1285         XDefineCursor(__glutDisplay, xdraw, cursor);
1286 }
1287
1288 */