• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3  *
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
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_X11_X_ERROR_TRAP_H_
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_X11_X_ERROR_TRAP_H_
13 
14 #include <X11/Xlib.h>
15 
16 #include "webrtc/base/constructormagic.h"
17 
18 namespace webrtc {
19 
20 // Helper class that registers X Window error handler. Caller can use
21 // GetLastErrorAndDisable() to get the last error that was caught, if any.
22 class XErrorTrap {
23  public:
24   explicit XErrorTrap(Display* display);
25   ~XErrorTrap();
26 
27   // Returns last error and removes unregisters the error handler.
28   int GetLastErrorAndDisable();
29 
30  private:
31   XErrorHandler original_error_handler_;
32   bool enabled_;
33 
34   RTC_DISALLOW_COPY_AND_ASSIGN(XErrorTrap);
35 };
36 
37 }  // namespace webrtc
38 
39 #endif  // WEBRTC_MODULES_DESKTOP_CAPTURE_X11_X_ERROR_TRAP_H_
40