~ubuntu-branches/ubuntu/raring/xfce4-volumed/raring

« back to all changes in this revision

Viewing changes to src/xvd_keys.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc
  • Date: 2009-11-29 21:35:27 UTC
  • mfrom: (1.1.4 upstream) (0.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091129213527-98p288tholw46fnu
Tags: 0.1.8-1ubuntu1
* Merge with Debian testing, remaining Ubuntu changes:
  - debian/{control,rules}: add a -dbg package, bump debhelper b-d to 7.0.50~
    to have overrides
  - debian/xfce4-volumed.install: added
  - debian/control:
    + update Vcs-* fields for lucid
    + depends on gstreamer0.10-plugins-base, and recommends xfce4-mixer,
      notify-osd.

* debian/patches/xubuntu-use-notification-icons.patch: use "notification-*"
  icons. lp: #475954
* debian/rules: enable quilt.
* debian/control: b-d on quilt.
* debian/{README.source,patches/series}: added.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
#include "xvd_notify.h"
28
28
#endif
29
29
 
 
30
#ifndef LEGACY_XCBKEYSYMS
 
31
// This is only needed when the keycodes are a list and not a struct
30
32
static gboolean
31
33
_xvd_keys_is_symbol(xcb_keycode_t elem,
32
34
                                        xcb_keycode_t *list)
44
46
        
45
47
        return belongs;
46
48
}
 
49
#endif
47
50
 
