This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: [patch] GtkMainThread.c calculate the dpi value in case ofgtk-xft-dpi can't
- From: Thomas Fitzsimmons <fitzsim at redhat dot com>
- To: Andreas Tobler <toa at pop dot agri dot ch>
- Cc: Java Patches <java-patches at gcc dot gnu dot org>
- Date: Fri, 25 Jun 2004 17:41:24 -0400
- Subject: Re: [patch] GtkMainThread.c calculate the dpi value in case ofgtk-xft-dpi can't
- References: <40DC980A.10302@pop.agri.ch>
On Fri, 2004-06-25 at 17:24, Andreas Tobler wrote:
> 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.
>
Hi Andreas,
Thanks for tracking this down.
> 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);
Can we split this into an if-else statement where we set
dpi_conversion_factor to PANGO_SCALE * 72.0 / 96.0 or to the result of
the current calculation if int_dpi is meaninful? (I know this is the
value I said on IRC, but I was just "roughing it in" -- I'd rather not
have this magic number in the code ;-)
With these changes, this can go in.
Thanks again,
Tom
> 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);