New LFUN lyx-activate to focus LyX window

On Linux and Mac OS, this action brings the LyX window into focus.
Such behavior is not allowed by Windows OS so instead the color of
the taskbar entry is changed to indicate that the window has changed
in some way.

The action is hidden in the shortcuts menu because it would make
sense to assign a shortcut to it. The only way to execute shortcut
would be if the LyX window is already activated.

lyx-activate will be used (see next commit) to allow the PDF viewer
to switch to LyX after executing a reverse search.
This commit is contained in:
Scott Kostyshak 2016-08-04 01:20:14 -04:00
parent bd5d0a6254
commit 60515b996b
5 changed files with 42 additions and 0 deletions

View File

@ -22,6 +22,9 @@ material in different versions easier.
* branch-invert * branch-invert
Toggles inversion status of branch inset. Toggles inversion status of branch inset.
* lyx-activate
Activates the LyX window. Useful in combination with reverse search.
!!!The following LyX functions have been changed in 2.3: !!!The following LyX functions have been changed in 2.3:

View File

@ -7025,6 +7025,26 @@ This is probably usable only with connection to lyxserver.
Syntax command-prefix Syntax command-prefix
\end_layout \end_layout
\begin_layout Subsection*
lyx-activate
\end_layout
\begin_layout Description
Action Activates the LyX window.
\end_layout
\begin_layout Description
Notion On Linux and Mac OS, this action brings the LyX window into focus. Such behavior is not allowed by Windows OS so instead the color of the taskbar entry is changed to indicate that the window has changed in some way. This action is useful in combination with reverse search.
\end_layout
\begin_layout Description
Syntax lyx-activate
\end_layout
\begin_layout Description
Origin skostysh, 4 Aug 2016
\end_layout
\begin_layout Subsection* \begin_layout Subsection*
self-insert self-insert
\end_layout \end_layout

View File

@ -466,6 +466,7 @@ enum FuncCode
LFUN_BUFFER_MOVE_PREVIOUS, // skostysh 20150408 LFUN_BUFFER_MOVE_PREVIOUS, // skostysh 20150408
LFUN_TABULAR_FEATURE, // gm, 20151210 LFUN_TABULAR_FEATURE, // gm, 20151210
LFUN_BRANCH_INVERT, // rgheck, 20160712 LFUN_BRANCH_INVERT, // rgheck, 20160712
LFUN_LYX_ACTIVATE, // skostysh, 20160804
LFUN_LASTACTION // end of the table LFUN_LASTACTION // end of the table
}; };

View File

@ -2715,6 +2715,19 @@ void LyXAction::init()
* \endvar * \endvar
*/ */
{ LFUN_LYX_QUIT, "lyx-quit", NoBuffer, Buffer }, { LFUN_LYX_QUIT, "lyx-quit", NoBuffer, Buffer },
/*!
* \var lyx::FuncCode lyx::LFUN_LYX_ACTIVATE
* \li Action: Activates the LyX window.
* \li Notion: On Linux and Mac OS, this action brings the LyX window
into focus. Such behavior is not allowed by Windows OS
so instead the color of the taskbar entry is changed to
indicate that the window has changed in some way.
This action is useful in combination with reverse search.
* \li Syntax: lyx-activate
* \li Origin: skostysh, 4 Aug 2016
* \endvar
*/
{ LFUN_LYX_ACTIVATE, "lyx-activate", ReadOnly | NoBuffer, Hidden },
/*! /*!
* \var lyx::FuncCode lyx::LFUN_TOOLBAR_TOGGLE * \var lyx::FuncCode lyx::LFUN_TOOLBAR_TOGGLE
* \li Action: Toggles visibility of a given toolbar between on/off/auto. * \li Action: Toggles visibility of a given toolbar between on/off/auto.

View File

@ -2055,6 +2055,7 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
break; break;
case LFUN_SERVER_GOTO_FILE_ROW: case LFUN_SERVER_GOTO_FILE_ROW:
case LFUN_LYX_ACTIVATE:
break; break;
case LFUN_FORWARD_SEARCH: case LFUN_FORWARD_SEARCH:
enable = !(lyxrc.forward_search_dvi.empty() && lyxrc.forward_search_pdf.empty()); enable = !(lyxrc.forward_search_dvi.empty() && lyxrc.forward_search_pdf.empty());
@ -3978,6 +3979,10 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
goToFileRow(to_utf8(cmd.argument())); goToFileRow(to_utf8(cmd.argument()));
break; break;
case LFUN_LYX_ACTIVATE:
activateWindow();
break;
case LFUN_FORWARD_SEARCH: { case LFUN_FORWARD_SEARCH: {
// it seems safe to assume we have a document buffer, since // it seems safe to assume we have a document buffer, since
// getStatus wants one. // getStatus wants one.