///////////////////////////////////////////////////////
| 55 | { |
| 56 | //////////////////////////////////////////////////////////// |
| 57 | std::shared_ptr<Display> openDisplay() |
| 58 | { |
| 59 | const std::lock_guard lock(UnixDisplayImpl::mutex); |
| 60 | |
| 61 | auto sharedDisplay = UnixDisplayImpl::weakSharedDisplay.lock(); |
| 62 | if (!sharedDisplay) |
| 63 | { |
| 64 | sharedDisplay.reset(XOpenDisplay(nullptr), XCloseDisplay); |
| 65 | UnixDisplayImpl::weakSharedDisplay = sharedDisplay; |
| 66 | |
| 67 | // Opening display failed: The best we can do at the moment is to output a meaningful error message |
| 68 | // and cause an abnormal program termination |
| 69 | if (!sharedDisplay) |
| 70 | { |
| 71 | err() << "Failed to open X11 display; make sure the DISPLAY environment variable is set correctly" << std::endl; |
| 72 | std::abort(); |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | return sharedDisplay; |
| 77 | } |
| 78 | |
| 79 | |
| 80 | //////////////////////////////////////////////////////////// |
no test coverage detected