Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8236651: Simplify and update glass gtk backend #77

Open
wants to merge 24 commits into
base: master
from
Open
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

@@ -84,6 +84,7 @@ if (hasProperty('toolchainDir')) {

def gtk2CCFlags = [ "-Wno-deprecated-declarations" ];
def gtk3CCFlags = [ "-Wno-deprecated-declarations" ];
def gtk3expCCFlags = [ "-Wno-deprecated-declarations" ];
def gtk2LinkFlags = [ ];
def gtk3LinkFlags = [ ];

@@ -138,6 +139,7 @@ setupTools("linux_gtk3",
def libsGTK3 = properties.getProperty("libsGTK3")
if (cflagsGTK3 && libsGTK3) {
gtk3CCFlags.addAll(cflagsGTK3.split(" "))
gtk3expCCFlags.addAll(cflagsGTK3.split(" "))
gtk3LinkFlags.addAll(libsGTK3.split(" "))
} else {
throw new IllegalStateException("GTK3 development packages not found. If GTK3 packages are installed, please remove the build directory and try again.")
@@ -212,7 +214,7 @@ def compiler = IS_COMPILE_PARFAIT ? "parfait-gcc" : "${toolchainDir}gcc";
def linker = IS_STATIC_BUILD ? "ar" : IS_COMPILE_PARFAIT ? "parfait-g++" : "${toolchainDir}g++";

LINUX.glass = [:]
LINUX.glass.variants = ["glass", "glassgtk2", "glassgtk3"]
LINUX.glass.variants = ["glass", "glassgtk2", "glassgtk3", "glassgtk2_exp", "glassgtk3_exp"]

FileTree ft_gtk_launcher = fileTree("${project(":graphics").projectDir}/src/main/native-glass/gtk/") {
include("**/launcher.c")
@@ -222,6 +224,11 @@ FileTree ft_gtk = fileTree("${project(":graphics").projectDir}/src/main/native-g
exclude("**/launcher.c")
}

FileTree ft_gtkexp = fileTree("${project(":graphics").projectDir}/src/main/native-glass/gtk_experimental/") {
exclude("**/launcher.c")
}


LINUX.glass.glass = [:]
LINUX.glass.glass.nativeSource = ft_gtk_launcher.getFiles()
LINUX.glass.glass.compiler = compiler
@@ -250,6 +257,26 @@ LINUX.glass.glassgtk3.linker = linker
LINUX.glass.glassgtk3.linkFlags = IS_STATIC_BUILD ? linkFlags : [linkFlags, gtk3LinkFlags].flatten()
LINUX.glass.glassgtk3.lib = "glassgtk3"

LINUX.glass.glassgtk2_exp = [:]
LINUX.glass.glassgtk2_exp.nativeSource = ft_gtkexp.getFiles()
LINUX.glass.glassgtk2_exp.compiler = compiler
LINUX.glass.glassgtk2_exp.ccFlags = IS_STATIC_BUILD ?
["-fno-threadsafe-statics", ccFlags, gtk2CCFlags].flatten() :
[cppFlags, gtk2CCFlags, "-Werror"].flatten()
LINUX.glass.glassgtk2_exp.linker = linker
LINUX.glass.glassgtk2_exp.linkFlags = IS_STATIC_BUILD ? linkFlags : [linkFlags, gtk2LinkFlags].flatten()
LINUX.glass.glassgtk2_exp.lib = "glassgtk2_exp"

LINUX.glass.glassgtk3_exp = [:]
LINUX.glass.glassgtk3_exp.nativeSource = ft_gtkexp.getFiles()
LINUX.glass.glassgtk3_exp.compiler = compiler
LINUX.glass.glassgtk3_exp.ccFlags = IS_STATIC_BUILD ?
["-fno-threadsafe-statics", ccFlags, gtk3expCCFlags].flatten() :
[cppFlags, gtk3expCCFlags, "-Werror"].flatten()
LINUX.glass.glassgtk3_exp.linker = linker
LINUX.glass.glassgtk3_exp.linkFlags = IS_STATIC_BUILD ? linkFlags : [linkFlags, gtk3LinkFlags].flatten()
LINUX.glass.glassgtk3_exp.lib = "glassgtk3_exp"

LINUX.decora = [:]
LINUX.decora.compiler = compiler
LINUX.decora.ccFlags = [cppFlags, "-ffast-math"].flatten()
@@ -155,10 +155,15 @@ private static float getFloat(String propname, float defval, String description)
}
return ret;
}) : forcedGtkVersion;

boolean gtkExperimental = AccessController.doPrivileged((PrivilegedAction<Boolean>) () ->
Boolean.getBoolean("javafx.gtk.experimental"));

boolean gtkVersionVerbose =
AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> {
return Boolean.getBoolean("jdk.gtk.verbose");
});

