OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 MouseCursorMonitorX11::MouseCursorMonitorX11( | 91 MouseCursorMonitorX11::MouseCursorMonitorX11( |
92 const DesktopCaptureOptions& options, | 92 const DesktopCaptureOptions& options, |
93 Window window) | 93 Window window) |
94 : x_display_(options.x_display()), | 94 : x_display_(options.x_display()), |
95 callback_(NULL), | 95 callback_(NULL), |
96 mode_(SHAPE_AND_POSITION), | 96 mode_(SHAPE_AND_POSITION), |
97 window_(window), | 97 window_(window), |
98 have_xfixes_(false), | 98 have_xfixes_(false), |
99 xfixes_event_base_(-1), | 99 xfixes_event_base_(-1), |
100 xfixes_error_base_(-1) {} | 100 xfixes_error_base_(-1) { |
| 101 // Set a default initial cursor shape in case XFixes is not present. |
| 102 const int kSize = 5; |
| 103 std::unique_ptr<DesktopFrame> default_cursor( |
| 104 new BasicDesktopFrame(DesktopSize(kSize, kSize))); |
| 105 const uint8_t pixels[kSize * kSize] = { |
| 106 0x00, 0x00, 0x00, 0x00, 0x00, |
| 107 0x00, 0xff, 0xff, 0xff, 0x00, |
| 108 0x00, 0xff, 0xff, 0xff, 0x00, |
| 109 0x00, 0xff, 0xff, 0xff, 0x00, |
| 110 0x00, 0x00, 0x00, 0x00, 0x00 |
| 111 }; |
| 112 uint8_t* ptr = default_cursor->data(); |
| 113 for (int y = 0; y < kSize; ++y) { |
| 114 for (int x = 0; x < kSize; ++x) { |
| 115 *ptr++ = pixels[kSize * y + x]; |
| 116 *ptr++ = pixels[kSize * y + x]; |
| 117 *ptr++ = pixels[kSize * y + x]; |
| 118 *ptr++ = 0xff; |
| 119 } |
| 120 } |
| 121 DesktopVector hotspot(2, 2); |
| 122 cursor_shape_.reset(new MouseCursor(default_cursor.release(), hotspot)); |
| 123 } |
101 | 124 |
102 MouseCursorMonitorX11::~MouseCursorMonitorX11() { | 125 MouseCursorMonitorX11::~MouseCursorMonitorX11() { |
103 if (have_xfixes_) { | 126 if (have_xfixes_) { |
104 x_display_->RemoveEventHandler(xfixes_event_base_ + XFixesCursorNotify, | 127 x_display_->RemoveEventHandler(xfixes_event_base_ + XFixesCursorNotify, |
105 this); | 128 this); |
106 } | 129 } |
107 } | 130 } |
108 | 131 |
109 void MouseCursorMonitorX11::Init(Callback* callback, Mode mode) { | 132 void MouseCursorMonitorX11::Init(Callback* callback, Mode mode) { |
110 // Init can be called only once per instance of MouseCursorMonitor. | 133 // Init can be called only once per instance of MouseCursorMonitor. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 MouseCursorMonitor* MouseCursorMonitor::CreateForScreen( | 247 MouseCursorMonitor* MouseCursorMonitor::CreateForScreen( |
225 const DesktopCaptureOptions& options, | 248 const DesktopCaptureOptions& options, |
226 ScreenId screen) { | 249 ScreenId screen) { |
227 if (!options.x_display()) | 250 if (!options.x_display()) |
228 return NULL; | 251 return NULL; |
229 return new MouseCursorMonitorX11( | 252 return new MouseCursorMonitorX11( |
230 options, DefaultRootWindow(options.x_display()->display())); | 253 options, DefaultRootWindow(options.x_display()->display())); |
231 } | 254 } |
232 | 255 |
233 } // namespace webrtc | 256 } // namespace webrtc |
OLD | NEW |