wmusic: Update location of libdockapp header file.
[dockapps.git] / wmusic / src / wmusic.c
blobe3404821a3d8449e47ced6e0edc581d8b403d451
1 /* wmusic - a xmms remote-controlling DockApp
2 * Copyright (C) 2000-2001 Bastien Nocera <hadess@hadess.net>
3 * Maintained by John Chapin <john+wmusic@jtan.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #define DBL_CLICK_INTERVAL 250 /* double click interval in milliseconds */
21 #define ARROW_INTERVAL 100 /* arrow update interval in milliseconds */
22 #define SCROLL_INTERVAL 300 /* scroll update interval in milliseconds */
23 #define SEPARATOR " ** " /* The separator for the scrolling title */
24 #define DISPLAYSIZE 6 /* width of text to display (running title) */
26 #include <libdockapp/dockapp.h>
27 #include <unistd.h>
28 #include <ctype.h>
29 #include <string.h>
30 #include <locale.h>
31 #include <xmms/xmmsctrl.h>
33 #include "wmusic-master.xpm"
34 #include "wmusic-digits.xpm"
36 /*---------------------------------------------------------------------------*/
37 /* Prototypes */
38 /*---------------------------------------------------------------------------*/
40 void copyNumArea(int x, int y, int sx, int sy, int dx, int dy);
41 void ActionPlay(int x, int y, DARect rect, void *data);
42 void ActionPause(int x, int y, DARect rect, void *data);
43 void ActionEject(int x, int y, DARect rect, void *data);
44 void ActionPrev(int x, int y, DARect rect, void *data);
45 void ActionNext(int x, int y, DARect rect, void *data);
46 void ActionStop(int x, int y, DARect rect, void *data);
47 void ActionFastr(int x, int y, DARect rect, void *data);
48 void ActionFastf(int x, int y, DARect rect, void *data);
49 void ToggleWins(int x, int y, DARect rect, void *data);
50 void ToggleVol(int x, int y, DARect rect, void *data);
51 void ChangeVol(int x, int y, DARect rect, void *data);
52 void ToggleTitle(int x, int y, DARect rect, void *data);
53 void ToggleTime(int x, int y, DARect rect, void *data);
54 void buttonPress(int button, int state, int x, int y);
55 void buttonRelease(int button, int state, int x, int y);
56 void DisplayRoutine();
57 void DrawPos (int pos);
58 void DrawTime(int time);
59 void DrawArrow(void);
60 void DrawChannels(int channels);
61 void DrawKbps(int bps);
62 void DrawTitle(char *title);
63 void ExecuteXmms(void);
65 /*----------------------------------------------------------------------------*/
66 /* Variables */
67 /*----------------------------------------------------------------------------*/
69 /* X11 variables */
70 char *displayName = "";
71 GC gc;
72 XEvent ev;
74 /* Dockapp variables */
75 unsigned int xmms_session = 0;
76 char *xmms_cmd = "xmms";
77 Bool main_vis=0, pl_vis=0, eq_vis=0;
78 Bool xmms_running;
79 unsigned int volume_step = 5;
80 Bool run_excusive=0;
82 Bool t_scroll=0;
83 Bool t_time=0;
84 Bool t_volume=0;
85 float title_pos = 0;
86 unsigned int arrow_pos = 0;
87 Bool pause_norotate = 0;
88 Time click_time=0;
90 Pixmap pixmap, mask; /* Pixmap that is displayed */
91 Pixmap pixnum, masknum; /* Pixmap source */
93 int left_pressed = 0; /* for pseudo drag callback */
94 int motion_event = 0; /* on motion events we do not want(too fast) display update */
96 static DAActionRect buttonRects[] = {
97 {{5, 39, 14, 9}, ActionPrev},
98 {{19, 39, 14, 9}, ActionNext},
99 {{33, 39, 13, 9}, ActionFastr},
100 {{46, 39, 13, 9}, ActionFastf},
101 {{5, 48, 11, 11}, ActionEject},
102 {{16, 48, 21, 11}, ActionPlay},
103 {{37, 48, 11, 11}, ActionPause},
104 {{48, 48, 11, 11}, ActionStop}
107 static DAActionRect toggleRect[] = {
108 {{5, 5, 54, 30}, ToggleWins}
111 static DAActionRect globRect[] = {
112 {{0, 0, 64, 64}, ToggleVol}
115 static DAActionRect displayRects[] = {
116 {{5, 5, 54, 12}, ToggleTime},
117 {{5, 25, 54, 9}, ToggleTitle}
120 static DAActionRect volumeRects[] = {
121 {{5, 17, 38, 8 }, ChangeVol}
124 static DAProgramOption options[] = {
125 {"-c", "--command", "Command to launch xmms", DOString, False,
126 {&xmms_cmd} },
127 {"-d", "--display", "Display to use", DOString, False, {&displayName} },
128 {"-r", "--run", "Run xmms on startup", DONone, False, {NULL} },
129 {"-s", "--session", "Xmms session to use", DONatural, False,
130 {&xmms_session} },
131 {"-t", "--title", "Show title instead of kbps by default", DONone,
132 False, {NULL} },
133 {"-u", "--hide", "Hide xmms windows on startup", DONone, False,
134 {NULL} },
135 {"-V", "--volume", "Stepping of the wheel volume control (in percent)",
136 DONatural, False, {&volume_step} },
137 {"-x", "--wmxmms", "Use wmxmms-like show and hide", DONone, False,
138 {NULL} },
139 {"-a", "--rotate-arrow", "Do not rotate the arrow, when paused",
140 DONone, False, {NULL} },
141 {"-l", "--time-left", "Show time left instead of time remaining by default",
142 DONone, False, {NULL} },
143 {"-b", "--volume-slider", "Show volume slider instead of channels",
144 DONone, False, {NULL}},
145 {"-R", "--run-excusive", "Run xmms on startup, exit when xmms exits", DONone, False, {NULL} }
148 typedef struct
150 wchar_t c;
151 int x;
152 int y;
153 } glyphdescr;
155 static glyphdescr glyphs[] = {
156 {L'-', 67, 83}, {L'.', 73, 83}, {L'\x27', 79, 83},
157 {L'(', 85, 83}, {L')', 91, 83}, {L'*', 97, 83}, {L'/', 103, 83},
159 {L'0', 1, 83}, {L'1', 7, 83}, {L'2', 13, 83}, {L'3', 19, 83}, {L'4', 25, 83},
160 {L'5', 31, 83}, {L'6', 37, 83}, {L'7', 43, 83}, {L'8', 49, 83}, {L'9', 55, 83},
164 {L'A', 1, 73}, {L'a', 1, 73},
165 {L'B', 7, 73}, {L'b', 7, 73},
166 {L'C', 13, 73}, {L'c', 13, 73},
167 {L'D', 19, 73}, {L'd', 19, 73},
168 {L'E', 25, 73}, {L'e', 25, 73},
170 {L'F', 31, 73}, {L'f', 31, 73},
171 {L'G', 37, 73}, {L'g', 37, 73},
172 {L'H', 43, 73}, {L'h', 43, 73},
173 {L'I', 49, 73}, {L'i', 49, 73},
174 {L'J', 55, 73}, {L'j', 55, 73},
176 {L'K', 61, 73}, {L'k', 61, 73},
177 {L'L', 67, 73}, {L'l', 67, 73},
178 {L'M', 73, 73}, {L'm', 73, 73},
179 {L'N', 79, 73}, {L'n', 79, 73},
180 {L'O', 85, 73}, {L'o', 85, 73},
182 {L'P', 91, 73}, {L'p', 91, 73},
183 {L'Q', 97, 73}, {L'q', 97, 73},
184 {L'R',103, 73}, {L'r',103, 73},
185 {L'S',109, 73}, {L's',109, 73},
186 {L'T',115, 73}, {L't',115, 73},
188 {L'U',121, 73}, {L'u',121, 73},
189 {L'V',127, 73}, {L'v',127, 73},
190 {L'W',133, 73}, {L'w',133, 73},
191 {L'X',139, 73}, {L'x',139, 73},
192 {L'Y',145, 73}, {L'y',145, 73},
194 {L'Z',151, 73}, {L'z',151, 73},
197 {L'\x42e', 1, 93}, {L'\x44e', 1, 93}, /* cyrillic Yu */
199 {L'\x410', 7, 93}, {L'\x430', 7, 93}, /* cyrillic A */
200 {L'\x411', 13, 93}, {L'\x431', 13, 93}, /* cyrillic Be */
201 {L'\x426', 19, 93}, {L'\x446', 19, 93}, /* cyrillic Ce */
202 {L'\x414', 25, 93}, {L'\x434', 25, 93}, /* cyrillic De */
203 {L'\x415', 31, 93}, {L'\x435', 31, 93}, /* cyrillic Ye */
205 {L'\x424', 37, 93}, {L'\x444', 37, 93}, /* cyrillic eF */
206 {L'\x413', 43, 93}, {L'\x433', 43, 93}, /* cyrillic Ge */
207 {L'\x425', 49, 93}, {L'\x445', 49, 93}, /* cyrillic Ha */
208 {L'\x418', 55, 93}, {L'\x438', 55, 93}, /* cyrillic I */
209 {L'\x419', 61, 93}, {L'\x439', 61, 93}, /* cyrillic I-kratkoe */
211 {L'\x41a', 67, 93}, {L'\x43a', 67, 93}, /* cyrillic Ka */
212 {L'\x41b', 73, 93}, {L'\x43b', 73, 93}, /* cyrillic eL */
213 {L'\x41c', 79, 93}, {L'\x43c', 79, 93}, /* cyrillic eM */
214 {L'\x41d', 85, 93}, {L'\x43d', 85, 93}, /* cyrillic eN */
215 {L'\x41e', 91, 93}, {L'\x43e', 91, 93}, /* cyrillic O */
217 {L'\x41f', 97, 93}, {L'\x43f', 97, 93}, /* cyrillic Pe */
218 {L'\x42f',103, 93}, {L'\x44f',103, 93}, /* cyrillic Ya */
219 {L'\x420',109, 93}, {L'\x440',109, 93}, /* cyrillic eR */
220 {L'\x421',115, 93}, {L'\x441',115, 93}, /* cyrillic eS */
221 {L'\x422',121, 93}, {L'\x442',121, 93}, /* cyrillic Te */
223 {L'\x423',127, 93}, {L'\x443',127, 93}, /* cyrillic U */
224 {L'\x416',133, 93}, {L'\x436',133, 93}, /* cyrillic Je */
225 {L'\x412',139, 93}, {L'\x432',139, 93}, /* cyrillic Ve */
226 {L'\x42c',145, 93}, {L'\x44c',145, 93}, /* cyrillic MyagkijZnak */
227 {L'\x42b',151, 93}, {L'\x44b',151, 93}, /* cyrillic Y */
229 {L'\x417',157, 93}, {L'\x437',157, 93}, /* cyrillic Ze */
230 {L'\x428',163, 93}, {L'\x448',163, 93}, /* cyrillic Sha */
231 {L'\x42d',169, 93}, {L'\x44d',169, 93}, /* cyrillic E */
232 {L'\x429',175, 93}, {L'\x449',175, 93}, /* cyrillic Scha */
233 {L'\x427',181, 93}, {L'\x447',181, 93}, /* cyrillic Che */
235 {L'\x42a',187, 93}, {L'\x44a',187, 93}, /* cyrillic TvyordyiZnak */
236 {L'\x404',115, 83}, {L'\x454',115, 83}, /* ukrainian IE */
237 {L'\x406', 49, 73}, {L'\x456', 49, 73}, /* ukrainian I */
238 {L'\x407',109, 83}, {L'\x457',109, 83}, /* ukrainian YI */
239 {L'\x491', 43, 93}, {L'\x490', 43, 93}, /* ukrainian GHE with upturn */
241 {L'\x401',121, 83}, {L'\x451',121, 83}, /* cyrillic Yo */
243 {L' ', 61, 83}
246 /*----------------------------------------------------------------------------*/
247 /* Functions */
248 /*----------------------------------------------------------------------------*/
250 void copyNumArea(int x, int y, int sx, int sy, int dx, int dy)
252 XCopyArea(DADisplay, pixnum, pixmap, gc, x, y, sx, sy, dx, dy);
255 void buttonDraw(DARect rect)
257 copyNumArea((rect.x)-5, (rect.y)-8, rect.width, rect.height,
258 rect.x, rect.y);
259 DASetPixmap(pixmap);
262 void ActionPlay(int x, int y, DARect rect, void *data)
264 if (data) {
265 buttonDraw(rect);
266 } else {
267 xmms_remote_play(xmms_session);
271 void ActionPause(int x, int y, DARect rect, void *data)
273 if (data) {
274 buttonDraw(rect);
275 } else {
276 xmms_remote_pause(xmms_session);
280 void ActionEject(int x, int y, DARect rect, void *data)
282 if (data) {
283 buttonDraw(rect);
284 } else {
285 xmms_remote_eject(xmms_session);
289 void ActionPrev(int x, int y, DARect rect, void *data)
291 if (data) {
292 buttonDraw(rect);
293 } else {
294 xmms_remote_playlist_prev(xmms_session);
298 void ActionNext(int x, int y, DARect rect, void *data)
300 if (data) {
301 buttonDraw(rect);
302 } else {
303 xmms_remote_playlist_next(xmms_session);
307 void ActionStop(int x, int y, DARect rect, void *data)
309 if (data) {
310 buttonDraw(rect);
311 } else {
312 xmms_remote_stop(xmms_session);
316 void ActionFastr(int x, int y, DARect rect, void *data)
318 if (data) {
319 buttonDraw(rect);
320 } else {
321 xmms_remote_jump_to_time(xmms_session,
322 xmms_remote_get_output_time(xmms_session)-10000);
326 void ActionFastf(int x, int y, DARect rect, void *data)
328 if (data) {
329 buttonDraw(rect);
330 } else {
331 xmms_remote_jump_to_time(xmms_session,
332 xmms_remote_get_output_time(xmms_session)+10000);
336 void ToggleWins(int x, int y, DARect rect, void *data)
338 if (xmms_running)
340 if (options[7].used)
342 if (data)
343 xmms_remote_main_win_toggle(xmms_session,
344 !xmms_remote_is_main_win(xmms_session));
345 if (!data)
346 xmms_remote_pl_win_toggle(xmms_session,
347 !xmms_remote_is_pl_win(xmms_session));
348 } else {
349 if (xmms_remote_is_main_win(xmms_session) ||
350 xmms_remote_is_pl_win(xmms_session) ||
351 xmms_remote_is_eq_win(xmms_session))
353 main_vis = xmms_remote_is_main_win(xmms_session);
354 pl_vis = xmms_remote_is_pl_win(xmms_session);
355 eq_vis = xmms_remote_is_eq_win(xmms_session);
357 xmms_remote_main_win_toggle(xmms_session, 0);
358 xmms_remote_pl_win_toggle(xmms_session, 0);
359 xmms_remote_eq_win_toggle(xmms_session, 0);
360 } else {
361 xmms_remote_main_win_toggle(xmms_session, main_vis);
362 xmms_remote_pl_win_toggle(xmms_session, pl_vis);
363 xmms_remote_eq_win_toggle(xmms_session, eq_vis);
366 } else {
367 if ( (ev.xbutton.time-click_time) <= DBL_CLICK_INTERVAL )
369 click_time=0;
370 ExecuteXmms();
371 } else {
372 click_time=ev.xbutton.time;
377 void ToggleVol(int x, int y, DARect rect, void *data)
379 int volume;
380 int factor;
382 if (*(int*)data == 1)
383 factor = volume_step;
384 else
385 factor = -volume_step;
387 /* xmms seems to do the bounds checking for us */
389 volume = xmms_remote_get_main_volume(xmms_session);
390 xmms_remote_set_main_volume(xmms_session, volume+factor);
393 void ChangeVol(int x, int y, DARect rect, void *data)
395 int volume = (int)100*(((float)x)/38);
396 xmms_remote_set_main_volume(xmms_session, volume);
399 void ToggleTitle(int x, int y, DARect rect, void *data)
401 if (t_scroll)
402 t_scroll = 0;
403 else t_scroll =1;
406 void ToggleTime(int x, int y, DARect rect, void *data)
408 if (t_time)
409 t_time = 0;
410 else t_time =1;
413 void buttonPress(int button, int state, int x, int y)
415 if (button==1)
416 left_pressed=1;
417 if (xmms_running)
419 if (button == 1)
421 char *tmp="1";
422 DAProcessActionRects(x, y, buttonRects, sizeof(buttonRects)/sizeof(DAActionRect), tmp);
423 DAProcessActionRects(x, y, displayRects, sizeof(displayRects)/sizeof(DAActionRect), tmp);
425 if (button == 2)
427 DAProcessActionRects(x, y, toggleRect, sizeof(toggleRect)/sizeof(DAActionRect), NULL);
429 if (button == 3)
431 char *tmp="1";
432 DAProcessActionRects(x, y, toggleRect, sizeof(toggleRect)/sizeof(DAActionRect), tmp);
434 if ((button == 4) || (button == 5))
436 if (button == 5)
438 /* Wheel scrolls down */
439 int tmp=2;
440 DAProcessActionRects(x, y, globRect, sizeof(globRect)/sizeof(DAActionRect), &tmp);
441 } else {
442 /* Wheel scrolls up */
443 int tmp=1;
444 DAProcessActionRects(x, y, globRect, sizeof(globRect)/sizeof(DAActionRect), &tmp);
448 else
449 DAProcessActionRects(x, y, toggleRect, sizeof(toggleRect)/sizeof(DAActionRect), NULL);
452 void buttonRelease(int button, int state, int x, int y)
454 if (button==1)
455 left_pressed=0;
456 if (xmms_running)
458 if (button == 1)
460 copyNumArea(0,51, 54, 20, 5,39);
461 DASetPixmap(pixmap);
462 DAProcessActionRects(x, y, buttonRects, sizeof(buttonRects)/sizeof(DAActionRect), NULL);
467 void buttonDrag(int x, int y)
469 motion_event=1;
470 if (t_volume)
471 if (left_pressed==1) {
472 DAProcessActionRects(x,y, volumeRects, 1, NULL);
473 DrawChannels(0); /* volume only update */
474 DASetPixmap(pixmap);
478 void DisplayRoutine()
480 int time = 0, length = 0, position = 100;
481 int rate, freq, nch;
482 char *title = NULL;
483 Bool do_scroll=t_scroll;
485 xmms_running=xmms_remote_is_running(xmms_session);
487 /* Compute diplay */
488 if (!xmms_running)
490 if (run_excusive)
491 exit(0);
492 position = 100; /* Will display "00" as the current position */
493 do_scroll = 0; /* Will display channel/kbps info */
494 arrow_pos = 5;
495 rate = 0;
496 time = 0;
497 nch = 4;
498 freq = 0;
499 length = 0;
500 } else {
501 /* check again, avoiding xmms_remote_* functions to hang,
502 if xmms was closed in the meantime */
503 if ((xmms_running = xmms_remote_is_running(xmms_session)))
505 position = xmms_remote_get_playlist_pos(xmms_session);
506 xmms_remote_get_info(xmms_session, &rate, &freq, &nch);
507 time = xmms_remote_get_output_time(xmms_session);
508 length = xmms_remote_get_playlist_time(xmms_session, position);
509 title = xmms_remote_get_playlist_title(xmms_session, position);
510 if (!xmms_remote_is_playing(xmms_session) || (pause_norotate &&
511 xmms_remote_is_paused(xmms_session) ))
512 arrow_pos = 5;
516 /*Draw everything */
517 if (t_time) DrawTime(length-time);
518 else DrawTime(time);
519 DrawPos(position);
520 DrawArrow();
521 DrawChannels(nch);
522 if (do_scroll && (title != NULL))
523 DrawTitle(title);
524 else
525 DrawKbps(rate);
527 DASetPixmap(pixmap);
529 if (title != NULL)
530 free(title);
533 void DrawPos (int pos)
535 char posstr[16];
536 char *p = posstr;
537 int i=1;
539 pos++;
540 if (pos > 99) pos=0;
541 sprintf(posstr, "%02d", pos);
543 for (;i<3; i++)
545 copyNumArea((*p-'0')*6 + 1, 1, 6, 7, (i*6)+39, 7);
546 p++;
550 void DrawTime(int time)
552 char timestr[16];
553 char *p = timestr;
554 int i=0;
556 time = time / 1000;
558 /* 3 cases:
559 * up to 99 minutes and 59 seconds
560 * up to 99 hours and 59 minutes
561 * more
563 if (time < 6000)
565 sprintf(timestr, "%02d%02d", time / 60, time % 60);
566 } else {
567 if (time < 360000)
569 sprintf(timestr, "%02d%02d", time / 3600,
570 time % 3600 / 60);
571 } else {
572 sprintf(timestr, "%02d%02d", 0, 0);
576 for (;i<4; i++)
578 copyNumArea((*p-'0')*7 + 2, 11, 7, 9, i<2 ?(i*7)+7:(i*7)+12, 7);
579 p++;
583 void DrawArrow(void)
585 copyNumArea((arrow_pos*8)+30, 22, 8, 9, 47, 19);
586 arrow_pos++;
587 if (arrow_pos > 4) arrow_pos = 0;
590 void DrawChannels(int channels)
593 if (t_volume) {
594 int volume = (int)(0.36*(float)xmms_remote_get_main_volume(xmms_session));
595 if (volume > 36)
596 volume = 36;
597 copyNumArea(61, 0, volume, 6, 7, 18);
598 copyNumArea(97, 0, 36-volume, 6, 7+volume, 18);
599 } else {
600 if (channels == 4)
602 copyNumArea(55, 32, 10, 6, 10, 18);
603 } else {
604 copyNumArea((channels*10), 22, 10, 6, 10, 18);
609 void DrawKbps(int bps)
611 char kbpstr[16];
612 char *p = kbpstr;
613 int i=1;
615 if (bps > 999000) bps=0;
616 sprintf(kbpstr, "%03d", bps / 1000);
618 for (;i<4; i++)
620 copyNumArea((*p-'0')*6 + 1, 1, 6, 7, (i*6)+1, 26);
621 p++;
623 copyNumArea(55, 39, 18, 8, 25, 26);
626 void DrawChar(wchar_t wc, int x, int y)
628 int i;
629 for(i = 0; i < sizeof(glyphs)/sizeof(glyphdescr) - 1; ++i)
631 if(wc == glyphs[i].c)
632 break;
634 copyNumArea(glyphs[i].x, glyphs[i].y, 6, 8, x, y);
637 int DrawChars(char *title, int tpos, int pos)
639 wchar_t wc;
641 mbtowc(NULL, NULL, 0);
642 while(*title && (pos <= (tpos + DISPLAYSIZE)))
644 int len = mbtowc(&wc, title, MB_CUR_MAX);
645 title += len;
646 if(pos > tpos)
647 DrawChar(wc, (pos - tpos)*6 + 1, 26);
648 ++pos;
650 return pos;
653 void DrawTitle(char *name)
655 int len, pos, tpos = title_pos;
657 if (name == NULL)
658 return;
659 #ifdef DEBUG
660 printf("name: %s\n", name);
661 #endif
662 len = pos = DrawChars(name, tpos, 0);
663 if(pos < 6)
665 DrawChars(" ", tpos, pos);
666 return;
669 if(pos <= tpos + DISPLAYSIZE)
670 pos = DrawChars(SEPARATOR, tpos, pos);
672 if(pos <= tpos + DISPLAYSIZE)
673 DrawChars(name, tpos, pos);
675 if(tpos >= len + strlen(SEPARATOR))
676 title_pos = 0;
678 title_pos = title_pos + 0.5;
681 void ExecuteXmms(void)
683 char *command;
684 int status;
686 command=malloc(strlen(xmms_cmd)+5);
687 sprintf(command, "%s &", xmms_cmd);
688 status = system(command);
689 if (status)
691 fprintf(stderr, "XMMS can't be launched, exiting...");
692 exit(1);
694 while (!xmms_remote_is_running(xmms_session))
695 usleep(10000L);
696 free(command);
698 /*----------------------------------------------------------------------------*/
699 /* Main */
700 /*----------------------------------------------------------------------------*/
702 int main(int argc, char **argv)
704 unsigned height, width;
705 DACallbacks callbacks={NULL, buttonPress, buttonRelease, buttonDrag,
706 NULL, NULL, NULL};
708 /* Initialization */
709 DAParseArguments(argc, argv, options,
710 sizeof(options)/sizeof(DAProgramOption),
711 "XMMS remote control by Bastien Nocera <hadess@hadess.net>",
712 PACKAGE_STRING);
714 setlocale(LC_ALL, "");
715 DAInitialize(displayName, "wmusic", 64, 64, argc, argv);
716 DASetCallbacks(&callbacks);
717 DASetTimeout(100);
719 DAMakePixmapFromData(wmusic_master_xpm, &pixmap,
720 &mask, &height, &width);
721 DAMakePixmapFromData(wmusic_digits_xpm, &pixnum,
722 &masknum, &height, &width);
723 gc = DefaultGC(DADisplay, DefaultScreen(DADisplay));
724 DASetShapeWithOffset(mask, 0, 0);
726 DASetPixmap(pixmap);
727 DAShow();
729 /* End of initialization */
731 if (options[4].used) t_scroll=1;
732 if (options[8].used) pause_norotate=1;
733 if (options[9].used) t_time=1;
734 if (options[10].used) t_volume=1;
735 if (options[11].used) run_excusive=1;
737 /* Launch xmms if it's not running and -r or -R was used */
738 xmms_running=xmms_remote_is_running(xmms_session);
739 if ((!xmms_running) && (options[2].used || run_excusive))
741 ExecuteXmms();
742 xmms_running=1;
745 if(xmms_remote_is_main_win(xmms_session) && (options[6].used))
746 ToggleWins(0, 0, DANoRect, NULL);
748 /* Update the display */
749 DisplayRoutine();
751 while (1) {
752 if (DANextEventOrTimeout(&ev, 100))
753 DAProcessEvent(&ev);
754 if (!motion_event)
755 DisplayRoutine();
756 else
757 motion_event=0;
759 return 0;