From b05a94c3dd7cf276e531f22f20ec47e791b46fc0 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Tue, 14 Jul 2009 11:36:08 +0000 Subject: [PATCH] Fix again ticket #1720. This got broken during frontend reorganization. The situation now is almost good, although preference and about LyX are now disabled. I moved the code that sets buffer to 0 to LyXFunc::getStatus, where it belongs. I also set lyx_view_ to 0 when the window does not have focus. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30557 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXFunc.cpp | 21 ++++++++++++++++++--- src/frontends/LyXView.h | 2 ++ src/frontends/qt4/GuiView.cpp | 11 ----------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 98b21d1872..6a35feb326 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -398,7 +398,22 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const //lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl; FuncStatus flag; - Buffer * buf = lyx_view_ ? lyx_view_->buffer() : 0; + /* In LyX/Mac, when a dialog is open, the menus of the + application can still be accessed without giving focus to + the main window. In this case, we want to disable the menu + entries that are buffer or view-related. + + If this code is moved somewhere else (like in + GuiView::getStatus), then several functions will not be + handled correctly. + */ + frontend::LyXView * lv = 0; + Buffer * buf = 0; + if (lyx_view_ + && (cmd.origin != FuncRequest::MENU || lyx_view_->hasFocus())) { + lv = lyx_view_; + buf = lyx_view_->buffer(); + } if (cmd.action == LFUN_NOACTION) { flag.message(from_utf8(N_("Nothing to do"))); @@ -663,11 +678,11 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & cmd) const break; // Does the view know something? - if (!lyx_view_) { + if (!lv) { enable = false; break; } - if (lyx_view_->getStatus(cmd, flag)) + if (lv->getStatus(cmd, flag)) break; // If we do not have a BufferView, then other functions are disabled diff --git a/src/frontends/LyXView.h b/src/frontends/LyXView.h index f084449b5e..cb183a011b 100644 --- a/src/frontends/LyXView.h +++ b/src/frontends/LyXView.h @@ -66,6 +66,8 @@ public: virtual void setBuffer(Buffer * b) = 0; ///< \c Buffer to set. /// virtual bool closeBuffer() = 0; + /// + virtual bool hasFocus() const = 0; /// load a document into the current workarea. virtual Buffer * loadDocument( diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 184ad31390..028111545e 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -1223,17 +1223,6 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag) bool enable = true; Buffer * buf = buffer(); - /* In LyX/Mac, when a dialog is open, the menus of the - application can still be accessed without giving focus to - the main window. In this case, we want to disable the menu - entries that are buffer-related. - - Note that this code is not perfect, as bug 1941 attests: - http://bugzilla.lyx.org/show_bug.cgi?id=1941#c4 - */ - if (cmd.origin == FuncRequest::MENU && !hasFocus()) - buf = 0; - if (cmd.origin == FuncRequest::TOC) { GuiToc * toc = static_cast(findOrBuild("toc", false)); FuncStatus fs; -- 2.39.2