SenseApiMgr: Refcount device spec objects
This commit is contained in:
@@ -54,7 +54,9 @@ std::string WindowSelector::stringify() const
|
||||
return os.str();
|
||||
}
|
||||
|
||||
AttachedWindow::AttachedWindow(const smo::device::SenseDeviceSpec& spec)
|
||||
AttachedWindow::AttachedWindow(
|
||||
const std::shared_ptr<smo::device::SenseDeviceSpec>& spec
|
||||
)
|
||||
: deviceSpec(spec)
|
||||
{
|
||||
// Validate required function pointers are available
|
||||
@@ -66,9 +68,9 @@ AttachedWindow::AttachedWindow(const smo::device::SenseDeviceSpec& spec)
|
||||
": Required xcbXorg function pointers not available");
|
||||
}
|
||||
|
||||
windowSelector.display = getRequiredParamAsInt(spec, "display");
|
||||
windowSelector.screen = getRequiredParamAsInt(spec, "screen");
|
||||
parseWindowSelector(spec);
|
||||
windowSelector.display = getRequiredParamAsInt(*spec, "display");
|
||||
windowSelector.screen = getRequiredParamAsInt(*spec, "screen");
|
||||
parseWindowSelector(*spec);
|
||||
|
||||
// Get connection from libxcbXorg
|
||||
std::shared_ptr<xcb_xorg::XcbConnection> conn =
|
||||
@@ -293,7 +295,9 @@ static int xcbWindow_finalizeInd(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xcbWindow_attachDeviceReq(const smo::device::SenseDeviceSpec& desc)
|
||||
static int xcbWindow_attachDeviceReq(
|
||||
const std::shared_ptr<smo::device::SenseDeviceSpec>& desc
|
||||
)
|
||||
{
|
||||
g_attachedWindows.emplace_back(
|
||||
std::make_unique<xcb_window::AttachedWindow>(desc));
|
||||
@@ -304,7 +308,9 @@ static int xcbWindow_attachDeviceReq(const smo::device::SenseDeviceSpec& desc)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int xcbWindow_detachDeviceReq(const smo::device::SenseDeviceSpec& spec)
|
||||
static int xcbWindow_detachDeviceReq(
|
||||
const std::shared_ptr<smo::device::SenseDeviceSpec>& spec
|
||||
)
|
||||
{
|
||||
auto it = std::find_if(g_attachedWindows.begin(), g_attachedWindows.end(),
|
||||
[&spec](const std::unique_ptr<xcb_window::AttachedWindow>& window) {
|
||||
@@ -315,13 +321,13 @@ static int xcbWindow_detachDeviceReq(const smo::device::SenseDeviceSpec& spec)
|
||||
if (it == g_attachedWindows.end())
|
||||
{
|
||||
std::cerr << __func__ << ": Device not found for detachment:\n"
|
||||
<< spec.stringify() << "\n";
|
||||
<< spec->stringify() << "\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_attachedWindows.erase(it);
|
||||
std::cout << __func__ << ": Detached X11 window device:\n"
|
||||
<< spec.stringify() << "\n";
|
||||
<< spec->stringify() << "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user