OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "remoting/host/linux/x11_util.h" | 5 #include "remoting/host/linux/x11_util.h" |
6 | 6 |
7 #include <X11/extensions/XTest.h> | 7 #include <X11/extensions/XTest.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 | 10 |
11 namespace remoting { | 11 namespace remoting { |
12 | 12 |
13 static ScopedXErrorHandler* g_handler = nullptr; | 13 static ScopedXErrorHandler* g_handler = nullptr; |
14 | 14 |
15 ScopedXErrorHandler::ScopedXErrorHandler(const Handler& handler): | 15 ScopedXErrorHandler::ScopedXErrorHandler(const Handler& handler): |
16 handler_(handler), | 16 handler_(handler), |
17 ok_(true) { | 17 ok_(true) { |
18 // This is a poor-man's check for incorrect usage. It doesn't handle the case | 18 // This is an non-exhaustive check for incorrect usage. It doesn't handle the |
Lambros
2016/11/29 18:36:06
s/an/a/
Matt Giuca
2016/11/30 07:28:59
Done.
| |
19 // where a mix of ScopedXErrorHandler and raw XSetErrorHandler calls are used, | 19 // case where a mix of ScopedXErrorHandler and raw XSetErrorHandler calls are |
20 // and it disallows nested ScopedXErrorHandlers on the same thread, despite | 20 // used, and it disallows nested ScopedXErrorHandlers on the same thread, |
21 // these being perfectly safe. | 21 // despite these being perfectly safe. |
22 DCHECK(g_handler == nullptr); | 22 DCHECK(g_handler == nullptr); |
23 g_handler = this; | 23 g_handler = this; |
24 previous_handler_ = XSetErrorHandler(HandleXErrors); | 24 previous_handler_ = XSetErrorHandler(HandleXErrors); |
25 } | 25 } |
26 | 26 |
27 ScopedXErrorHandler::~ScopedXErrorHandler() { | 27 ScopedXErrorHandler::~ScopedXErrorHandler() { |
28 g_handler = nullptr; | 28 g_handler = nullptr; |
29 XSetErrorHandler(previous_handler_); | 29 XSetErrorHandler(previous_handler_); |
30 } | 30 } |
31 | 31 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 if (!XTestQueryExtension(display, &test_event_base, &test_error_base, | 65 if (!XTestQueryExtension(display, &test_event_base, &test_error_base, |
66 &major, &minor)) { | 66 &major, &minor)) { |
67 return false; | 67 return false; |
68 } | 68 } |
69 | 69 |
70 XTestGrabControl(display, ignore); | 70 XTestGrabControl(display, ignore); |
71 return true; | 71 return true; |
72 } | 72 } |
73 | 73 |
74 } // namespace remoting | 74 } // namespace remoting |
OLD | NEW |