"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/startupnotification.cpp" between
xfe-1.41.tar.gz and xfe-1.42.tar.gz

About: Xfe (X File Explorer) is a file manager and browser (using the FOX toolkit).

startupnotification.cpp  (xfe-1.41):startupnotification.cpp  (xfe-1.42)
skipping to change at line 47 skipping to change at line 47
sn_launchee_context_unref(launchee); sn_launchee_context_unref(launchee);
} }
sn_display_unref(display); sn_display_unref(display);
XCloseDisplay(xdisplay); XCloseDisplay(xdisplay);
} }
} }
// Hack to obtain a timestamp for startup notification // Hack to obtain a timestamp for startup notification
// Create a fake window and set up a property change event // Create a fake window and set up a property change event
// Code snippet borrowed from the Internet // Code snippet borrowed from the Internet
Time gettimestamp(void) Time gettimestamp(Display *display)
{ {
Display* display;
Window window; Window window;
XEvent event; XEvent event;
Atom atom_name, atom_type; Atom atom_name, atom_type;
display = XOpenDisplay(0);
window = XCreateWindow(display, DefaultRootWindow(display), 0, 0, 1, 1, 0, 0 , InputOnly, 0, 0, NULL); window = XCreateWindow(display, DefaultRootWindow(display), 0, 0, 1, 1, 0, 0 , InputOnly, 0, 0, NULL);
XSelectInput(display, window, PropertyChangeMask); XSelectInput(display, window, PropertyChangeMask);
atom_name = XInternAtom(display, "_NET_WM_USER_TIME_WINDOW", False); atom_name = XInternAtom(display, "_NET_WM_USER_TIME_WINDOW", False);
atom_type = XInternAtom(display, "WINDOW", true); atom_type = XInternAtom(display, "WINDOW", true);
XChangeProperty(display, window, atom_name, atom_type, 8, PropModeReplace, ( const FXuchar*)&window, 1); XChangeProperty(display, window, atom_name, atom_type, 8, PropModeReplace, ( const FXuchar*)&window, 1);
XNextEvent(display, &event); XNextEvent(display, &event);
assert(event.type == PropertyNotify); assert(event.type == PropertyNotify);
XCloseDisplay(display);
return(((XPropertyEvent*)&event)->time); return(((XPropertyEvent*)&event)->time);
} }
// Launch a command and initiate a startup notification // Launch a command and initiate a startup notification
int runcmd(FXString cmd, FXString cmdname, FXString dir, FXString startdir, FXbo ol usesn = true, FXString snexcepts = "") int runcmd(FXString cmd, FXString cmdname, FXString dir, FXString startdir, FXbo ol usesn = true, FXString snexcepts = "")
{ {
int ret; int ret;
// Change to current directory // Change to current directory
skipping to change at line 152 skipping to change at line 149
FXString message; FXString message;
message.format(_("Start of %s"), cmdname.text()); message.format(_("Start of %s"), cmdname.text());
// Initiate launcher context // Initiate launcher context
display = sn_display_new(xdisplay, NULL, NULL); display = sn_display_new(xdisplay, NULL, NULL);
context = sn_launcher_context_new(display, DefaultScreen(xdisplay)); context = sn_launcher_context_new(display, DefaultScreen(xdisplay));
sn_launcher_context_set_name(context, message.text()); sn_launcher_context_set_name(context, message.text());
sn_launcher_context_set_binary_name(context, cmdname.text()); sn_launcher_context_set_binary_name(context, cmdname.text());
sn_launcher_context_set_description(context, message.text()); sn_launcher_context_set_description(context, message.text());
sn_launcher_context_set_icon_name(context, cmdname.text()); sn_launcher_context_set_icon_name(context, cmdname.text());
timestamp = gettimestamp(); timestamp = gettimestamp(xdisplay);
sn_launcher_context_initiate(context, "Xfe", cmd.text(), timestamp); sn_launcher_context_initiate(context, "Xfe", cmd.text(), timestamp);
// Run command in background // Run command in background
cmd += " &"; cmd += " &";
static pid_t child_pid = 0; static pid_t child_pid = 0;
switch ((child_pid = fork())) switch ((child_pid = fork()))
{ {
case -1: case -1:
fprintf(stderr, _("Error: Fork failed: %s\n"), strerror(errno)); fprintf(stderr, _("Error: Fork failed: %s\n"), strerror(errno));
break; break;
case 0: // Child case 0: // Child
sn_launcher_context_setup_child_process(context); sn_launcher_context_setup_child_process(context);
execl("/bin/sh", "sh", "-c", cmd.text(), (char*)NULL); execl("/bin/sh", "sh", "-c", cmd.text(), (char*)NULL);
_exit(EXIT_SUCCESS); _exit(EXIT_SUCCESS);
break; break;
} }
sn_launcher_context_unref(context); sn_launcher_context_unref(context);
XCloseDisplay(xdisplay);
} }
// Run command without startup notification // Run command without startup notification
else else
{ {
// Run command in background // Run command in background
cmd += " &"; cmd += " &";
ret = system(cmd.text()); ret = system(cmd.text());
if (ret < 0) if (ret < 0)
{ {
 End of changes. 6 change blocks. 
5 lines changed or deleted 3 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS