RFR: 8236651: Simplify and update glass gtk backend

Thiago Milczarek Sayao tsayao at openjdk.java.net
Wed Jan 13 12:59:25 UTC 2021

On Mon, 6 Jan 2020 22:57:31 GMT, Thiago Milczarek Sayao <tsayao at openjdk.org> wrote:

>> This sort of enhancement needs to be discussed on the openjfx-dev mailing list first. While the WIP PR might be used to illustrate what you have in mind to propose, it is premature to actually review the implementation without first discussing whether and it makes sense to do it, what the high-level goals are, etc.
> I understand. Will do that when the code works 100%. I have submitted the PR to avoid duplicated efforts and let people test it (if anyone is willing).

**Code Changes**

* glass_window.cpp / glass_window.h
    * Removed WindowContextPlug and WindowContextChild (that were used for applets / web start) and moved everything to
one class named WindowContext (since inheritance was no required anymore)
    * Changed set_enabled() to use gtk_widget_set_sensitive instead of custom code;
    * Moved to gtk signals instead of gdk events (to use gtk_widget_set_sensitive and gtk_grab_add);
    * Frame Extents: Removed the code to request extents and gtk already does it by default;
    * Size calculation: Reworked size calculation code. In general, X windows are content size instead of whole window size (considering extents - frame decorations). OpenJfx uses "whole window size" as  window sizes, so it requires a "hack" to recalculate sizes when set_bounds() is called with window sizes instead of content sizes. The rework was to simplify code paths and make it more straightforward.
    * Other Size calculation changes:
        * Use gtk_window_set_default_size() for initial size which is the appropriate function; 
        * Gravity is now ignored as it is on Windows glass impl;
        * Avoid sending same sizes to Java;
        * Introduced calculate_adjustments() which is a fallback when frame extents is not present (it's optional  to window managers to implement it);
    * Geometry: Min / Max sizes - reworked it to simplify / Concentrated geometry changes on
    * Mouse grab: Reworked it to use to correct functions according to gtk+ version;
    * Draw: Reworked it to use the correct calls accord to gtk+ version changes;
    * Fixed JDK-8237491;
    * Moved background code to paint() as gtk3 uses styles to set the background and other functions were deprecated;
    * Reorganized function order on glass_window.cpp to match glass_window.h

* GlassCursor.cpp
    * Gtk+3 uses a name-like-css approach - so it was properly ported to gtk3 way;
    * Reworked Gtk+2 to use a function instead of manual calls to find the cursor;

* GtkWindow.java
    * Moved the extents special case to native glass;

* GlassApplication.cpp
    * Removed Gdk events where possible (it's now on glass_window as signals);
    * Removed applet/web start code;

* GlassView.cpp
    * Changes to reflect frame extents rework on glass_window

* GlassWindow.cpp
    * WindowContextTop -> WindowContext
    * Removed applet / web start code;
    * Removed frame extents (which is not called anymore due to GtkWindow.java change);

* glass_general.cpp
    * Removed functions that became unused;
    * Added is_grab_disabled() that is used on glass_window

* glass_window_ime.cpp
    * WindowContextTop -> WindowContext;
* glass_dnd.cpp / glass_dnd.h
    * Ported to Gtk signals;
    * Use all possible image formats (supported by GdkPixbuf / OpenJfx) - .gif is now possible (for ex.);
    * Allow COMPOUND_TEXT;
    * Do not request content while dragging;
    * Reduce overall code size.


PR: https://git.openjdk.java.net/jfx/pull/77

More information about the openjfx-dev mailing list