same as r23322 in 2.4x
[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 /* These C functions are copied from Wine 1.1.13's wintab.c */
418 #define BOOL int
419 #define TRUE 1
420 #define FALSE 0
421
422 static bool match_token(const char *haystack, const char *needle)
423 {
424         const char *p, *q;
425         for (p = haystack; *p; )
426         {
427                 while (*p && isspace(*p))
428                         p++;
429                 if (! *p)
430                         break;
431
432                 for (q = needle; *q && *p && tolower(*p) == tolower(*q); q++)
433                         p++;
434                 if (! *q && (isspace(*p) || !*p))
435                         return TRUE;
436
437                 while (*p && ! isspace(*p))
438                         p++;
439         }
440         return FALSE;
441 }
442
443 /*      Determining if an X device is a Tablet style device is an imperfect science.
444 **  We rely on common conventions around device names as well as the type reported
445 **  by Wacom tablets.  This code will likely need to be expanded for alternate tablet types
446 **
447 **      Wintab refers to any device that interacts with the tablet as a cursor,
448 **  (stylus, eraser, tablet mouse, airbrush, etc)
449 **  this is not to be confused with wacom x11 configuration "cursor" device.
450 **  Wacoms x11 config "cursor" refers to its device slot (which we mirror with
451 **  our gSysCursors) for puck like devices (tablet mice essentially).
452 */
453
454 static BOOL is_tablet_cursor(const char *name, const char *type)
455 {
456         int i;
457         static const char *tablet_cursor_whitelist[] = {
458                 "wacom",
459                 "wizardpen",
460                 "acecad",
461                 "tablet",
462                 "cursor",
463                 "stylus",
464                 "eraser",
465                 "pad",
466                 NULL
467         };
468
469         for (i=0; tablet_cursor_whitelist[i] != NULL; i++) {
470                 if (name && match_token(name, tablet_cursor_whitelist[i]))
471                         return TRUE;
472                 if (type && match_token(type, tablet_cursor_whitelist[i]))
473                         return TRUE;
474         }
475         return FALSE;
476 }
477
478 static BOOL is_stylus(const char *name, const char *type)
479 {
480         int i;
481         static const char* tablet_stylus_whitelist[] = {
482                 "stylus",
483                 "wizardpen",
484                 "acecad",
485                 NULL
486         };
487
488         for (i=0; tablet_stylus_whitelist[i] != NULL; i++) {
489                 if (name && match_token(name, tablet_stylus_whitelist[i]))
490                         return TRUE;
491                 if (type && match_token(type, tablet_stylus_whitelist[i]))
492                         return TRUE;
493         }
494
495         return FALSE;
496 }
497
498 static BOOL is_eraser(const char *name, const char *type)
499 {
500         if (name && match_token(name, "eraser"))
501                 return TRUE;
502         if (type && match_token(type, "eraser"))
503                 return TRUE;
504         return FALSE;
505 }
506 #undef BOOL
507 #undef TRUE
508 #undef FALSE
509 /* end code copied from wine */
510
511 void GHOST_WindowX11::initXInputDevices()
512 {
513         static XErrorHandler old_handler = (XErrorHandler) 0 ;
514         XExtensionVersion *version = XGetExtensionVersion(m_display, INAME);
515
516         if(version && (version != (XExtensionVersion*)NoSuchExtension)) {
517                 if(version->present) {
518                         int device_count;
519                         XDeviceInfo* device_info = XListInputDevices(m_display, &device_count);
520                         m_xtablet.StylusDevice = NULL;
521                         m_xtablet.EraserDevice = NULL;
522                         m_xtablet.CommonData.Active= GHOST_kTabletModeNone;
523
524                         /* Install our error handler to override Xlib's termination behavior */
525                         old_handler = XSetErrorHandler(ApplicationErrorHandler) ;
526
527                         for(int i=0; i<device_count; ++i) {
528                                 char *device_type = device_info[i].type ? XGetAtomName(m_display, device_info[i].type) : NULL;
529                                 
530 //                              printf("Tablet type:'%s', name:'%s', index:%d\n", device_type, device_info[i].name, i);
531
532
533                                 if(m_xtablet.StylusDevice==NULL && is_stylus(device_info[i].name, device_type)) {
534 //                                      printf("\tfound stylus\n");
535                                         m_xtablet.StylusID= device_info[i].id;
536                                         m_xtablet.StylusDevice = XOpenDevice(m_display, m_xtablet.StylusID);
537
538                                         if (m_xtablet.StylusDevice != NULL) {
539                                                 /* Find how many pressure levels tablet has */
540                                                 XAnyClassPtr ici = device_info[i].inputclassinfo;
541                                                 for(int j=0; j<m_xtablet.StylusDevice->num_classes; ++j) {
542                                                         if(ici->c_class==ValuatorClass) {
543 //                                                              printf("\t\tfound ValuatorClass\n");
544                                                                 XValuatorInfo* xvi = (XValuatorInfo*)ici;
545                                                                 m_xtablet.PressureLevels = xvi->axes[2].max_value;
546                                                         
547                                                                 /* this is assuming that the tablet has the same tilt resolution in both
548                                                                  * positive and negative directions. It would be rather weird if it didn't.. */
549                                                                 m_xtablet.XtiltLevels = xvi->axes[3].max_value;
550                                                                 m_xtablet.YtiltLevels = xvi->axes[4].max_value;
551                                                                 break;
552                                                         }
553                                                 
554                                                         ici = (XAnyClassPtr)(((char *)ici) + ici->length);
555                                                 }
556                                         } else {
557                                                 m_xtablet.StylusID= 0;
558                                         }
559                                 }
560                                 else if(m_xtablet.EraserDevice==NULL && is_eraser(device_info[i].name, device_type)) {
561 //                                      printf("\tfound eraser\n");
562                                         m_xtablet.EraserID= device_info[i].id;
563                                         m_xtablet.EraserDevice = XOpenDevice(m_display, m_xtablet.EraserID);
564                                         if (m_xtablet.EraserDevice == NULL) m_xtablet.EraserID= 0;
565                                 }
566
567                                 if(device_type) {
568                                         XFree((void*)device_type);
569                                 }
570                         }
571
572                         /* Restore handler */
573                         (void) XSetErrorHandler(old_handler) ;
574
575                         XFreeDeviceList(device_info);
576
577
578                         XEventClass xevents[10], ev;
579                         int dcount = 0;
580
581                         if(m_xtablet.StylusDevice) {
582                                 DeviceMotionNotify(m_xtablet.StylusDevice, m_xtablet.MotionEvent, ev);
583                                 if(ev) xevents[dcount++] = ev;
584                                 ProximityIn(m_xtablet.StylusDevice, m_xtablet.ProxInEvent, ev);
585                                 if(ev) xevents[dcount++] = ev;
586                                 ProximityOut(m_xtablet.StylusDevice, m_xtablet.ProxOutEvent, ev);
587                                 if(ev) xevents[dcount++] = ev;
588                         }
589                         if(m_xtablet.EraserDevice) {
590                                 DeviceMotionNotify(m_xtablet.EraserDevice, m_xtablet.MotionEvent, ev);
591                                 if(ev) xevents[dcount++] = ev;
592                                 ProximityIn(m_xtablet.EraserDevice, m_xtablet.ProxInEvent, ev);
593                                 if(ev) xevents[dcount++] = ev;
594                                 ProximityOut(m_xtablet.EraserDevice, m_xtablet.ProxOutEvent, ev);
595                                 if(ev) xevents[dcount++] = ev;
596                         }
597
598                         XSelectExtensionEvent(m_display, m_window, xevents, dcount);
599                 }
600                 XFree(version);
601         }
602 }       
603
604
605         Window 
606 GHOST_WindowX11::
607 getXWindow(
608 ){
609         return m_window;
610 }
611
612         bool 
613 GHOST_WindowX11::
614 getValid(
615 ) const {
616         return m_valid_setup;
617 }
618
619         void 
620 GHOST_WindowX11::
621 setTitle(
622         const STR_String& title
623 ){
624         Atom name = XInternAtom(m_display, "_NET_WM_NAME", 0);
625         Atom utf8str = XInternAtom(m_display, "UTF8_STRING", 0);
626         XChangeProperty(m_display, m_window,
627                         name, utf8str, 8, PropModeReplace,
628                         (const unsigned char*) title.ReadPtr(),
629                         strlen(title.ReadPtr()));
630
631 // This should convert to valid x11 string
632 //  and getTitle would need matching change
633         XStoreName(m_display,m_window,title);
634
635         XFlush(m_display);
636 }
637
638         void 
639 GHOST_WindowX11::
640 getTitle(
641         STR_String& title
642 ) const {
643         char *name = NULL;
644         
645         XFetchName(m_display,m_window,&name);
646         title= name?name:"untitled";
647         XFree(name);
648 }
649         
650         void 
651 GHOST_WindowX11::
652 getWindowBounds(
653         GHOST_Rect& bounds
654 ) const {
655                 // Getting the window bounds under X11 is not
656                 // really supported (nor should it be desired).
657         getClientBounds(bounds);
658 }
659
660         void 
661 GHOST_WindowX11::
662 getClientBounds(
663         GHOST_Rect& bounds
664 ) const {
665         Window root_return;
666         int x_return,y_return;
667         unsigned int w_return,h_return,border_w_return,depth_return;
668         GHOST_TInt32 screen_x, screen_y;
669         
670         XGetGeometry(m_display,m_window,&root_return,&x_return,&y_return,
671                 &w_return,&h_return,&border_w_return,&depth_return);
672
673         clientToScreen(0, 0, screen_x, screen_y);
674         
675         bounds.m_l = screen_x;
676         bounds.m_r = bounds.m_l + w_return;
677         bounds.m_t = screen_y;
678         bounds.m_b = bounds.m_t + h_return;
679
680 }
681
682         GHOST_TSuccess 
683 GHOST_WindowX11::
684 setClientWidth(
685         GHOST_TUns32 width
686 ){      
687         XWindowChanges values;
688         unsigned int value_mask= CWWidth;               
689         values.width = width;
690         XConfigureWindow(m_display,m_window,value_mask,&values);
691
692         return GHOST_kSuccess;
693 }
694
695         GHOST_TSuccess 
696 GHOST_WindowX11::
697 setClientHeight(
698         GHOST_TUns32 height
699 ){
700         XWindowChanges values;
701         unsigned int value_mask= CWHeight;              
702         values.height = height;
703         XConfigureWindow(m_display,m_window,value_mask,&values);
704         return GHOST_kSuccess;
705
706 }
707
708         GHOST_TSuccess 
709 GHOST_WindowX11::
710 setClientSize(
711         GHOST_TUns32 width,
712         GHOST_TUns32 height
713 ){
714         XWindowChanges values;
715         unsigned int value_mask= CWWidth | CWHeight;            
716         values.width = width;
717         values.height = height;
718         XConfigureWindow(m_display,m_window,value_mask,&values);
719         return GHOST_kSuccess;
720
721 }       
722
723         void 
724 GHOST_WindowX11::
725 screenToClient(
726         GHOST_TInt32 inX,
727         GHOST_TInt32 inY,
728         GHOST_TInt32& outX,
729         GHOST_TInt32& outY
730 ) const {
731         // This is correct!
732
733         int ax,ay;
734         Window temp;
735
736         XTranslateCoordinates(
737                         m_display,
738                         RootWindow(m_display, m_visual->screen),
739                         m_window,
740                         inX,
741                         inY,
742                         &ax,
743                         &ay,
744                         &temp
745                 );
746         outX = ax;
747         outY = ay;
748 }
749                  
750         void 
751 GHOST_WindowX11::
752 clientToScreen(
753         GHOST_TInt32 inX,
754         GHOST_TInt32 inY,
755         GHOST_TInt32& outX,
756         GHOST_TInt32& outY
757 ) const {
758         int ax,ay;
759         Window temp;
760
761         XTranslateCoordinates(
762                         m_display,
763                         m_window,
764                         RootWindow(m_display, m_visual->screen),
765                         inX,
766                         inY,
767                         &ax,
768                         &ay,
769                         &temp
770                 );
771         outX = ax;
772         outY = ay;
773 }
774
775 void GHOST_WindowX11::icccmSetState(int state)
776 {
777         XEvent xev;
778
779         if (state != IconicState)
780                 return;
781
782         xev.xclient.type = ClientMessage;
783         xev.xclient.serial = 0;
784         xev.xclient.send_event = True;
785         xev.xclient.display = m_display;
786         xev.xclient.window = m_window;
787         xev.xclient.format = 32;
788         xev.xclient.message_type = m_system->m_wm_change_state;
789         xev.xclient.data.l[0] = state;
790         XSendEvent (m_display, RootWindow(m_display, DefaultScreen(m_display)),
791                 False, SubstructureNotifyMask | SubstructureRedirectMask, &xev);
792 }
793
794 int GHOST_WindowX11::icccmGetState(void) const
795 {
796         unsigned char *prop_ret;
797         unsigned long bytes_after, num_ret;
798         Atom type_ret;
799         int format_ret, st;
800
801         prop_ret = NULL;
802         st = XGetWindowProperty(m_display, m_window, m_system->m_wm_state, 0,
803                         0x7fffffff, False, m_system->m_wm_state, &type_ret,
804                         &format_ret, &num_ret, &bytes_after, &prop_ret);
805
806         if ((st == Success) && (prop_ret) && (num_ret == 2))
807                 st = prop_ret[0];
808         else
809                 st = NormalState;
810
811         if (prop_ret)
812                 XFree(prop_ret);
813         return (st);
814 }
815
816 void GHOST_WindowX11::netwmMaximized(bool set)
817 {
818         XEvent xev;
819
820         xev.xclient.type = ClientMessage;
821         xev.xclient.serial = 0;
822         xev.xclient.send_event = True;
823         xev.xclient.window = m_window;
824         xev.xclient.message_type = m_system->m_net_state;
825         xev.xclient.format = 32;
826
827         if (set == True)
828                 xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
829         else
830                 xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
831
832         xev.xclient.data.l[1] = m_system->m_net_max_horz;
833         xev.xclient.data.l[2] = m_system->m_net_max_vert;
834         xev.xclient.data.l[3] = 0;
835         xev.xclient.data.l[4] = 0;
836         XSendEvent(m_display, RootWindow(m_display, DefaultScreen(m_display)),
837                 False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
838 }
839
840 bool GHOST_WindowX11::netwmIsMaximized(void) const
841 {
842         unsigned char *prop_ret;
843         unsigned long bytes_after, num_ret, i;
844         Atom type_ret;
845         bool st;
846         int format_ret, ret, count;
847
848         prop_ret = NULL;
849         st = False;
850         ret = XGetWindowProperty(m_display, m_window, m_system->m_net_state, 0,
851                         0x7fffffff, False, XA_ATOM, &type_ret, &format_ret,
852                         &num_ret, &bytes_after, &prop_ret);
853         if ((ret == Success) && (prop_ret) && (format_ret == 32)) {
854                 count = 0;
855                 for (i = 0; i < num_ret; i++) {
856                         if (((unsigned long *) prop_ret)[i] == m_system->m_net_max_horz)
857                                 count++;
858                         if (((unsigned long *) prop_ret)[i] == m_system->m_net_max_vert)
859                                 count++;
860                         if (count == 2) {
861                                 st = True;
862                                 break;
863                         }
864                 }
865         }
866
867         if (prop_ret)
868                 XFree(prop_ret);
869         return (st);
870 }
871
872 void GHOST_WindowX11::netwmFullScreen(bool set)
873 {
874         XEvent xev;
875
876         xev.xclient.type = ClientMessage;
877         xev.xclient.serial = 0;
878         xev.xclient.send_event = True;
879         xev.xclient.window = m_window;
880         xev.xclient.message_type = m_system->m_net_state;
881         xev.xclient.format = 32;
882
883         if (set == True)
884                 xev.xclient.data.l[0] = _NET_WM_STATE_ADD;
885         else
886                 xev.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
887
888         xev.xclient.data.l[1] = m_system->m_net_fullscreen;
889         xev.xclient.data.l[2] = 0;
890         xev.xclient.data.l[3] = 0;
891         xev.xclient.data.l[4] = 0;
892         XSendEvent(m_display, RootWindow(m_display, DefaultScreen(m_display)),
893                 False, SubstructureRedirectMask | SubstructureNotifyMask, &xev);
894 }
895
896 bool GHOST_WindowX11::netwmIsFullScreen(void) const
897 {
898         unsigned char *prop_ret;
899         unsigned long bytes_after, num_ret, i;
900         Atom type_ret;
901         bool st;
902         int format_ret, ret;
903
904         prop_ret = NULL;
905         st = False;
906         ret = XGetWindowProperty(m_display, m_window, m_system->m_net_state, 0,
907                         0x7fffffff, False, XA_ATOM, &type_ret, &format_ret,
908                         &num_ret, &bytes_after, &prop_ret);
909         if ((ret == Success) && (prop_ret) && (format_ret == 32)) {
910                 for (i = 0; i < num_ret; i++) {
911                         if (((unsigned long *) prop_ret)[i] == m_system->m_net_fullscreen) {
912                                 st = True;
913                                 break;
914                         }
915                 }
916         }
917
918         if (prop_ret)
919                 XFree(prop_ret);
920         return (st);
921 }
922
923 void GHOST_WindowX11::motifFullScreen(bool set)
924 {
925         MotifWmHints hints;
926
927         hints.flags = MWM_HINTS_DECORATIONS;
928         if (set == True)
929                 hints.decorations = 0;
930         else
931                 hints.decorations = 1;
932
933         XChangeProperty(m_display, m_window, m_system->m_motif,
934                         m_system->m_motif, 32, PropModeReplace,
935                         (unsigned char *) &hints, 4);
936 }
937
938 bool GHOST_WindowX11::motifIsFullScreen(void) const
939 {
940         unsigned char *prop_ret;
941         unsigned long bytes_after, num_ret;
942         MotifWmHints *hints;
943         Atom type_ret;
944         bool state;
945         int format_ret, st;
946
947         prop_ret = NULL;
948         state = False;
949         st = XGetWindowProperty(m_display, m_window, m_system->m_motif, 0,
950                                 0x7fffffff, False, m_system->m_motif,
951                                 &type_ret, &format_ret, &num_ret,
952                                 &bytes_after, &prop_ret);
953         if ((st == Success) && (prop_ret)) {
954                 hints = (MotifWmHints *) prop_ret;
955                 if (hints->flags & MWM_HINTS_DECORATIONS) {
956                         if (!hints->decorations)
957                                 state = True;
958                 }
959         }
960
961         if (prop_ret)
962                 XFree(prop_ret);
963         return (state);
964 }
965
966 GHOST_TWindowState GHOST_WindowX11::getState() const
967 {
968         GHOST_TWindowState state_ret;
969         int state;
970
971         state_ret = GHOST_kWindowStateNormal;
972         state = icccmGetState();
973         /*
974          * In the Iconic and Withdrawn state, the window
975          * is unmaped, so only need return a Minimized state.
976          */
977         if ((state == IconicState) || (state == WithdrawnState))
978                 state_ret = GHOST_kWindowStateMinimized;
979         else if (netwmIsMaximized() == True)
980                 state_ret = GHOST_kWindowStateMaximized;
981         else if (netwmIsFullScreen() == True)
982                 state_ret = GHOST_kWindowStateFullScreen;
983         else if (motifIsFullScreen() == True)
984                 state_ret = GHOST_kWindowStateFullScreen;
985         return (state_ret);
986 }
987
988 GHOST_TSuccess GHOST_WindowX11::setState(GHOST_TWindowState state)
989 {
990         GHOST_TWindowState cur_state;
991         bool is_max, is_full, is_motif_full;
992
993         cur_state = getState();
994         if (state == (int)cur_state)
995                 return GHOST_kSuccess;
996
997         if (cur_state != GHOST_kWindowStateMinimized) {
998                 /*
999                  * The window don't have this property's
1000                  * if it's not mapped.
1001                  */
1002                 is_max = netwmIsMaximized();
1003                 is_full = netwmIsFullScreen();
1004         }
1005         else {
1006                 is_max = False;
1007                 is_full = False;
1008         }
1009
1010         is_motif_full = motifIsFullScreen();
1011
1012         if (state == GHOST_kWindowStateNormal) {
1013                 if (is_max == True)
1014                         netwmMaximized(False);
1015                 if (is_full == True)
1016                         netwmFullScreen(False);
1017                 if (is_motif_full == True)
1018                         motifFullScreen(False);
1019                 icccmSetState(NormalState);
1020                 return (GHOST_kSuccess);
1021         }
1022
1023         if (state == GHOST_kWindowStateFullScreen) {
1024                 /*
1025                  * We can't change to full screen if the window
1026                  * isn't mapped.
1027                  */
1028                 if (cur_state == GHOST_kWindowStateMinimized)
1029                         return (GHOST_kFailure);
1030
1031                 if (is_max == True)
1032                         netwmMaximized(False);
1033                 if (is_full == False)
1034                         netwmFullScreen(True);
1035                 if (is_motif_full == False)
1036                         motifFullScreen(True);
1037                 return (GHOST_kSuccess);
1038         }
1039
1040         if (state == GHOST_kWindowStateMaximized) {
1041                 /*
1042                  * We can't change to Maximized if the window
1043                  * isn't mapped.
1044                  */
1045                 if (cur_state == GHOST_kWindowStateMinimized)
1046                         return (GHOST_kFailure);
1047
1048                 if (is_full == True)
1049                         netwmFullScreen(False);
1050                 if (is_motif_full == True)
1051                         motifFullScreen(False);
1052                 if (is_max == False)
1053                         netwmMaximized(True);
1054                 return (GHOST_kSuccess);
1055         }
1056
1057         if (state == GHOST_kWindowStateMinimized) {
1058                 /*
1059                  * The window manager need save the current state of
1060                  * the window (maximized, full screen, etc).
1061                  */
1062                 icccmSetState(IconicState);
1063                 return (GHOST_kSuccess);
1064         }
1065
1066         return (GHOST_kFailure);
1067 }
1068
1069 #include <iostream>
1070 using namespace std;
1071
1072         GHOST_TSuccess 
1073 GHOST_WindowX11::
1074 setOrder(
1075         GHOST_TWindowOrder order
1076 ){
1077         if (order == GHOST_kWindowOrderTop) {
1078                 XWindowAttributes attr;   
1079                 Atom atom;
1080
1081                 /* We use both XRaiseWindow and _NET_ACTIVE_WINDOW, since some
1082                    window managers ignore the former (e.g. kwin from kde) and others
1083                    don't implement the latter (e.g. fluxbox pre 0.9.9) */
1084
1085                 XRaiseWindow(m_display, m_window);
1086
1087                 atom = XInternAtom(m_display, "_NET_ACTIVE_WINDOW", True);
1088
1089                 if (atom != None) {
1090                         Window root;
1091                         XEvent xev;
1092                         long eventmask;
1093
1094                         xev.xclient.type = ClientMessage;
1095                         xev.xclient.serial = 0;
1096                         xev.xclient.send_event = True;
1097                         xev.xclient.window = m_window;
1098                         xev.xclient.message_type = atom;
1099
1100                         xev.xclient.format = 32;
1101                         xev.xclient.data.l[0] = 1;
1102                         xev.xclient.data.l[1] = CurrentTime;
1103                         xev.xclient.data.l[2] = m_window;
1104                         xev.xclient.data.l[3] = 0;
1105                         xev.xclient.data.l[4] = 0;
1106
1107                         root = RootWindow(m_display, m_visual->screen),
1108                         eventmask = SubstructureRedirectMask | SubstructureNotifyMask;
1109
1110                         XSendEvent(m_display, root, False, eventmask, &xev);
1111                 }
1112
1113                 XGetWindowAttributes(m_display, m_window, &attr);
1114
1115                 /* iconized windows give bad match error */
1116                 if (attr.map_state == IsViewable)
1117                         XSetInputFocus(m_display, m_window, RevertToPointerRoot,
1118                                                  CurrentTime);
1119                 XFlush(m_display);
1120         } else if (order == GHOST_kWindowOrderBottom) {
1121                 XLowerWindow(m_display,m_window);
1122                 XFlush(m_display);
1123         } else {
1124                 return GHOST_kFailure;
1125         }
1126         
1127         return GHOST_kSuccess;
1128 }
1129
1130         GHOST_TSuccess 
1131 GHOST_WindowX11::
1132 swapBuffers(
1133 ){
1134         if (getDrawingContextType() == GHOST_kDrawingContextTypeOpenGL) {
1135                 glXSwapBuffers(m_display,m_window);
1136                 return GHOST_kSuccess;
1137         } else {
1138                 return GHOST_kFailure;
1139         }
1140 }
1141
1142         GHOST_TSuccess 
1143 GHOST_WindowX11::
1144 activateDrawingContext(
1145 ){
1146         if (m_context !=NULL) {
1147                 glXMakeCurrent(m_display, m_window,m_context);                                          
1148                 return GHOST_kSuccess;
1149         } 
1150         return GHOST_kFailure;
1151 }
1152
1153         GHOST_TSuccess 
1154 GHOST_WindowX11::
1155 invalidate(
1156 ){
1157         
1158         // So the idea of this function is to generate an expose event
1159         // for the window.
1160         // Unfortunately X does not handle expose events for you and 
1161         // it is the client's job to refresh the dirty part of the window.
1162         // We need to queue up invalidate calls and generate GHOST events 
1163         // for them in the system.
1164
1165         // We implement this by setting a boolean in this class to concatenate 
1166         // all such calls into a single event for this window.
1167
1168         // At the same time we queue the dirty windows in the system class
1169         // and generate events for them at the next processEvents call.
1170
1171         if (m_invalid_window == false) {
1172                 m_system->addDirtyWindow(this);
1173                 m_invalid_window = true;
1174         } 
1175  
1176         return GHOST_kSuccess;
1177 }
1178
1179 /**
1180  * called by the X11 system implementation when expose events
1181  * for the window have been pushed onto the GHOST queue
1182  */
1183  
1184         void
1185 GHOST_WindowX11::
1186 validate(
1187 ){
1188         m_invalid_window = false;
1189 }       
1190  
1191  
1192 /**
1193  * Destructor.
1194  * Closes the window and disposes resources allocated.
1195  */
1196
1197 GHOST_WindowX11::
1198 ~GHOST_WindowX11(
1199 ){
1200         static Atom Primary_atom, Clipboard_atom;
1201         Window p_owner, c_owner;
1202         /*Change the owner of the Atoms to None if we are the owner*/
1203         Primary_atom = XInternAtom(m_display, "PRIMARY", False);
1204         Clipboard_atom = XInternAtom(m_display, "CLIPBOARD", False);
1205         
1206         p_owner = XGetSelectionOwner(m_display, Primary_atom);
1207         c_owner = XGetSelectionOwner(m_display, Clipboard_atom);
1208         
1209         std::map<unsigned int, Cursor>::iterator it = m_standard_cursors.begin();
1210         for (; it != m_standard_cursors.end(); it++) {
1211                 XFreeCursor(m_display, it->second);
1212         }
1213
1214         if (m_empty_cursor) {
1215                 XFreeCursor(m_display, m_empty_cursor);
1216         }
1217         if (m_custom_cursor) {
1218                 XFreeCursor(m_display, m_custom_cursor);
1219         }
1220         
1221         /* close tablet devices */
1222         if(m_xtablet.StylusDevice)
1223                 XCloseDevice(m_display, m_xtablet.StylusDevice);
1224         
1225         if(m_xtablet.EraserDevice)
1226                 XCloseDevice(m_display, m_xtablet.EraserDevice);
1227         
1228         if (m_context) {
1229                 if (m_context == s_firstContext) {
1230                         s_firstContext = NULL;
1231                 }
1232                 glXDestroyContext(m_display, m_context);
1233         }
1234         
1235         if (p_owner == m_window) {
1236                 XSetSelectionOwner(m_display, Primary_atom, None, CurrentTime);
1237         }
1238         if (c_owner == m_window) {
1239                 XSetSelectionOwner(m_display, Clipboard_atom, None, CurrentTime);
1240         }
1241         
1242         XDestroyWindow(m_display, m_window);
1243         XFree(m_visual);
1244 }
1245
1246
1247
1248
1249 /**
1250  * Tries to install a rendering context in this window.
1251  * @param type  The type of rendering context installed.
1252  * @return Indication as to whether installation has succeeded.
1253  */
1254         GHOST_TSuccess 
1255 GHOST_WindowX11::
1256 installDrawingContext(
1257         GHOST_TDrawingContextType type
1258 ){
1259         // only support openGL for now.
1260         GHOST_TSuccess success;
1261         switch (type) {
1262         case GHOST_kDrawingContextTypeOpenGL:
1263                 m_context = glXCreateContext(m_display, m_visual, s_firstContext, True);
1264                 if (m_context !=NULL) {
1265                         if (!s_firstContext) {
1266                                 s_firstContext = m_context;
1267                         }
1268                         glXMakeCurrent(m_display, m_window,m_context);                                          
1269                         success = GHOST_kSuccess;
1270                 } else {
1271                         success = GHOST_kFailure;
1272                 }
1273
1274                 break;
1275
1276         case GHOST_kDrawingContextTypeNone:
1277                 success = GHOST_kSuccess;
1278                 break;
1279
1280         default:
1281                 success = GHOST_kFailure;
1282         }
1283         return success;
1284 }
1285
1286
1287
1288 /**
1289  * Removes the current drawing context.
1290  * @return Indication as to whether removal has succeeded.
1291  */
1292         GHOST_TSuccess 
1293 GHOST_WindowX11::
1294 removeDrawingContext(
1295 ){
1296         GHOST_TSuccess success;
1297
1298         if (m_context != NULL) {
1299                 glXDestroyContext(m_display, m_context);
1300                 success = GHOST_kSuccess;
1301         } else {
1302                 success = GHOST_kFailure;
1303         }
1304         return success; 
1305 }
1306
1307
1308         Cursor
1309 GHOST_WindowX11::
1310 getStandardCursor(
1311         GHOST_TStandardCursor g_cursor
1312 ){
1313         unsigned int xcursor_id;
1314
1315 #define GtoX(gcurs, xcurs)      case gcurs: xcursor_id = xcurs
1316         switch (g_cursor) {
1317         GtoX(GHOST_kStandardCursorRightArrow, XC_arrow); break;
1318         GtoX(GHOST_kStandardCursorLeftArrow, XC_top_left_arrow); break;
1319         GtoX(GHOST_kStandardCursorInfo, XC_hand1); break;
1320         GtoX(GHOST_kStandardCursorDestroy, XC_pirate); break;
1321         GtoX(GHOST_kStandardCursorHelp, XC_question_arrow); break; 
1322         GtoX(GHOST_kStandardCursorCycle, XC_exchange); break;
1323         GtoX(GHOST_kStandardCursorSpray, XC_spraycan); break;
1324         GtoX(GHOST_kStandardCursorWait, XC_watch); break;
1325         GtoX(GHOST_kStandardCursorText, XC_xterm); break;
1326         GtoX(GHOST_kStandardCursorCrosshair, XC_crosshair); break;
1327         GtoX(GHOST_kStandardCursorUpDown, XC_sb_v_double_arrow); break;
1328         GtoX(GHOST_kStandardCursorLeftRight, XC_sb_h_double_arrow); break;
1329         GtoX(GHOST_kStandardCursorTopSide, XC_top_side); break;
1330         GtoX(GHOST_kStandardCursorBottomSide, XC_bottom_side); break;
1331         GtoX(GHOST_kStandardCursorLeftSide, XC_left_side); break;
1332         GtoX(GHOST_kStandardCursorRightSide, XC_right_side); break;
1333         GtoX(GHOST_kStandardCursorTopLeftCorner, XC_top_left_corner); break;
1334         GtoX(GHOST_kStandardCursorTopRightCorner, XC_top_right_corner); break;
1335         GtoX(GHOST_kStandardCursorBottomRightCorner, XC_bottom_right_corner); break;
1336         GtoX(GHOST_kStandardCursorBottomLeftCorner, XC_bottom_left_corner); break;
1337         GtoX(GHOST_kStandardCursorPencil, XC_pencil); break;
1338         default:
1339                 xcursor_id = 0;
1340         }
1341 #undef GtoX
1342
1343         if (xcursor_id) {
1344                 Cursor xcursor = m_standard_cursors[xcursor_id];
1345                 
1346                 if (!xcursor) {
1347                         xcursor = XCreateFontCursor(m_display, xcursor_id);
1348
1349                         m_standard_cursors[xcursor_id] = xcursor;
1350                 }
1351                 
1352                 return xcursor;
1353         } else {
1354                 return None;
1355         }
1356 }
1357
1358         Cursor 
1359 GHOST_WindowX11::
1360 getEmptyCursor(
1361 ) {
1362         if (!m_empty_cursor) {
1363                 Pixmap blank;
1364                 XColor dummy;
1365                 char data[1] = {0};
1366                         
1367                 /* make a blank cursor */
1368                 blank = XCreateBitmapFromData (
1369                         m_display, 
1370                         RootWindow(m_display,DefaultScreen(m_display)),
1371                         data, 1, 1
1372                 );
1373
1374                 m_empty_cursor = XCreatePixmapCursor(m_display, blank, blank, &dummy, &dummy, 0, 0);
1375                 XFreePixmap(m_display, blank);
1376         }
1377
1378         return m_empty_cursor;
1379 }
1380
1381         GHOST_TSuccess
1382 GHOST_WindowX11::
1383 setWindowCursorVisibility(
1384         bool visible
1385 ){
1386         Cursor xcursor;
1387         
1388         if (visible) {
1389                 xcursor = getStandardCursor( getCursorShape() );
1390         } else {
1391                 xcursor = getEmptyCursor();
1392         }
1393
1394         XDefineCursor(m_display, m_window, xcursor);
1395         XFlush(m_display);
1396         
1397         return GHOST_kSuccess;
1398 }
1399
1400         GHOST_TSuccess
1401 GHOST_WindowX11::
1402 setWindowCursorGrab(
1403         bool grab
1404 ){
1405         if(grab)
1406                 XGrabPointer(m_display, m_window, True, ButtonPressMask| ButtonReleaseMask|PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime);
1407         else
1408                 XUngrabPointer(m_display, CurrentTime);
1409
1410         XFlush(m_display);
1411         
1412         return GHOST_kSuccess;
1413 }
1414
1415         GHOST_TSuccess
1416 GHOST_WindowX11::
1417 setWindowCursorShape(
1418         GHOST_TStandardCursor shape
1419 ){
1420         Cursor xcursor = getStandardCursor( shape );
1421         
1422         XDefineCursor(m_display, m_window, xcursor);
1423         XFlush(m_display);
1424
1425         return GHOST_kSuccess;
1426 }
1427
1428         GHOST_TSuccess
1429 GHOST_WindowX11::
1430 setWindowCustomCursorShape(
1431         GHOST_TUns8 bitmap[16][2], 
1432         GHOST_TUns8 mask[16][2], 
1433         int hotX, 
1434         int hotY
1435 ){
1436
1437 setWindowCustomCursorShape((GHOST_TUns8*)bitmap, (GHOST_TUns8*)mask, 
1438                                                                         16, 16, hotX, hotY, 0, 1);
1439         return GHOST_kSuccess;
1440 }
1441
1442         GHOST_TSuccess
1443 GHOST_WindowX11::
1444 setWindowCustomCursorShape(     
1445         GHOST_TUns8 *bitmap, 
1446         GHOST_TUns8 *mask, 
1447         int sizex, 
1448         int sizey, 
1449         int hotX, 
1450         int hotY, 
1451         int fg_color, 
1452         int bg_color
1453 ){
1454         Colormap colormap= DefaultColormap(m_display, DefaultScreen(m_display));
1455         Pixmap bitmap_pix, mask_pix;
1456         XColor fg, bg;
1457         
1458         if(XAllocNamedColor(m_display, colormap, "White", &fg, &fg) == 0) return GHOST_kFailure;
1459         if(XAllocNamedColor(m_display, colormap, "Black", &bg, &bg) == 0) return GHOST_kFailure;
1460
1461         if (m_custom_cursor) {
1462                 XFreeCursor(m_display, m_custom_cursor);
1463         }
1464
1465         bitmap_pix = XCreateBitmapFromData(m_display, m_window, (char*) bitmap, sizex, sizey);
1466         mask_pix = XCreateBitmapFromData(m_display, m_window, (char*) mask, sizex, sizey);
1467                 
1468         m_custom_cursor = XCreatePixmapCursor(m_display, bitmap_pix, mask_pix, &fg, &bg, hotX, hotY);
1469         XDefineCursor(m_display, m_window, m_custom_cursor);
1470         XFlush(m_display);
1471         
1472         XFreePixmap(m_display, bitmap_pix);
1473         XFreePixmap(m_display, mask_pix);
1474
1475     XFreeColors(m_display, colormap, &fg.pixel, 1, 0L);
1476     XFreeColors(m_display, colormap, &bg.pixel, 1, 0L);
1477
1478         return GHOST_kSuccess;
1479 }
1480
1481 /*
1482
1483 void glutCustomCursor(char *data1, char *data2, int size)
1484 {
1485         Pixmap source, mask;
1486         Cursor cursor;
1487         XColor fg, bg;
1488         
1489         if(XAllocNamedColor(__glutDisplay, DefaultColormap(__glutDisplay, __glutScreen),
1490                 "White", &fg, &fg) == 0) return;
1491         if(XAllocNamedColor(__glutDisplay, DefaultColormap(__glutDisplay, __glutScreen),
1492                 "Red", &bg, &bg) == 0) return;
1493
1494
1495         source= XCreateBitmapFromData(__glutDisplay, xdraw, data2, size, size);
1496         mask= XCreateBitmapFromData(__glutDisplay, xdraw, data1, size, size);
1497                 
1498         cursor= XCreatePixmapCursor(__glutDisplay, source, mask, &fg, &bg, 7, 7);
1499                 
1500         XFreePixmap(__glutDisplay, source);
1501         XFreePixmap(__glutDisplay, mask);
1502                 
1503         XDefineCursor(__glutDisplay, xdraw, cursor);
1504 }
1505
1506 */