gosu 0.7.33 → 0.7.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. data/Gosu/Async.hpp +10 -8
  2. data/Gosu/Audio.hpp +6 -4
  3. data/Gosu/AutoLink.hpp +0 -0
  4. data/Gosu/Bitmap.hpp +4 -5
  5. data/Gosu/ButtonsX.hpp +1 -1
  6. data/Gosu/Color.hpp +8 -8
  7. data/Gosu/Font.hpp +2 -2
  8. data/Gosu/Graphics.hpp +4 -6
  9. data/Gosu/IO.hpp +11 -4
  10. data/Gosu/Image.hpp +9 -7
  11. data/Gosu/ImageData.hpp +10 -4
  12. data/Gosu/Input.hpp +4 -5
  13. data/Gosu/Sockets.hpp +10 -12
  14. data/Gosu/TR1.hpp +44 -0
  15. data/Gosu/TextInput.hpp +2 -2
  16. data/Gosu/Version.hpp +2 -2
  17. data/Gosu/WinUtility.hpp +5 -6
  18. data/Gosu/Window.hpp +5 -6
  19. data/GosuImpl/Async.cpp +4 -3
  20. data/GosuImpl/Audio/ALChannelManagement.hpp +23 -11
  21. data/GosuImpl/Audio/AudioFile.hpp +11 -3
  22. data/GosuImpl/Audio/AudioOpenAL.cpp +613 -0
  23. data/GosuImpl/Audio/AudioOpenAL.mm +1 -605
  24. data/GosuImpl/Audio/AudioSDL.cpp +12 -14
  25. data/GosuImpl/Audio/AudioToolboxFile.hpp +0 -1
  26. data/GosuImpl/Audio/OggFile.hpp +2 -0
  27. data/GosuImpl/Audio/SndFile.hpp +158 -0
  28. data/GosuImpl/DirectoriesWin.cpp +18 -18
  29. data/GosuImpl/Graphics/BitmapApple.mm +17 -19
  30. data/GosuImpl/Graphics/BitmapBMP.cpp +7 -2
  31. data/GosuImpl/Graphics/BitmapFreeImage.cpp +11 -12
  32. data/GosuImpl/Graphics/BitmapGDIplus.cpp +35 -31
  33. data/GosuImpl/Graphics/BitmapUtils.cpp +1 -1
  34. data/GosuImpl/Graphics/BlockAllocator.cpp +7 -8
  35. data/GosuImpl/Graphics/BlockAllocator.hpp +3 -4
  36. data/GosuImpl/Graphics/Common.hpp +3 -2
  37. data/GosuImpl/Graphics/DrawOp.hpp +2 -3
  38. data/GosuImpl/Graphics/DrawOpQueue.hpp +28 -20
  39. data/GosuImpl/Graphics/Font.cpp +13 -13
  40. data/GosuImpl/Graphics/FormattedString.hpp +93 -86
  41. data/GosuImpl/Graphics/Graphics.cpp +16 -14
  42. data/GosuImpl/Graphics/Image.cpp +7 -3
  43. data/GosuImpl/Graphics/LargeImageData.hpp +4 -5
  44. data/GosuImpl/Graphics/Macro.hpp +11 -11
  45. data/GosuImpl/Graphics/RenderState.hpp +5 -4
  46. data/GosuImpl/Graphics/TexChunk.cpp +3 -3
  47. data/GosuImpl/Graphics/TexChunk.hpp +4 -4
  48. data/GosuImpl/Graphics/Text.cpp +29 -30
  49. data/GosuImpl/Graphics/TextMac.cpp +9 -7
  50. data/GosuImpl/Graphics/TextTTFWin.cpp +3 -1
  51. data/GosuImpl/Graphics/TextTouch.mm +0 -1
  52. data/GosuImpl/Graphics/TextUnix.cpp +12 -4
  53. data/GosuImpl/Graphics/TextWin.cpp +4 -2
  54. data/GosuImpl/Graphics/Texture.cpp +7 -6
  55. data/GosuImpl/Graphics/Texture.hpp +3 -4
  56. data/GosuImpl/InputMac.mm +12 -15
  57. data/GosuImpl/InputTouch.mm +3 -3
  58. data/GosuImpl/InputWin.cpp +149 -159
  59. data/GosuImpl/InputX.cpp +0 -0
  60. data/GosuImpl/MacUtility.hpp +9 -4
  61. data/GosuImpl/RubyGosu.swg +38 -43
  62. data/GosuImpl/RubyGosu_wrap.cxx +89 -96
  63. data/GosuImpl/Sockets/CommSocket.cpp +5 -5
  64. data/GosuImpl/Sockets/Sockets.hpp +4 -4
  65. data/GosuImpl/TimingApple.cpp +2 -3
  66. data/GosuImpl/Utility.cpp +18 -0
  67. data/GosuImpl/WinMain.cpp +0 -1
  68. data/GosuImpl/WinUtility.cpp +2 -2
  69. data/GosuImpl/WindowMac.mm +20 -17
  70. data/GosuImpl/WindowTouch.mm +8 -7
  71. data/GosuImpl/WindowWin.cpp +12 -7
  72. data/GosuImpl/WindowX.cpp +67 -18
  73. data/lib/gosu.rb +14 -12
  74. data/linux/extconf.rb +11 -6
  75. metadata +8 -7
  76. data/GosuImpl/Audio/AudioAudiere.cpp +0 -448
  77. data/GosuImpl/RubyGosu_DllMain.cxx +0 -31
