/[classpath]/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c
ViewVC logotype

Diff of /classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkToolkit.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.19 by fitzsim, Thu Jul 14 22:07:02 2005 UTC revision 1.20 by fitzsim, Mon Aug 15 18:32:38 2005 UTC
# Line 41  exception statement from your version. * Line 41  exception statement from your version. *
41  #include "gthread-jni.h"  #include "gthread-jni.h"
42  #include "jcl.h"  #include "jcl.h"
43    
 #include <sys/time.h>  
   
44  #define RC_FILE ".classpath-gtkrc"  #define RC_FILE ".classpath-gtkrc"
45    
46  /* From java.awt.SystemColor */  /* From java.awt.SystemColor */
# Line 292  dpi_changed_cb (GtkSettings  *settings, Line 290  dpi_changed_cb (GtkSettings  *settings,
290        PANGO_SCALE * 72.0 / (int_dpi / PANGO_SCALE);        PANGO_SCALE * 72.0 / (int_dpi / PANGO_SCALE);
291  }  }
292    
 static int  
 within_human_latency_tolerance(struct timeval *init)  
 {  
   struct timeval curr;  
   unsigned long milliseconds_elapsed;  
   
   gettimeofday(&curr, NULL);  
     
   milliseconds_elapsed = (((curr.tv_sec * 1000) + (curr.tv_usec / 1000))  
                           - ((init->tv_sec * 1000) + (init->tv_usec / 1000)));  
     
   return milliseconds_elapsed < 100;  
 }  
   
293  #if GTK_MINOR_VERSION > 4  #if GTK_MINOR_VERSION > 4
294  static void  static void
295  glog_func (const gchar *log_domain,  glog_func (const gchar *log_domain,
# Line 332  glog_func (const gchar *log_domain, Line 316  glog_func (const gchar *log_domain,
316  }  }
317  #endif  #endif
318    
319  JNIEXPORT void JNICALL  JNIEXPORT void JNICALL
320  Java_gnu_java_awt_peer_gtk_GtkToolkit_iterateNativeQueue  Java_gnu_java_awt_peer_gtk_GtkToolkit_gtkMain
321  (JNIEnv *env,  (JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)))
  jobject self __attribute__((unused)),  
  jobject lockedQueue,  
  jboolean block)  
322  {  {
   /* We're holding an EventQueue lock, and we're about to acquire the GDK  
    * lock before dropping the EventQueue lock. This can deadlock if someone  
    * holds the GDK lock and wants to acquire the EventQueue lock; however  
    * all callbacks from GTK happen with the GDK lock released, so this  
    * would only happen in an odd case such as some JNI helper code  
    * acquiring the GDK lock and calling back into  
    * EventQueue.getNextEvent().  
    */  
   
   struct timeval init;  
   gettimeofday(&init, NULL);  
   
323    gdk_threads_enter ();    gdk_threads_enter ();
   (*env)->MonitorExit (env, lockedQueue);  
324    
325    if (block)    gtk_main ();
     {  
         
       /* If we're blocking-when-empty, we want a do .. while loop. */  
       do  
         gtk_main_iteration ();  
       while (within_human_latency_tolerance (&init)  
              && gtk_events_pending ());  
     }  
   else  
     {  
       /* If we're not blocking-when-empty, we want a while loop. */  
       while (within_human_latency_tolerance (&init)  
              && gtk_events_pending ())  
         gtk_main_iteration ();        
     }  
     
   (*env)->MonitorEnter (env, lockedQueue);  
   gdk_threads_leave ();  
 }  
326    
327  JNIEXPORT void JNICALL    gdk_threads_leave ();
 Java_gnu_java_awt_peer_gtk_GtkToolkit_wakeNativeQueue  
   (JNIEnv *env __attribute__((unused)), jobject obj __attribute__((unused)))  
 {  
   g_main_context_wakeup (NULL);  
328  }  }
329    
330  JNIEXPORT jboolean JNICALL  JNIEXPORT jboolean JNICALL

Legend:
Removed from v.1.19  
changed lines
  Added in v.1.20

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26