This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] GtkMainThread.c calculate the dpi value in case of gtk-xft-dpican't


Hi,
currently if we build the awt peers with recent gtk/pango packages we run into troubles if gtk-xft-dpi can't calculate a reasonable value. Then it returns -1 as default value and we end up with a bogus value for dpi_conversion_factor.


The attached patch fixes this. Tested on darwin-7.4.0 with the TestAWT.java.

Ok on main?

Andreas

2004-06-25 Andreas Tobler <a.tobler@schweiz.ch>

	* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
	(init_dpi_conversion_factor): Check for int_dpi < 0 in case gtk-xft-dpi
	can no calculate the right value.
	(dpi_changed_cb): Mark *pspec as unsused.


Index: jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c
===================================================================
RCS file: /cvs/gcc/gcc/libjava/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c,v
retrieving revision 1.13
diff -u -r1.13 gnu_java_awt_peer_gtk_GtkMainThread.c
--- jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c	17 Jun 2004 23:43:16 -0000	1.13
+++ jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c	25 Jun 2004 21:10:01 -0000
@@ -231,9 +231,13 @@
     {
       int int_dpi;
       g_object_get (settings, "gtk-xft-dpi", &int_dpi, NULL);
+      /* If int_dpi == -1 gtk-xft-dpi returns the default value. So we
+	 have to do approximate calculation here.  The value is 1024 * dots.
+	 We take 96 for dots.  */
+      if (int_dpi < 0)  int_dpi = 98304;
       dpi_conversion_factor = PANGO_SCALE * 72.0 / (int_dpi / PANGO_SCALE);
       g_signal_connect (settings, "notify::gtk-xft-dpi",
-                        G_CALLBACK (dpi_changed_cb), NULL);
+			G_CALLBACK (dpi_changed_cb), NULL);
     }
   else
     /* Approximate. */
@@ -242,7 +246,7 @@
 
 static void
 dpi_changed_cb (GtkSettings  *settings,
-                GParamSpec   *pspec)
+		GParamSpec *pspec __attribute__((unused)))
 {
   int int_dpi;
   g_object_get (settings, "gtk-xft-dpi", &int_dpi, NULL);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]