}
+bool GuiView::hasFocus() const
+{
+ if (currentWorkArea())
+ return currentWorkArea()->hasFocus();
+ if (currentMainWorkArea())
+ return currentMainWorkArea()->hasFocus();
+ return d.bg_widget_->hasFocus();
+}
+
+
void GuiView::focusInEvent(QFocusEvent * e)
{
LYXERR(Debug::DEBUG, "GuiView::focusInEvent()" << this);
Buffer * doc_buffer = documentBufferView()
? &(documentBufferView()->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-related.
+ */
+ if (cmd.origin() == FuncRequest::MENU && !hasFocus()) {
+ buf = 0;
+ doc_buffer = 0;
+ }
+
// Check whether we need a buffer
if (!lyxaction.funcHasFlag(cmd.action(), LyXAction::NoBuffer) && !buf) {
// no, exit directly
enable = doc_buffer;
break;
+ case LFUN_BUFFER_MOVE_NEXT:
+ case LFUN_BUFFER_MOVE_PREVIOUS:
+ // we do not cycle when moving
case LFUN_BUFFER_NEXT:
case LFUN_BUFFER_PREVIOUS:
- // FIXME: should we check is there is an previous or next buffer?
+ // because we cycle, it doesn't matter whether on first or last
+ enable = (d.currentTabWorkArea()->count() > 1);
break;
case LFUN_BUFFER_SWITCH:
// toggle on the current buffer, but do not toggle off
}
-void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np)
+void GuiView::gotoNextOrPreviousBuffer(NextOrPrevious np, bool const move)
{
if (!documentBufferView())
return;
next_index = (i == nwa - 1 ? 0 : i + 1);
else
next_index = (i == 0 ? nwa - 1 : i - 1);
- setBuffer(&workArea(next_index)->bufferView().buffer());
+ if (move)
+ twa->moveTab(i, next_index);
+ else
+ setBuffer(&workArea(next_index)->bufferView().buffer());
break;
}
}
}
case LFUN_BUFFER_NEXT:
- gotoNextOrPreviousBuffer(NEXTBUFFER);
+ gotoNextOrPreviousBuffer(NEXTBUFFER, false);
+ break;
+
+ case LFUN_BUFFER_MOVE_NEXT:
+ gotoNextOrPreviousBuffer(NEXTBUFFER, true);
break;
case LFUN_BUFFER_PREVIOUS:
- gotoNextOrPreviousBuffer(PREVBUFFER);
+ gotoNextOrPreviousBuffer(PREVBUFFER, false);
+ break;
+
+ case LFUN_BUFFER_MOVE_PREVIOUS:
+ gotoNextOrPreviousBuffer(PREVBUFFER, true);
break;
case LFUN_COMMAND_EXECUTE: {