Skip to content

Commit

Permalink
Allow building with GTK 3.18
Browse files Browse the repository at this point in the history
  • Loading branch information
jlindgren90 committed Jun 19, 2024
1 parent 55cd30d commit b9c1cf2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ if test $USE_GTK2 = yes ; then
PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.24)
AC_DEFINE([USE_GTK], [1], [Define if GTK support enabled])
elif test $USE_GTK = yes ; then
PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.22)
PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.18)
AC_DEFINE(USE_GTK, 1, [Define if GTK support enabled])
AC_DEFINE(USE_GTK3, 1, [Define if GTK 3 support enabled])
fi
Expand Down
13 changes: 8 additions & 5 deletions src/libaudgui/prefs-window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ static void titlestring_tag_menu_cb (GtkMenuItem * menuitem, void * data)

static void on_titlestring_help_button_clicked (GtkWidget * button, void * menu)
{
#ifdef USE_GTK3
#if GTK_CHECK_VERSION(3, 22, 0)
gtk_menu_popup_at_widget ((GtkMenu *) menu, button, GDK_GRAVITY_CENTER, GDK_GRAVITY_STATIC, nullptr);
#else
gtk_menu_popup ((GtkMenu *) menu, nullptr, nullptr, nullptr, nullptr, 0, GDK_CURRENT_TIME);
Expand Down Expand Up @@ -624,8 +624,6 @@ static void * create_titlestring_table ()
gtk_widget_set_hexpand (titlestring_cbox, true);
gtk_widget_set_hexpand (titlestring_entry, true);

gtk_widget_set_focus_on_click (titlestring_help_button, false);

gtk_grid_attach ((GtkGrid *) grid, format_label, 0, 0, 1, 1);
gtk_grid_attach ((GtkGrid *) grid, custom_label, 0, 1, 1, 1);
gtk_grid_attach ((GtkGrid *) grid, titlestring_cbox, 1, 0, 1, 1);
Expand All @@ -635,15 +633,20 @@ static void * create_titlestring_table ()
gtk_misc_set_alignment ((GtkMisc *) format_label, 1, 0.5);
gtk_misc_set_alignment ((GtkMisc *) custom_label, 1, 0.5);

gtk_button_set_focus_on_click ((GtkButton *) titlestring_help_button, false);

gtk_table_attach ((GtkTable *) grid, format_label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach ((GtkTable *) grid, custom_label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
gtk_table_attach_defaults ((GtkTable *) grid, titlestring_cbox, 1, 2, 0, 1);
gtk_table_attach_defaults ((GtkTable *) grid, titlestring_entry, 1, 2, 1, 2);
gtk_table_attach ((GtkTable *) grid, titlestring_help_button, 2, 3, 1, 2,
GTK_FILL, GTK_FILL, 0, 0);
#endif

#if GTK_CHECK_VERSION(3, 20, 0)
gtk_widget_set_focus_on_click (titlestring_help_button, false);
#else
gtk_button_set_focus_on_click ((GtkButton *) titlestring_help_button, false);
#endif

return grid;
}

Expand Down
14 changes: 11 additions & 3 deletions src/libaudgui/util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#include <libaudcore/i18n.h>
#include <libaudcore/runtime.h>

#include "internal.h"
#include "libaudgui.h"
#include "libaudgui-gtk.h"

#define PORTABLE_DPI 96
Expand Down Expand Up @@ -95,8 +93,13 @@ EXPORT void audgui_get_mouse_coords (GtkWidget * widget, int * x, int * y)

GdkWindow * window = gtk_widget_get_window (widget);
GdkDisplay * display = gdk_window_get_display (window);
#if GTK_CHECK_VERSION(3, 20, 0)
GdkSeat * seat = gdk_display_get_default_seat (display);
GdkDevice * device = gdk_seat_get_pointer (seat);
#else
GdkDeviceManager * manager = gdk_display_get_device_manager (display);
GdkDevice * device = gdk_device_manager_get_client_pointer (manager);
#endif

gdk_window_get_device_position (window, device, & xwin, & ywin, nullptr);
gtk_widget_get_allocation (widget, & alloc);
Expand All @@ -112,8 +115,13 @@ EXPORT void audgui_get_mouse_coords (GdkScreen * screen, int * x, int * y)
{
#ifdef USE_GTK3
GdkDisplay * display = gdk_screen_get_display (screen);
#if GTK_CHECK_VERSION(3, 20, 0)
GdkSeat * seat = gdk_display_get_default_seat (display);
GdkDevice * device = gdk_seat_get_pointer (seat);
#else
GdkDeviceManager * manager = gdk_display_get_device_manager (display);
GdkDevice * device = gdk_device_manager_get_client_pointer (manager);
#endif
gdk_device_get_position (device, nullptr, x, y);
#else
gdk_display_get_pointer (gdk_screen_get_display (screen), nullptr, x, y, nullptr);
Expand All @@ -122,7 +130,7 @@ EXPORT void audgui_get_mouse_coords (GdkScreen * screen, int * x, int * y)

EXPORT void audgui_get_monitor_geometry (GdkScreen * screen, int x, int y, GdkRectangle * geom)
{
#ifdef USE_GTK3
#if GTK_CHECK_VERSION(3, 22, 0)
GdkDisplay * display = gdk_screen_get_display (screen);
GdkMonitor * monitor = gdk_display_get_monitor_at_point (display, x, y);
gdk_monitor_get_geometry (monitor, geom);
Expand Down

2 comments on commit b9c1cf2

@radioactiveman
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GTK 3.22 was released in 2016. Which outdated distribution do you intend to support with this?
And please update meson.build as well for the version requirement. :)

@jlindgren90
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ubuntu 16.04 is my current baseline for checking backward compatibility. Our Qt 5 and FFmpeg version requirements also go back 8+ years, for what it's worth (though Qt 6 did not exist back then). I have updated meson.build too now -- though systems that old will likely use autotools anyway, since the available meson version will not be new enough.

Please sign in to comment.