author  Sam Lantinga <slouken@libsdl.org> 
Fri, 02 Jan 2009 17:39:48 +0000  
changeset 2967  e4a469d6ddab 
parent 2945  e38423786728 
child 2990  502adab079a4 
permissions  rwrr 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

1 
/* 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

2 
SDL  Simple DirectMedia Layer 
2859  3 
Copyright (C) 19972009 Sam Lantinga 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

4 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

5 
This library is free software; you can redistribute it and/or 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

6 
modify it under the terms of the GNU Lesser General Public 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

7 
License as published by the Free Software Foundation; either 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

8 
version 2.1 of the License, or (at your option) any later version. 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

9 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

10 
This library is distributed in the hope that it will be useful, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

11 
but WITHOUT ANY WARRANTY; without even the implied warranty of 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

12 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

13 
Lesser General Public License for more details. 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

14 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

15 
You should have received a copy of the GNU Lesser General Public 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

16 
License along with this library; if not, write to the Free Software 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

17 
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 021101301 USA 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

18 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

19 
Sam Lantinga 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

20 
slouken@libsdl.org 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

21 
*/ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

22 
#include "SDL_config.h" 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

23 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

24 
#include "SDL_syswm.h" 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

25 
#include "../SDL_sysvideo.h" 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

26 
#include "../../events/SDL_keyboard_c.h" 
2940
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

27 
#include "../../events/SDL_mouse_c.h" 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

28 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

29 
#include "SDL_x11video.h" 
2940
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

30 
#include "SDL_x11mouse.h" 
2185
2032348afed1
This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents:
2143
diff
changeset

31 
#include "../Xext/extensions/StdCmap.h" 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

32 

2931
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

33 
static void 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

34 
X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h) 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

35 
{ 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

36 
SDL_VideoData *data = (SDL_VideoData *) _this>driverdata; 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

37 
SDL_DisplayData *displaydata = 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

38 
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)>driverdata; 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

39 
XWindowAttributes attr; 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

40 

e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

41 
XGetWindowAttributes(data>display, RootWindow(data>display, 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

42 
displaydata>screen), 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

43 
&attr); 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

44 
if (w) { 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

45 
*w = attr.width; 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

46 
} 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

47 
if (h) { 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

48 
*h = attr.height; 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

49 
} 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

50 
} 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

51 

1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

52 
static int 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

53 
SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

54 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

55 
SDL_VideoData *videodata = (SDL_VideoData *) _this>driverdata; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

56 
SDL_WindowData *data; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

57 
int numwindows = videodata>numwindows; 
2324
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

58 
int windowlistlength = videodata>windowlistlength; 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

59 
SDL_WindowData **windowlist = videodata>windowlist; 
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset

60 
int index; 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

61 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

62 
/* Allocate the window data */ 
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset

63 
data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data)); 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

64 
if (!data) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

65 
SDL_OutOfMemory(); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

66 
return 1; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

67 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

68 
data>windowID = window>id; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

69 
data>window = w; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

70 
#ifdef X_HAVE_UTF8_STRING 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

71 
if (SDL_X11_HAVE_UTF8) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

72 
data>ic = 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

73 
pXCreateIC(videodata>im, XNClientWindow, w, XNFocusWindow, w, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

74 
XNInputStyle, XIMPreeditNothing  XIMStatusNothing, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

75 
XNResourceName, videodata>classname, XNResourceClass, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

76 
videodata>classname, NULL); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

77 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

78 
#endif 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

79 
data>created = created; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

80 
data>videodata = videodata; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

81 

2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset

82 
/* Associate the data with the window */ 
2324
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

83 

3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

84 
if (numwindows < windowlistlength) { 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

85 
windowlist[numwindows] = data; 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

86 
videodata>numwindows++; 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

87 
} else { 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

88 
windowlist = 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

89 
(SDL_WindowData **) SDL_realloc(windowlist, 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

90 
(numwindows + 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

91 
1) * sizeof(*windowlist)); 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

92 
if (!windowlist) { 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

93 
SDL_OutOfMemory(); 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

94 
SDL_free(data); 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

95 
return 1; 
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset

96 
} 
2324
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

97 
windowlist[numwindows] = data; 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

98 
videodata>numwindows++; 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

99 
videodata>windowlistlength++; 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

100 
videodata>windowlist = windowlist; 
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset

101 
} 
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset

102 

1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

103 
/* Fill in the SDL window with the window data */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

104 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

105 
XWindowAttributes attrib; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

106 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

107 
XGetWindowAttributes(data>videodata>display, w, &attrib); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

108 
window>x = attrib.x; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

109 
window>y = attrib.y; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

110 
window>w = attrib.width; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

111 
window>h = attrib.height; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

112 
if (attrib.map_state != IsUnmapped) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

113 
window>flags = SDL_WINDOW_SHOWN; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

