Skip to content

Commit

Permalink
Minor adjustment of logic to handle when no "current Desktop is found…
Browse files Browse the repository at this point in the history
…" for the nedit server.

Maybe fixes issue eteran#253 ?
  • Loading branch information
eteran authored and 1div0 committed Mar 24, 2021
1 parent 72933ea commit 0afba1d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/NeditServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ long QueryDesktop(Display *display, Window window) {
* @return
*/
bool isLocatedOnDesktop(QWidget *widget, long currentDesktop) {
#if defined(QT_X11)
if (currentDesktop == -1) {
return true; /* No desktop information available */
}
#if defined(QT_X11)

Display *TheDisplay = QX11Info::display();
long windowDesktop = QueryDesktop(TheDisplay, widget->winId());
Expand Down Expand Up @@ -299,11 +299,12 @@ void NeditServer::newConnection() {

std::vector<DocumentWidget *> documents = DocumentWidget::allDocuments();

auto it = std::find_if(documents.begin(), documents.end(), [currentDesktop](DocumentWidget *doc) {
return (!doc->filenameSet() && !doc->fileChanged() && isLocatedOnDesktop(MainWindow::fromDocument(doc), currentDesktop));
});

if (doCommand.isEmpty()) {

auto it = std::find_if(documents.begin(), documents.end(), [currentDesktop](DocumentWidget *doc) {
return (!doc->filenameSet() && !doc->fileChanged() && isLocatedOnDesktop(MainWindow::fromDocument(doc), currentDesktop));
});

if (it == documents.end()) {

MainWindow::editNewFile(
Expand Down

0 comments on commit 0afba1d

Please sign in to comment.