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