48
51
static gboolean 
49
52
_xvd_keys_handle_events(GIOChannel *source, 
61
64
                                case XCB_KEY_PRESS:
62
65
                                        kpe = (xcb_key_press_event_t *)ev;
63
66
                                        
 
67
                                        #ifndef LEGACY_XCBKEYSYMS
64
68
                                        if (_xvd_keys_is_symbol(kpe->detail, Inst->keyRaise)) {
 
69
                    #else
 
70
                                        if (kpe->detail == Inst->keyRaise) {
 
71
                    #endif
 
72
                                            #ifndef NDEBUG
 
73
                                g_debug ("The RaiseVolume key was pressed.\n");
 
74
                                #endif
65
75
                                                if (xvd_mixer_change_volume (Inst, Inst->vol_step)) {
66
76
                                                        #ifdef HAVE_LIBNOTIFY
67
77
/*                                                      if (!Inst->muted) {*/
74
84
                                                }
75
85
                                        }
76
86
 
 
87
                                        #ifndef LEGACY_XCBKEYSYMS
77
88
                                        else if (_xvd_keys_is_symbol(kpe->detail, Inst->keyLower)) {
 
89
                    #else
 
90
                                        else if (kpe->detail == Inst->keyLower) {
 
91
                    #endif
 
92
                                            #ifndef NDEBUG
 
93
                                g_debug ("The LowerVolume key was pressed.\n");
 
94
                                #endif
78
95
                                                if (xvd_mixer_change_volume (Inst, (Inst->vol_step * -1))) {
79
96
                                                        #ifdef HAVE_LIBNOTIFY
80
97
/*                                                      if (!Inst->muted) {*/
87
104
                                                }
88
105
                                        }
89
106
 
 
107
                                        #ifndef LEGACY_XCBKEYSYMS
90
108
                                        else if (_xvd_keys_is_symbol(kpe->detail, Inst->keyMute)) {
 
109
                    #else
 
110
                                        else if (kpe->detail == Inst->keyMute) {
 
111
                    #endif
 
112
                                            #ifndef NDEBUG
 
113
                                g_debug ("The Mute key was pressed.\n");
 
114
                                #endif
91
115
                                                if (xvd_mixer_toggle_mute (Inst)) {
92
116
                                                        #ifdef HAVE_LIBNOTIFY
93
117
                                                        if (Inst->muted)
94
 
                                                                xvd_notify_notification (Inst, "notification-audio-volume-muted", 0);
 
118
                                                                xvd_notify_notification (Inst, "audio-volume-muted", Inst->current_vol);
95
119
                                                        else {
96
120
                                                                xvd_mixer_init_volume (Inst);
97
121
                                                                xvd_notify_volume_notification (Inst);
155
179
        Inst->kss = xcb_key_symbols_alloc (Inst->conn);
156
180
 
157
181
        /* Grab the XF86AudioRaiseVolume key */
158
 
        Inst->keyRaise = xcb_key_symbols_get_keycode (Inst->kss, XF86XK_AudioRaiseVolume);
159
 
        i = 0;
160
 
        
161
 
        while (Inst->keyRaise[i] != XCB_NO_SYMBOL) {
162
 
                cookie = xcb_grab_key_checked (Inst->conn, TRUE, Inst->root_win, 
163
 
                                                                                mod, Inst->keyRaise[i], 
164
 
                                                                                XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
165
 
                error = xcb_request_check (Inst->conn, cookie);
166
 
                if (error) {
167
 
                        fprintf (stderr, "XCB: Unable to bind RaiseVolume keycode=%d mod=0x%04x: %d\n",
168
 
                        Inst->keyRaise[i], mod, error->error_code);
169
 
                }
170
 
                else {
171
 
                        g_print ("XCB: RaiseVolume ok, keycode=%d mod=0x%04x\n",
172
 
                        Inst->keyRaise[i], mod);
173
 
                }
174
 
                i++;
175
 
        }
176
 
 
177
 
        /* Grab the XF86AudioLowerVolume key */
178
 
        Inst->keyLower = xcb_key_symbols_get_keycode (Inst->kss, XF86XK_AudioLowerVolume);
179
 
        i = 0;
180
 
        
181
 
        while (Inst->keyLower[i] != XCB_NO_SYMBOL) {
182
 
                cookie = xcb_grab_key_checked (Inst->conn, TRUE, Inst->root_win, 
183
 
                                                                                mod, Inst->keyLower[i], 
184
 
                                                                                XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
185
 
                error = xcb_request_check (Inst->conn, cookie);
186
 
                if (error) {
187
 
                        fprintf (stderr, "XCB: Unable to bind LowerVolume keycode=%d mod=0x%04x: %d\n",
188
 
                        Inst->keyLower[i], mod, error->error_code);
189
 
                }
190
 
                else {
191
 
                        g_print ("XCB: LowerVolume ok, keycode=%d mod=0x%04x\n",
192
 
                        Inst->keyLower[i], mod);
193
 
                }
194
 
                i++;
195
 
        }
196
 
 
197
 
        
198
 
        /* Grab the XF86AudioMute key */
199
 
        Inst->keyMute = xcb_key_symbols_get_keycode (Inst->kss, XF86XK_AudioMute);
200
 
        i = 0;
201
 
        
202
 
        while (Inst->keyMute[i] != XCB_NO_SYMBOL) {
203
 
                cookie = xcb_grab_key_checked (Inst->conn, TRUE, Inst->root_win, 
204
 
                                                                                mod, Inst->keyMute[i], 
205
 
                                                                                XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
206
 
                error = xcb_request_check (Inst->conn, cookie);
207
 
                if (error) {
208
 
                        fprintf (stderr, "XCB: Unable to bind Mute keycode=%d mod=0x%04x: %d\n",
209
 
                        Inst->keyMute[i], mod, error->error_code);
210
 
                }
211
 
                else {
212
 
                        g_print ("XCB: Mute ok, keycode=%d mod=0x%04x\n",
213
 
                        Inst->keyMute[i], mod);
214
 
                }
215
 
                i++;
216
 
        }
 
182
        #ifndef LEGACY_XCBKEYSYMS
 
183
        Inst->keyRaise = xcb_key_symbols_get_keycode (Inst->kss, XF86XK_AudioRaiseVolume);
 
184
        
 
185
        if (Inst->keyRaise == NULL) {
 
186
                g_debug ("There is no X86AudioRaiseVolume key on your system.\n");
 
187
        }
 
188
        else {
 
189
                i = 0;
 
190
                while (Inst->keyRaise[i] != XCB_NO_SYMBOL) {
 
191
                        cookie = xcb_grab_key_checked (Inst->conn, TRUE, Inst->root_win, 
 
192
                                                                                        mod, Inst->keyRaise[i], 
 
193
                                                                                        XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
 
194
                        error = xcb_request_check (Inst->conn, cookie);
 
195
                        if (error) {
 
196
                                fprintf (stderr, "XCB: Unable to bind RaiseVolume keycode=%d mod=0x%04x: %d\n",
 
197
                                Inst->keyRaise[i], mod, error->error_code);
 
198
                        }
 
199
                        else {
 
200
                                g_print ("XCB: RaiseVolume ok, keycode=%d mod=0x%04x\n",
 
201
                                Inst->keyRaise[i], mod);
 
202
                        }
 
203
                        i++;
 
204
                }
 
205
        }
 
206
 
 
207
        /* Grab the XF86AudioLowerVolume key */
 
208
        Inst->keyLower = xcb_key_symbols_get_keycode (Inst->kss, XF86XK_AudioLowerVolume);
 
209
        
 
210
        if (Inst->keyLower == NULL) {
 
211
                g_debug ("There is no X86AudioLowerVolume key on your system.\n");
 
212
        }
 
213
        else {
 
214
                i = 0;
 
215
                while (Inst->keyLower[i] != XCB_NO_SYMBOL) {
 
216
                        cookie = xcb_grab_key_checked (Inst->conn, TRUE, Inst->root_win, 
 
217
                                                                                        mod, Inst->keyLower[i], 
 
218
                                                                                        XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
 
219
                        error = xcb_request_check (Inst->conn, cookie);
 
220
                        if (error) {
 
221
                                fprintf (stderr, "XCB: Unable to bind LowerVolume keycode=%d mod=0x%04x: %d\n",
 
222
                                Inst->keyLower[i], mod, error->error_code);
 
223
                        }
 
224
                        else {
 
225
                                g_print ("XCB: LowerVolume ok, keycode=%d mod=0x%04x\n",
 
226
                                Inst->keyLower[i], mod);
 
227
                        }
 
228
                        i++;
 
229
                }
 
230
        }
 
231
        
 
232
        /* Grab the XF86AudioMute key */
 
233
        Inst->keyMute = xcb_key_symbols_get_keycode (Inst->kss, XF86XK_AudioMute);
 
234
 
 
235
        if (Inst->keyMute == NULL) {
 
236
                g_debug ("There is no X86AudioMute key on your system.\n");
 
237
        }
 
238
        else {  
 
239
                i = 0;
 
240
                while (Inst->keyMute[i] != XCB_NO_SYMBOL) {
 
241
                        cookie = xcb_grab_key_checked (Inst->conn, TRUE, Inst->root_win, 
 
242
                                                                                        mod, Inst->keyMute[i], 
 
243
                                                                                        XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
 
244
                        error = xcb_request_check (Inst->conn, cookie);
 
245
                        if (error) {
 
246
                                fprintf (stderr, "XCB: Unable to bind Mute keycode=%d mod=0x%04x: %d\n",
 
247
                                Inst->keyMute[i], mod, error->error_code);
 
248
                        }
 
249
                        else {
 
250
                                g_print ("XCB: Mute ok, keycode=%d mod=0x%04x\n",
 
251
                                Inst->keyMute[i], mod);
 
252
                        }
 
253
                        i++;
 
254
                }
 
255
        }
 
256
        
 
257
        
 
258
        #else
 
259
        Inst->keyRaise = xcb_key_symbols_get_keycode (Inst->kss, XF86XK_AudioRaiseVolume);
 
260
        
 
261
        cookie = xcb_grab_key_checked (Inst->conn, TRUE, Inst->root_win, 
 
262
                                                                        mod, Inst->keyRaise, 
 
263
                                                                        XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
 
264
        error = xcb_request_check (Inst->conn, cookie);
 
265
        if (error) {
 
266
                fprintf (stderr, "XCB: Unable to bind RaiseVolume keycode=%d mod=0x%04x: %d\n",
 
267
                Inst->keyRaise, mod, error->error_code);
 
268
        }
 
269
        else {
 
270
                g_print ("XCB: RaiseVolume ok, keycode=%d mod=0x%04x\n",
 
271
                Inst->keyRaise, mod);
 
272
        }
 
273
 
 
274
        /* Grab the XF86AudioLowerVolume key */
 
275
        Inst->keyLower = xcb_key_symbols_get_keycode (Inst->kss, XF86XK_AudioLowerVolume);
 
276
        
 
277
        cookie = xcb_grab_key_checked (Inst->conn, TRUE, Inst->root_win, 
 
278
                                                                        mod, Inst->keyLower, 
 
279
                                                                        XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
 
280
        error = xcb_request_check (Inst->conn, cookie);
 
281
        if (error) {
 
282
                fprintf (stderr, "XCB: Unable to bind LowerVolume keycode=%d mod=0x%04x: %d\n",
 
283
                Inst->keyLower, mod, error->error_code);
 
284
        }
 
285
        else {
 
286
                g_print ("XCB: LowerVolume ok, keycode=%d mod=0x%04x\n",
 
287
                Inst->keyLower, mod);
 
288
        }
 
289
 
 
290
        
 
291
        /* Grab the XF86AudioMute key */
 
292
        Inst->keyMute = xcb_key_symbols_get_keycode (Inst->kss, XF86XK_AudioMute);
 
293
        
 
294
        cookie = xcb_grab_key_checked (Inst->conn, TRUE, Inst->root_win, 
 
295
                                                                        mod, Inst->keyMute, 
 
296
                                                                        XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC);
 
297
        error = xcb_request_check (Inst->conn, cookie);
 
298
        if (error) {
 
299
                fprintf (stderr, "XCB: Unable to bind Mute keycode=%d mod=0x%04x: %d\n",
 
300
                Inst->keyMute, mod, error->error_code);
 
301
        }
 
302
        else {
 
303
                g_print ("XCB: Mute ok, keycode=%d mod=0x%04x\n",
 
304
                Inst->keyMute, mod);
 
305
        }
 
306
        #endif
217
307
 
218
308
        GIOChannel *channel = g_io_channel_unix_new (xcb_get_file_descriptor (Inst->conn));
219
309
        g_io_add_watch (channel, G_IO_IN|G_IO_HUP, _xvd_keys_handle_events, Inst);
222
312
void 
223
313
xvd_keys_release (XvdInstance *Inst)
224
314
{
 
315
        #ifndef LEGACY_XCBKEYSYMS
225
316
        g_free (Inst->keyRaise);
226
317
        g_free (Inst->keyLower);
227
318
        g_free (Inst->keyMute);
 
319
        #endif
228
320
        if (Inst->kss)
229
321
                xcb_key_symbols_free (Inst->kss);
230
322
        if (Inst->conn)