// 380
LFUN_MASTER_BUFFER_FORALL, // spitz 20191231
LFUN_IF_RELATIVES, // spitz 20200102
+ LFUN_WINDOW_RAISE, // forenr, 20202104
LFUN_LASTACTION // end of the table
};
*/
{ LFUN_WINDOW_NEW, "window-new", NoBuffer, Buffer },
+/*!
+ * \var lyx::FuncCode lyx::LFUN_WINDOW_RAISE
+ * \li Action: Raises the LyX window.
+ * \li Notion: Brings the LyX window to the front. Such behavior is allowed
+ on Windows only when no other application has focus.
+ This action is used when LyX is in single instance mode.
+ * \li Syntax: window-raise
+ * \li Origin: forenr, 21 Apr 2020
+ * \endvar
+ */
+ { LFUN_WINDOW_RAISE, "window-raise", ReadOnly | NoBuffer, Hidden },
+
/*!
* \var lyx::FuncCode lyx::LFUN_WORD_BACKWARD
* \li Action: Moves the cursor to the logically previous beginning of a word.
bool LyXComm::loadFilesInOtherInstance()
{
+ int pipefd;
+ FileName const pipe(inPipeName());
+
if (theFilesToLoad().empty()) {
LYXERR0("LyX is already running in another instance\n"
"and 'use single instance' is active.");
+ // Wait a while for the other instance to reset the connection
+ Sleep::millisec(200);
+ pipefd = ::open(pipe.toFilesystemEncoding().c_str(), O_WRONLY);
+ if (pipefd >= 0) {
+ string const cmd = "LYXCMD:pipe:window-raise\n";
+ if (::write(pipefd, cmd.c_str(), cmd.length()) < 0)
+ LYXERR0("Cannot communicate with running instance!");
+ ::close(pipefd);
+ }
return true;
}
- int pipefd;
+
int loaded_files = 0;
- FileName const pipe(inPipeName());
vector<string>::iterator it = theFilesToLoad().begin();
while (it != theFilesToLoad().end()) {
FileName fname = fileSearch(string(), os::internal_path(*it),
case LFUN_SERVER_GOTO_FILE_ROW:
case LFUN_LYX_ACTIVATE:
+ case LFUN_WINDOW_RAISE:
break;
case LFUN_FORWARD_SEARCH:
enable = !(lyxrc.forward_search_dvi.empty() && lyxrc.forward_search_pdf.empty());
activateWindow();
break;
+ case LFUN_WINDOW_RAISE:
+ raise();
+ activateWindow();
+ showNormal();
+ break;
+
case LFUN_FORWARD_SEARCH: {
// it seems safe to assume we have a document buffer, since
// getStatus wants one.