diff options
Diffstat (limited to 'unity-shared')
| -rw-r--r-- | unity-shared/InputMonitor.cpp | 11 | ||||
| -rw-r--r-- | unity-shared/MenuManager.cpp | 11 |
2 files changed, 10 insertions, 12 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"; } diff --git a/unity-shared/MenuManager.cpp b/unity-shared/MenuManager.cpp index 77828700d..36d9d538b 100644 --- a/unity-shared/MenuManager.cpp +++ b/unity-shared/MenuManager.cpp @@ -325,17 +325,12 @@ struct Manager::Impl : sigc::trackable bool RegisterTracker(std::string const& menubar, PositionTracker const& cb) { - auto it = position_trackers_.find(menubar); - - if (it != end(position_trackers_)) - return false; - - position_trackers_.insert({menubar, cb}); + bool added = position_trackers_.insert({menubar, cb}).second; - if (active_menubar_ == menubar) + if (added && active_menubar_ == menubar) UpdateActiveTracker(); - return true; + return added; } bool UnregisterTracker(std::string const& menubar, PositionTracker const& cb) |