if (PrismSettings.allowHiDPIScaling) {
overrideUIScale = AccessController.doPrivileged((PrivilegedAction<Float>) () ->
getFloat("glass.gtk.uiScale", -1.0f, "Forcing UI scaling factor: "));
@@ -176,18 +181,23 @@ private static float getFloat(String propname, float defval, String description)
System.out.println("Glass GTK library to load is already loaded");
}
} else if (libraryToLoad == QUERY_LOAD_GTK2) {
String libName = (gtkExperimental) ? "glassgtk2_exp" : "glassgtk2";
if (gtkVersionVerbose) {
System.out.println("Glass GTK library to load is glassgtk2");
System.out.println(String.format("Glass GTK library to load is %s", libName));
}
NativeLibLoader.loadLibrary("glassgtk2");

NativeLibLoader.loadLibrary(libName);
} else if (libraryToLoad == QUERY_LOAD_GTK3) {
String libName = (gtkExperimental) ? "glassgtk3_exp" : "glassgtk3";
if (gtkVersionVerbose) {
System.out.println("Glass GTK library to load is glassgtk3");
System.out.println(String.format("Glass GTK library to load is %s", libName));
}
NativeLibLoader.loadLibrary("glassgtk3");

NativeLibLoader.loadLibrary(libName);
} else {
throw new UnsupportedOperationException("Internal Error");
}

return null;
});

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,6 +32,7 @@
import com.sun.glass.ui.Window;

class GtkWindow extends Window {
private static boolean USE_EXPERIMENTAL_GTK_IMPL = Boolean.getBoolean("javafx.gtk.experimental");

public GtkWindow(Window owner, Screen screen, int styleMask) {
super(owner, screen, styleMask);
@@ -201,16 +202,18 @@ protected void _setBounds(long ptr, int x, int y, boolean xSet, boolean ySet, in
_setGravity(ptr, xGravity, yGravity);
setBoundsImpl(ptr, x, y, xSet, ySet, w, h, cw, ch);

if ((w <= 0) && (cw > 0) || (h <= 0) && (ch > 0)) {
final int[] extarr = new int[4];
getFrameExtents(ptr, extarr);

// TODO: ((w <= 0) && (cw <= 0)) || ((h <= 0) && (ch <= 0))
notifyResize(WindowEvent.RESIZE,
((w <= 0) && (cw > 0)) ? cw + extarr[0] + extarr[1]
: w,
((h <= 0) && (ch > 0)) ? ch + extarr[2] + extarr[3]
: h);
if (!USE_EXPERIMENTAL_GTK_IMPL) {
if ((w <= 0) && (cw > 0) || (h <= 0) && (ch > 0)) {
final int[] extarr = new int[4];
getFrameExtents(ptr, extarr);

// TODO: ((w <= 0) && (cw <= 0)) || ((h <= 0) && (ch <= 0))
notifyResize(WindowEvent.RESIZE,
((w <= 0) && (cw > 0)) ? cw + extarr[0] + extarr[1]
: w,
((h <= 0) && (ch > 0)) ? ch + extarr[2] + extarr[3]
: h);
}
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.