]> pilppa.org Git - familiar-h63xx-build.git/blob - org.handhelds.familiar/packages/minimix/files/disable-polling.patch
minimix: disable polling and repaint icon when idle.
[familiar-h63xx-build.git] / org.handhelds.familiar / packages / minimix / files / disable-polling.patch
1 Index: minimix/minimix.c
2 ===================================================================
3 RCS file: /cvs/gpe/base/minimix/minimix.c,v
4 retrieving revision 1.10
5 diff -u -r1.10 minimix.c
6 --- minimix/minimix.c   19 Sep 2005 15:36:02 -0000      1.10
7 +++ minimix/minimix.c   2 Aug 2006 17:06:51 -0000
8 @@ -2,7 +2,7 @@
9   * minimix -- volume control
10   *
11   * Copyright (c) 2002, 2003, 2004 Phil Blundell
12 - *               2005 Rene Wagner
13 + *               2005, 2006 Rene Wagner
14   *
15   * This program is free software; you can redistribute it and/or
16   * modify it under the terms of the GNU General Public License
17 @@ -39,7 +39,13 @@
18  GtkWidget *icon;
19  gint icon_size;
20  gboolean configure_done = FALSE;
21 +
22 +#ifdef ENABLE_POLLING
23  guint timeout;
24 +#endif /* ENABLE_POLLING */
25 +
26 +guint render_idle_source;
27 +gboolean render_idle_scheduled = FALSE;
28  
29  int mixerfd;
30  
31 @@ -87,9 +93,11 @@
32        current_vol_icon = vol_icons[level < SLIDER_MAX ? level / (SLIDER_MAX / (NUM_VOL_ICONS - 1)) + 1 : VOL_ICON_MAX];
33      }
34  
35 +#ifdef ENABLE_POLLING
36    /* avoid loops... */
37    if (level != gtk_adjustment_get_value (adj))
38      gtk_adjustment_set_value (adj, level);
39 +#endif /* ENABLE_POLLING */
40  }
41  
42  void
43 @@ -106,6 +114,7 @@
44    gtk_image_set_from_pixbuf(GTK_IMAGE(icon), dbuf);
45  }
46  
47 +#ifdef ENABLE_POLLING
48  gboolean
49  timeout_cb (gpointer data)
50  {
51 @@ -118,6 +127,16 @@
52  
53    return TRUE;
54  }
55 +#endif /* ENABLE_POLLING */
56 +
57 +gboolean
58 +render_when_idle (gpointer data)
59 +{
60 +  render_icon();
61 +  render_idle_scheduled = FALSE;
62 +
63 +  return FALSE;
64 +}
65  
66  void
67  value_changed (GtkAdjustment *adj)
68 @@ -129,7 +148,13 @@
69    refresh (value);
70  
71    if (configure_done && current_vol_icon != old_icon)
72 -    render_icon ();
73 +    {
74 +      if (G_UNLIKELY (render_idle_scheduled))
75 +        g_source_remove (render_idle_source);
76 +      else
77 +        render_idle_scheduled = TRUE;
78 +      render_idle_source = g_idle_add(render_when_idle, NULL);
79 +    }
80  
81    value |= (value << 8);
82    ioctl (mixerfd, SOUND_MIXER_WRITE_VOLUME, &value);
83 @@ -282,9 +307,12 @@
84    gtk_widget_add_events (slider_window, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
85  
86    refresh (read_volume_level ());
87 +
88 +#ifdef ENABLE_POLLING
89    timeout = g_timeout_add (200,
90                             (GSourceFunc) timeout_cb,
91                             NULL);
92 +#endif /* ENABLE_POLLING */
93  
94    gtk_widget_show_all (box);
95