@@ -1,6 +1,6 @@
1
1
  #include <Gosu/Sockets.hpp>
2
+ #include <Gosu/TR1.hpp>
2
3
  #include <GosuImpl/Sockets/Sockets.hpp>
3
- #include <boost/cstdint.hpp>
4
4
  #include <cassert>
5
5
  #include <cstring>
6
6
  #include <stdexcept>
@@ -15,7 +15,7 @@ struct Gosu::CommSocket::Impl
15
15
  Buffer inbox, outbox;
16
16
 
17
17
  void appendBuffer(const char* buffer, std::size_t size,
18
- boost::function<void (const void*, std::size_t)>& event)
18
+ std::tr1::function<void (const void*, std::size_t)>& event)
19
19
  {
20
20
  switch (mode)
21
21
  {
@@ -35,7 +35,7 @@ struct Gosu::CommSocket::Impl
35
35
 
36
36
  for (;;) // IMPR.
37
37
  {
38
- const size_t sizeSize = sizeof(boost::uint32_t);
38
+ const size_t sizeSize = 4;
39
39
 
40
40
  // Not even enough bytes there to determine the size of the
41
41
  // incoming message.
@@ -43,7 +43,7 @@ struct Gosu::CommSocket::Impl
43
43
  break;
44
44
 
45
45
  // Message size is already here, convert it.
46
- boost::uint32_t msgSize = *reinterpret_cast<boost::uint32_t*>(&inbox[0]);
46
+ std::tr1::uint32_t msgSize = *reinterpret_cast<std::tr1::uint32_t*>(&inbox[0]);
47
47
  msgSize = ntohl(msgSize);
48
48
 
49
49
  // Can't really handle zero-size messages. IMPR?!
@@ -241,7 +241,7 @@ void Gosu::CommSocket::send(const void* buffer, std::size_t size)
241
241
  // In managed mode, also send the length of the buffer.
242
242
  if (mode() == cmManaged)
243
243
  {
244
- boost::uint32_t netSize = htonl(size);
244
+ std::tr1::uint32_t netSize = htonl(size);
245
245
  const char* charBuf = reinterpret_cast<const char*>(&netSize);
246
246
  pimpl->outbox.insert(pimpl->outbox.end(), charBuf,
247
247
  charBuf + sizeof netSize);
@@ -2,7 +2,6 @@
2
2
  #define GOSUIMPL_SOCKETS_HPP
3
3
 
4
4
  #include <Gosu/Platform.hpp>
5
- #include <boost/utility.hpp>
6
5
 
7
6
  #ifdef GOSU_IS_WIN
8
7
  #include "winsock2.h"
@@ -27,10 +26,11 @@
27
26
  namespace Gosu
28
27
  {
29
28
  // Owns a socket and manages library initialization.
30
- class Socket : boost::noncopyable
31
- {
29
+ class Socket {
30
+ Socket(const Socket&);
31
+ Socket& operator=(const Socket&);
32
+
32
33
  SocketHandle handle_;
33
-
34
34
  public:
35
35
  Socket();
36
36
  ~Socket();
@@ -9,12 +9,11 @@ void Gosu::sleep(unsigned milliseconds)
9
9
  // Thanks to this blog for the unconvoluted code example:
10
10
  // http://shiftedbits.org/2008/10/01/mach_absolute_time-on-the-iphone/
11
11
 
12
- #include <boost/cstdint.hpp>
13
12
  #include <mach/mach_time.h>
14
13
 
15
14
  unsigned long Gosu::milliseconds()
16
15
  {
17
- static boost::uint64_t firstTick = 0;
16
+ static uint64_t firstTick = 0;
18
17
  static mach_timebase_info_data_t info;
19
18
 
20
19
  if (firstTick == 0)
@@ -23,6 +22,6 @@ unsigned long Gosu::milliseconds()
23
22
  firstTick = mach_absolute_time();
24
23
  }
25
24
 
26
- boost::uint64_t runtime = mach_absolute_time() - firstTick;
25
+ uint64_t runtime = mach_absolute_time() - firstTick;
27
26
  return runtime * info.numer / info.denom / 1000000.0;
28
27
  }
@@ -2,6 +2,8 @@
2
2
  #include <Gosu/Platform.hpp>
3
3
  #include <cstddef>
4
4
  #include <cstdlib>
5
+ #include <cwctype>
6
+ #include <cwchar>
5
7
  #include <stdexcept>
6
8
  #include <algorithm>
7
9
  #include <vector>
@@ -99,3 +101,19 @@ string Gosu::narrow(const wstring& ws)
99
101
 
100
102
  return string(buf.begin(), buf.end() - 1);
101
103
  }
104
+
105
+ // TODO: This function needs to go into some internal header.
106
+ namespace Gosu
107
+ {
108
+ bool isExtension(const wchar_t* str, const wchar_t* ext)
109
+ {
110
+ size_t strLen = wcslen(str), extLen = wcslen(ext);
111
+ if (extLen > strLen)
112
+ return false;
113
+ str += strLen, ext += extLen;
114
+ while (extLen--)
115
+ if (towlower((wint_t)*--str) != *--ext)
116
+ return false;
117
+ return true;
118
+ }
119
+ }
@@ -1,4 +1,3 @@
1
- #include <boost/lexical_cast.hpp>
2
1
  #include <windows.h>
3
2
  #include <exception>
4
3
  #include <string>
@@ -5,7 +5,7 @@
5
5
 
6
6
  namespace
7
7
  {
8
- typedef std::vector<boost::function<bool (MSG&)> > Hooks;
8
+ typedef std::vector<std::tr1::function<bool (MSG&)> > Hooks;
9
9
  Hooks hooks;
10
10
 
11
11
  bool handledByHook(MSG& message)
@@ -68,7 +68,7 @@ void Gosu::Win::processMessages()
68
68
  }
69
69
  }
70
70
 
71
- void Gosu::Win::registerMessageHook(const boost::function<bool (MSG&)>& hook)
71
+ void Gosu::Win::registerMessageHook(const std::tr1::function<bool (MSG&)>& hook)
72
72
  {
73
73
  hooks.push_back(hook);
74
74
  }
@@ -1,17 +1,20 @@
1
- #import <Gosu/Window.hpp>
2
- #import <Gosu/Audio.hpp>
3
- #import <Gosu/Graphics.hpp>
4
- #import <Gosu/Input.hpp>
5
- #import <GosuImpl/MacUtility.hpp>
6
- #import <Gosu/Timing.hpp>
7
- #import <Gosu/Utility.hpp>
1
+ #include <Gosu/Window.hpp>
2
+ #include <Gosu/Audio.hpp>
3
+ #include <Gosu/Graphics.hpp>
4
+ #include <Gosu/Input.hpp>
5
+ #include <GosuImpl/MacUtility.hpp>
6
+ #include <Gosu/Timing.hpp>
7
+ #include <Gosu/TR1.hpp>
8
+ #include <Gosu/Utility.hpp>
9
+ #include <OpenGL/OpenGL.h>
10
+ #include <OpenGL/gl.h>
11
+ #include <memory>
12
+ #include <vector>
13
+ using namespace std::tr1::placeholders;
14
+
8
15
  #import <AppKit/AppKit.h>
9
16
  #import <ApplicationServices/ApplicationServices.h>
10
17
  #import <Carbon/Carbon.h>
11
- #import <OpenGL/OpenGL.h>
12
- #import <OpenGL/gl.h>
13
- #import <boost/bind.hpp>
14
- #import <vector>
15
18
 
16
19
  namespace Gosu
17
20
  {
@@ -190,8 +193,8 @@ struct Gosu::Window::Impl
190
193
  NSRect savedFrame;
191
194
 
192
195
  ObjRef<NSOpenGLContext> context;
193
- boost::scoped_ptr<Graphics> graphics;
194
- boost::scoped_ptr<Input> input;
196
+ std::auto_ptr<Graphics> graphics;
197
+ std::auto_ptr<Input> input;
195
198
  double interval;
196
199
  bool mouseViz;
197
200
 
@@ -302,8 +305,8 @@ Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen,
302
305
  pimpl->graphics->setResolution(width, height);
303
306
 
304
307
  pimpl->input.reset(new Input(pimpl->window.get()));
305
- pimpl->input->onButtonDown = boost::bind(&Window::buttonDown, this, _1);
306
- pimpl->input->onButtonUp = boost::bind(&Window::buttonUp, this, _1);
308
+ pimpl->input->onButtonDown = std::tr1::bind(&Window::buttonDown, this, _1);
309
+ pimpl->input->onButtonUp = std::tr1::bind(&Window::buttonUp, this, _1);
307
310
  pimpl->input->setMouseFactors(1.0 * width / realWidth, 1.0 * height / realHeight);
308
311
  if (fullscreen)
309
312
  [NSApp setInput: input()];
@@ -476,8 +479,8 @@ Gosu::Window::SharedContext Gosu::Window::createSharedContext()
476
479
  initWithFormat: pf
477
480
  shareContext: pimpl->context.obj()];
478
481
 
479
- return SharedContext(new boost::function<void()>(boost::bind(makeCurrentContext, ctx)),
480
- boost::bind(releaseContext, ctx));
482
+ return SharedContext(new std::tr1::function<void()>(std::tr1::bind(makeCurrentContext, ctx)),
483
+ std::tr1::bind(releaseContext, ctx));
481
484
  }
482
485
 
483
486
  namespace GosusDarkSide
@@ -4,12 +4,13 @@
4
4
  #include <Gosu/Input.hpp>
5
5
  #include <GosuImpl/MacUtility.hpp>
6
6
  #include <GosuImpl/Graphics/GosuView.hpp>
7
- #include <boost/bind.hpp>
8
7
 
9
8
  #import <CoreGraphics/CoreGraphics.h>
10
9
  #import <UIKit/UIKit.h>
11
10
  #import <OpenGLES/EAGL.h>
12
11
 
12
+ using namespace std::tr1::placeholders;
13
+
13
14
  namespace Gosu
14
15
  {
15
16
  CGRect screenRect = [[UIScreen mainScreen] bounds];
@@ -35,9 +36,9 @@ class Gosu::Audio {};
35
36
  struct Gosu::Window::Impl {
36
37
  ObjRef<UIWindow> window;
37
38
  ObjRef<GosuViewController> controller;
38
- boost::scoped_ptr<Graphics> graphics;
39
- boost::scoped_ptr<Audio> audio;
40
- boost::scoped_ptr<Input> input;
39
+ std::auto_ptr<Graphics> graphics;
40
+ std::auto_ptr<Audio> audio;
41
+ std::auto_ptr<Input> input;
41
42
  double interval;
42
43
  };
43
44
 
@@ -126,9 +127,9 @@ Gosu::Window::Window(unsigned width, unsigned height,
126
127
  pimpl->graphics->setResolution(screenHeight(), screenWidth());
127
128
  pimpl->audio.reset(new Audio());
128
129
  pimpl->input.reset(new Input(gosuView, updateInterval));
129
- pimpl->input->onTouchBegan = boost::bind(&Window::touchBegan, this, _1);
130
- pimpl->input->onTouchMoved = boost::bind(&Window::touchMoved, this, _1);
131
- pimpl->input->onTouchEnded = boost::bind(&Window::touchEnded, this, _1);
130
+ pimpl->input->onTouchBegan = std::tr1::bind(&Window::touchBegan, this, _1);
131
+ pimpl->input->onTouchMoved = std::tr1::bind(&Window::touchMoved, this, _1);
132
+ pimpl->input->onTouchEnded = std::tr1::bind(&Window::touchEnded, this, _1);
132
133
  pimpl->interval = updateInterval;
133
134
 
134
135
  [pimpl->window.obj() makeKeyAndVisible];
@@ -5,15 +5,19 @@
5
5
  #include <Gosu/Window.hpp>
6
6
  #include <Gosu/WinUtility.hpp>
7
7
  #include <Gosu/Timing.hpp>
8
+ #include <Gosu/Audio.hpp>
8
9
  #include <Gosu/Graphics.hpp>
9
10
  #include <Gosu/Input.hpp>
10
11
  #include <Gosu/TextInput.hpp>
12
+ #include <Gosu/TR1.hpp>
11
13
  #include <GosuImpl/Graphics/Common.hpp>
12
- #include <boost/bind.hpp>
13
14
  #include <cassert>
15
+ #include <memory>
14
16
  #include <stdexcept>
15
17
  #include <vector>
16
18
 
19
+ using namespace std::tr1::placeholders;
20
+
17
21
  // TODO: Put fullscreen logic in different file, track fullscreen state and
18
22
  // enable dynamic toggling between fullscreen and window.
19
23
 
@@ -173,8 +177,8 @@ struct Gosu::Window::Impl
173
177
  {
174
178
  HWND handle;
175
179
  HDC hdc;
176
- boost::scoped_ptr<Graphics> graphics;
177
- boost::scoped_ptr<Input> input;
180
+ std::auto_ptr<Graphics> graphics;
181
+ std::auto_ptr<Input> input;
178
182
  double updateInterval;
179
183
  bool iconified;
180
184
 
@@ -286,8 +290,8 @@ Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen,
286
290
  graphics().setResolution(pimpl->originalWidth, pimpl->originalHeight);
287
291
  pimpl->input.reset(new Gosu::Input(handle()));
288
292
  input().setMouseFactors(1.0 * pimpl->originalWidth / width, 1.0 * pimpl->originalHeight / height);
289
- input().onButtonDown = boost::bind(&Window::buttonDown, this, _1);
290
- input().onButtonUp = boost::bind(&Window::buttonUp, this, _1);
293
+ input().onButtonDown = std::tr1::bind(&Window::buttonDown, this, _1);
294
+ input().onButtonUp = std::tr1::bind(&Window::buttonUp, this, _1);
291
295
 
292
296
  pimpl->updateInterval = updateInterval;
293
297
  }
@@ -357,6 +361,7 @@ void Gosu::Window::show()
357
361
  if (ms < lastTick || ms - lastTick >= static_cast<unsigned>(pimpl->updateInterval))
358
362
  {
359
363
  lastTick = ms;
364
+ Song::update();
360
365
  input().update();
361
366
  // TODO: Bad heuristic -- this causes flickering cursor on right and bottom border of the
362
367
  // window.
@@ -463,7 +468,7 @@ LRESULT Gosu::Window::handleMessage(UINT message, WPARAM wparam, LPARAM lparam)
463
468
 
464
469
  if (message == WM_PAINT)
465
470
  {
466
- if (pimpl->graphics && graphics().begin())
471
+ if (pimpl->graphics.get() && graphics().begin())
467
472
  {
468
473
  try
469
474
  {
@@ -496,7 +501,7 @@ LRESULT Gosu::Window::handleMessage(UINT message, WPARAM wparam, LPARAM lparam)
496
501
  }
497
502
  }
498
503
 
499
- if (pimpl->input && input().textInput() && input().textInput()->feedMessage(message, wparam, lparam))
504
+ if (pimpl->input.get() && input().textInput() && input().textInput()->feedMessage(message, wparam, lparam))
500
505
  return 0;
501
506
 
502
507
  return DefWindowProc(handle(), message, wparam, lparam);
@@ -4,29 +4,34 @@
4
4
  // understand than that! --jlnr
5
5
 
6
6
  #include <Gosu/Window.hpp>
7
- #include <Gosu/Timing.hpp>
8
- #include <Gosu/Utility.hpp>
7
+ #include <Gosu/Audio.hpp>
9
8
  #include <Gosu/Input.hpp>
10
9
  #include <Gosu/Graphics.hpp>
11
- #include <Gosu/Audio.hpp>
12
- #include <boost/bind.hpp>
13
- #include <stdexcept>
14
- #include <algorithm>
10
+ #include <Gosu/Timing.hpp>
11
+ #include <Gosu/TR1.hpp>
12
+ #include <Gosu/Utility.hpp>
15
13
  #include <cstdio>
14
+ #include <algorithm>
15
+ #include <memory>
16
+ #include <sstream>
17
+ #include <stdexcept>
16
18
  #include <vector>
17
19
 
18
20
  #include <GL/glx.h>
19
21
  #include <X11/Xlib.h>
20
22
  #include <X11/Xutil.h>
23
+ #include <X11/extensions/Xdamage.h>
21
24
  #include "X11vroot.h"
22
25
 
26
+ using namespace std::tr1::placeholders;
27
+
23
28
  namespace
24
29
  {
25
30
  template<typename T>
26
31
  class scoped_resource
27
32
  {
28
33
  T* pointer;
29
- typedef boost::function<void(T*)> Deleter;
34
+ typedef std::tr1::function<void(T*)> Deleter;
30
35
  Deleter deleter;
31
36
 
32
37
  public:
@@ -81,8 +86,8 @@ namespace Gosu
81
86
 
82
87
  struct Gosu::Window::Impl
83
88
  {
84
- boost::scoped_ptr<Graphics> graphics;
85
- boost::scoped_ptr<Input> input;
89
+ std::auto_ptr<Graphics> graphics;
90
+ std::auto_ptr<Input> input;
86
91
 
87
92
  ::Display* display;
88
93
 
@@ -94,6 +99,10 @@ struct Gosu::Window::Impl
94
99
  ::GLXContext context;
95
100
  ::Window window;
96
101
  ::XVisualInfo* visual;
102
+
103
+ // We use the XDamage extension to detect when we need to redraw ourselves
104
+ Damage damage;
105
+ int damageEvent, damageError;
97
106
 
98
107
  // Last set title
99
108
  std::wstring title;
@@ -113,7 +122,7 @@ struct Gosu::Window::Impl
113
122
 
114
123
  }
115
124
 
116
- void executeAndWait(boost::function<void(Display*, ::Window)> function, int forMessage)
125
+ void executeAndWait(std::tr1::function<void(Display*, ::Window)> function, int forMessage)
117
126
  {
118
127
  XSelectInput(display, window, StructureNotifyMask);
119
128
  function(display, window);
@@ -133,7 +142,7 @@ struct Gosu::Window::Impl
133
142
  {
134
143
  XEvent event;
135
144
  XNextEvent(display, &event);
136
-
145
+
137
146
  // Override redirect fix (thanks go to the Pyglet folks again):
138
147
  if (event.type == ButtonPress && fullscreen && !active)
139
148
  XSetInputFocus(display, this->window, RevertToParent, CurrentTime);
@@ -156,6 +165,22 @@ struct Gosu::Window::Impl
156
165
  else if (event.type == FocusOut)
157
166
  active = false;
158
167
  }
168
+
169
+ // Force redraw on window damage; don't check needsRedraw()
170
+ if (event.type == damageEvent + XDamageNotify)
171
+ {
172
+ XDamageNotifyEvent* dev = (XDamageNotifyEvent*)&event;
173
+ XDamageSubtract(display, dev->damage, None, None);
174
+ // If there are more events queued up right after this one, we
175
+ // don't need to redraw just yet
176
+ if (dev->more == false &&
177
+ window->graphics().begin(Colors::black))
178
+ {
179
+ window->draw();
180
+ window->graphics().end();
181
+ glXSwapBuffers(display, this->window);
182
+ }
183
+ }
159
184
  }
160
185
 
161
186
  if (showingCursor && !window->needsCursor())
@@ -169,6 +194,7 @@ struct Gosu::Window::Impl
169
194
  showingCursor = true;
170
195
  }
171
196
 
197
+ Song::update();
172
198
  window->input().update();
173
199
  window->update();
174
200
 
@@ -180,6 +206,18 @@ struct Gosu::Window::Impl
180
206
  glXSwapBuffers(display, this->window);
181
207
  }
182
208
  }
209
+
210
+ // The ICCCM standard requires that compositing window managers acquire
211
+ // ownership of a selection named _NET_WM_CM_Sn, where n is the screen
212
+ // number
213
+ bool isComposited()
214
+ {
215
+ std::ostringstream atomName;
216
+ atomName << "_NET_WM_CM_S" << XDefaultScreen(display);
217
+ const std::string& tmp = atomName.str();
218
+ Atom selection = XInternAtom(display, tmp.c_str(), False);
219
+ return XGetSelectionOwner(display, selection) != None;
220
+ }
183
221
  };
184
222
 
185
223
  Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen,
@@ -267,8 +305,8 @@ Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen,
267
305
  // Now set up major Gosu components
268
306
  pimpl->graphics.reset(new Graphics(pimpl->width, pimpl->height, fullscreen));
269
307
  pimpl->input.reset(new Input(pimpl->display, pimpl->window));
270
- input().onButtonDown = boost::bind(&Window::buttonDown, this, _1);
271
- input().onButtonUp = boost::bind(&Window::buttonUp, this, _1);
308
+ input().onButtonDown = std::tr1::bind(&Window::buttonDown, this, _1);
309
+ input().onButtonUp = std::tr1::bind(&Window::buttonUp, this, _1);
272
310
 
273
311
  // Fix coordinates for fullscreen screen-scaling
274
312
  if (fullscreen)
@@ -277,10 +315,21 @@ Gosu::Window::Window(unsigned width, unsigned height, bool fullscreen,
277
315
  input().setMouseFactors(1.0 * width / pimpl->width,
278
316
  1.0 * height / pimpl->height);
279
317
  }
318
+
319
+ // Composited windows, by nature, don't need to monitor XDamage
320
+ if (!pimpl->isComposited())
321
+ {
322
+ // Register our intent to monitor this window for damage
323
+ XDamageQueryExtension(pimpl->display, &pimpl->damageEvent, &pimpl->damageError);
324
+ pimpl->damage = XDamageCreate(pimpl->display, pimpl->window,
325
+ XDamageReportNonEmpty);
326
+ }
280
327
  }
281
328
 
282
329
  Gosu::Window::~Window()
283
- {
330
+ {
331
+ if (!pimpl->isComposited())
332
+ XDamageDestroy(pimpl->display, pimpl->damage);
284
333
  XFreeCursor(pimpl->display, pimpl->emptyCursor);
285
334
  XDestroyWindow(pimpl->display, pimpl->window);
286
335
  XSync(pimpl->display, false);
@@ -403,13 +452,13 @@ Gosu::Window::SharedContext Gosu::Window::createSharedContext() {
403
452
  if (!dpy2)
404
453
  throw std::runtime_error("Could not duplicate X display");
405
454
 
406
- GLXContext ctx = glXCreateContext(dpy2, pimpl->visual, pimpl->context, True);
407
- if (!ctx)
455
+ GLXContext ctx = glXCreateContext(dpy2, pimpl->visual, pimpl->context, True);
456
+ if (!ctx)
408
457
  throw std::runtime_error("Could not create shared GLX context");
409
458
 
410
459
  return SharedContext(
411
- new boost::function<void()>(boost::bind(makeCurrentContext, dpy2, pimpl->window, ctx)),
412
- boost::bind(releaseContext, dpy2, ctx));
460
+ new std::tr1::function<void()>(std::tr1::bind(makeCurrentContext, dpy2, pimpl->window, ctx)),
461
+ std::tr1::bind(releaseContext, dpy2, ctx));
413
462
  }
414
463
 
415
464
  // Deprecated.