>>>>> "Bennett" == Bennett Helm <[EMAIL PROTECTED]> writes:
Bennett> Yes, there is a difference (for the better!) with the patch Bennett> applied. I meant to say that I'd leave your criterion (as Bennett> used in the most recent patch) as is: everything that does Bennett> not apply to the current document is OK. Bennett> Using that criterion, here's the summary of what menu options Bennett> the patch leaves still available that it shouldn't: Could you try the following updated patch? I forgot the case of command-sequence. Bennett> There's one additional oddity I've now noticed. The current Bennett> patch allows menu access for things like File > New, and Bennett> selecting the menu option with the mouse works as expected. Bennett> However, typing the relevant keybinding ("<Cmd>N") does Bennett> nothing. This is true for all menu options still available Bennett> under the File menu; it is not true of LyX > Preferences, the Bennett> only other available menu option with a standard keybinding. This is because bindings are handled directly in the main lyx window. They are not accessible from the dialog. Preference is different, since its binding is hijacked by qt/mac. JMarc
Index: src/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/ChangeLog,v retrieving revision 1.2035 diff -u -p -r1.2035 ChangeLog --- src/ChangeLog 15 Nov 2004 13:39:05 -0000 1.2035 +++ src/ChangeLog 15 Nov 2004 16:11:58 -0000 @@ -1,3 +1,13 @@ +2004-11-15 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * lyxfunc.C (getStatus): when the origin of the request is menu or + toolbar, and the LyXView does not have focus, do as if there was + no buffer [bug 1720] + + (getStatus): + (dispatch): propagate the origin of a FuncRequest to individual + entries of LFUN_SEQUENCE + 2004-11-10 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * output_latex.C (TeXOnePar): override runparams.moving_arg Index: src/lyxfunc.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/lyxfunc.C,v retrieving revision 1.628 diff -u -p -r1.628 lyxfunc.C --- src/lyxfunc.C 8 Nov 2004 10:54:28 -0000 1.628 +++ src/lyxfunc.C 15 Nov 2004 16:11:59 -0000 @@ -272,9 +272,19 @@ FuncStatus LyXFunc::getStatus(FuncReques { //lyxerr << "LyXFunc::getStatus: cmd: " << cmd << endl; FuncStatus flag; - Buffer * buf = owner->buffer(); LCursor & cur = view()->cursor(); + /* 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. + */ + Buffer * buf; + if (cmd.origin == FuncRequest::UI && !owner->hasFocus()) + buf = 0; + else + buf = owner->buffer(); + if (cmd.action == LFUN_NOACTION) { setStatusMessage(N_("Nothing to do")); flag.enabled(false); @@ -447,7 +457,9 @@ FuncStatus LyXFunc::getStatus(FuncReques case LFUN_SEQUENCE: { // argument contains ';'-terminated commands string const firstcmd = token(cmd.argument, ';', 0); - flag = getStatus(lyxaction.lookupFunc(firstcmd)); + FuncRequest func(lyxaction.lookupFunc(firstcmd)); + func.origin = cmd.origin; + flag = getStatus(func); } case LFUN_MENUNEW: @@ -1219,7 +1231,9 @@ void LyXFunc::dispatch(FuncRequest const while (!arg.empty()) { string first; arg = split(arg, first, ';'); - dispatch(lyxaction.lookupFunc(first)); + FuncRequest func(lyxaction.lookupFunc(first)); + func.origin = cmd.origin; + dispatch(func); } break; } Index: src/frontends/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/ChangeLog,v retrieving revision 1.262 diff -u -p -r1.262 ChangeLog --- src/frontends/ChangeLog 9 Nov 2004 12:40:33 -0000 1.262 +++ src/frontends/ChangeLog 15 Nov 2004 16:11:59 -0000 @@ -1,3 +1,7 @@ +2004-11-15 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * LyXView.h (hasFocus): new abstract virtual function + 2004-11-08 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * Toolbars.C (layoutSelected): new method, which was triplicated Index: src/frontends/LyXView.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/LyXView.h,v retrieving revision 1.33 diff -u -p -r1.33 LyXView.h --- src/frontends/LyXView.h 27 Sep 2004 20:52:39 -0000 1.33 +++ src/frontends/LyXView.h 15 Nov 2004 16:11:59 -0000 @@ -142,6 +142,9 @@ public: */ Buffer const * const updateInset(InsetBase const *) const; + // returns true if this view has the focus. + virtual bool hasFocus() const = 0; + protected: /// view of a buffer. Eventually there will be several. boost::shared_ptr<BufferView> bufferview_; Index: src/frontends/gtk/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/ChangeLog,v retrieving revision 1.83 diff -u -p -r1.83 ChangeLog --- src/frontends/gtk/ChangeLog 14 Nov 2004 18:26:16 -0000 1.83 +++ src/frontends/gtk/ChangeLog 15 Nov 2004 16:11:59 -0000 @@ -1,3 +1,7 @@ +2004-11-15 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * GView.C (hasFocus): new method, always returns true for now + 2004-11-14 John Spray <[EMAIL PROTECTED]> * The ERT dialog: Index: src/frontends/gtk/GView.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/GView.C,v retrieving revision 1.19 diff -u -p -r1.19 GView.C --- src/frontends/gtk/GView.C 10 Oct 2004 15:10:37 -0000 1.19 +++ src/frontends/gtk/GView.C 15 Nov 2004 16:11:59 -0000 @@ -171,5 +171,13 @@ void GView::clearMessage() message(getLyXFunc().viewStatusMessage()); } + +bool GView::hasFocus() const +{ + // No real implementation needed for now + return true; +} + + } // namespace frontend } // namespace lyx Index: src/frontends/gtk/GView.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/gtk/GView.h,v retrieving revision 1.9 diff -u -p -r1.9 GView.h --- src/frontends/gtk/GView.h 26 Sep 2004 18:36:07 -0000 1.9 +++ src/frontends/gtk/GView.h 15 Nov 2004 16:11:59 -0000 @@ -51,6 +51,10 @@ public: virtual void busy(bool) const; /// clear any temporary message and replace with current status virtual void clearMessage(); + + // returns true if this view has the focus. + virtual bool hasFocus() const; + private: void showViewState(); bool onFocusIn(GdkEventFocus * event); Index: src/frontends/qt2/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/ChangeLog,v retrieving revision 1.723 diff -u -p -r1.723 ChangeLog --- src/frontends/qt2/ChangeLog 9 Nov 2004 12:40:33 -0000 1.723 +++ src/frontends/qt2/ChangeLog 15 Nov 2004 16:11:59 -0000 @@ -1,3 +1,10 @@ +2004-11-15 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * QtView.C (hasFocus): new method + + * QLPopupMenu.C (populate): remove a Qt/Mac hack to disable some + menu entries when the main window does not have focus + 2004-11-08 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * QLToolbar.C (selected): use layoutSelected Index: src/frontends/qt2/QLPopupMenu.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QLPopupMenu.C,v retrieving revision 1.37 diff -u -p -r1.37 QLPopupMenu.C --- src/frontends/qt2/QLPopupMenu.C 26 Oct 2004 21:16:43 -0000 1.37 +++ src/frontends/qt2/QLPopupMenu.C 15 Nov 2004 16:11:59 -0000 @@ -24,7 +24,6 @@ #ifdef Q_WS_MACX #include "kbmap.h" -#include "LyXAction.h" #include "QLyXKeySym.h" extern boost::scoped_ptr<kb_keymap> toplevel_keymap; #endif @@ -122,26 +121,6 @@ void QLPopupMenu::populate(Menu * menu) QString label = toqstr(getLabel(*m)); #ifdef Q_WS_MACX - /* 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. - */ - /* This test is actually not adequate, - for example "dialog-show document" is not - correctly disabled. What should be done - (but is maybe hackish) define a version of - LyXFunc::getStatus that takes a Buffer* as - argument, so that we can call it with buf=0 - (JMarc) - */ - if (status.enabled() - && qApp->activeWindow() != qApp->mainWidget() - && !lyxaction.funcHasFlag(m->func().action, - LyXAction::NoBuffer)) - status.enabled(false); - /* There are two constraints on Qt/Mac: (1) the bindings require a unicode string to be represented meaningfully and std::string Index: src/frontends/qt2/QtView.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QtView.C,v retrieving revision 1.47 diff -u -p -r1.47 QtView.C --- src/frontends/qt2/QtView.C 8 Nov 2004 10:54:29 -0000 1.47 +++ src/frontends/qt2/QtView.C 15 Nov 2004 16:11:59 -0000 @@ -144,6 +144,12 @@ void QtView::activated(FuncRequest const } +bool QtView::hasFocus() const +{ + return qApp->activeWindow() == this; +} + + void QtView::closeEvent(QCloseEvent *) { QuitLyX(); Index: src/frontends/qt2/QtView.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QtView.h,v retrieving revision 1.19 diff -u -p -r1.19 QtView.h --- src/frontends/qt2/QtView.h 19 May 2004 15:11:34 -0000 1.19 +++ src/frontends/qt2/QtView.h 15 Nov 2004 16:11:59 -0000 @@ -59,6 +59,9 @@ public: /// menu item has been selected void activated(FuncRequest const &); + // returns true if this view has the focus. + virtual bool hasFocus() const; + public slots: /// idle timeout void update_view_state_qt(); Index: src/frontends/xforms/ChangeLog =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/ChangeLog,v retrieving revision 1.944 diff -u -p -r1.944 ChangeLog --- src/frontends/xforms/ChangeLog 9 Nov 2004 12:40:34 -0000 1.944 +++ src/frontends/xforms/ChangeLog 15 Nov 2004 16:11:59 -0000 @@ -1,3 +1,7 @@ +2004-11-15 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> + + * XFormsView.C (hasFocus): new method, always returns true for now + 2004-11-08 Jean-Marc Lasgouttes <[EMAIL PROTECTED]> * XFormsToolbar.C (selected): use layoutSelected Index: src/frontends/xforms/XFormsView.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/XFormsView.C,v retrieving revision 1.47 diff -u -p -r1.47 XFormsView.C --- src/frontends/xforms/XFormsView.C 19 May 2004 15:11:37 -0000 1.47 +++ src/frontends/xforms/XFormsView.C 15 Nov 2004 16:11:59 -0000 @@ -218,6 +218,13 @@ void XFormsView::updateMetrics(bool resi } +bool XFormsView::hasFocus() const +{ + // No real implementation needed for now + return true; +} + + void XFormsView::setWindowTitle(string const & title, string const & icon_title) { fl_set_form_title(getForm(), title.c_str()); Index: src/frontends/xforms/XFormsView.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/xforms/XFormsView.h,v retrieving revision 1.24 diff -u -p -r1.24 XFormsView.h --- src/frontends/xforms/XFormsView.h 26 Sep 2004 14:19:46 -0000 1.24 +++ src/frontends/xforms/XFormsView.h 15 Nov 2004 16:11:59 -0000 @@ -79,6 +79,9 @@ public: /// boost::signal<void()> metricsUpdated; + // returns true if this view has the focus. + virtual bool hasFocus() const; + private: /** * setWindowTitle - set title of window