|
From: <mla...@us...> - 2007-11-19 05:37:32
|
Revision: 319
http://g15daemon.svn.sourceforge.net/g15daemon/?rev=319&view=rev
Author: mlampard
Date: 2007-11-18 21:37:36 -0800 (Sun, 18 Nov 2007)
Log Message:
-----------
remove dependency on X11, use the EVDEV devices available in /dev/input/eventX for input. Fix fast-scrolling through the playlist.
Modified Paths:
--------------
trunk/g15daemon-audio-plugins/g15mpd/ChangeLog
trunk/g15daemon-audio-plugins/g15mpd/Makefile.am
trunk/g15daemon-audio-plugins/g15mpd/configure.in
trunk/g15daemon-audio-plugins/g15mpd/g15mpd.c
Modified: trunk/g15daemon-audio-plugins/g15mpd/ChangeLog
===================================================================
--- trunk/g15daemon-audio-plugins/g15mpd/ChangeLog 2007-11-18 23:20:11 UTC (rev 318)
+++ trunk/g15daemon-audio-plugins/g15mpd/ChangeLog 2007-11-19 05:37:36 UTC (rev 319)
@@ -2,10 +2,16 @@
- Initial release
SVN
- added ability to scroll through playlist and play selected songs with the
-volume control/play button.
+ volume control/play button.
- best used with g15daemon wip
- Respond to volume wheel & mute button
- Improve responsiveness
- Fix display if stream name is NULL
- Dont display elapsed or total time if playing a radio stream where we dont
have that information.
+- Use EVDEV rather than X events. g15mpd can now be started from init.
+ It now needs to be run as root or be in the same group as /dev/input/eventX.
+- Fix playlist mode scroll feature (uses volume control to fast scroll
+ through playlist if --quickscroll option is used, otherwise uses prev/next
+ keys.
+- Only respond to mmedia keys if the display is in the foreground.
Modified: trunk/g15daemon-audio-plugins/g15mpd/Makefile.am
===================================================================
--- trunk/g15daemon-audio-plugins/g15mpd/Makefile.am 2007-11-18 23:20:11 UTC (rev 318)
+++ trunk/g15daemon-audio-plugins/g15mpd/Makefile.am 2007-11-19 05:37:36 UTC (rev 319)
@@ -6,7 +6,7 @@
docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
doc_DATA = README ChangeLog AUTHORS NEWS COPYING
-LIBS = -lg15daemon_client -lg15render -lX11 -lXtst -lmpd
+LIBS = -lg15daemon_client -lg15render -lmpd
IMCLUDES = -I
g15mpd_LDFLAGS = -avoid-version
g15mpd_SOURCES = g15mpd.c
Modified: trunk/g15daemon-audio-plugins/g15mpd/configure.in
===================================================================
--- trunk/g15daemon-audio-plugins/g15mpd/configure.in 2007-11-18 23:20:11 UTC (rev 318)
+++ trunk/g15daemon-audio-plugins/g15mpd/configure.in 2007-11-19 05:37:36 UTC (rev 319)
@@ -1,7 +1,7 @@
-AC_INIT(g15mpd.c,[1.0svn], [mla...@us...])
+AC_INIT(g15mpd.c,[1.2svn], [mla...@us...])
PACKAGE=g15mpd
-VERSION=1.0.0
+VERSION=1.2.0
AC_PREFIX_DEFAULT(/usr)
AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
@@ -12,12 +12,9 @@
AC_PROG_RANLIB
AC_CHECK_LIB([g15daemon_client], [g15daemon_version],,AC_MSG_ERROR(["libg15daemon_client (or its devel package) not found. please install it"]))
-AC_CHECK_LIB([Xtst],[XTestQueryExtension],,AC_MSG_ERROR(["Xorg XTest extension library not found. please install it"]))
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(g15daemon_client.h libg15render.h,,AC_MSG_ERROR(["libg15daemon_client (or its devel package) could not be found. please install it"]))
-AC_CHECK_HEADERS(X11/Xlib.h X11/XF86keysym.h,,AC_MSG_ERROR(["Xorg development files could not be found. please install the devel package"]))
-AC_CHECK_HEADERS(X11/extensions/XTest.h,,AC_MSG_ERROR(["Xorg XTEST Extension devel headers could not be found. please install the devel package"]))
AC_CHECK_HEADERS(libmpd/libmpd.h,,AC_MSG_ERROR(["libmpd development files could not be found. please install the libmpd devel package"]))
AC_PATH_X
Modified: trunk/g15daemon-audio-plugins/g15mpd/g15mpd.c
===================================================================
--- trunk/g15daemon-audio-plugins/g15mpd/g15mpd.c 2007-11-18 23:20:11 UTC (rev 318)
+++ trunk/g15daemon-audio-plugins/g15mpd/g15mpd.c 2007-11-19 05:37:36 UTC (rev 319)
@@ -14,15 +14,15 @@
You should have received a copy of the GNU General Public License
along with g15daemon; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
- (c) 2006 Mike Lampard
+ (c) 2006-2007 Mike Lampard
+
$Revision$ - $Date$ $Author$
-
+
This daemon listens on localhost port 15550 for client connections,
and arbitrates LCD display. Allows for multiple simultaneous clients.
Client screens can be cycled through by pressing the 'L1' key.
-
+
This is a simple frontend for the Media Player Daemon (MPD)
*/
@@ -42,32 +42,28 @@
#include <libg15render.h>
#include <poll.h>
#include <pthread.h>
-#include <X11/Xlib.h>
-#ifdef HAVE_X11_EXTENSIONS_XTEST_H
-#include <X11/extensions/XTest.h>
-#endif
-#include <X11/XF86keysym.h>
- extern int debug_level;
+#include <linux/input.h>
+
+extern int debug_level;
int g15screen_fd, retval;
g15canvas *canvas;
-
-static Display *dpy;
-static Window root_win;
-
+int current_fg_check=0;
static int playing;
-static int paused;
+static int paused=0;
+static int quickscroll = 0;
MpdObj *obj = NULL;
int leaving = 0;
-int have_xtest=0;
static int voltimeout=0;
static int own_keyboard=0;
pthread_mutex_t daemon_mutex;
pthread_mutex_t lockit;
+int mmedia_fd;
+
static int menulevel=0;
#define MENU_MODE1 0
#define MENU_MODE2 1
@@ -103,7 +99,6 @@
int volume;
struct pollfd fds;
char ver[5];
- int foo;
strncpy(ver,G15DAEMON_VERSION,3);
float g15v;
@@ -111,31 +106,28 @@
fds.fd = g15screen_fd;
fds.events = POLLIN;
-
+
while(!leaving){
- int foo=0;
- int current_fg_check = g15_send_cmd (g15screen_fd, G15DAEMON_IS_FOREGROUND, foo);
- static int last_fg_check = 0;
- if(playlist_mode && last_fg_check != current_fg_check){
- if(own_keyboard){
- if(current_fg_check==0){
- own_keyboard=0;
- XUngrabKeyboard(dpy,CurrentTime);
- XFlush(dpy);
+ int foo=0;
+ current_fg_check = g15_send_cmd (g15screen_fd, G15DAEMON_IS_FOREGROUND, foo);
+ static int last_fg_check = 0;
+ if(playlist_mode && last_fg_check != current_fg_check){
+ if(own_keyboard){
+ if(current_fg_check==0){
+ own_keyboard=0;
+ }
+ }else if(current_fg_check && !own_keyboard) {
+ own_keyboard=1;
}
- }else if(current_fg_check && !own_keyboard) {
- own_keyboard=1;
- XGrabKeyboard(dpy, root_win, True, GrabModeAsync, GrabModeAsync, CurrentTime);
- }
- last_fg_check = current_fg_check;
- }
-
+ last_fg_check = current_fg_check;
+ }
+
/* g15daemon series 1.2 need key request packets */
- pthread_mutex_lock(&daemon_mutex);
- if((g15v*10)<=18) {
+ pthread_mutex_lock(&daemon_mutex);
+ if((g15v*10)<=18) {
keystate = g15_send_cmd (g15screen_fd, G15DAEMON_GET_KEYSTATE, foo);
- } else {
+ } else {
if ((poll(&fds, 1, 5)) > 0)
read (g15screen_fd, &keystate, sizeof (keystate));
}
@@ -154,16 +146,14 @@
menulevel=0;
break;
case G15_KEY_L3:
- if(!own_keyboard){ //activate keyboard grab mode
+ if(!own_keyboard){
own_keyboard=playlist_mode=1;
- XGrabKeyboard(dpy, root_win, True, GrabModeAsync, GrabModeAsync, CurrentTime);
mpd_Song *song = mpd_playlist_get_current_song(obj);
if(song)
if(song->pos)
track_info.currentsong=song->pos;
}else{ //de-activate
own_keyboard=playlist_mode=0;
- XUngrabKeyboard(dpy,CurrentTime);
}
break;
case G15_KEY_L4:
@@ -198,142 +188,121 @@
return NULL;
}
-void xkey_handler(XEvent *event){
-
- int keycode = event->xkey.keycode;
- int code_audio_play = XKeysymToKeycode(dpy,XF86XK_AudioPlay);
- int code_audio_stop = XKeysymToKeycode(dpy, XF86XK_AudioStop);
- int code_audio_next = XKeysymToKeycode(dpy, XF86XK_AudioNext);
- int code_audio_prev = XKeysymToKeycode(dpy, XF86XK_AudioPrev);
- int code_audio_raisevol = XKeysymToKeycode(dpy, XF86XK_AudioRaiseVolume);
- int code_audio_lowervol = XKeysymToKeycode(dpy, XF86XK_AudioLowerVolume);
- int code_audio_mute = XKeysymToKeycode(dpy, XF86XK_AudioMute);
-/* printf("keycode = %d\n", keycode); */
+void *event_key_thread() {
- if(keycode == code_audio_play) {
- if(playing && !playlist_mode) {
- if (paused) {
- mpd_player_play(obj);
- paused = 0;
- } else {
- mpd_player_pause(obj);
- paused = 1;
- }
- } else {
- mpd_player_play(obj);
- playing = 1;
- }
- if(playlist_mode){
- mpd_player_play_id(obj, item_selected);
- }
- return;
- }
+ struct input_event *event;
+ event=malloc(sizeof(struct input_event));
+ struct pollfd fds;
- if(keycode == code_audio_stop) {
- mpd_player_stop(obj);
- playing = 0;
- return;
- }
-
- if(keycode == code_audio_next) {
- mpd_player_next(obj);
- return;
- }
+ int retval;
+ while(!leaving) {
- if(keycode == code_audio_prev) {
- mpd_player_prev(obj);
- return;
- }
+ event->value=0;
+ event->code=0;
+ fds.fd=mmedia_fd;
+ fds.events=POLLIN;
- if(keycode == code_audio_raisevol){
- pthread_mutex_lock(&daemon_mutex);
- volume_adjust+=1;
- pthread_mutex_unlock(&daemon_mutex);
- return;
- }
- if(keycode == code_audio_lowervol){
- pthread_mutex_lock(&daemon_mutex);
- volume_adjust-=1;
- pthread_mutex_unlock(&daemon_mutex);
- return;
- }
+ if(poll(&fds,1,500)<1)
+ continue;
- if(keycode == code_audio_mute){
- pthread_mutex_lock(&daemon_mutex);
- mute = 1;
- pthread_mutex_unlock(&daemon_mutex);
- return;
- }
+ retval=read(mmedia_fd,event,sizeof(struct input_event));
- /* now the default stuff */
- if(own_keyboard) {
- menulevel=MENU_MODE1;
- XUngrabKeyboard(dpy,CurrentTime);
- XFlush(dpy);
- }
-#ifdef HAVE_X11_EXTENSIONS_XTEST_H
- if(have_xtest) { // send the keypress elsewhere
- if(event->type==KeyPress){
- XTestFakeKeyEvent(dpy, keycode, True, CurrentTime);
- }
- XFlush(dpy);
- }
-#endif
- if(own_keyboard && have_xtest) { // we only regrab if the XTEST extension is available.
- XGrabKeyboard(dpy, root_win, True, GrabModeAsync, GrabModeAsync, CurrentTime);
- }
- XFlush(dpy);
+ if(event->value==0||current_fg_check==0)
+ continue;
-}
+ int keycode = event->code;
+ int code_audio_play = KEY_PLAYPAUSE;
+ int code_audio_stop = KEY_STOPCD;
+ int code_audio_next = KEY_NEXTSONG;
+ int code_audio_prev = KEY_PREVIOUSSONG;
+ int code_audio_raisevol = KEY_VOLUMEUP;
+ int code_audio_lowervol = KEY_VOLUMEDOWN;
+ int code_audio_mute = KEY_MUTE;
-static void* xevent_thread()
-{
- XEvent event;
- long event_mask = KeyPressMask|FocusChangeMask|SubstructureNotifyMask;
+ /* printf("keycode = %d\n", keycode); */
- XSelectInput(dpy, root_win, event_mask);
-
- while(!leaving){
- if(XCheckMaskEvent(dpy, event_mask, &event)){
- switch(event.type) {
- case KeyPress: {
- xkey_handler(&event);
- break;
+ if(keycode == code_audio_play) {
+ if(playing && !playlist_mode) {
+ if (paused==1) {
+ mpd_player_play(obj);
+ paused = 0;
+ } else {
+ mpd_player_pause(obj);
+ paused = 1;
+
}
- case KeyRelease: {
- break;
- }
- case FocusIn:
- case FocusOut:
- case EnterNotify:
- case LeaveNotify:
- case MapNotify:
- case UnmapNotify:
- case MapRequest:
- case ConfigureNotify:
- case CreateNotify:
- case DestroyNotify:
- break;
- case ReparentNotify: {
- if(own_keyboard && have_xtest) { // we only regrab if the XTEST extension is available.
- XGrabKeyboard(dpy, root_win, True, GrabModeAsync, GrabModeAsync, CurrentTime);
- }
- XFlush(dpy);
- break;
- }
- default:
- printf("Unhandled event (%i) received\n",event.type);
+
+ } else {
+ mpd_player_play(obj);
+ playing = 1;
}
+ if(playlist_mode){
+ mpd_player_play_id(obj, item_selected);
+ }
}
- if(voltimeout)
- voltimeout--;
- usleep(1000);
+ if(keycode == code_audio_stop) {
+ mpd_player_stop(obj);
+ playing = 0;
+ continue;
+ }
+
+ if(keycode == code_audio_next) {
+ if(playlist_mode)
+ playlist_selection+=1;
+ else
+ mpd_player_next(obj);
+ continue;
+ }
+
+ if(keycode == code_audio_prev) {
+ if(playlist_mode)
+ playlist_selection-=1;
+ else
+ mpd_player_prev(obj);
+ continue;
+ }
+
+ if(keycode == code_audio_raisevol){
+ if(playlist_mode && quickscroll)
+ playlist_selection+=1;
+ else {
+ pthread_mutex_lock(&daemon_mutex);
+ volume_adjust+=1;
+ pthread_mutex_unlock(&daemon_mutex);
+ continue;
+ }
+ }
+ if(keycode == code_audio_lowervol){
+ if(playlist_mode && quickscroll)
+ playlist_selection-=1;
+ else {
+ pthread_mutex_lock(&daemon_mutex);
+ volume_adjust-=1;
+ pthread_mutex_unlock(&daemon_mutex);
+ continue;
+ }
+ }
+
+ if(keycode == code_audio_mute){
+ pthread_mutex_lock(&daemon_mutex);
+ mute = 1;
+ pthread_mutex_unlock(&daemon_mutex);
+ continue;
+ }
+
+ /* now the default stuff */
+ if(own_keyboard) {
+ menulevel=MENU_MODE1;
+ continue;
+ }
}
+ free(event);
return NULL;
}
+
/* take the track_info structure and render it */
void *g15display_thread(){
long chksum=0;
@@ -345,11 +314,11 @@
int changed =0;
while(!leaving){
if(playlist_mode){
-
+
int y=0;
int offset=2;
changed = 0;
-
+
if(track_info.currentsong>-1){
current=track_info.currentsong;
track_info.currentsong = -1;
@@ -375,44 +344,44 @@
if(current-offset<0)
offset-=current;
-
+
if(changed){
g15r_pixelBox (canvas, 0, 0, 159, 42, G15_COLOR_WHITE, 1, 1);
- for(i=current-offset;i<current+6;i++){
- char title[100];
- mpd_Song *song;
+ for(i=current-offset;i<current+6;i++){
+ char title[100];
+ mpd_Song *song;
- song = mpd_playlist_get_song_from_pos(obj, i);
- if(song) {
- if(song->title!=NULL)
- strncpy(title,song->title,99);
- else
+ song = mpd_playlist_get_song_from_pos(obj, i);
+ if(song) {
+ if(song->title!=NULL)
+ strncpy(title,song->title,99);
+ else
+ strncpy(title,"",99);
+ if(song->artist!=NULL){
+ strncat(title," - ",99);
+ strncat(title,song->artist,99);
+ }
+ }
+ /* sanitise the display */
+ if(i==mpd_playlist_get_playlist_length(obj))
+ strncpy(title,"End of PlayList",99);
+ if(i>mpd_playlist_get_playlist_length(obj))
+ break;
+ if(i<0)
strncpy(title,"",99);
- if(song->artist!=NULL){
- strncat(title," - ",99);
- strncat(title,song->artist,99);
+
+ if(y==offset){
+ g15r_pixelBox (canvas, 0, 7*offset, 159 , 7*(offset+1), G15_COLOR_BLACK, 1, 1);
+ canvas->mode_xor=1;
+ if(song)
+ if(song->id)
+ item_selected=song->id;
}
+ g15r_renderString (canvas, (unsigned char *)title, y, G15_TEXT_MED, 1, 1);
+ canvas->mode_xor=0;
+ y++;
}
- /* sanitise the display */
- if(i==mpd_playlist_get_playlist_length(obj))
- strncpy(title,"End of PlayList",99);
- if(i>mpd_playlist_get_playlist_length(obj))
- break;
- if(i<0)
- strncpy(title,"",99);
-
- if(y==offset){
- g15r_pixelBox (canvas, 0, 7*offset, 159 , 7*(offset+1), G15_COLOR_BLACK, 1, 1);
- canvas->mode_xor=1;
- if(song)
- if(song->id)
- item_selected=song->id;
- }
- g15r_renderString (canvas, (unsigned char *)title, y, G15_TEXT_MED, 1, 1);
- canvas->mode_xor=0;
- y++;
}
- }
}else{
/* track info */
g15r_pixelBox (canvas, 0, 0, 159, 42, G15_COLOR_WHITE, 1, 1);
@@ -423,8 +392,8 @@
memset(time_elapsed,0,41);
memset(time_total,0,41);
if (track_info.total != 0) {
- snprintf((char*)time_elapsed,40,"%02i:%02i",track_info.elapsed/60, track_info.elapsed%60);
- snprintf((char*)time_total,40,"%02i:%02i",track_info.total/60, track_info.total%60);
+ snprintf((char*)time_elapsed,40,"%02i:%02i",track_info.elapsed/60, track_info.elapsed%60);
+ snprintf((char*)time_total,40,"%02i:%02i",track_info.total/60, track_info.total%60);
}
if(track_info.elapsed>0&&track_info.total>0)
g15r_drawBar (canvas, 10, 22, 149, 30, G15_COLOR_BLACK, track_info.elapsed, track_info.total, 1);
@@ -500,9 +469,9 @@
g15r_pixelBox (canvas, 130, 34, 149 , 42, G15_COLOR_BLACK, 1, 0);
g15r_renderString (canvas, (unsigned char *)"Vol+", 0, G15_TEXT_SMALL, 132, 36);
- // 2nd box from left - if you want it...
- //g15r_pixelBox (canvas, 34, 34, 54 , 42, G15_COLOR_BLACK, 1, 0);
- //g15r_renderString (canvas, (unsigned char *)"test", 0, G15_TEXT_SMALL, 36, 36);
+ // 2nd box from left - if you want it...
+ //g15r_pixelBox (canvas, 34, 34, 54 , 42, G15_COLOR_BLACK, 1, 0);
+ //g15r_renderString (canvas, (unsigned char *)"test", 0, G15_TEXT_SMALL, 36, 36);
}
if(muted_volume != 0){
@@ -532,7 +501,6 @@
}
pthread_mutex_unlock(&daemon_mutex);
last_chksum=chksum;
-
usleep(75*1000);
if(playlist_mode)
usleep(75*1000);
@@ -562,12 +530,12 @@
if(what&MPD_CST_CROSSFADE){
// printf(GREEN"X-Fade:"RESET" %i sec.\n",mpd_status_get_crossfade(mi));
}
-
+
if(what&MPD_CST_PLAYLIST)
{
// printf(GREEN"Playlist changed"RESET"\n");
track_info.totalsongs_in_playlist = mpd_playlist_get_playlist_length(mi);
-
+
}
if(what&MPD_CST_ELAPSED_TIME && !voltimeout){
@@ -579,44 +547,83 @@
voltimeout=500;
track_info.volume = mpd_status_get_volume(mi);
}
-
+
if(what&MPD_CST_STATE) {
track_info.playstate = mpd_player_get_state(mi);
}
-
+
track_info.repeat = mpd_player_get_repeat(obj);
track_info.random = mpd_player_get_random(obj);
-
+
pthread_mutex_unlock(&lockit);
usleep(10*1000);
}
-int myx_error_handler(Display *dpy, XErrorEvent *err){
- printf("error (%i) occured - ignoring\n",err->error_code);
- return 0;
-}
int main(int argc, char **argv)
{
int fdstdin = 0;
- pthread_t Xkeys;
pthread_t Lkeys;
pthread_t g15display;
- int xtest_major_version = 0;
- int xtest_minor_version = 0;
- int dummy;
+ pthread_t EKeys;
int volume;
int volume_new;
-
+ char devname[256] = "Unknown";
int iport = 6600;
char *hostname = getenv("MPD_HOST");
char *port = getenv("MPD_PORT");
char *password = getenv("MPD_PASSWORD");
-
+ int eventdev;
+ char evdev_name[128];
pthread_mutex_init(&lockit,NULL);
pthread_mutex_init(&daemon_mutex,NULL);
+ int i;
+
+ for (i=0;i<argc;i++) {
+ char argument[20];
+ memset(argument,0,20);
+ strncpy(argument,argv[i],19);
+ if (!strncmp(argument, "-q",2) || !strncmp(argument, "--quickscroll",13)) {
+ quickscroll=1;
+ }
+ if (!strncmp(argument, "-h",2) || !strncmp(argument, "--help",6)) {
+ printf(" %s version %s\n (c)2006-2007 Mike Lampard\n\n",argv[0],VERSION);
+ printf("%s -q or --quickscroll Use volume control to scroll through the playlist\n",argv[0]);
+ printf("%s -v or --version Show program version\n",argv[0]);
+ printf("%s -h or --help This help text\n\n",argv[0]);
+ exit(0);
+ }
+ if (!strncmp(argument, "-v",2) || !strncmp(argument, "--version",9)) {
+ printf("%s version %s\n",argv[0],VERSION);
+ exit(0);
+ }
+ }
+
+ for(eventdev=0;eventdev<127;eventdev++) {
+ snprintf(evdev_name,127,"/dev/input/event%i",eventdev);
+ if ((mmedia_fd = open(evdev_name, O_NONBLOCK|O_RDONLY)) < 0) {
+ printf("error opening interface %i",eventdev);
+ }
+ ioctl(mmedia_fd, EVIOCGNAME(sizeof(devname)), devname);
+ if(0==strncmp(devname,"Logitech Logitech Gaming Keyboard",256)){
+ printf("Found device: \"%s\" on %s ", devname,evdev_name);
+ break;
+ }else
+ close(mmedia_fd);
+ }
+ if (mmedia_fd) { // we assume that the next event device is the multimedia keys
+ close(mmedia_fd);
+ snprintf(evdev_name,127,"/dev/input/event%i",++eventdev);
+ printf("and %s\n",evdev_name);
+ if ((mmedia_fd = open(evdev_name, O_NONBLOCK|O_RDONLY)) < 0) {
+ printf("error opening interface %i",eventdev);
+ }
+ }else {
+ printf("Unable to find Keyboard via EVENT interface... is /dev/input/event[0-9] readable??\n");
+ }
+
/* set correct hostname */
if(!hostname) {
hostname = "localhost";
@@ -638,43 +645,6 @@
canvas->mode_xor = 0;
}
- dpy = XOpenDisplay(getenv("DISPLAY"));
- if (!dpy) {
- printf("Can't open display\n");
- return 1;
- }
-
- root_win = DefaultRootWindow(dpy);
- if (!root_win) {
- printf("Cant find root window\n");
- return 1;
- }
-#ifdef HAVE_X11_EXTENSIONS_XTEST_H
- have_xtest = XTestQueryExtension(dpy, &dummy, &dummy, &xtest_major_version, &xtest_minor_version);
- if(have_xtest == False || xtest_major_version < 2 || (xtest_major_version <= 2 && xtest_minor_version < 2))
- {
- printf("XTEST extension not supported");
- }
-#endif
- /* completely ignore errors and carry on */
- XSetErrorHandler(myx_error_handler);
- XFlush(dpy);
-
- XGrabKey(dpy,XKeysymToKeycode(dpy, XF86XK_AudioPlay), AnyModifier, root_win,
- False, GrabModeAsync, GrabModeAsync);
- XGrabKey(dpy,XKeysymToKeycode(dpy, XF86XK_AudioStop), AnyModifier, root_win,
- False, GrabModeAsync, GrabModeAsync);
- XGrabKey(dpy,XKeysymToKeycode(dpy, XF86XK_AudioPrev), AnyModifier, root_win,
- False, GrabModeAsync, GrabModeAsync);
- XGrabKey(dpy,XKeysymToKeycode(dpy, XF86XK_AudioNext), AnyModifier, root_win,
- False, GrabModeAsync, GrabModeAsync);
- XGrabKey(dpy,XKeysymToKeycode(dpy, XF86XK_AudioRaiseVolume), AnyModifier, root_win,
- False, GrabModeAsync, GrabModeAsync);
- XGrabKey(dpy,XKeysymToKeycode(dpy, XF86XK_AudioLowerVolume), AnyModifier, root_win,
- False, GrabModeAsync, GrabModeAsync);
- XGrabKey(dpy,XKeysymToKeycode(dpy, XF86XK_AudioMute), AnyModifier, root_win,
- False, GrabModeAsync, GrabModeAsync);
-
/* Create mpd object */
obj = mpd_new(hostname, iport,password);
/* Connect signals */
@@ -693,8 +663,8 @@
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr,32*1024); /* set stack to 64k - dont need 8Mb !! */
- pthread_create(&Xkeys, &attr, xevent_thread, NULL);
pthread_create(&Lkeys, &attr, Lkeys_thread, NULL);
+ pthread_create(&EKeys, &attr,event_key_thread, NULL);
pthread_create(&g15display, &attr, g15display_thread, NULL);
do{
@@ -735,6 +705,7 @@
}
mpd_status_update(obj);
pthread_mutex_unlock(&daemon_mutex);
+
}while(!usleep(5000) && !leaving);
}
mpd_free(obj);
@@ -744,17 +715,12 @@
free(canvas);
close(g15screen_fd);
+ close(mmedia_fd);
leaving = 1;
- pthread_join(Xkeys,NULL);
pthread_join(Lkeys,NULL);
pthread_join(g15display,NULL);
- XUngrabKey(dpy, XF86XK_AudioPrev, AnyModifier, root_win);
- XUngrabKey(dpy, XF86XK_AudioNext, AnyModifier, root_win);
- XUngrabKey(dpy, XF86XK_AudioPlay, AnyModifier, root_win);
- XUngrabKey(dpy, XF86XK_AudioStop, AnyModifier, root_win);
- if(own_keyboard)
- XUngrabKeyboard(dpy,CurrentTime);
+
pthread_mutex_destroy(&lockit);
-
+
return 1;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|