From 6e99d4bcc99c80f4521eae4af8529b3d9b005c7a Mon Sep 17 00:00:00 2001 From: eidheim Date: Sat, 4 Jul 2015 09:58:45 +0200 Subject: [PATCH] Minor fixes to tooltip, now hides more often. --- juci/selectiondialog.cc | 2 ++ juci/source.cc | 7 +++++++ juci/source.h | 1 + juci/tooltips.cc | 7 +++++++ juci/tooltips.h | 2 ++ juci/window.cc | 2 +- 6 files changed, 20 insertions(+), 1 deletion(-) diff --git a/juci/selectiondialog.cc b/juci/selectiondialog.cc index 8eca51d..28a45c1 100644 --- a/juci/selectiondialog.cc +++ b/juci/selectiondialog.cc @@ -2,6 +2,8 @@ SelectionDialog::SelectionDialog(Gtk::TextView& text_view): Gtk::Dialog(), text_view(text_view), list_view_text(1, false, Gtk::SelectionMode::SELECTION_SINGLE) { + property_decorated()=false; + set_skip_taskbar_hint(true); scrolled_window.set_policy(Gtk::PolicyType::POLICY_NEVER, Gtk::PolicyType::POLICY_NEVER); list_view_text.set_enable_search(true); list_view_text.set_headers_visible(false); diff --git a/juci/source.cc b/juci/source.cc index c5010d2..f75fb72 100644 --- a/juci/source.cc +++ b/juci/source.cc @@ -218,6 +218,7 @@ parse_thread_go(true), parse_thread_mapped(false), parse_thread_stop(false) { signal_key_press_event().connect(sigc::mem_fun(*this, &Source::ClangView::on_key_press), false); signal_key_release_event().connect(sigc::mem_fun(*this, &Source::ClangView::on_key_release), false); signal_motion_notify_event().connect(sigc::mem_fun(*this, &Source::ClangView::clangview_on_motion_notify_event), false); + signal_focus_out_event().connect(sigc::mem_fun(*this, &Source::ClangView::clangview_on_focus_out_event), false); get_buffer()->signal_mark_set().connect(sigc::mem_fun(*this, &Source::ClangView::clangview_on_mark_set), false); } @@ -438,6 +439,12 @@ void Source::ClangView::clangview_on_mark_set(const Gtk::TextBuffer::iterator& i } } +bool Source::ClangView::clangview_on_focus_out_event(GdkEventFocus* event) { + diagnostic_tooltips.hide(); + type_tooltips.hide(); + return false; +} + void Source::ClangView:: highlight_cursor(clang::Token *token, std::vector *source_ranges) { diff --git a/juci/source.h b/juci/source.h index 1d8dc44..03c4db5 100644 --- a/juci/source.h +++ b/juci/source.h @@ -102,6 +102,7 @@ namespace Source { Tooltips type_tooltips; bool clangview_on_motion_notify_event(GdkEventMotion* event); void clangview_on_mark_set(const Gtk::TextBuffer::iterator& iterator, const Glib::RefPtr& mark); + bool clangview_on_focus_out_event(GdkEventFocus* event); static clang::Index clang_index; std::map get_buffer_map() const; diff --git a/juci/tooltips.cc b/juci/tooltips.cc index 3676d4d..d06fdaa 100644 --- a/juci/tooltips.cc +++ b/juci/tooltips.cc @@ -37,6 +37,8 @@ void Tooltip::adjust() { //init window window=std::unique_ptr(new Gtk::Window(Gtk::WindowType::WINDOW_POPUP)); + window->set_events(Gdk::POINTER_MOTION_MASK); + window->signal_motion_notify_event().connect(sigc::mem_fun(*this, &Tooltip::tooltip_on_motion_notify_event), false); window->property_decorated()=false; window->set_accept_focus(false); window->set_skip_taskbar_hint(true); @@ -70,6 +72,11 @@ void Tooltip::adjust() { window->move(rectangle.get_x(), rectangle.get_y()); } +bool Tooltip::tooltip_on_motion_notify_event(GdkEventMotion* event) { + window->hide(); + return false; +} + void Tooltips::show(const Gdk::Rectangle& rectangle) { for(auto& tooltip: *this) { tooltip.update(); diff --git a/juci/tooltips.h b/juci/tooltips.h index decaff4..9189622 100644 --- a/juci/tooltips.h +++ b/juci/tooltips.h @@ -15,6 +15,8 @@ public: Gdk::Rectangle activation_rectangle; std::unique_ptr window; private: + bool tooltip_on_motion_notify_event(GdkEventMotion* event); + std::function()> get_buffer; std::unique_ptr tooltip_widget; Glib::RefPtr start_mark; diff --git a/juci/window.cc b/juci/window.cc index d784d23..0494c5d 100644 --- a/juci/window.cc +++ b/juci/window.cc @@ -14,7 +14,7 @@ Window::Window() : INFO("Create Window"); set_title("juCi++"); set_default_size(600, 400); - set_events(Gdk::POINTER_MOTION_MASK); + set_events(Gdk::POINTER_MOTION_MASK|Gdk::FOCUS_CHANGE_MASK); add(window_box_); keybindings_.action_group_menu()->add(Gtk::Action::create("FileQuit", "Quit juCi++"),