diff -Nru desklaunch-1.1.7/debian/changelog desklaunch-1.1.8/debian/changelog --- desklaunch-1.1.7/debian/changelog 2010-02-14 16:11:08.000000000 +0000 +++ desklaunch-1.1.8/debian/changelog 2010-11-30 11:39:59.000000000 +0000 @@ -1,3 +1,11 @@ +desklaunch (1.1.8) unstable; urgency=low + + * Fix NumLock and other modifiers handling. (Closes: #459074) + * Fix cpu usage by porting the select mechanism from oroborus. + (Closes: #604117) + + -- Stefan Pfetzing Tue, 30 Nov 2010 12:21:58 +0100 + desklaunch (1.1.7) unstable; urgency=low * Fix lintian errors. diff -Nru desklaunch-1.1.7/debian/example_rc desklaunch-1.1.8/debian/example_rc --- desklaunch-1.1.7/debian/example_rc 2006-01-09 16:43:23.000000000 +0000 +++ desklaunch-1.1.8/debian/example_rc 2010-11-30 11:41:24.000000000 +0000 @@ -6,6 +6,6 @@ # program-to-launch # -icon=5:5:/usr/X11R6/include/X11/pixmaps/monitor.xpm:Terminal:x-terminal-emulator +icon=5:5:/usr/share/pixmaps/xterm_32x32.xpm:Terminal:x-terminal-emulator icon=5:60:/usr/share/pixmaps/emelfm.xpm:File Manager:emelfm icon=5:115:/usr/share/xmms/xmms.xpm:Xmms:xmms diff -Nru desklaunch-1.1.7/desklaunch.c desklaunch-1.1.8/desklaunch.c --- desklaunch-1.1.7/desklaunch.c 2010-02-14 15:13:07.000000000 +0000 +++ desklaunch-1.1.8/desklaunch.c 2010-11-30 11:56:49.000000000 +0000 @@ -29,8 +29,11 @@ #include #include #include +#include #include #include +#include +#include #define TOOLTIP_COL "#fffacd" #define TOOLTIP_FONT "lucidasans-12" @@ -116,7 +119,7 @@ set_mwm_hints (Window w, PropMwmHints * hints) { #ifdef DEBUG - printf ("set_mwm_hints"); + printf ("set_mwm_hints\n"); #endif XChangeProperty (dpy, w, motif, motif, 32, PropModeReplace, @@ -214,7 +217,7 @@ XRaiseWindow (dpy, i->window); } else - print_error ("Xpm file not found.", False); + print_error ("Xpm file not found.\n", False); } Icon * @@ -409,9 +412,7 @@ if (active_icon) { if (ev->window == active_icon->window && ev->button == Button1 - && (ev->state == Button1Mask - || ev->state == (Button1Mask | LockMask) - || ev->state == (Button1Mask | ShiftMask))) + && (ev->state & Button1Mask)) fork_exec (active_icon->command); } } @@ -531,6 +532,32 @@ parse_rc (getenv ("HOME"), RCFILE); } +void +process_all_events () +{ + while (XPending (dpy)) + { + XEvent ev; + + XNextEvent (dpy, &ev); + switch (ev.type) + { + case EnterNotify: + event_enter_notify (&ev.xcrossing); + break; + case LeaveNotify: + event_leave_notify (); + break; + case ButtonRelease: + event_button_release (&ev.xbutton); + break; + case ConfigureNotify: + event_configure_notify (&ev.xconfigure); + break; + } + } +} + /* * * Main @@ -540,40 +567,60 @@ int main (int argc, char *argv[]) { + fd_set readset; + int x_fd; + int nfds; + struct timeval timeout; + initialize (); + process_all_events (); + + x_fd = XConnectionNumber (dpy); - /* Event loop */ while (1) { - XEvent ev; + FD_ZERO (&readset); + FD_SET (x_fd, &readset); + + /* compute the number of the highest fd for the select call */ + nfds = x_fd+1; + + timeout.tv_sec=1; + timeout.tv_usec=0; + +#ifdef DEBUG + printf("Calling select. x_fd=%d\n", x_fd); +#endif - while (XPending (dpy)) +INT: if (-1 == select (nfds, &readset, NULL, NULL, &timeout)) { - XNextEvent (dpy, &ev); - switch (ev.type) + if (errno == EINTR) { - case EnterNotify: - event_enter_notify (&ev.xcrossing); - break; - case LeaveNotify: - event_leave_notify (); - break; - case ButtonRelease: - event_button_release (&ev.xbutton); - break; - case ConfigureNotify: - event_configure_notify (&ev.xconfigure); - break; + if (do_update) + { + free_icons (); + parse_rc (getenv ("HOME"), RCFILE); + } + + /* EINTR means, we just can re-execute the select call. + * Sorry, but in this case just the best is a goto. + */ + goto INT; } - } - if (do_update) + /* now comes the case, select fails, and errno is not EINTR. */ + else + return 1; + } + else { - free_icons (); - parse_rc (getenv ("HOME"), RCFILE); + /* now lets check the fd's */ + if (FD_ISSET (x_fd, &readset)) + /* process all pending requests */ + process_all_events (); } - usleep (250); } + return 0; }