From 4f7afedcc47b54096ac11141c25f7e3c2991a6f2 Mon Sep 17 00:00:00 2001 From: eidheim Date: Mon, 13 Jul 2015 00:12:02 +0200 Subject: [PATCH] Minor autocomplete fixes. --- juci/selectiondialog.cc | 2 +- juci/source.cc | 12 ++++++++++-- juci/source.h | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/juci/selectiondialog.cc b/juci/selectiondialog.cc index ca794bc..be51467 100644 --- a/juci/selectiondialog.cc +++ b/juci/selectiondialog.cc @@ -61,8 +61,8 @@ void SelectionDialog::show() { } void SelectionDialog::hide() { - window->hide(); shown=false; + window->hide(); if(tooltips) tooltips->hide(); } diff --git a/juci/source.cc b/juci/source.cc index 49b8595..51c024d 100644 --- a/juci/source.cc +++ b/juci/source.cc @@ -580,7 +580,6 @@ bool Source::ClangView::on_key_press_event(GdkEventKey* key) { ////////////////////////////// //// ClangViewAutocomplete /// ////////////////////////////// -//TODO: Raise autocomplete window after alt-tab back to application Source::ClangViewAutocomplete::ClangViewAutocomplete(const std::string& file_path, const std::string& project_path, Terminal::Controller& terminal): Source::ClangView(file_path, project_path, terminal), selection_dialog(*this), autocomplete_cancel_starting(false) { get_buffer()->signal_changed().connect([this](){ @@ -625,7 +624,7 @@ Source::ClangView(file_path, project_path, terminal), selection_dialog(*this), a }); signal_scroll_event().connect([this](GdkEventScroll* event){ if(selection_dialog.shown) - selection_dialog.move(); + selection_dialog.hide(); return false; }, false); signal_key_release_event().connect([this](GdkEventKey* key){ @@ -647,6 +646,15 @@ bool Source::ClangViewAutocomplete::on_key_press_event(GdkEventKey *key) { } return ClangView::on_key_press_event(key); } + +bool Source::ClangViewAutocomplete::on_focus_out_event(GdkEventFocus* event) { + if(selection_dialog.shown) { + selection_dialog.hide(); + } + + return Source::ClangView::on_focus_out_event(event); +} + void Source::ClangViewAutocomplete::autocomplete() { if(!autocomplete_starting) { autocomplete_starting=true; diff --git a/juci/source.h b/juci/source.h index 51386c0..40a8ad0 100644 --- a/juci/source.h +++ b/juci/source.h @@ -83,6 +83,7 @@ namespace Source { std::mutex parsing_mutex; sigc::connection delayed_reparse_connection; bool on_key_press_event(GdkEventKey* key); + bool on_focus_out_event(GdkEventFocus* event); private: // inits the syntax highligthing on file open void init_syntax_highlighting(const std::map @@ -99,7 +100,6 @@ namespace Source { bool on_motion_notify_event(GdkEventMotion* event); void on_mark_set(const Gtk::TextBuffer::iterator& iterator, const Glib::RefPtr& mark); sigc::connection delayed_tooltips_connection; - bool on_focus_out_event(GdkEventFocus* event); bool on_scroll_event(GdkEventScroll* event); static clang::Index clang_index; std::unique_ptr clang_tokens; @@ -128,6 +128,7 @@ namespace Source { ClangViewAutocomplete(const std::string& file_path, const std::string& project_path, Terminal::Controller& terminal); protected: bool on_key_press_event(GdkEventKey* key); + bool on_focus_out_event(GdkEventFocus* event); private: void autocomplete(); SelectionDialog selection_dialog;