frame classifiaction not needed anymore

This commit is contained in:
Gregor Lohaus
2026-05-31 19:46:55 +02:00
parent 59ab33bc01
commit 093a09da39

View File

@@ -23,7 +23,6 @@ import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.Set; import java.util.Set;
/** /**
@@ -48,12 +47,9 @@ public final class Compositor {
private final List<Tab> tabs = new ArrayList<>(); private final List<Tab> tabs = new ArrayList<>();
private final Map<TerminalPane, TerminalPaneNode> nodes = new HashMap<>(); private final Map<TerminalPane, TerminalPaneNode> nodes = new HashMap<>();
private int currentTabIndex; private int currentTabIndex;
private long layoutVersion; private boolean sceneDirty = true;
private double lastWidth = -1.0; private double lastWidth = -1.0;
private double lastHeight = -1.0; private double lastHeight = -1.0;
private String lastFontFamily;
private double lastFontSize = -1.0;
private long lastLayoutVersion = Long.MIN_VALUE;
private long lastContentVersion = Long.MIN_VALUE; private long lastContentVersion = Long.MIN_VALUE;
private boolean mouseButtonPressed; private boolean mouseButtonPressed;
private MouseButton pressedButton = MouseButton.UNKNOWN; private MouseButton pressedButton = MouseButton.UNKNOWN;
@@ -80,7 +76,7 @@ public final class Compositor {
public void setFont(String family, double size) { public void setFont(String family, double size) {
metrics.setFont(family, size); metrics.setFont(family, size);
nodes.values().forEach(TerminalPaneNode::discard); nodes.values().forEach(TerminalPaneNode::discard);
lastWidth = -1.0; markSceneDirty();
} }
// ---- Tabs and panes ------------------------------------------------------------- // ---- Tabs and panes -------------------------------------------------------------
@@ -95,7 +91,7 @@ public final class Compositor {
public void navigate(Direction direction) { public void navigate(Direction direction) {
if (!isEmpty() && currentTab().navigate(direction)) { if (!isEmpty() && currentTab().navigate(direction)) {
layoutVersion++; markSceneDirty();
} }
} }
@@ -104,7 +100,7 @@ public final class Compositor {
return; return;
} }
currentTab().toggleFloating(); currentTab().toggleFloating();
layoutVersion++; markSceneDirty();
} }
public void createPane() { public void createPane() {
@@ -112,7 +108,7 @@ public final class Compositor {
return; return;
} }
currentTab().createPane(); currentTab().createPane();
layoutVersion++; markSceneDirty();
} }
public void nextFloatingPane() { public void nextFloatingPane() {
@@ -120,7 +116,7 @@ public final class Compositor {
return; return;
} }
currentTab().nextFloatingPane(); currentTab().nextFloatingPane();
layoutVersion++; markSceneDirty();
} }
public void closeActivePane() { public void closeActivePane() {
@@ -134,26 +130,26 @@ public final class Compositor {
currentTabIndex = Math.max(0, tabs.size() - 1); currentTabIndex = Math.max(0, tabs.size() - 1);
} }
} }
layoutVersion++; markSceneDirty();
} }
public void newTab() { public void newTab() {
tabs.add(new Tab(config, metrics)); tabs.add(new Tab(config, metrics));
currentTabIndex = tabs.size() - 1; currentTabIndex = tabs.size() - 1;
layoutVersion++; markSceneDirty();
} }
public void nextTab() { public void nextTab() {
if (tabs.size() > 1) { if (tabs.size() > 1) {
currentTabIndex = (currentTabIndex + 1) % tabs.size(); currentTabIndex = (currentTabIndex + 1) % tabs.size();
layoutVersion++; markSceneDirty();
} }
} }
public void previousTab() { public void previousTab() {
if (tabs.size() > 1) { if (tabs.size() > 1) {
currentTabIndex = (currentTabIndex - 1 + tabs.size()) % tabs.size(); currentTabIndex = (currentTabIndex - 1 + tabs.size()) % tabs.size();
layoutVersion++; markSceneDirty();
} }
} }
@@ -180,49 +176,35 @@ public final class Compositor {
private void focus(TerminalPane pane) { private void focus(TerminalPane pane) {
if (!tabs.isEmpty() && currentTab().focus(pane)) { if (!tabs.isEmpty() && currentTab().focus(pane)) {
layoutVersion++; markSceneDirty();
} }
} }
// ---- Rendering ------------------------------------------------------------------ // ---- Rendering ------------------------------------------------------------------
public void render() { public void render() {
switch (nextFrameType()) {
case IDLE -> { }
case LAYOUT -> renderLayoutFrame();
case CONTENT -> renderContentFrame();
}
}
private FrameType nextFrameType() {
double width = root.getWidth(); double width = root.getWidth();
double height = root.getHeight(); double height = root.getHeight();
long contentVersion = tabs.isEmpty() ? 0 : currentTab().contentVersion(); long contentVersion = tabs.isEmpty() ? 0 : currentTab().contentVersion();
boolean geometryChanged = width != lastWidth || height != lastHeight;
boolean layoutChanged = width != lastWidth || height != lastHeight
|| metrics.fontSize() != lastFontSize || !Objects.equals(metrics.fontFamily(), lastFontFamily)
|| layoutVersion != lastLayoutVersion;
boolean contentChanged = contentVersion != lastContentVersion; boolean contentChanged = contentVersion != lastContentVersion;
if (!sceneDirty && !geometryChanged && !contentChanged) {
return;
}
lastWidth = width; lastWidth = width;
lastHeight = height; lastHeight = height;
lastFontFamily = metrics.fontFamily();
lastFontSize = metrics.fontSize();
lastLayoutVersion = layoutVersion;
lastContentVersion = contentVersion; lastContentVersion = contentVersion;
sceneDirty = false;
if (layoutChanged) { renderFrame(width, height);
return FrameType.LAYOUT;
}
if (contentChanged) {
return FrameType.CONTENT;
}
return FrameType.IDLE;
} }
private void renderLayoutFrame() { private void markSceneDirty() {
double width = root.getWidth(); sceneDirty = true;
double height = root.getHeight(); }
private void renderFrame(double width, double height) {
double topInset = tabs.size() > 1 ? TAB_BAR_HEIGHT : 0.0; double topInset = tabs.size() > 1 ? TAB_BAR_HEIGHT : 0.0;
paneLayer.resizeRelocate(0.0, 0.0, width, height); paneLayer.resizeRelocate(0.0, 0.0, width, height);
@@ -245,15 +227,6 @@ public final class Compositor {
paneLayer.getChildren().setAll(orderedNodes); paneLayer.getChildren().setAll(orderedNodes);
} }
private void renderContentFrame() {
for (TerminalPane pane : currentPanes()) {
TerminalPaneNode node = nodes.get(pane);
if (node != null) {
node.renderIncremental(isActive(pane));
}
}
}
private TerminalPaneNode nodeFor(TerminalPane pane) { private TerminalPaneNode nodeFor(TerminalPane pane) {
return nodes.computeIfAbsent(pane, this::createNode); return nodes.computeIfAbsent(pane, this::createNode);
} }
@@ -299,7 +272,7 @@ public final class Compositor {
final int index = i; final int index = i;
label.setOnMousePressed(event -> { label.setOnMousePressed(event -> {
currentTabIndex = index; currentTabIndex = index;
layoutVersion++; markSceneDirty();
root.requestFocus(); root.requestFocus();
event.consume(); event.consume();
}); });
@@ -452,12 +425,6 @@ public final class Compositor {
}; };
} }
private enum FrameType {
IDLE,
LAYOUT,
CONTENT
}
private record MouseTarget(MouseEncoderSize size, long screenWidth, long screenHeight) { private record MouseTarget(MouseEncoderSize size, long screenWidth, long screenHeight) {
} }
} }