Skip to content

Commit

Permalink
Splash Screen getting Flipped in MacOs Sonoma.
Browse files Browse the repository at this point in the history
Fixes: eclipse-platform/eclipse.platform.swt#772
Due to a bug in MacOS
Sonoma(eclipse-platform/eclipse.platform.swt#772)
,Splash Screen gets flipped.As a workaround the image is flipped and
returned.
  • Loading branch information
elsazac committed Mar 20, 2024
1 parent 6d0359a commit 00c1e5f
Showing 1 changed file with 27 additions and 1 deletion.
Expand Up @@ -135,6 +135,7 @@
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.OpenStrategy;
import org.eclipse.jface.util.SafeRunnable;
import org.eclipse.jface.util.Util;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.jface.window.Window;
Expand All @@ -145,8 +146,11 @@
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.graphics.DeviceData;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.graphics.Transform;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
Expand Down Expand Up @@ -849,14 +853,36 @@ private static Image loadSplashScreenImage(Display display, String splashLoc) {
Image background = null;
if (splashLoc != null) {
try (InputStream input = new BufferedInputStream(new FileInputStream(splashLoc))) {
background = new Image(display, input);
background = getImage(display, input);
} catch (SWTException | IOException e) {
StatusManager.getManager().handle(StatusUtil.newStatus(WorkbenchPlugin.PI_WORKBENCH, e));
}
}
return background;
}

private static Image getImage(Display display, InputStream input) {
Image image = new Image(display, input);

if (Util.isMac()) {
/*
* Due to a bug in MacOS Sonoma
* (https://github.com/eclipse-platform/eclipse.platform.swt/issues/772) ,Splash
* Screen gets flipped.As a workaround the image is flipped and returned.
*/
if (System.getProperty("os.version").startsWith("14")) { //$NON-NLS-1$ //$NON-NLS-2$
GC gc = new GC(image);
Transform tr = new Transform(display);
tr.setElements(1, 0, 0, -1, 0, 0);
gc.setTransform(tr);
gc.drawImage(image, 0, -(image.getBounds().height));
tr.dispose();
gc.dispose();
}
}
return image;
}

/**
* Return the splash handler for this application. If none is specifically
* provided the default Eclipse implementation is returned.
Expand Down

0 comments on commit 00c1e5f

Please sign in to comment.