GTK+ 3.22 deprecations

162 views
Skip to first unread message

Neil Hodgson

unread,
Nov 24, 2016, 5:35:57 PM11/24/16
to Scintilla mailing list
There are some new deprecations with GTK+ 3.22 mostly for screen-oriented functions which I expect are going away due to Wayland. While I’ll eventually get around to fixing these, help would be appreciated. Just working out what the replacement function is can take some time. GTK+ 3.22 is the version of GTK+ used by Fedora 25.

Functions that are deprecated and used in Scintilla:

gdk_screen_width
gdk_screen_height
gdk_screen_get_monitor_at_point
gdk_screen_get_monitor_geometry
gtk_menu_popup
gdk_window_set_background_pattern

Some of the warnings:
PlatGTK.cxx: In member function 'void Window::SetPositionRelative(PRectangle, Window)':
PlatGTK.cxx:1051:20: warning: 'gint gdk_screen_width()' is deprecated [-Wdeprecated-declarations]
int screenWidth = gdk_screen_width();
^~~~~~~~~~~~~~~~
In file included from /usr/include/gtk-3.0/gdk/gdk.h:50:0,
from PlatGTK.cxx:19:
/usr/include/gtk-3.0/gdk/gdkmain.h:108:6: note: declared here
gint gdk_screen_width (void) G_GNUC_CONST;
^~~~~~~~~~~~~~~~
PlatGTK.cxx:1052:21: warning: 'gint gdk_screen_height()' is deprecated [-Wdeprecated-declarations]
int screenHeight = gdk_screen_height();
^~~~~~~~~~~~~~~~~
In file included from /usr/include/gtk-3.0/gdk/gdk.h:50:0,
from PlatGTK.cxx:19:
/usr/include/gtk-3.0/gdk/gdkmain.h:110:6: note: declared here
gint gdk_screen_height (void) G_GNUC_CONST;
^~~~~~~~~~~~~~~~~
PlatGTK.cxx: In member function 'PRectangle Window::GetMonitorRect(Point)':
PlatGTK.cxx:1153:16: warning: 'gint gdk_screen_get_monitor_at_point(GdkScreen*, gint, gint)' is deprecated: Use 'gdk_display_get_monitor_at_point' instead [-Wdeprecated-declarations]
monitor_num = gdk_screen_get_monitor_at_point(screen, pt.x + x_offset, pt.y + y_offset);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/gtk-3.0/gdk/gdkapplaunchcontext.h:31:0,
from /usr/include/gtk-3.0/gdk/gdk.h:32,
from PlatGTK.cxx:19:
/usr/include/gtk-3.0/gdk/gdkscreen.h:87:15: note: declared here
gint gdk_screen_get_monitor_at_point (GdkScreen *screen,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PlatGTK.cxx:1154:2: warning: 'void gdk_screen_get_monitor_geometry(GdkScreen*, gint, GdkRectangle*)' is deprecated: Use 'gdk_monitor_get_geometry' instead [-Wdeprecated-declarations]
gdk_screen_get_monitor_geometry(screen, monitor_num, &rect);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/gtk-3.0/gdk/gdkapplaunchcontext.h:31:0,
from /usr/include/gtk-3.0/gdk/gdk.h:32,
from PlatGTK.cxx:19:
/usr/include/gtk-3.0/gdk/gdkscreen.h:78:14: note: declared here
void gdk_screen_get_monitor_geometry (GdkScreen *screen,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PlatGTK.cxx:1908:2: warning: 'void gtk_menu_popup(GtkMenu*, GtkWidget*, GtkWidget*, GtkMenuPositionFunc, gpointer, guint, guint32)' is deprecated: Use '(gtk_menu_popup_at_widget, gtk_menu_popup_at_pointer, gtk_menu_popup_at_rect)' instead [-Wdeprecated-declarations]
gtk_menu_popup(widget, NULL, NULL, MenuPositionFunc,
^~~~~~~~~~~~~~
In file included from /usr/include/gtk-3.0/gtk/gtklabel.h:34:0,
from /usr/include/gtk-3.0/gtk/gtkaccellabel.h:35,
from /usr/include/gtk-3.0/gtk/gtk.h:33,
from PlatGTK.cxx:20:
/usr/include/gtk-3.0/gtk/gtkmenu.h:138:9: note: declared here
void gtk_menu_popup (GtkMenu *menu,
^~~~~~~~~~~~~~
ScintillaGTK.cxx: In static member function 'static void ScintillaGTK::RealizeText(GtkWidget*, void*)':
ScintillaGTK.cxx:2392:3: warning: 'void gdk_window_set_background_pattern(GdkWindow*, cairo_pattern_t*)' is deprecated [-Wdeprecated-declarations]
gdk_window_set_background_pattern(WindowFromWidget(widget), NULL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/gtk-3.0/gdk/gdkseat.h:28:0,
from /usr/include/gtk-3.0/gdk/gdkdisplay.h:33,
from /usr/include/gtk-3.0/gdk/gdkscreen.h:32,
from /usr/include/gtk-3.0/gdk/gdkapplaunchcontext.h:31,
from /usr/include/gtk-3.0/gdk/gdk.h:32,
from ScintillaGTK.cxx:22:
/usr/include/gtk-3.0/gdk/gdkwindow.h:781:12: note: declared here
void gdk_window_set_background_pattern (GdkWindow *window,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Neil

Neil Hodgson

unread,
Dec 5, 2016, 12:33:50 AM12/5/16
to scintilla...@googlegroups.com
Here are some unfinished changes for the 3.22 deprecations and other problems on Wayland.

It appears that there are issues with specifying global coordinates in Wayland and popup windows need to be attached to another top-level window. This affects autocompletion and calltips and it may also be behind the changes to menus that affects the context menu.

I’m unsure about these changes and there is a good chance they are not optimal.

1) Attach calltips and autocompletion lists to the parent window with gtk_window_set_transient_for.

2) Drop the background pattern or pixmap code. Scintilla wants to be responsible for all painting in the window and doesn’t want GTK+ to first paint a background. It appears this is now the default.

3) Display/screen/monitor APIs have changed so previous use of (GdkScreen*, gint monitor) changes to (GdkDisplay*, GdkMonitor*).

4) The old menu display function gtk_menu_popup has 3 replacements. The simplest gtk_menu_popup_at_pointer(menu, NULL) shows the menu at the mouse location of the click which is normally what is wanted. The old code took care of positioning including avoiding out-of-monitor locations. Its possible this is still needed but the more complex functions didn’t produce good results and the simple one did.

Neil
gtk322.patch

Neil Hodgson

unread,
Jan 3, 2017, 7:07:35 PM1/3/17
to Scintilla mailing list, scite-i...@googlegroups.com
Changes for GTK+ 3.22 and Wayland have been committed.

Fix display of autocompletion lists and calltips:
https://sourceforge.net/p/scintilla/code/ci/8cb0c9214098538d01461e046c86f7e0abc79073/
This was the most important change as these pop-up windows simply didn’t appear on Wayland. The fix was to mark them as ‘transient for’ the parent window.

Don't set window background on GTK+ 3.22 as this is deprecated:
https://sourceforge.net/p/scintilla/code/ci/8af598bfd5009fca6fa1ac9e9c10a30f55931643/
Appears to work OK with Scintilla drawing the entire area.

** BUGGY ** Use newer APIs for screen/monitor/display on GTK+ 3.22:
https://sourceforge.net/p/scintilla/code/ci/4fcd47d43161cfe072cdb355a19b4deef7206322/
GTK+ 3.22 has changed the types and APIs used for screen management. This change set updates the calls to use the newer non-deprecated APIs. Scintilla uses these APIs to move pop-ups that would be cut off by the screen bounds fully onto the screen.
On GTK+ 3.22/Wayland, Scintilla does not always move pop-ups correctly. There seems to be some interaction between the containing application window position so that when the application starts near the top of the screen and the caret is near the bottom, then vertical flipping of pop-ups works but it doesn’t if the top of the application window is further down the screen.

Use new simplified API for showing menu:
https://sourceforge.net/p/scintilla/code/ci/f47420bbbb8706446623dc9fd03c834ca2cef352/
Couldn't emulate the pre-GTK+ 3.22 approach with the new API, so a new simple API was used that places the menu at the mouse position. This is the same as the current behaviour but doesn’t allow for changes that could move the pop-up menu.

A similar menu change was made to SciTE. A change to use the newer screen APIs in SciTE that was included in the previous mail showed errors so was not committed. This was probably because the calls were made early in the application before the Wayland window is really there. The divider between the panes can be made wider with the split.wide property (=0/1) on some versions/themes/installations of GTK+: the default width has become too thin to be easily moved sometimes.

Neil

Reply all
Reply to author
Forward
0 new messages