mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Fix focus lost order
This commit is contained in:
parent
da93936067
commit
3803cd1e16
2 changed files with 37 additions and 6 deletions
|
@ -46,6 +46,8 @@ public class TerminalViewDockComp extends SimpleComp {
|
||||||
s.focusedProperty().addListener((observable, oldValue, newValue) -> {
|
s.focusedProperty().addListener((observable, oldValue, newValue) -> {
|
||||||
if (newValue) {
|
if (newValue) {
|
||||||
TerminalView.get().onFocusGain();
|
TerminalView.get().onFocusGain();
|
||||||
|
} else {
|
||||||
|
TerminalView.get().onFocusLost();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
s.addEventFilter(WindowEvent.WINDOW_SHOWN,event -> {
|
s.addEventFilter(WindowEvent.WINDOW_SHOWN,event -> {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import io.xpipe.app.core.window.NativeWinWindowControl;
|
||||||
import io.xpipe.app.issue.TrackEvent;
|
import io.xpipe.app.issue.TrackEvent;
|
||||||
import io.xpipe.app.prefs.AppPrefs;
|
import io.xpipe.app.prefs.AppPrefs;
|
||||||
import io.xpipe.app.terminal.DockableTerminalType;
|
import io.xpipe.app.terminal.DockableTerminalType;
|
||||||
import io.xpipe.app.terminal.ExternalTerminalType;
|
|
||||||
import io.xpipe.core.process.OsType;
|
import io.xpipe.core.process.OsType;
|
||||||
import javafx.application.Platform;
|
import javafx.application.Platform;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
|
@ -43,10 +42,12 @@ public class TerminalView {
|
||||||
|
|
||||||
public abstract void minimize();
|
public abstract void minimize();
|
||||||
|
|
||||||
public abstract void front();
|
public abstract void alwaysInFront();
|
||||||
|
|
||||||
public abstract void back();
|
public abstract void back();
|
||||||
|
|
||||||
|
public abstract void frontOfMainWindow();
|
||||||
|
|
||||||
public abstract void updatePosition(Rect bounds);
|
public abstract void updatePosition(Rect bounds);
|
||||||
|
|
||||||
public abstract void close();
|
public abstract void close();
|
||||||
|
@ -89,7 +90,7 @@ public class TerminalView {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void front() {
|
public void alwaysInFront() {
|
||||||
this.control.alwaysInFront();
|
this.control.alwaysInFront();
|
||||||
this.control.removeBorders();
|
this.control.removeBorders();
|
||||||
}
|
}
|
||||||
|
@ -101,6 +102,12 @@ public class TerminalView {
|
||||||
NativeWinWindowControl.MAIN_WINDOW.defaultOrder();
|
NativeWinWindowControl.MAIN_WINDOW.defaultOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void frontOfMainWindow() {
|
||||||
|
this.control.alwaysInFront();
|
||||||
|
this.control.defaultOrder();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatePosition(Rect bounds) {
|
public void updatePosition(Rect bounds) {
|
||||||
control.move(bounds);
|
control.move(bounds);
|
||||||
|
@ -211,7 +218,7 @@ public class TerminalView {
|
||||||
|
|
||||||
this.viewActive = active;
|
this.viewActive = active;
|
||||||
if (active) {
|
if (active) {
|
||||||
terminalInstances.forEach(terminalInstance -> terminalInstance.front());
|
terminalInstances.forEach(terminalInstance -> terminalInstance.alwaysInFront());
|
||||||
updatePositions();
|
updatePositions();
|
||||||
} else {
|
} else {
|
||||||
terminalInstances.forEach(terminalInstance -> terminalInstance.back());
|
terminalInstances.forEach(terminalInstance -> terminalInstance.back());
|
||||||
|
@ -236,6 +243,28 @@ public class TerminalView {
|
||||||
}
|
}
|
||||||
|
|
||||||
terminalInstance.show();
|
terminalInstance.show();
|
||||||
|
terminalInstance.alwaysInFront();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void onFocusLost() {
|
||||||
|
if (!viewActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TrackEvent.withTrace("Terminal view focus lost")
|
||||||
|
.handle();
|
||||||
|
terminalInstances.forEach(terminalInstance -> {
|
||||||
|
if (!terminalInstance.isActive()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
terminalInstance.updateBoundsState();
|
||||||
|
if (terminalInstance.isCustomBounds()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
terminalInstance.frontOfMainWindow();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +279,7 @@ public class TerminalView {
|
||||||
|
|
||||||
terminalInstance.show();
|
terminalInstance.show();
|
||||||
if (viewActive) {
|
if (viewActive) {
|
||||||
terminalInstance.front();
|
terminalInstance.alwaysInFront();
|
||||||
} else {
|
} else {
|
||||||
terminalInstance.back();
|
terminalInstance.back();
|
||||||
}
|
}
|
||||||
|
@ -318,7 +347,7 @@ public class TerminalView {
|
||||||
|
|
||||||
terminalInstances.forEach(terminalInstance -> {
|
terminalInstances.forEach(terminalInstance -> {
|
||||||
terminalInstance.show();
|
terminalInstance.show();
|
||||||
terminalInstance.front();
|
terminalInstance.alwaysInFront();
|
||||||
terminalInstance.updatePosition(viewBounds);
|
terminalInstance.updatePosition(viewBounds);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue