Class SWTAccessor


  • public class SWTAccessor
    extends Object
    • 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
    • Constructor Detail

      • SWTAccessor

        public SWTAccessor()
    • Method Detail

      • isUsingLongHandles

        public static boolean isUsingLongHandles()
      • useX11GTK

        public static boolean useX11GTK()
      • 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)
      • gdk_window_set_back_pixmap

        public static void gdk_window_set_back_pixmap​(long window,
                                                      long pixmap,
                                                      boolean parent_relative)
      • getClientAreaInPixels

        public static org.eclipse.swt.graphics.Rectangle getClientAreaInPixels​(org.eclipse.swt.widgets.Scrollable s)
                                                                        throws NativeWindowException
        Returns the unscaled Scrollable.getClientArea() in pixels.

        If the package restricted method Scrollable.getClientAreaInPixels() is implemented, we return its result.

        Fallback is to return DPIUtil#autoScaleUp(Scrollable.getClientArea()), reverting Scrollable.getClientArea()'s DPIUtil.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.

        Requires SWT >= 3.105 (DPIUtil)
        Parameters:
        s - the Scrollable instance
        Returns:
        unscaled client area in pixels, see above
        Throws:
        NativeWindowException - during invocation of the method, if any
      • 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
      • 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)
      • 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)
      • invoke

        public static void invoke​(boolean wait,
                                  Runnable runnable)
        Runs the specified action in an SWT compatible 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.
        • Linux, Windows, ..
          • Current thread.
        See Also:
        Platform.AWT_AVAILABLE, Platform.getOSType()
      • invoke

        public static void invoke​(org.eclipse.swt.widgets.Display display,
                                  boolean wait,
                                  Runnable runnable)
        Runs the specified action on the SWT UI thread.

        If display is disposed or the current thread is the SWT UI thread invoke(boolean, Runnable) is being used.

        See Also:
        invoke(boolean, Runnable)
      • 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)
      • 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)