mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2026-01-08 01:21:42 +01:00
JBR-6445 Prepare RepaintManager code for displaySync=false
Refactored AWTAccessor code
This commit is contained in:
@@ -4324,20 +4324,10 @@ public class Window extends Container implements Accessible {
|
||||
new GetPropertyAction("awt.window.counters"));
|
||||
|
||||
AWTAccessor.setWindowAccessor(new AWTAccessor.WindowAccessor() {
|
||||
private static final boolean isWLToolkit = Toolkit.getDefaultToolkit()
|
||||
.getClass().getName().equals("sun.awt.wl.WLToolkit");
|
||||
public void updateWindow(Window window) {
|
||||
window.updateWindow();
|
||||
}
|
||||
|
||||
public boolean needUpdateWindowAfterPaint(Window window) {
|
||||
return window != null && isWLToolkit;
|
||||
}
|
||||
|
||||
public boolean needUpdateWindow(Window window) {
|
||||
return window != null && (isWLToolkit || !window.isOpaque());
|
||||
}
|
||||
|
||||
public void setPopupParent(Window window, Component component) {
|
||||
window.popupParent = component;
|
||||
}
|
||||
|
||||
@@ -801,27 +801,24 @@ public class RepaintManager
|
||||
.forEach(w -> AWTAccessor.getWindowAccessor()
|
||||
.bumpCounter(w, "swing.RepaintManager.updateWindows"));
|
||||
|
||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
if (!(toolkit instanceof SunToolkit &&
|
||||
((SunToolkit)toolkit).needUpdateWindow()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Set<Window> windows = new HashSet<Window>();
|
||||
Set<Component> dirtyComps = dirtyComponents.keySet();
|
||||
for (Component dirty : dirtyComps) {
|
||||
Window window = dirty instanceof Window ?
|
||||
(Window)dirty :
|
||||
SwingUtilities.getWindowAncestor(dirty);
|
||||
if (AWTAccessor.getWindowAccessor().needUpdateWindow(window))
|
||||
{
|
||||
windows.add(window);
|
||||
if (Toolkit.getDefaultToolkit() instanceof SunToolkit sunToolkit &&
|
||||
sunToolkit.needUpdateWindow()) {
|
||||
Set<Window> windows = new HashSet<Window>();
|
||||
Set<Component> dirtyComps = dirtyComponents.keySet();
|
||||
for (Component dirty : dirtyComps) {
|
||||
Window window = dirty instanceof Window ?
|
||||
(Window) dirty :
|
||||
SwingUtilities.getWindowAncestor(dirty);
|
||||
if (window != null &&
|
||||
(!window.isOpaque() || sunToolkit.needUpdateWindowAfterPaint()))
|
||||
{
|
||||
windows.add(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Window window : windows) {
|
||||
AWTAccessor.getWindowAccessor().updateWindow(window);
|
||||
for (Window window : windows) {
|
||||
AWTAccessor.getWindowAccessor().updateWindow(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1355,9 +1352,12 @@ public class RepaintManager
|
||||
g.setClip(x, y, w, h);
|
||||
paintingComponent.paintToOffscreen(g, x, y, w, h, x + w, y + h);
|
||||
}
|
||||
final Window window = SwingUtilities.getWindowAncestor(paintingComponent);
|
||||
if (AWTAccessor.getWindowAccessor().needUpdateWindowAfterPaint(window)) {
|
||||
AWTAccessor.getWindowAccessor().updateWindow(window);
|
||||
|
||||
if (Toolkit.getDefaultToolkit() instanceof SunToolkit tk) {
|
||||
final Window window = SwingUtilities.getWindowAncestor(paintingComponent);
|
||||
if (window != null && tk.needUpdateWindowAfterPaint()) {
|
||||
AWTAccessor.getWindowAccessor().updateWindow(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -307,10 +307,6 @@ public final class AWTAccessor {
|
||||
*/
|
||||
void updateWindow(Window window);
|
||||
|
||||
boolean needUpdateWindowAfterPaint(Window window);
|
||||
|
||||
boolean needUpdateWindow(Window window);
|
||||
|
||||
void setPopupParent(Window window, Component component);
|
||||
Component getPopupParent(Window window);
|
||||
|
||||
|
||||
@@ -185,6 +185,11 @@ public class WLToolkit extends UNIXToolkit implements Runnable {
|
||||
return Thread.currentThread() == toolkitThread;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needUpdateWindowAfterPaint() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ButtonPeer createButton(Button target) {
|
||||
ButtonPeer peer = new WLButtonPeer(target);
|
||||
|
||||
Reference in New Issue
Block a user