summaryrefslogtreecommitdiff
path: root/unity-shared
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2017-02-28 18:16:14 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2017-02-28 18:16:14 +0100
commit678278f7e6b5cf8d073edefdc20faee13230fc7e (patch)
tree9d123dc6905e3a5f9a3b225bd74955c89d608da8 /unity-shared
parentbb11475ecd3599fbf9124ebfc1a039cddfb6a7e9 (diff)
InputMonitor: don't try to deference an invalid Nux display
Fixes LP: #1632656 (bzr r4220.3.1)
Diffstat (limited to 'unity-shared')
-rw-r--r--unity-shared/InputMonitor.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/unity-shared/InputMonitor.cpp b/unity-shared/InputMonitor.cpp
index 465c5afad..c7b70538a 100644
--- a/unity-shared/InputMonitor.cpp
+++ b/unity-shared/InputMonitor.cpp
@@ -225,7 +225,8 @@ struct Monitor::Impl
void UpdateEventMonitor()
{
- auto* dpy = nux::GetGraphicsDisplay()->GetX11Display();
+ auto* nux_dpy = nux::GetGraphicsDisplay();
+ auto* dpy = nux_dpy ? nux_dpy->GetX11Display() : gdk_x11_get_default_xdisplay();
Window root = DefaultRootWindow(dpy);
unsigned char master_dev_bits[XIMaskLen(XI_LASTEVENT)] = { 0 };
@@ -263,9 +264,9 @@ struct Monitor::Impl
if (!pointer_callbacks_.empty() || !key_callbacks_.empty() || !barrier_callbacks_.empty())
{
- if (!event_filter_set_)
+ if (!event_filter_set_ && nux_dpy)
{
- nux::GetGraphicsDisplay()->AddEventFilter({[] (XEvent event, void* data) {
+ nux_dpy->AddEventFilter({[] (XEvent event, void* data) {
return static_cast<Impl*>(data)->HandleEvent(event);
}, this});
@@ -275,7 +276,9 @@ struct Monitor::Impl
}
else if (event_filter_set_)
{
- nux::GetGraphicsDisplay()->RemoveEventFilter(this);
+ if (nux_dpy)
+ nux_dpy->RemoveEventFilter(this);
+
event_filter_set_ = false;
LOG_DEBUG(logger) << "Event filter disabled";
}