On 2007-1104 09:22:18, Mario Frasca wrote:
> I opened the source and maybe a better idea is in the enclosed patch,
> which I could not test because of some broken dependencies on my system...
I repaired the dependencies and tested the patch.
it did not work: I was calling the function 'swallow' once a second while
the same function contained a loop keeping it alive during 10 seconds...
I've removed the loop and it now works (on my system)...
see enclosed new patch.
ciao,
Mario Frasca
................................................................
--- gnome-swallow-1.2/gnome-swallow.c 2006-04-27 23:08:30.000000000 +0200
+++ gnome-swallow-1.2.400265/gnome-swallow.c 2007-11-05 19:57:27.000000000
+0100
@@ -47,19 +47,12 @@
char *windowname;
XWMHints *leader_change;
int x, y, junk;
- double start, now;
- struct timeval tv;
char ret;
if(! display) return; /* WTF? */
XSync (display, FALSE);
- gettimeofday(&tv);
- now = start = (double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0);
-
- while (ready == FALSE && now < (start + 10.0))
- {
if (children != (Window *) NULL) XFree (children);
XQueryTree (display, RootWindowOfScreen (screen), &root,
@@ -128,12 +121,6 @@
}
}
}
- fprintf(stderr,"Loop");
- gtk_main_iteration_do(FALSE);
-
- gettimeofday(&tv);
- now = (double)tv.tv_sec + ((double)tv.tv_usec / 1000000.0);
- }
if(ready) {
XSync (display, FALSE);
@@ -193,6 +180,7 @@
{
GdkDisplay* gdkdisplay = gdk_display_get_default ();
GdkScreen* gdkscreen = gdk_screen_get_default ();
+ static int count = 40; // max times to invoke the function
struct AppletConfigure* ap = (struct AppletConfigure*)data;
@@ -206,16 +194,19 @@
panel_applet_gconf_set_string(ap->applet, "applet_name",
ap->applet_name, NULL);
orientChanged(GTK_WIDGET(ap->applet), 0, ap);
+ return FALSE; // found it, remove the timeout!
} else {
+ // no window found...
+ if (count--)
+ return TRUE; // but keep trying...
GtkWidget* dialog = gtk_message_dialog_new(0, 0, GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"Swallower Applet: Could
not find a window named \"%s\" (ran program \"%s\")", ap->applet_name,
ap->program);
g_signal_connect_swapped (GTK_OBJECT(dialog), "response",
G_CALLBACK(gtk_widget_destroy),
GTK_OBJECT(dialog));
gtk_widget_show(dialog);
+ return FALSE; // remove the timeout!
}
-
- return FALSE;
}
void store_filename(GtkWidget* widget, struct AppletConfigure* ap)
@@ -286,7 +277,7 @@
_exit(0);
} else {
- gtk_timeout_add (1000, swallowIt, ap);
+ gtk_timeout_add (1000, swallowIt, ap); // try once a second...
}
}
................................................................
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]