From 58808234db8381a86518229e176f429f440ff93f Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Tue, 7 Feb 2017 18:34:57 +0000 Subject: Fix some new Gdk deprecations (bzr r15491) --- src/debug/log-display-config.cpp | 41 ++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) (limited to 'src/debug/log-display-config.cpp') diff --git a/src/debug/log-display-config.cpp b/src/debug/log-display-config.cpp index ecc05b7b7..1f436a708 100644 --- a/src/debug/log-display-config.cpp +++ b/src/debug/log-display-config.cpp @@ -27,9 +27,20 @@ typedef SimpleEvent ConfigurationEvent; class Monitor : public ConfigurationEvent { public: - Monitor(GdkScreen *screen, gint monitor) : ConfigurationEvent("monitor") { +#if GTK_CHECK_VERSION(3,22,0) + Monitor(GdkMonitor *monitor) +#else + Monitor(GdkScreen *screen, gint monitor) +#endif + : ConfigurationEvent("monitor") { GdkRectangle area; + +#if GTK_CHECK_VERSION(3,22,0) + gdk_monitor_get_geometry(monitor, &area); +#else gdk_screen_get_monitor_geometry(screen, monitor, &area); +#endif + _addProperty("x", area.x); _addProperty("y", area.y); _addProperty("width", area.width); @@ -37,10 +48,13 @@ public: } }; +#if !GTK_CHECK_VERSION(3,22,0) +// We don't need this in newer Gtk+ versions as GdkMonitor information is now +// returned directly from GdkDisplay rather than needing GdkScreen first class Screen : public ConfigurationEvent { public: Screen(GdkScreen *s) : ConfigurationEvent("screen"), screen(s) { - _addProperty("width", gdk_screen_get_width(screen)); + _addProperty("width", gdk_screen_get_width(screen)); _addProperty("height", gdk_screen_get_height(screen)); } void generateChildEvents() const { @@ -53,21 +67,28 @@ public: private: GdkScreen *screen; }; +#endif class Display : public ConfigurationEvent { public: Display() : ConfigurationEvent("display") {} void generateChildEvents() const { GdkDisplay *display=gdk_display_get_default(); -#if GTK_CHECK_VERSION(3,10,0) - GdkScreen *screen = gdk_display_get_screen(display, 0); - Logger::write(screen); -#else - gint n_screens = gdk_display_get_n_screens(display); - for ( gint i = 0 ; i < n_screens ; i++ ) { - GdkScreen *screen = gdk_display_get_screen(display, i); - Logger::write(screen); + +#if GTK_CHECK_VERSION(3,22,0) + gint const n_monitors = gdk_display_get_n_monitors(display); + + // Loop through all monitors and log their details + for (gint i_monitor = 0; i_monitor < n_monitors; ++i_monitor) { + GdkMonitor *monitor = gdk_display_get_monitor(display, i_monitor); + Logger::write(monitor); } +#else + // We used to find the number of screens, and log info for + // each of them. However, the number of screens is always + // one in Gtk+ 3 + GdkScreen *screen = gdk_display_get_default_screen(display); + Logger::write(screen); #endif } }; -- cgit v1.2.3