mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 05:01:49 +00:00
Raise the window in single-instance mode
Other than issuing a warning on the console, now the LyX window is raised when in single-instance mode and no files to load are specified. In this way, the user is aware that something happened after double clicking the program icon. To support this functionality the new lfun window-raise has been introduced.
This commit is contained in:
parent
986a55fd7e
commit
a73c2c2b93
@ -489,6 +489,7 @@ enum FuncCode
|
|||||||
// 380
|
// 380
|
||||||
LFUN_MASTER_BUFFER_FORALL, // spitz 20191231
|
LFUN_MASTER_BUFFER_FORALL, // spitz 20191231
|
||||||
LFUN_IF_RELATIVES, // spitz 20200102
|
LFUN_IF_RELATIVES, // spitz 20200102
|
||||||
|
LFUN_WINDOW_RAISE, // forenr, 20202104
|
||||||
LFUN_LASTACTION // end of the table
|
LFUN_LASTACTION // end of the table
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -4220,6 +4220,18 @@ void LyXAction::init()
|
|||||||
*/
|
*/
|
||||||
{ LFUN_WINDOW_NEW, "window-new", NoBuffer, Buffer },
|
{ 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
|
* \var lyx::FuncCode lyx::LFUN_WORD_BACKWARD
|
||||||
* \li Action: Moves the cursor to the logically previous beginning of a word.
|
* \li Action: Moves the cursor to the logically previous beginning of a word.
|
||||||
|
@ -1002,14 +1002,25 @@ struct Sleep : QThread
|
|||||||
|
|
||||||
bool LyXComm::loadFilesInOtherInstance()
|
bool LyXComm::loadFilesInOtherInstance()
|
||||||
{
|
{
|
||||||
|
int pipefd;
|
||||||
|
FileName const pipe(inPipeName());
|
||||||
|
|
||||||
if (theFilesToLoad().empty()) {
|
if (theFilesToLoad().empty()) {
|
||||||
LYXERR0("LyX is already running in another instance\n"
|
LYXERR0("LyX is already running in another instance\n"
|
||||||
"and 'use single instance' is active.");
|
"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;
|
return true;
|
||||||
}
|
}
|
||||||
int pipefd;
|
|
||||||
int loaded_files = 0;
|
int loaded_files = 0;
|
||||||
FileName const pipe(inPipeName());
|
|
||||||
vector<string>::iterator it = theFilesToLoad().begin();
|
vector<string>::iterator it = theFilesToLoad().begin();
|
||||||
while (it != theFilesToLoad().end()) {
|
while (it != theFilesToLoad().end()) {
|
||||||
FileName fname = fileSearch(string(), os::internal_path(*it),
|
FileName fname = fileSearch(string(), os::internal_path(*it),
|
||||||
|
@ -2312,6 +2312,7 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
|
|||||||
|
|
||||||
case LFUN_SERVER_GOTO_FILE_ROW:
|
case LFUN_SERVER_GOTO_FILE_ROW:
|
||||||
case LFUN_LYX_ACTIVATE:
|
case LFUN_LYX_ACTIVATE:
|
||||||
|
case LFUN_WINDOW_RAISE:
|
||||||
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());
|
||||||
@ -4502,6 +4503,12 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
|
|||||||
activateWindow();
|
activateWindow();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LFUN_WINDOW_RAISE:
|
||||||
|
raise();
|
||||||
|
activateWindow();
|
||||||
|
showNormal();
|
||||||
|
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user