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