diff options
author | Dirk Steinkamp | 2022-03-11 19:36:24 +0000 |
---|---|---|
committer | Mickael Istria | 2022-03-21 14:10:15 +0000 |
commit | a248547b39ae2984789286005debded9186534f6 (patch) | |
tree | 529ed036e3bf0a2f418350c4d241ee26ca050c74 | |
parent | b72d951ec19e9ff2db8478380fcf7e5cd9277d1c (diff) | |
download | eclipse.platform.swt-a248547b39ae2984789286005debded9186534f6.tar.gz eclipse.platform.swt-a248547b39ae2984789286005debded9186534f6.tar.xz eclipse.platform.swt-a248547b39ae2984789286005debded9186534f6.zip |
Bug 579225 - org.eclipse.swt.widget.Caret doesn't call OS.SetCaretPos if
primary caret of multiple carets has changed (win32)
- performs early returns in set...()-methods only when the called caret
is the currentCaret, and thus should be in sync with the OS-level
Change-Id: I408cdd368a7554924c6b48c04bbdb8146fb93b65
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.swt/+/191799
Tested-by: Platform Bot <platform-bot@eclipse.org>
Tested-by: Mickael Istria <mistria@redhat.com>
Reviewed-by: Mickael Istria <mistria@redhat.com>
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java index bc0f470331..5b5342b940 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java @@ -38,6 +38,9 @@ import org.eclipse.swt.internal.win32.*; * @noextend This class is not intended to be subclassed by clients. */ public class Caret extends Widget { + /** The Caret last updated on the OS-level */ + private static Caret currentCaret; + Canvas parent; int x, y, width, height; boolean moved, resized; @@ -285,6 +288,7 @@ void killFocus () { void move () { moved = false; + setCurrentCaret(this); if (!OS.SetCaretPos (x, y)) return; resizeIME (); } @@ -332,6 +336,9 @@ void releaseParent () { @Override void releaseWidget () { super.releaseWidget (); + if (isCurrentCaret()) { + setCurrentCaret(null); + } parent = null; image = null; font = null; @@ -390,7 +397,7 @@ public void setBounds (int x, int y, int width, int height) { void setBoundsInPixels (int x, int y, int width, int height) { boolean samePosition = this.x == x && this.y == y; boolean sameExtent = this.width == width && this.height == height; - if (samePosition && sameExtent) return; + if (samePosition && sameExtent && isCurrentCaret()) return; this.x = x; this.y = y; this.width = width; @@ -530,12 +537,20 @@ public void setLocation (int x, int y) { } void setLocationInPixels (int x, int y) { - if (this.x == x && this.y == y) return; + if (this.x == x && this.y == y && isCurrentCaret()) return; this.x = x; this.y = y; moved = true; if (isVisible && hasFocus ()) move (); } +private boolean isCurrentCaret() { + return Caret.currentCaret == this; +} + +private void setCurrentCaret(Caret caret) { + Caret.currentCaret = caret; +} + /** * Sets the receiver's location to the point specified by * the argument which is relative to the receiver's @@ -572,7 +587,7 @@ public void setSize (int width, int height) { } void setSizeInPixels (int width, int height) { - if (this.width == width && this.height == height) return; + if (this.width == width && this.height == height && isCurrentCaret()) return; this.width = width; this.height = height; resized = true; if (isVisible && hasFocus ()) resize (); |