fixed dbus problem. Now CPU idle ok
[xscreensaver] / xscreensaver / hacks / screenhack.c
index 273c2e1..0f11991 100644 (file)
@@ -607,11 +607,16 @@ run_screenhack_table (Display *dpy,
         break;
 
       }
+      if (pause == 0)
       /* non blocking read of the next available message */
-      dbus_connection_read_write(conn, 0);
+       dbus_connection_read_write(conn, 0);
+      else
+      /* blocking read of the next available message */
+       dbus_connection_read_write(conn, -1);
       msg = dbus_connection_pop_message(conn);
-      if (NULL == msg)  
+      if (NULL == msg){  
           continue; 
+      }
       /* check this is a method call for the right interface & method */
       if ((view == 1 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PAUSE_LIVEBG_ON_VIEW1))||
           (view == 2 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PAUSE_LIVEBG_ON_VIEW2))||
@@ -619,6 +624,7 @@ run_screenhack_table (Display *dpy,
           (view == 4 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PAUSE_LIVEBG_ON_VIEW4))){
            fprintf(stderr, "Pause scene visible %i\n", view); 
           pause = 1;
+          dbus_message_unref (msg);
           continue;
       }
       if ((view == 1 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PLAY_LIVEBG_ON_VIEW1))||
@@ -627,8 +633,10 @@ run_screenhack_table (Display *dpy,
           (view == 4 && dbus_message_is_signal(msg, LIVEWP_SIGNAL_INTERFACE, LIVEWP_PLAY_LIVEBG_ON_VIEW4))){
            fprintf(stderr, "Play scene visible %i\n", view); 
           pause = 0;
+          dbus_message_unref (msg);
+          continue;
       }
-
+      dbus_message_unref (msg);
     }
 
   ft->free_cb (dpy, window, closure);