diff options
author | Markus Keller | 2016-04-11 16:30:02 +0000 |
---|---|---|
committer | Markus Keller | 2016-04-12 11:41:14 +0000 |
commit | f95da6f955729a642cbbfcd5c3bdf947f7a24a93 (patch) | |
tree | 2acb8846299fbc39aa686474964a2ceba72cdecc | |
parent | 0b2221dc32e9510f9f90a90c75ce6b1827d7e69c (diff) | |
download | eclipse.platform.swt-f95da6f955729a642cbbfcd5c3bdf947f7a24a93.tar.gz eclipse.platform.swt-f95da6f955729a642cbbfcd5c3bdf947f7a24a93.tar.xz eclipse.platform.swt-f95da6f955729a642cbbfcd5c3bdf947f7a24a93.zip |
Bug 445900: [GTK] Shell#computeTrim(..) wrong for first invisible shell (editor hovers jump when enriched)
Change-Id: I9b91e17984cd0aed9d98e4b3ee3da22308549a67
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java | 39 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java | 69 |
2 files changed, 69 insertions, 39 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java index cd50b1aaee..45155f133e 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java @@ -12,6 +12,7 @@ package org.eclipse.swt.widgets; import java.util.*; +import java.util.prefs.*; import java.util.regex.*; import java.util.regex.Pattern; @@ -457,11 +458,24 @@ public class Display extends Device { Object [] values; /* Initial Guesses for Shell Trimmings. */ - int borderTrimWidth = 4, borderTrimHeight = 4; - int resizeTrimWidth = 6, resizeTrimHeight = 6; - int titleBorderTrimWidth = 5, titleBorderTrimHeight = 28; - int titleResizeTrimWidth = 6, titleResizeTrimHeight = 29; - int titleTrimWidth = 0, titleTrimHeight = 23; + static final int TRIM_NONE = 0; + static final int TRIM_BORDER = 1; + static final int TRIM_RESIZE = 2; + static final int TRIM_TITLE_BORDER = 3; + static final int TRIM_TITLE_RESIZE = 4; + static final int TRIM_TITLE = 5; + int [] trimWidths = new int [6]; + int [] trimHeights = new int [6]; + { + Preferences prefs = Preferences.userRoot().node("/org/eclipse/swt/widgets/Display"); + Preferences node; + node = prefs.node("TRIM NONE"); trimWidths [TRIM_NONE] = node.getInt("W", 0); trimHeights [TRIM_NONE] = node.getInt("H", 0); + node = prefs.node("TRIM BORDER"); trimWidths [TRIM_BORDER] = node.getInt("W", 4); trimHeights [TRIM_BORDER] = node.getInt("H", 4); + node = prefs.node("TRIM RESIZE"); trimWidths [TRIM_RESIZE] = node.getInt("W", 6); trimHeights [TRIM_RESIZE] = node.getInt("H", 6); + node = prefs.node("TRIM TITLE BORDER"); trimWidths [TRIM_TITLE_BORDER] = node.getInt("W", 5); trimHeights [TRIM_TITLE_BORDER] = node.getInt("H", 28); + node = prefs.node("TRIM TITLE RESIZE"); trimWidths [TRIM_TITLE_RESIZE] = node.getInt("W", 6); trimHeights [TRIM_TITLE_RESIZE] = node.getInt("H", 29); + node = prefs.node("TRIM TITLE"); trimWidths [TRIM_TITLE] = node.getInt("W", 0); trimHeights [TRIM_TITLE] = node.getInt("H", 23); + } boolean ignoreTrim; /* Window Manager */ @@ -4306,6 +4320,21 @@ void releaseDisplay () { flushRect = null; exposeEvent = null; idleLock = null; + + /* Save window trim caches */ + Preferences prefs = Preferences.userRoot().node("/org/eclipse/swt/widgets/Display"); + Preferences node; + node = prefs.node("TRIM NONE"); node.putInt("W", trimWidths [TRIM_NONE]); node.putInt("H", trimHeights [TRIM_NONE]); + node = prefs.node("TRIM BORDER"); node.putInt("W", trimWidths [TRIM_BORDER]); node.putInt("H", trimHeights [TRIM_BORDER]); + node = prefs.node("TRIM RESIZE"); node.putInt("W", trimWidths [TRIM_RESIZE]); node.putInt("H", trimHeights [TRIM_RESIZE]); + node = prefs.node("TRIM TITLE BORDER"); node.putInt("W", trimWidths [TRIM_TITLE_BORDER]); node.putInt("H", trimHeights [TRIM_TITLE_BORDER]); + node = prefs.node("TRIM TITLE RESIZE"); node.putInt("W", trimWidths [TRIM_TITLE_RESIZE]); node.putInt("H", trimHeights [TRIM_TITLE_RESIZE]); + node = prefs.node("TRIM TITLE"); node.putInt("W", trimWidths [TRIM_TITLE]); node.putInt("H", trimHeights [TRIM_TITLE]); + try { + prefs.flush(); + } catch (BackingStoreException e) { + // continue without saving + } } /** diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java index ef42b042c3..cab1b8ff8c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java @@ -498,31 +498,32 @@ void adjustTrim () { hasResize = (style & SWT.RESIZE) != 0; hasBorder = (style & SWT.BORDER) != 0; } + int trimStyle; if (hasTitle) { - if (hasResize) { - display.titleResizeTrimWidth = trimWidth; - display.titleResizeTrimHeight = trimHeight; - return; - } - if (hasBorder) { - display.titleBorderTrimWidth = trimWidth; - display.titleBorderTrimHeight = trimHeight; - return; + if (hasResize) { + trimStyle = Display.TRIM_TITLE_RESIZE; + } else if (hasBorder) { + trimStyle = Display.TRIM_TITLE_BORDER; + } else { + trimStyle = Display.TRIM_TITLE; } - display.titleTrimWidth = trimWidth; - display.titleTrimHeight = trimHeight; - return; - } - if (hasResize) { - display.resizeTrimWidth = trimWidth; - display.resizeTrimHeight = trimHeight; - return; - } - if (hasBorder) { - display.borderTrimWidth = trimWidth; - display.borderTrimHeight = trimHeight; - return; + } else if (hasResize) { + trimStyle = Display.TRIM_RESIZE; + } else if (hasBorder) { + trimStyle = Display.TRIM_BORDER; + } else { + trimStyle = Display.TRIM_NONE; } + Rectangle bounds = getBoundsInPixels(); + int widthAdjustment = display.trimWidths[trimStyle] - trimWidth; + int heightAdjustment = display.trimHeights[trimStyle] - trimHeight; + bounds.width += widthAdjustment; + bounds.height += heightAdjustment; + oldWidth += widthAdjustment; + oldHeight += heightAdjustment; + setBounds(bounds.x, bounds.y, bounds.width, bounds.height, false, true); + display.trimWidths[trimStyle] = trimWidth; + display.trimHeights[trimStyle] = trimHeight; } void bringToTop (boolean force) { @@ -2507,13 +2508,13 @@ int trimHeight () { hasResize = (style & SWT.RESIZE) != 0; hasBorder = (style & SWT.BORDER) != 0; if (hasTitle) { - if (hasResize) return display.titleResizeTrimHeight; - if (hasBorder) return display.titleBorderTrimHeight; - return display.titleTrimHeight; + if (hasResize) return display.trimHeights [Display.TRIM_TITLE_RESIZE]; + if (hasBorder) return display.trimHeights [Display.TRIM_TITLE_BORDER]; + return display.trimHeights [Display.TRIM_TITLE]; } - if (hasResize) return display.resizeTrimHeight; - if (hasBorder) return display.borderTrimHeight; - return 0; + if (hasResize) return display.trimHeights [Display.TRIM_RESIZE]; + if (hasBorder) return display.trimHeights [Display.TRIM_BORDER]; + return display.trimHeights [Display.TRIM_NONE]; } int trimWidth () { @@ -2524,13 +2525,13 @@ int trimWidth () { hasResize = (style & SWT.RESIZE) != 0; hasBorder = (style & SWT.BORDER) != 0; if (hasTitle) { - if (hasResize) return display.titleResizeTrimWidth; - if (hasBorder) return display.titleBorderTrimWidth; - return display.titleTrimWidth; + if (hasResize) return display.trimWidths [Display.TRIM_TITLE_RESIZE]; + if (hasBorder) return display.trimWidths [Display.TRIM_TITLE_BORDER]; + return display.trimWidths [Display.TRIM_TITLE]; } - if (hasResize) return display.resizeTrimWidth; - if (hasBorder) return display.borderTrimWidth; - return 0; + if (hasResize) return display.trimWidths [Display.TRIM_RESIZE]; + if (hasBorder) return display.trimWidths [Display.TRIM_BORDER]; + return display.trimWidths [Display.TRIM_NONE]; } void updateModal () { |