[dasher] Use gdk_window_get_width/height() if the system has it.



commit 2804c2d47ead41415676cd87385089cfd5779ab7
Author: Patrick Welche <prlw1 cam ac uk>
Date:   Wed Mar 30 21:55:08 2011 +0100

    Use gdk_window_get_width/height() if the system has it.
    
    Those functions where introduced in gtk 2.24, and gdk_drawable_get_size()
    is going away in gtk 3 (with all other gdk_drawables).

 Src/Gtk2/DasherControl.cpp |   10 ++++++++--
 configure.ac               |    2 +-
 2 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/Src/Gtk2/DasherControl.cpp b/Src/Gtk2/DasherControl.cpp
index fde7212..2bbc8fb 100644
--- a/Src/Gtk2/DasherControl.cpp
+++ b/Src/Gtk2/DasherControl.cpp
@@ -432,6 +432,7 @@ void CDasherControl::HandleParameterNotification(int iParameter) {
 
 int CDasherControl::TimerEvent() {
   int x, y;
+  GdkWindow *default_root_window = gdk_get_default_root_window();
 
 #if GTK_CHECK_VERSION (2,14,0)
   gdk_window_get_pointer(gtk_widget_get_window(m_pCanvas), &x, &y, NULL);
@@ -440,12 +441,17 @@ int CDasherControl::TimerEvent() {
 #endif
   m_pMouseInput->SetCoordinates(x, y);
 
-  gdk_window_get_pointer(gdk_get_default_root_window(), &x, &y, NULL);
+  gdk_window_get_pointer(default_root_window, &x, &y, NULL);
 
   int iRootWidth;
   int iRootHeight;
 
-  gdk_drawable_get_size(gdk_get_default_root_window(), &iRootWidth, &iRootHeight);
+#ifdef HAVE_GDK_WINDOW_GET_WIDTH
+  iRootWidth  = gdk_window_get_width (default_root_window);
+  iRootHeight = gdk_window_get_height(default_root_window);
+#else
+  gdk_drawable_get_size(default_root_window, &iRootWidth, &iRootHeight);
+#endif
 
   if(GetLongParameter(LP_YSCALE) < 10)
     SetLongParameter(LP_YSCALE, 10);
diff --git a/configure.ac b/configure.ac
index 7999076..48361a7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -217,7 +217,7 @@ then
 	save_LIBS="$LIBS"
 	CFLAGS="$CFLAGS $GTK2_CFLAGS"
 	LIBS="$LIBS $GTK2_LIBS"
-	AC_CHECK_FUNCS([gtk_builder_new gtk_show_uri], [],
+	AC_CHECK_FUNCS([gtk_builder_new gtk_show_uri gdk_window_get_width], [],
 		[if test "x$ac_cv_func_gtk_builder_new" = "xno"; then
 			AC_MSG_ERROR([A version of GTK+ providing GtkBuilder is necessary.])
 		fi



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]