114 
} else { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

115 
window>flags &= ~SDL_WINDOW_SHOWN; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

116 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

117 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

118 
/* FIXME: How can I tell? 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

119 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

120 
DWORD style = GetWindowLong(hwnd, GWL_STYLE); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

121 
if (style & WS_VISIBLE) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

122 
if (style & (WS_BORDER  WS_THICKFRAME)) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

123 
window>flags &= ~SDL_WINDOW_BORDERLESS; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

124 
} else { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

125 
window>flags = SDL_WINDOW_BORDERLESS; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

126 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

127 
if (style & WS_THICKFRAME) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

128 
window>flags = SDL_WINDOW_RESIZABLE; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

129 
} else { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

130 
window>flags &= ~SDL_WINDOW_RESIZABLE; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

131 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

132 
if (style & WS_MAXIMIZE) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

133 
window>flags = SDL_WINDOW_MAXIMIZED; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

134 
} else { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

135 
window>flags &= ~SDL_WINDOW_MAXIMIZED; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

136 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

137 
if (style & WS_MINIMIZE) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

138 
window>flags = SDL_WINDOW_MINIMIZED; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

139 
} else { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

140 
window>flags &= ~SDL_WINDOW_MINIMIZED; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

141 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

142 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

143 
if (GetFocus() == hwnd) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

144 
int index = data>videodata>keyboard; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

145 
window>flags = SDL_WINDOW_INPUT_FOCUS; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

146 
SDL_SetKeyboardFocus(index, data>windowID); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

147 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

148 
if (window>flags & SDL_WINDOW_INPUT_GRABBED) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

149 
RECT rect; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

150 
GetClientRect(hwnd, &rect); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

151 
ClientToScreen(hwnd, (LPPOINT) & rect); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

152 
ClientToScreen(hwnd, (LPPOINT) & rect + 1); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

153 
ClipCursor(&rect); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

154 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

155 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

156 
*/ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

157 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

158 
/* All done! */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

159 
window>driverdata = data; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

160 
return 0; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

161 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

162 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

163 
int 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

164 
X11_CreateWindow(_THIS, SDL_Window * window) 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

165 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

166 
SDL_VideoData *data = (SDL_VideoData *) _this>driverdata; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

167 
SDL_DisplayData *displaydata = 
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

168 
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)>driverdata; 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

169 
Visual *visual; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

170 
int depth; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

171 
XSetWindowAttributes xattr; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

172 
int x, y; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

173 
Window w; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

174 
XSizeHints *sizehints; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

175 
XWMHints *wmhints; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

176 
XClassHint *classhints; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

177 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

178 
#if SDL_VIDEO_DRIVER_X11_XINERAMA 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

179 
/* FIXME 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

180 
if ( use_xinerama ) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

181 
x = xinerama_info.x_org; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

182 
y = xinerama_info.y_org; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

183 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

184 
*/ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

185 
#endif 
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

186 
#ifdef SDL_VIDEO_OPENGL_GLX 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

187 
if (window>flags & SDL_WINDOW_OPENGL) { 
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

188 
XVisualInfo *vinfo; 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

189 

420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

190 
if (X11_GL_Initialize(_this) < 0) { 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

191 
return 1; 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

192 
} 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

193 
vinfo = X11_GL_GetVisual(_this, data>display, displaydata>screen); 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

194 
if (!vinfo) { 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

195 
return 1; 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

196 
} 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

197 
visual = vinfo>visual; 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

198 
depth = vinfo>depth; 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

199 
XFree(vinfo); 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

200 
} else 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

201 
#endif 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

