mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Introduce / use UIUtil.setCursor to prevent setting the cursor that is already set.
Cursor is updated by native code even if component has the same cursor, causing performance problems (IDEA-167733)
This commit is contained in:
@@ -272,7 +272,7 @@ public class LinkLabel<T> extends JLabel {
|
||||
}
|
||||
|
||||
private void enableUnderline() {
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
UIUtil.setCursor(this, Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
myUnderline = true;
|
||||
if (myHoveringIcon != null) {
|
||||
super.setIcon(myHoveringIcon);
|
||||
@@ -286,7 +286,7 @@ public class LinkLabel<T> extends JLabel {
|
||||
}
|
||||
|
||||
private void disableUnderline() {
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
UIUtil.setCursor(this, Cursor.getDefaultCursor());
|
||||
myUnderline = false;
|
||||
super.setIcon(myInactiveIcon);
|
||||
setStatusBarText(null);
|
||||
|
||||
@@ -2161,12 +2161,12 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
if (getSelectionModel().hasSelection() && (e.getModifiersEx() & (InputEvent.BUTTON1_DOWN_MASK | InputEvent.BUTTON2_DOWN_MASK)) == 0) {
|
||||
int offset = logicalPositionToOffset(xyToLogicalPosition(e.getPoint()));
|
||||
if (getSelectionModel().getSelectionStart() <= offset && offset < getSelectionModel().getSelectionEnd()) {
|
||||
myEditorComponent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
UIUtil.setCursor(myEditorComponent, Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!IdeGlassPaneImpl.hasPreProcessedCursor(myEditorComponent)) {
|
||||
myEditorComponent.setCursor(UIUtil.getTextCursor(getBackgroundColor()));
|
||||
UIUtil.setCursor(myEditorComponent, UIUtil.getTextCursor(getBackgroundColor()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -886,7 +886,7 @@ public class EditorMarkupModelImpl extends MarkupModelImpl implements EditorMark
|
||||
}
|
||||
|
||||
if (e.getX() > 0 && e.getX() <= getWidth() && showToolTipByMouseMove(e)) {
|
||||
scrollbar.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
UIUtil.setCursor(scrollbar, Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+2
-6
@@ -18,6 +18,7 @@ package com.intellij.openapi.vcs.changes.issueLinks;
|
||||
import com.intellij.ui.ClickListener;
|
||||
import com.intellij.ui.SimpleColoredComponent;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -75,12 +76,7 @@ public abstract class LinkMouseListenerBase<T> extends ClickListener implements
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
Component component = (Component)e.getSource();
|
||||
Object tag = getTagAt(e);
|
||||
if (tag != null) {
|
||||
component.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
}
|
||||
else {
|
||||
component.setCursor(Cursor.getDefaultCursor());
|
||||
}
|
||||
UIUtil.setCursor(component, tag != null ? Cursor.getPredefinedCursor(Cursor.HAND_CURSOR) : Cursor.getDefaultCursor());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -271,13 +271,13 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
|
||||
final Component target =
|
||||
SwingUtilities.getDeepestComponentAt(myRootPane.getContentPane().getParent(), point.x, point.y);
|
||||
if (target != null) {
|
||||
setCursor(target.getCursor());
|
||||
UIUtil.setCursor(this, target.getCursor());
|
||||
cursorSet = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!cursorSet) {
|
||||
setCursor(Cursor.getDefaultCursor());
|
||||
UIUtil.setCursor(this, Cursor.getDefaultCursor());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -356,18 +356,18 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
|
||||
if (target instanceof JComponent) {
|
||||
((JComponent)target).putClientProperty(PREPROCESSED_CURSOR_KEY, Boolean.TRUE);
|
||||
}
|
||||
target.setCursor(cursor);
|
||||
UIUtil.setCursor(target, cursor);
|
||||
}
|
||||
}
|
||||
|
||||
getRootPane().setCursor(cursor);
|
||||
UIUtil.setCursor(getRootPane(), cursor);
|
||||
}
|
||||
}
|
||||
else if (!e.isConsumed() && e.getID() != MouseEvent.MOUSE_DRAGGED) {
|
||||
cursor = Cursor.getDefaultCursor();
|
||||
JRootPane rootPane = getRootPane();
|
||||
if (rootPane != null) {
|
||||
rootPane.setCursor(cursor);
|
||||
UIUtil.setCursor(rootPane, cursor);
|
||||
} else {
|
||||
LOG.warn("Root pane is null. Event: " + e);
|
||||
}
|
||||
@@ -403,7 +403,7 @@ public class IdeGlassPaneImpl extends JPanel implements IdeGlassPaneEx, IdeEvent
|
||||
|
||||
private void restoreLastComponent(Component newC) {
|
||||
if (myLastCursorComponent != null && myLastCursorComponent != newC) {
|
||||
myLastCursorComponent.setCursor(myLastOriginalCursor);
|
||||
UIUtil.setCursor(myLastCursorComponent, myLastOriginalCursor);
|
||||
if (myLastCursorComponent instanceof JComponent) {
|
||||
((JComponent)myLastCursorComponent).putClientProperty(PREPROCESSED_CURSOR_KEY, null);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import com.intellij.ui.JBColor;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.text.DateFormatUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -92,12 +93,6 @@ class StatusPanel extends JPanel {
|
||||
|
||||
return super.truncateText(text, bounds, fm, textR, iconR, maxWidth);
|
||||
}
|
||||
|
||||
@Override public void setCursor(Cursor cursor) {
|
||||
// cursor is updated by native code even if component has the same cursor, causing performance problems (IDEA-167733)
|
||||
if (isCursorSet() && cursor == getCursor()) return;
|
||||
super.setCursor(cursor);
|
||||
}
|
||||
};
|
||||
|
||||
StatusPanel() {
|
||||
@@ -113,7 +108,7 @@ class StatusPanel extends JPanel {
|
||||
EventLog.toggleLog(getActiveProject(), myCurrentNotification);
|
||||
myAfterClick = true;
|
||||
myTextPanel.setExplicitSize(myTextPanel.getSize());
|
||||
myTextPanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
UIUtil.setCursor(myTextPanel, Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -127,7 +122,7 @@ class StatusPanel extends JPanel {
|
||||
myTextPanel.revalidate();
|
||||
myAfterClick = false;
|
||||
if (myCurrentNotification == null) {
|
||||
myTextPanel.setCursor(Cursor.getDefaultCursor());
|
||||
UIUtil.setCursor(myTextPanel, Cursor.getDefaultCursor());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,7 +208,7 @@ class StatusPanel extends JPanel {
|
||||
}
|
||||
|
||||
if (myCurrentNotification != null) {
|
||||
myTextPanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
UIUtil.setCursor(myTextPanel, Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -232,7 +227,7 @@ class StatusPanel extends JPanel {
|
||||
}
|
||||
else {
|
||||
myTimeStart = -1;
|
||||
myTextPanel.setCursor(Cursor.getDefaultCursor());
|
||||
UIUtil.setCursor(myTextPanel, Cursor.getDefaultCursor());
|
||||
myDirty = true;
|
||||
setStatusText(nonLogText);
|
||||
}
|
||||
|
||||
@@ -4033,4 +4033,10 @@ public class UIUtil {
|
||||
p.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public static void setCursor(Component component, Cursor cursor) {
|
||||
// cursor is updated by native code even if component has the same cursor, causing performance problems (IDEA-167733)
|
||||
if(component.isCursorSet() && component.getCursor() == cursor) return;
|
||||
component.setCursor(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user