]> git.lyx.org Git - features.git/commitdiff
Let M-x give focus to minibuffer when it is already open
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 19 Aug 2016 12:53:31 +0000 (14:53 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 22 Aug 2016 16:20:09 +0000 (18:20 +0200)
src/frontends/qt4/GuiToolbar.cpp
src/frontends/qt4/GuiView.cpp
src/frontends/qt4/GuiView.h
src/frontends/qt4/Toolbars.h

index 77471c98af384e380cf2d720943aab5d65e901cc..2f0b5109918df72dda7e482fa679b511b1e74bfe 100644 (file)
@@ -324,9 +324,8 @@ void GuiToolbar::add(ToolbarItem const & item)
 void GuiToolbar::update(int context)
 {
        if (visibility_ & Toolbars::AUTO) {
-               bool const was_visible = isVisible();
                setVisible(visibility_ & context & Toolbars::ALLOWAUTO);
-               if (isVisible() && !was_visible && commandBuffer())
+               if (isVisible() && commandBuffer() && (context & Toolbars::MINIBUFFER_FOCUS))
                        commandBuffer()->setFocus();
        }
 
index b6d452231804ed5cd6111e812f6b7fb32d93eb07..39a72bb7bb6789a45158e5f7da950fb9750fd840 100644 (file)
@@ -513,7 +513,7 @@ QSet<Buffer const *> GuiView::GuiViewPrivate::busyBuffers;
 
 GuiView::GuiView(int id)
        : d(*new GuiViewPrivate(this)), id_(id), closing_(false), busy_(0),
-         command_execute_(false)
+         command_execute_(false), minibuffer_focus_(false)
 {
        // GuiToolbars *must* be initialised before the menu bar.
        normalSizedIcons(); // at least on Mac the default is 32 otherwise, which is huge
@@ -1564,6 +1564,10 @@ void GuiView::updateToolbars()
                        context |= Toolbars::IPA;
                if (command_execute_)
                        context |= Toolbars::MINIBUFFER;
+               if (minibuffer_focus_) {
+                       context |= Toolbars::MINIBUFFER_FOCUS;
+                       minibuffer_focus_ = false;
+               }
 
                for (ToolbarMap::iterator it = d.toolbars_.begin(); it != end; ++it)
                        it->second->update(context);
@@ -3661,6 +3665,7 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 
                case LFUN_COMMAND_EXECUTE: {
                        command_execute_ = true;
+                       minibuffer_focus_ = true;
                        break;
                }
                case LFUN_DROP_LAYOUTS_CHOICE:
index 33bfd97b05b14428c1df4c8074aff393693fab28..0d8cf8d1d2912095e03d16f6be1572f1c8d05647 100644 (file)
@@ -452,6 +452,8 @@ private:
 
        /// Request to open the command toolbar if it is "auto"
        bool command_execute_;
+       /// Request to give focus to minibuffer
+       bool minibuffer_focus_;
 
 };
 
index 02d0ebe5a4da275f7079da88d74936ed1bd4025d..dbaf3aaa21246dc93663276cb5b55b8513e20a25 100644 (file)
@@ -108,9 +108,10 @@ public:
                TABLE = 256, //< show when in table
                REVIEW = 512, //< show when change tracking is enabled
                MATHMACROTEMPLATE = 1024, //< show in math macro template
-               SAMEROW = 2048, //place to the current row, no new line
+               SAMEROW = 2048, //place to the current row, no new line
                IPA = 4096, //< show when in IPA inset
                MINIBUFFER = 8192, //< show when command-execute has been invoked
+               MINIBUFFER_FOCUS = 16384, //< set focus to minibuffer
                ALLOWAUTO = MATH | TABLE | REVIEW | MATHMACROTEMPLATE | IPA | MINIBUFFER
        };