From 4a0938d2b7e532d9118677a512e2d154f7ee9b74 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 22 May 2016 00:21:22 +0200 Subject: [PATCH] Allow "moving" wxX11Display objects This is not a real move-ctor but std::auto_ptr<>-like "stealing" ctor. It still allows to pass Display ownership to another function which is all that is needed for our purposes. --- include/wx/unix/utilsx11.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/wx/unix/utilsx11.h b/include/wx/unix/utilsx11.h index e3019acc67..498b22f061 100644 --- a/include/wx/unix/utilsx11.h +++ b/include/wx/unix/utilsx11.h @@ -67,6 +67,13 @@ public: wxX11Display() { m_dpy = XOpenDisplay(NULL); } ~wxX11Display() { if ( m_dpy ) XCloseDisplay(m_dpy); } + // Pseudo move ctor: steals the open display from the other object. + explicit wxX11Display(wxX11Display& display) + { + m_dpy = display.m_dpy; + display.m_dpy = NULL; + } + operator Display *() const { return m_dpy; } // Using DefaultRootWindow() with an object of wxX11Display class doesn't