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