Class SWTAccessor
- java.lang.Object
-
- com.jogamp.nativewindow.swt.SWTAccessor
-
public class SWTAccessor extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
isOSX
static boolean
isWindows
static boolean
isX11
static boolean
isX11GTK
static Class<?>
OS_gtk_class
static VersionNumber
OS_gtk_version
-
Constructor Summary
Constructors Constructor Description SWTAccessor()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
autoScaleDown(int v)
Returns SWT auto scaled-down valuev
, compatible withDPIUtil.autoScaleDown(int)
static int
autoScaleUp(int v)
Returns SWT auto scaled-up valuev
, compatible withDPIUtil.autoScaleUp(int)
static long
createCompatibleGDKChildWindow(org.eclipse.swt.widgets.Control swtControl, int visualID, int width, int height)
static long
createCompatibleX11ChildWindow(AbstractGraphicsScreen screen, org.eclipse.swt.widgets.Control swtControl, int visualID, int width, int height)
static void
destroyGDKWindow(long gdkWindow)
static void
destroyX11Window(AbstractGraphicsDevice device, long x11Window)
static int
deviceZoomScaleDown(int v)
Returns SWT derived scaled-down valuev
, based onDPIUtil.getDeviceZoom()
only, not considering higher-toolkit's compensation likeDPIUtil.useCairoAutoScale()
.static Point
deviceZoomScaleDown(Point v)
Returns SWT derived scaled-down valuev
, based onDPIUtil.getDeviceZoom()
only, not considering higher-toolkit's compensation likeDPIUtil.useCairoAutoScale()
.static int
deviceZoomScaleUp(int v)
Returns SWT derived scaled-up valuev
, based onDPIUtil.getDeviceZoom()
only, not considering higher-toolkit's compensation likeDPIUtil.useCairoAutoScale()
.static Point
deviceZoomScaleUp(Point v)
Returns SWT derived scaled-up valuev
, based onDPIUtil.getDeviceZoom()
only, not considering higher-toolkit's compensation likeDPIUtil.useCairoAutoScale()
.static void
disposeGC(org.eclipse.swt.widgets.Control swtControl, long gc, org.eclipse.swt.graphics.GCData gcData)
static void
focusGDKWindow(long gdkWindow)
static long
gdk_widget_get_window(long handle)
static long
gdk_window_get_xdisplay(long window)
static long
gdk_window_get_xwindow(long window)
static float
getAutoScalingFactor()
Returns SWT compatible auto scale-factor, used byDPIUtil
static org.eclipse.swt.graphics.Rectangle
getClientAreaInPixels(org.eclipse.swt.widgets.Scrollable s)
Returns the unscaledScrollable.getClientArea()
in pixels.static AbstractGraphicsDevice
getDevice(org.eclipse.swt.widgets.Control swtControl)
static float
getDeviceZoomScalingFactor()
Returns SWT derived scale-factor based onDPIUtil.getDeviceZoom()
only, not considering higher-toolkit's compensation likeDPIUtil.useCairoAutoScale()
.static long
getHandle(org.eclipse.swt.widgets.Control swtControl)
static org.eclipse.swt.graphics.Point
getLocationInPixels(org.eclipse.swt.widgets.Control c)
static int
getNativeVisualID(AbstractGraphicsDevice device, long windowHandle)
static AbstractGraphicsScreen
getScreen(AbstractGraphicsDevice device, int screen)
static org.eclipse.swt.graphics.Point
getSizeInPixels(org.eclipse.swt.widgets.Control c)
static long
getWindowHandle(org.eclipse.swt.widgets.Control swtControl)
static VersionNumber
GTK_VERSION()
static void
initSingleton()
Call this method, if this class shall be initialized before any other of its methods are called within the regular workflow.static void
invokeOnOSTKThread(boolean blocking, Runnable runnable)
Runs the specified action in an SWT compatible OS toolkit thread, which is: Mac OSX Main Thread: Run on OSX UI main thread.static void
invokeOnSWTThread(org.eclipse.swt.widgets.Display display, boolean blocking, Runnable runnable)
Runs the specified action on the SWT UI thread.static boolean
isOnSWTThread(org.eclipse.swt.widgets.Display display)
Return true if the current thread is the SWT UI thread, otherwise false.static boolean
isUsingLongHandles()
static long
newGC(org.eclipse.swt.widgets.Control swtControl, org.eclipse.swt.graphics.GCData gcData)
static void
printInfo(PrintStream out, org.eclipse.swt.widgets.Display d)
static void
resizeGDKWindow(org.eclipse.swt.graphics.Rectangle clientArea, long gdkWindow)
static void
resizeX11Window(AbstractGraphicsDevice device, org.eclipse.swt.graphics.Rectangle clientArea, long x11Window)
static void
setRealized(org.eclipse.swt.widgets.Control swtControl, boolean realize)
static void
showGDKWindow(long gdkWindow)
static boolean
useX11GTK()
-
-
-
Field Detail
-
isOSX
public static final boolean isOSX
-
isWindows
public static final boolean isWindows
-
isX11
public static final boolean isX11
-
isX11GTK
public static final boolean isX11GTK
-
OS_gtk_class
public static final Class<?> OS_gtk_class
-
OS_gtk_version
public static final VersionNumber OS_gtk_version
-
-
Method Detail
-
initSingleton
public static void initSingleton()
Call this method, if this class shall be initialized before any other of its methods are called within the regular workflow. This could be desired to ensure initialization before AWT. This method does nothing, but initializes this class's static SWT accessors if using this class for the first time.
-
isUsingLongHandles
public static boolean isUsingLongHandles()
-
useX11GTK
public static boolean useX11GTK()
-
GTK_VERSION
public static VersionNumber GTK_VERSION()
-
gdk_widget_get_window
public static long gdk_widget_get_window(long handle)
-
gdk_window_get_xdisplay
public static long gdk_window_get_xdisplay(long window)
-
gdk_window_get_xwindow
public static long gdk_window_get_xwindow(long window)
-
printInfo
public static void printInfo(PrintStream out, org.eclipse.swt.widgets.Display d)
-
getAutoScalingFactor
public static float getAutoScalingFactor() throws NativeWindowException
Returns SWT compatible auto scale-factor, used byDPIUtil
We need to keep track of SWT's implementation in this regard!
- Throws:
NativeWindowException
-
autoScaleUp
public static int autoScaleUp(int v)
Returns SWT auto scaled-up valuev
, compatible withDPIUtil.autoScaleUp(int)
We need to keep track of SWT's implementation in this regard!
-
autoScaleDown
public static int autoScaleDown(int v)
Returns SWT auto scaled-down valuev
, compatible withDPIUtil.autoScaleDown(int)
We need to keep track of SWT's implementation in this regard!
-
getDeviceZoomScalingFactor
public static float getDeviceZoomScalingFactor()
Returns SWT derived scale-factor based onDPIUtil.getDeviceZoom()
only, not considering higher-toolkit's compensation likeDPIUtil.useCairoAutoScale()
.This method should be used instead of
getAutoScalingFactor()
for native toolkits not caring about DPI scaling like X11 or GDI.We need to keep track of SWT's implementation in this regard!
-
deviceZoomScaleUp
public static int deviceZoomScaleUp(int v)
Returns SWT derived scaled-up valuev
, based onDPIUtil.getDeviceZoom()
only, not considering higher-toolkit's compensation likeDPIUtil.useCairoAutoScale()
.This method should be used instead of
autoScaleUp(int)
for native toolkits not caring about DPI scaling like X11 or GDI.We need to keep track of SWT's implementation in this regard!
-
deviceZoomScaleDown
public static int deviceZoomScaleDown(int v)
Returns SWT derived scaled-down valuev
, based onDPIUtil.getDeviceZoom()
only, not considering higher-toolkit's compensation likeDPIUtil.useCairoAutoScale()
.This method should be used instead of
autoScaleDown(int)
for native toolkits not caring about DPI scaling like X11 or GDI.We need to keep track of SWT's implementation in this regard!
-
deviceZoomScaleUp
public static Point deviceZoomScaleUp(Point v)
Returns SWT derived scaled-up valuev
, based onDPIUtil.getDeviceZoom()
only, not considering higher-toolkit's compensation likeDPIUtil.useCairoAutoScale()
.This method should be used instead of
#autoScaleUp(com.jogamp.nativewindow.util.Point)
for native toolkits not caring about DPI scaling like X11 or GDI.We need to keep track of SWT's implementation in this regard!
-
deviceZoomScaleDown
public static Point deviceZoomScaleDown(Point v)
Returns SWT derived scaled-down valuev
, based onDPIUtil.getDeviceZoom()
only, not considering higher-toolkit's compensation likeDPIUtil.useCairoAutoScale()
.This method should be used instead of
#autoScaleDown(com.jogamp.nativewindow.util.Point)
for native toolkits not caring about DPI scaling like X11 or GDI.We need to keep track of SWT's implementation in this regard!
-
getClientAreaInPixels
public static org.eclipse.swt.graphics.Rectangle getClientAreaInPixels(org.eclipse.swt.widgets.Scrollable s) throws NativeWindowException
Returns the unscaledScrollable.getClientArea()
in pixels.If the package restricted method
Scrollable.getClientAreaInPixels()
is implemented, we return its result.Fallback is to return
DPIUtil#autoScaleUp
(Scrollable.getClientArea()
), revertingScrollable.getClientArea()
'sDPIUtil.autoScaleDown(Rectangle)
.Note to SWT's API spec writers: You need to allow access to the unscaled value, scale properties and define what is being scaled (fonts, images, ..). Further more the scale should be separate for x/y coordinates, as DPI differs here.
Note to Eclipse authors: Scaling up the fonts and images hardly works on GTK/SWT/Eclipse. GDK_SCALE, GDK_DPI_SCALE and swt.autoScale produce inconsistent results with Eclipse. Broken High-DPI for .. some years now. This is especially true for using native high-dpi w/ scaling-factor 1f.
Requires SWT >= 3.105 (DPIUtil)- Parameters:
s
- theScrollable
instance- Returns:
- unscaled client area in pixels, see above
- Throws:
NativeWindowException
- during invocation of the method, if any
-
getLocationInPixels
public static org.eclipse.swt.graphics.Point getLocationInPixels(org.eclipse.swt.widgets.Control c) throws NativeWindowException
- Throws:
NativeWindowException
-
getSizeInPixels
public static org.eclipse.swt.graphics.Point getSizeInPixels(org.eclipse.swt.widgets.Control c) throws NativeWindowException
- Throws:
NativeWindowException
-
getHandle
public static long getHandle(org.eclipse.swt.widgets.Control swtControl) throws NativeWindowException
- Parameters:
swtControl
- the SWT Control to retrieve the native widget-handle from- Returns:
- the native widget-handle
- Throws:
NativeWindowException
- if the widget handle is null
-
setRealized
public static void setRealized(org.eclipse.swt.widgets.Control swtControl, boolean realize) throws NativeWindowException
- Throws:
NativeWindowException
-
getDevice
public static AbstractGraphicsDevice getDevice(org.eclipse.swt.widgets.Control swtControl) throws NativeWindowException, UnsupportedOperationException
- Parameters:
swtControl
- the SWT Control to retrieve the native device handle from- Returns:
- the AbstractGraphicsDevice w/ the native device handle
- Throws:
NativeWindowException
- if the widget handle is nullUnsupportedOperationException
- if the windowing system is not supported
-
getScreen
public static AbstractGraphicsScreen getScreen(AbstractGraphicsDevice device, int screen)
- Parameters:
device
-screen
- -1 is default screen of the given device, e.g. maybe 0 or determined by native API. >= 0 is specific screen- Returns:
-
getNativeVisualID
public static int getNativeVisualID(AbstractGraphicsDevice device, long windowHandle)
-
getWindowHandle
public static long getWindowHandle(org.eclipse.swt.widgets.Control swtControl) throws NativeWindowException, UnsupportedOperationException
- Parameters:
swtControl
- the SWT Control to retrieve the native window handle from- Returns:
- the native window handle
- Throws:
NativeWindowException
- if the widget handle is nullUnsupportedOperationException
- if the windowing system is not supported
-
newGC
public static long newGC(org.eclipse.swt.widgets.Control swtControl, org.eclipse.swt.graphics.GCData gcData)
-
disposeGC
public static void disposeGC(org.eclipse.swt.widgets.Control swtControl, long gc, org.eclipse.swt.graphics.GCData gcData)
-
invokeOnOSTKThread
public static void invokeOnOSTKThread(boolean blocking, Runnable runnable)
Runs the specified action in an SWT compatible OS toolkit thread, which is:- Mac OSX
- Main Thread: Run on OSX UI main thread. 'wait' is implemented on Java site via lock/wait on
RunnableTask
to not freeze OSX main thread.
- Main Thread: Run on OSX UI main thread. 'wait' is implemented on Java site via lock/wait on
- Linux, Windows, ..
- Current thread.
- See Also:
Platform.AWT_AVAILABLE
,Platform.getOSType()
- Mac OSX
-
invokeOnSWTThread
public static void invokeOnSWTThread(org.eclipse.swt.widgets.Display display, boolean blocking, Runnable runnable)
Runs the specified action on the SWT UI thread.If
blocking
istrue
implementation usesDisplay.syncExec(Runnable)
, otherwiseDisplay.asyncExec(Runnable)
.If
display
isnull
or disposed or the current thread is the SWT UI threadinvokeOnOSTKThread(boolean, Runnable)
is being used.- See Also:
invokeOnOSTKThread(boolean, Runnable)
-
isOnSWTThread
public static boolean isOnSWTThread(org.eclipse.swt.widgets.Display display)
Return true if the current thread is the SWT UI thread, otherwise false.
-
createCompatibleX11ChildWindow
public static long createCompatibleX11ChildWindow(AbstractGraphicsScreen screen, org.eclipse.swt.widgets.Control swtControl, int visualID, int width, int height)
-
resizeX11Window
public static void resizeX11Window(AbstractGraphicsDevice device, org.eclipse.swt.graphics.Rectangle clientArea, long x11Window)
-
destroyX11Window
public static void destroyX11Window(AbstractGraphicsDevice device, long x11Window)
-
createCompatibleGDKChildWindow
public static long createCompatibleGDKChildWindow(org.eclipse.swt.widgets.Control swtControl, int visualID, int width, int height)
-
showGDKWindow
public static void showGDKWindow(long gdkWindow)
-
focusGDKWindow
public static void focusGDKWindow(long gdkWindow)
-
resizeGDKWindow
public static void resizeGDKWindow(org.eclipse.swt.graphics.Rectangle clientArea, long gdkWindow)
-
destroyGDKWindow
public static void destroyGDKWindow(long gdkWindow)
-
-