202 
{ 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

203 
visual = displaydata>visual; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

204 
depth = displaydata>depth; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

205 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

206 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

207 
if (window>flags & SDL_WINDOW_FULLSCREEN) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

208 
xattr.override_redirect = True; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

209 
} else { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

210 
xattr.override_redirect = False; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

211 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

212 
xattr.background_pixel = 0; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

213 
xattr.border_pixel = 0; 
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

214 

2945
e38423786728
Fixed DirectColor visual window creation problem
Sam Lantinga <slouken@libsdl.org>
parents:
2942
diff
changeset

215 
if (visual>class == PseudoColor) { 
2185
2032348afed1
This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents:
2143
diff
changeset

216 
int nmaps; 
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

217 
XStandardColormap cmap; 
2185
2032348afed1
This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents:
2143
diff
changeset

218 
XStandardColormap *stdmaps; 
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

219 
XColor *colorcells; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

220 
Colormap colormap; 
2185
2032348afed1
This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents:
2143
diff
changeset

221 
Bool found = False; 
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

222 
int i; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

223 
int ncolors; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

224 
int rmax, gmax, bmax; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

225 
int rmul, gmul, bmul; 
2185
2032348afed1
This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents:
2143
diff
changeset

226 

2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

227 
if (colormap = 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

228 
X11_LookupColormap(data>display, displaydata>screen, 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

229 
visual>visualid)) { 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

230 
xattr.colormap = colormap; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

231 
} else { 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

232 
/* check to see if the colormap we need already exists */ 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

233 
if (0 != XGetRGBColormaps(data>display, 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

234 
RootWindow(data>display, 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

235 
displaydata>screen), 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

236 
&stdmaps, &nmaps, XA_RGB_BEST_MAP)) { 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

237 
for (i = 0; i < nmaps; i++) { 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

238 
if (stdmaps[i].visualid == visual>visualid) { 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

239 
SDL_memcpy(&cmap, &stdmaps[i], 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

240 
sizeof(XStandardColormap)); 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

241 
found = True; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

242 
break; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

243 
} 
2185
2032348afed1
This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents:
2143
diff
changeset

244 
} 
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

245 
XFree(stdmaps); 
2185
2032348afed1
This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents:
2143
diff
changeset

246 
} 
2213  247 

2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

248 
/* it doesn't exist, so create it */ 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

249 
if (!found) { 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

250 
int max = visual>map_entries  1; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

251 
stdmaps = 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

252 
XmuStandardColormap(data>display, displaydata>screen, 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

253 
visual>visualid, depth, 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

254 
XA_RGB_BEST_MAP, None, max, max, max); 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

255 
if (NULL == stdmaps  stdmaps>visualid != visual>visualid) { 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

256 
SDL_SetError 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

257 
("Couldn't create window:XA_RGB_BEST_MAP not found and could not be created"); 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

258 
return 1; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

259 
} 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

260 
SDL_memcpy(&cmap, stdmaps, sizeof(XStandardColormap)); 
2322  261 
XFree(stdmaps); 
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

262 
} 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

263 

e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

264 
/* OK, we have the best color map, now copy it for use by the 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

265 
program */ 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

266 

e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

267 
colorcells = SDL_malloc(visual>map_entries * sizeof(XColor)); 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

268 
if (NULL == colorcells) { 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

269 
SDL_SetError("out of memory in X11_CreateWindow"); 
2185
2032348afed1
This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents:
2143
diff
changeset

270 
return 1; 
2032348afed1
This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents:
2143
diff
changeset

271 
} 
2214
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

272 
ncolors = visual>map_entries; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

273 
rmax = cmap.red_max + 1; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

274 
gmax = cmap.blue_max + 1; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

275 
bmax = cmap.green_max + 1; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

276 

e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

277 
rmul = cmap.red_mult; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

278 
gmul = cmap.blue_mult; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

279 
bmul = cmap.green_mult; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

280 

e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

281 
/* build the color table pixel values */ 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

282 
for (i = 0; i < ncolors; i++) { 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

283 
Uint32 red = (rmax * i) / ncolors; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

284 
Uint32 green = (gmax * i) / ncolors; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

285 
Uint32 blue = (bmax * i) / ncolors; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

286 

e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

287 
colorcells[i].pixel = 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

288 
(red * rmul)  (green * gmul)  (blue * bmul); 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

289 
} 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

290 
XQueryColors(data>display, cmap.colormap, colorcells, ncolors); 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

291 
colormap = XCreateColormap(data>display, 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

292 
RootWindow(data>display, 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

293 
displaydata>screen), 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

294 
visual, AllocAll); 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

295 
XStoreColors(data>display, colormap, colorcells, ncolors); 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

296 
SDL_free(colorcells); 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

297 

e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

298 
xattr.colormap = colormap; 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

299 
X11_TrackColormap(data>display, displaydata>screen, colormap, 
e7164a4dac62
Added gamma table support to X11. Also now supports DirectColor visuals.
Bob Pendleton <bob@pendleton.com>
parents:
2213
diff
changeset

300 
&cmap, visual); 
2185
2032348afed1
This code adds support for DirectColor visuals to SDL 1.3. The support uses part of the Xmu library. To ensure that the library is
Bob Pendleton <bob@pendleton.com>
parents:
2143
diff
changeset

301 
} 
2945
e38423786728
Fixed DirectColor visual window creation problem
Sam Lantinga <slouken@libsdl.org>
parents:
2942
diff
changeset

302 
} else if (visual>class == DirectColor) { 
e38423786728
Fixed DirectColor visual window creation problem
Sam Lantinga <slouken@libsdl.org>
parents:
2942
diff
changeset

303 
/* FIXME: Allocate a readwrite colormap for gamma fading someday */ 
e38423786728
Fixed DirectColor visual window creation problem
Sam Lantinga <slouken@libsdl.org>
parents:
2942
diff
changeset

304 
xattr.colormap = 
e38423786728
Fixed DirectColor visual window creation problem
Sam Lantinga <slouken@libsdl.org>
parents:
2942
diff
changeset

305 
XCreateColormap(data>display, 
e38423786728
Fixed DirectColor visual window creation problem
Sam Lantinga <slouken@libsdl.org>
parents:
2942
diff
changeset

306 
RootWindow(data>display, displaydata>screen), 
e38423786728
Fixed DirectColor visual window creation problem
Sam Lantinga <slouken@libsdl.org>
parents:
2942
diff
changeset

307 
visual, AllocNone); 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

308 
} else { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

309 
xattr.colormap = 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

310 
XCreateColormap(data>display, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

311 
RootWindow(data>display, displaydata>screen), 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

312 
visual, AllocNone); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

313 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

314 

2876  315 
if ((window>flags & SDL_WINDOW_FULLSCREEN) 
316 
 window>x == SDL_WINDOWPOS_CENTERED) { 

2931
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

317 
X11_GetDisplaySize(_this, window, &x, NULL); 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

318 
x = (x  window>w) / 2; 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

319 
} else if (window>x == SDL_WINDOWPOS_UNDEFINED) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

320 
x = 0; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

321 
} else { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

322 
x = window>x; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

323 
} 
2876  324 
if ((window>flags & SDL_WINDOW_FULLSCREEN) 
325 
 window>y == SDL_WINDOWPOS_CENTERED) { 

2931
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

326 
X11_GetDisplaySize(_this, window, NULL, &y); 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

327 
y = (y  window>h) / 2; 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

328 
} else if (window>y == SDL_WINDOWPOS_UNDEFINED) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

329 
y = 0; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

330 
} else { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

331 
y = window>y; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

332 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

333 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

334 
w = XCreateWindow(data>display, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

335 
RootWindow(data>display, displaydata>screen), x, y, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

336 
window>w, window>h, 0, depth, InputOutput, visual, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

337 
(CWOverrideRedirect  CWBackPixel  CWBorderPixel  
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

338 
CWColormap), &xattr); 
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

339 
if (!w) { 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

340 
#ifdef SDL_VIDEO_OPENGL_GLX 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

341 
if (window>flags & SDL_WINDOW_OPENGL) { 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

342 
X11_GL_Shutdown(_this); 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

343 
} 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

344 
#endif 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

345 
SDL_SetError("Couldn't create window"); 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

346 
return 1; 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

347 
} 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

348 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

349 
sizehints = XAllocSizeHints(); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

350 
if (sizehints) { 
2876  351 
if ((window>flags & SDL_WINDOW_RESIZABLE) 
352 
&& !(window>flags & SDL_WINDOW_FULLSCREEN)) { 

1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

353 
sizehints>min_width = 32; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

354 
sizehints>min_height = 32; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

355 
sizehints>max_height = 4096; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

356 
sizehints>max_width = 4096; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

357 
} else { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

358 
sizehints>min_width = sizehints>max_width = window>w; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

359 
sizehints>min_height = sizehints>max_height = window>h; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

360 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

361 
sizehints>flags = PMaxSize  PMinSize; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

362 
if (!(window>flags & SDL_WINDOW_FULLSCREEN) 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

363 
&& window>x != SDL_WINDOWPOS_UNDEFINED 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

364 
&& window>y != SDL_WINDOWPOS_UNDEFINED) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

365 
sizehints>x = x; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

366 
sizehints>y = y; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

367 
sizehints>flags = USPosition; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

368 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

369 
XSetWMNormalHints(data>display, w, sizehints); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

370 
XFree(sizehints); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

371 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

372 

2876  373 
if (window>flags & (SDL_WINDOW_BORDERLESS  SDL_WINDOW_FULLSCREEN)) { 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

374 
SDL_bool set; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

375 
Atom WM_HINTS; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

376 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

377 
/* We haven't modified the window manager hints yet */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

378 
set = SDL_FALSE; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

379 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

380 
/* First try to set MWM hints */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

381 
WM_HINTS = XInternAtom(data>display, "_MOTIF_WM_HINTS", True); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

382 
if (WM_HINTS != None) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

383 
/* Hints used by Motif compliant window managers */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

384 
struct 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

385 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

386 
unsigned long flags; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

387 
unsigned long functions; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

388 
unsigned long decorations; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

389 
long input_mode; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

390 
unsigned long status; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

391 
} MWMHints = { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

392 
(1L << 1), 0, 0, 0, 0}; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

393 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

394 
XChangeProperty(data>display, w, WM_HINTS, WM_HINTS, 32, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

395 
PropModeReplace, (unsigned char *) &MWMHints, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

396 
sizeof(MWMHints) / sizeof(long)); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

397 
set = SDL_TRUE; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

398 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

399 
/* Now try to set KWM hints */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

400 
WM_HINTS = XInternAtom(data>display, "KWM_WIN_DECORATION", True); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

401 
if (WM_HINTS != None) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

402 
long KWMHints = 0; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

403 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

404 
XChangeProperty(data>display, w, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

405 
WM_HINTS, WM_HINTS, 32, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

406 
PropModeReplace, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

407 
(unsigned char *) &KWMHints, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

408 
sizeof(KWMHints) / sizeof(long)); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

409 
set = SDL_TRUE; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

410 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

411 
/* Now try to set GNOME hints */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

412 
WM_HINTS = XInternAtom(data>display, "_WIN_HINTS", True); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

413 
if (WM_HINTS != None) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

414 
long GNOMEHints = 0; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

415 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

416 
XChangeProperty(data>display, w, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

417 
WM_HINTS, WM_HINTS, 32, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

418 
PropModeReplace, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

419 
(unsigned char *) &GNOMEHints, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

420 
sizeof(GNOMEHints) / sizeof(long)); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

421 
set = SDL_TRUE; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

422 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

423 
/* Finally set the transient hints if necessary */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

424 
if (!set) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

425 
XSetTransientForHint(data>display, w, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

426 
RootWindow(data>display, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

427 
displaydata>screen)); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

428 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

429 
} else { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

430 
SDL_bool set; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

431 
Atom WM_HINTS; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

432 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

433 
/* We haven't modified the window manager hints yet */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

434 
set = SDL_FALSE; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

435 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

436 
/* First try to unset MWM hints */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

437 
WM_HINTS = XInternAtom(data>display, "_MOTIF_WM_HINTS", True); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

438 
if (WM_HINTS != None) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

439 
XDeleteProperty(data>display, w, WM_HINTS); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

440 
set = SDL_TRUE; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

441 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

442 
/* Now try to unset KWM hints */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

443 
WM_HINTS = XInternAtom(data>display, "KWM_WIN_DECORATION", True); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

444 
if (WM_HINTS != None) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

445 
XDeleteProperty(data>display, w, WM_HINTS); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

446 
set = SDL_TRUE; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

447 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

448 
/* Now try to unset GNOME hints */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

449 
WM_HINTS = XInternAtom(data>display, "_WIN_HINTS", True); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

450 
if (WM_HINTS != None) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

451 
XDeleteProperty(data>display, w, WM_HINTS); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

452 
set = SDL_TRUE; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

453 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

454 
/* Finally unset the transient hints if necessary */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

455 
if (!set) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

456 
/* NOTE: Does this work? */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

457 
XSetTransientForHint(data>display, w, None); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

458 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

459 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

460 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

461 
/* Tell KDE to keep fullscreen windows on top */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

462 
if (window>flags & SDL_WINDOW_FULLSCREEN) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

463 
XEvent ev; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

464 
long mask; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

465 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

466 
SDL_zero(ev); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

467 
ev.xclient.type = ClientMessage; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

468 
ev.xclient.window = RootWindow(data>display, displaydata>screen); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

469 
ev.xclient.message_type = 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

470 
XInternAtom(data>display, "KWM_KEEP_ON_TOP", False); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

471 
ev.xclient.format = 32; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

472 
ev.xclient.data.l[0] = w; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

473 
ev.xclient.data.l[1] = CurrentTime; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

474 
XSendEvent(data>display, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

475 
RootWindow(data>display, displaydata>screen), False, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

476 
SubstructureRedirectMask, &ev); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

477 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

478 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

479 
/* Set the input hints so we get keyboard input */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

480 
wmhints = XAllocWMHints(); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

481 
if (wmhints) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

482 
wmhints>input = True; 
1956
ba0d62354872
Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents:
1952
diff
changeset

483 
wmhints>flags = InputHint; 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

484 
XSetWMHints(data>display, w, wmhints); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

485 
XFree(wmhints); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

486 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

487 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

488 
/* Set the class hints so we can get an icon (AfterStep) */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

489 
classhints = XAllocClassHint(); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

490 
if (classhints != NULL) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

491 
classhints>res_name = data>classname; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

492 
classhints>res_class = data>classname; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

493 
XSetClassHint(data>display, w, classhints); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

494 
XFree(classhints); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

495 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

496 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

497 
/* Allow the window to be deleted by the window manager */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

498 
XSetWMProtocols(data>display, w, &data>WM_DELETE_WINDOW, 1); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

499 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

500 
if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) { 
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

501 
#ifdef SDL_VIDEO_OPENGL_GLX 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

502 
if (window>flags & SDL_WINDOW_OPENGL) { 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

503 
X11_GL_Shutdown(_this); 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

504 
} 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

505 
#endif 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

506 
XDestroyWindow(data>display, w); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

507 
return 1; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

508 
} 
2325
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset

509 
#ifdef X_HAVE_UTF8_STRING 
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset

510 
{ 
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset

511 
Uint32 fevent = 0; 
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset

512 
pXGetICValues(((SDL_WindowData *) window>driverdata)>ic, 
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset

513 
XNFilterEvents, &fevent, NULL); 
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset

514 
XSelectInput(data>display, w, 
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset

515 
(FocusChangeMask  EnterWindowMask  LeaveWindowMask  
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset

516 
ExposureMask  ButtonPressMask  ButtonReleaseMask  
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset

517 
PointerMotionMask  KeyPressMask  KeyReleaseMask  
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset

518 
PropertyChangeMask  StructureNotifyMask  
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset

519 
KeymapStateMask  fevent)); 
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset

520 
} 
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset

521 
#else 
2718
abacf2555bb4
Removed unneccesary code lines. Fixed mousename bug. Added lacking code in mousebutton
Szymon Wilczek <kazeuser@gmail.com>
parents:
2710
diff
changeset

522 
{ 
abacf2555bb4
Removed unneccesary code lines. Fixed mousename bug. Added lacking code in mousebutton
Szymon Wilczek <kazeuser@gmail.com>
parents:
2710
diff
changeset

523 
XSelectInput(data>display, w, 
2725  524 
(FocusChangeMask  EnterWindowMask  LeaveWindowMask  
525 
ExposureMask  ButtonPressMask  ButtonReleaseMask  

526 
PointerMotionMask  KeyPressMask  KeyReleaseMask  

527 
PropertyChangeMask  StructureNotifyMask  

528 
KeymapStateMask)); 

2718
abacf2555bb4
Removed unneccesary code lines. Fixed mousename bug. Added lacking code in mousebutton
Szymon Wilczek <kazeuser@gmail.com>
parents:
2710
diff
changeset

529 
} 
2325
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset

530 
#endif 
c7bcf84ba1b9
Next version of internationalized input for X11. On my machine (famous last words :) with a US English keyboard and locale I can compose ` and e and get a text
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset

531 

2940
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

532 
#if SDL_VIDEO_DRIVER_X11_XINPUT 
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2325
diff
changeset

533 
/* we're informing the display what extension events we want to receive from it */ 
2940
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

534 
{ 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

535 
int i, j, n = 0; 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

536 
XEventClass xevents[256]; 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

537 

b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

538 
for (i = 0; i < SDL_GetNumMice(); ++i) { 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

539 
SDL_Mouse *mouse; 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

540 
X11_MouseData *data; 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

541 

b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

542 
mouse = SDL_GetMouse(i); 
2942  543 
data = (X11_MouseData *) mouse>driverdata; 
2940
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

544 
if (!data) { 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

545 
continue; 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

546 
} 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

547 

b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

548 
for (j = 0; j < data>num_xevents; ++j) { 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

549 
xevents[n++] = data>xevents[j]; 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

550 
} 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

551 
} 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

552 
if (n > 0) { 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

553 
XSelectExtensionEvent(data>display, w, xevents, n); 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

554 
} 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

555 
} 
b93965a16fe0
Fixed X11 mouse motion/button events  it's not actually safe to cast mouse events to device events.
Sam Lantinga <slouken@libsdl.org>
parents:
2931
diff
changeset

556 
#endif 
2710
44e49d3fa6cf
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
2325
diff
changeset

557 

1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

558 
return 0; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

559 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

560 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

561 
int 
2324
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

562 
X11_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

563 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

564 
Window w = (Window) data; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

565 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

566 
/* FIXME: Query the title from the existing window */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

567 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

568 
if (SetupWindowData(_this, window, w, SDL_FALSE) < 0) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

569 
return 1; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

570 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

571 
return 0; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

572 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

573 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

574 
void 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

575 
X11_SetWindowTitle(_THIS, SDL_Window * window) 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

576 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

577 
SDL_WindowData *data = (SDL_WindowData *) window>driverdata; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

578 
Display *display = data>videodata>display; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

579 
XTextProperty titleprop, iconprop; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

580 
Status status; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

581 
const char *title = window>title; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

582 
const char *icon = NULL; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

583 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

584 
#ifdef X_HAVE_UTF8_STRING 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

585 
Atom _NET_WM_NAME = 0; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

586 
Atom _NET_WM_ICON_NAME = 0; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

587 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

588 
/* Look up some useful Atoms */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

589 
if (SDL_X11_HAVE_UTF8) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

590 
_NET_WM_NAME = XInternAtom(display, "_NET_WM_NAME", False); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

591 
_NET_WM_ICON_NAME = XInternAtom(display, "_NET_WM_ICON_NAME", False); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

592 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

593 
#endif 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

594 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

595 
if (title != NULL) { 
2143
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset

596 
char *title_locale = SDL_iconv_utf8_locale(title); 
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset

597 
if (!title_locale) { 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

598 
SDL_OutOfMemory(); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

599 
return; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

600 
} 
2143
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset

601 
status = XStringListToTextProperty(&title_locale, 1, &titleprop); 
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset

602 
SDL_free(title_locale); 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

603 
if (status) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

604 
XSetTextProperty(display, data>window, &titleprop, XA_WM_NAME); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

605 
XFree(titleprop.value); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

606 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

607 
#ifdef X_HAVE_UTF8_STRING 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

608 
if (SDL_X11_HAVE_UTF8) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

609 
status = 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

610 
Xutf8TextListToTextProperty(display, (char **) &title, 1, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

611 
XUTF8StringStyle, &titleprop); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

612 
if (status == Success) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

613 
XSetTextProperty(display, data>window, &titleprop, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

614 
_NET_WM_NAME); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

615 
XFree(titleprop.value); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

616 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

617 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

618 
#endif 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

619 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

620 
if (icon != NULL) { 
2143
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset

621 
char *icon_locale = SDL_iconv_utf8_locale(icon); 
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset

622 
if (!icon_locale) { 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

623 
SDL_OutOfMemory(); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

624 
return; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

625 
} 
2143
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset

626 
status = XStringListToTextProperty(&icon_locale, 1, &iconprop); 
e906da4414a3
Fix for bug #447 merged from SDL 1.2
Sam Lantinga <slouken@libsdl.org>
parents:
1956
diff
changeset

627 
SDL_free(icon_locale); 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

628 
if (status) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

629 
XSetTextProperty(display, data>window, &iconprop, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

630 
XA_WM_ICON_NAME); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

631 
XFree(iconprop.value); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

632 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

633 
#ifdef X_HAVE_UTF8_STRING 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

634 
if (SDL_X11_HAVE_UTF8) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

635 
status = 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

636 
Xutf8TextListToTextProperty(display, (char **) &icon, 1, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

637 
XUTF8StringStyle, &iconprop); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

638 
if (status == Success) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

639 
XSetTextProperty(display, data>window, &iconprop, 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

640 
_NET_WM_ICON_NAME); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

641 
XFree(iconprop.value); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

642 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

643 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

644 
#endif 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

645 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

646 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

647 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

648 
void 
2967
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

649 
X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

650 
{ 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

651 
SDL_WindowData *data = (SDL_WindowData *) window>driverdata; 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

652 
Display *display = data>videodata>display; 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

653 
Atom _NET_WM_ICON = XInternAtom(display, "_NET_WM_ICON", False); 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

654 

e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

655 
if (icon) { 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

656 
SDL_PixelFormat format; 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

657 
SDL_Surface *surface; 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

658 
int propsize; 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

659 
Uint32 *propdata; 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

660 

e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

661 
/* Convert the icon to ARGB for modern window managers */ 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

662 
SDL_InitFormat(&format, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

663 
surface = SDL_ConvertSurface(icon, &format, 0); 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

664 
if (!surface) { 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

665 
return; 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

666 
} 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

667 

e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

668 
/* Set the _NET_WM_ICON property */ 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

669 
propsize = 2+(icon>w*icon>h); 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

670 
propdata = SDL_malloc(propsize * sizeof(Uint32)); 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

671 
if (propdata) { 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

672 
propdata[0] = icon>w; 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

673 
propdata[1] = icon>h; 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

674 
SDL_memcpy(&propdata[2], surface>pixels, surface>h*surface>pitch); 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

675 
XChangeProperty(display, data>window, _NET_WM_ICON, 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

676 
XA_CARDINAL, 32, PropModeReplace, 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

677 
(unsigned char *) propdata, propsize); 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

678 
} 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

679 
SDL_FreeSurface(surface); 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

680 
} else { 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

681 
XDeleteProperty(display, data>window, _NET_WM_ICON); 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

682 
} 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

683 
} 
e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

684 

e4a469d6ddab
Implemented SDL_SetWindowIcon(), with translucent icon support under X11.
Sam Lantinga <slouken@libsdl.org>
parents:
2945
diff
changeset

685 
void 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

686 
X11_SetWindowPosition(_THIS, SDL_Window * window) 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

687 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

688 
SDL_WindowData *data = (SDL_WindowData *) window>driverdata; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

689 
SDL_DisplayData *displaydata = 
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

690 
(SDL_DisplayData *) SDL_GetDisplayFromWindow(window)>driverdata; 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

691 
Display *display = data>videodata>display; 
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

692 
int x, y; 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

693 

2876  694 
if ((window>flags & SDL_WINDOW_FULLSCREEN) 
695 
 window>x == SDL_WINDOWPOS_CENTERED) { 

2931
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

696 
X11_GetDisplaySize(_this, window, &x, NULL); 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

697 
x = (x  window>w) / 2; 
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

698 
} else { 
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

699 
x = window>x; 
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

700 
} 
2876  701 
if ((window>flags & SDL_WINDOW_FULLSCREEN) 
702 
 window>y == SDL_WINDOWPOS_CENTERED) { 

2931
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

703 
X11_GetDisplaySize(_this, window, NULL, &y); 
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

704 
y = (y  window>h) / 2; 
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

705 
} else { 
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

706 
y = window>y; 
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

707 
} 
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

708 
XMoveWindow(display, data>window, x, y); 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

709 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

710 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

711 
void 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

712 
X11_SetWindowSize(_THIS, SDL_Window * window) 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

713 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

714 
SDL_WindowData *data = (SDL_WindowData *) window>driverdata; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

715 
Display *display = data>videodata>display; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

716 

2931
e705adf6f3dc
Date: Mon, 29 Dec 2008 23:29:52 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2876
diff
changeset

717 
XResizeWindow(display, data>window, window>w, window>h); 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

718 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

719 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

720 
void 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

721 
X11_ShowWindow(_THIS, SDL_Window * window) 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

722 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

723 
SDL_WindowData *data = (SDL_WindowData *) window>driverdata; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

724 
Display *display = data>videodata>display; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

725 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

726 
XMapRaised(display, data>window); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

727 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

728 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

729 
void 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

730 
X11_HideWindow(_THIS, SDL_Window * window) 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

731 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

732 
SDL_WindowData *data = (SDL_WindowData *) window>driverdata; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

733 
Display *display = data>videodata>display; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

734 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

735 
XUnmapWindow(display, data>window); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

736 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

737 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

738 
void 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

739 
X11_RaiseWindow(_THIS, SDL_Window * window) 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

740 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

741 
SDL_WindowData *data = (SDL_WindowData *) window>driverdata; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

742 
Display *display = data>videodata>display; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

743 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

744 
XRaiseWindow(display, data>window); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

745 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

746 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

747 
void 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

748 
X11_MaximizeWindow(_THIS, SDL_Window * window) 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

749 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

750 
/* FIXME: is this even possible? */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

751 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

752 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

753 
void 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

754 
X11_MinimizeWindow(_THIS, SDL_Window * window) 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

755 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

756 
X11_HideWindow(_this, window); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

757 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

758 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

759 
void 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

760 
X11_RestoreWindow(_THIS, SDL_Window * window) 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

761 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

762 
X11_ShowWindow(_this, window); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

763 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

764 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

765 
void 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

766 
X11_SetWindowGrab(_THIS, SDL_Window * window) 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

767 
{ 
2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

768 
SDL_WindowData *data = (SDL_WindowData *) window>driverdata; 
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

769 
Display *display = data>videodata>display; 
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

770 

2876  771 
if ((window>flags & (SDL_WINDOW_INPUT_GRABBED  SDL_WINDOW_FULLSCREEN)) 
772 
&& (window>flags & SDL_WINDOW_INPUT_FOCUS)) { 

2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

773 
/* Try to grab the mouse */ 
2876  774 
for (;;) { 
775 
int result = 

776 
XGrabPointer(display, data>window, True, 0, GrabModeAsync, 

777 
GrabModeAsync, data>window, None, CurrentTime); 

778 
if (result == GrabSuccess) { 

2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

779 
break; 
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

780 
} 
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

781 
SDL_Delay(100); 
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

782 
} 
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

783 

91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

784 
/* Raise the window if we grab the mouse */ 
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

785 
XRaiseWindow(display, data>window); 
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

786 

91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

787 
/* Now grab the keyboard */ 
2876  788 
XGrabKeyboard(display, data>window, True, GrabModeAsync, 
789 
GrabModeAsync, CurrentTime); 

2875
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

790 
} else { 
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

791 
XUngrabPointer(display, CurrentTime); 
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

792 
XUngrabKeyboard(display, CurrentTime); 
91a7e08cd238
* Implemented X11 fullscreen input grab
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset

793 
} 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

794 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

795 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

796 
void 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

797 
X11_DestroyWindow(_THIS, SDL_Window * window) 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

798 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

799 
SDL_WindowData *data = (SDL_WindowData *) window>driverdata; 
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset

800 
window>driverdata = NULL; 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

801 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

802 
if (data) { 
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset

803 
SDL_VideoData *videodata = (SDL_VideoData *) data>videodata; 
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset

804 
Display *display = videodata>display; 
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset

805 
int numwindows = videodata>numwindows; 
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset

806 
SDL_WindowData **windowlist = videodata>windowlist; 
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset

807 
int i; 
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset

808 

4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset

809 
if (windowlist) { 
2324
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

810 
for (i = 0; i < numwindows; ++i) { 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

811 
if (windowlist[i] && (windowlist[i]>windowID == window>id)) { 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

812 
windowlist[i] = windowlist[numwindows  1]; 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

813 
windowlist[numwindows  1] = NULL; 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

814 
videodata>numwindows; 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

815 
break; 
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset

816 
} 
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset

817 
} 
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset

818 
} 
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

819 
#ifdef SDL_VIDEO_OPENGL_GLX 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

820 
if (window>flags & SDL_WINDOW_OPENGL) { 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

821 
X11_GL_Shutdown(_this); 
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
1951
diff
changeset

822 
} 
1951
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

823 
#endif 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

824 
#ifdef X_HAVE_UTF8_STRING 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

825 
if (data>ic) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

826 
XDestroyIC(data>ic); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

827 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

828 
#endif 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

829 
if (data>created) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

830 
XDestroyWindow(display, data>window); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

831 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

832 
SDL_free(data); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

833 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

834 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

835 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

836 
SDL_bool 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

837 
X11_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

838 
{ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

839 
if (info>version.major <= SDL_MAJOR_VERSION) { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

840 
/* FIXME! */ 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

841 
return SDL_TRUE; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

842 
} else { 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

843 
SDL_SetError("Application not compiled with SDL %d.%d\n", 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

844 
SDL_MAJOR_VERSION, SDL_MINOR_VERSION); 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

845 
return SDL_FALSE; 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

846 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

847 
} 
7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

848 

7177581dc9fa
Initial work on X11 window code in.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset

849 
/* vi: set ts=4 sw=4 expandtab: */ 