X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=driver%2Fdemo-Gtk.c;h=13033fa731ad5b914024003400f3aebe5c8f13ae;hb=bbd0773f2adde4927a6196361d4061e70bf48cd9;hp=b2620a4f7ef12d17e8488a2a6b1afae377dea322;hpb=96bdd7cf6ea60c418a76921acaf0e34d6f5be930;p=xscreensaver diff --git a/driver/demo-Gtk.c b/driver/demo-Gtk.c index b2620a4f..13033fa7 100644 --- a/driver/demo-Gtk.c +++ b/driver/demo-Gtk.c @@ -24,6 +24,13 @@ # include #endif +# ifdef __GNUC__ +# define STFU __extension__ /* ignore gcc -pendantic warnings in next sexp */ +# else +# define STFU /* */ +# endif + + #ifdef ENABLE_NLS # include #endif /* ENABLE_NLS */ @@ -128,6 +135,8 @@ enum { /* from exec.c */ extern void exec_command (const char *shell, const char *command, int nice); +static void hack_subproc_environment (Window preview_window_id, Bool debug_p); + #undef countof #define countof(x) (sizeof((x))/sizeof((*x))) @@ -515,13 +524,13 @@ warning_dialog (GtkWidget *parent, const char *message, gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); gtk_container_set_border_width (GTK_CONTAINER (dialog), 10); gtk_window_set_title (GTK_WINDOW (dialog), progclass); - GTK_WIDGET_SET_FLAGS (ok, GTK_CAN_DEFAULT); + STFU GTK_WIDGET_SET_FLAGS (ok, GTK_CAN_DEFAULT); gtk_widget_show (ok); gtk_widget_grab_focus (ok); if (cancel) { - GTK_WIDGET_SET_FLAGS (cancel, GTK_CAN_DEFAULT); + STFU GTK_WIDGET_SET_FLAGS (cancel, GTK_CAN_DEFAULT); gtk_widget_show (cancel); } gtk_widget_show (label); @@ -850,6 +859,12 @@ await_xscreensaver (state *s) "\n")); if (root_p) + +# ifdef __GNUC__ + __extension__ /* don't warn about "string length is greater than + the length ISO C89 compilers are required to + support" in the following expression... */ +# endif strcat (buf, _("You are running as root. This usually means that xscreensaver\n" "was unable to contact your X server because access control is\n" @@ -988,7 +1003,7 @@ force_list_select_item (state *s, GtkWidget *list, int list_elt, Bool scroll_p) if (!was) gtk_widget_set_sensitive (parent, True); #ifdef HAVE_GTK2 model = gtk_tree_view_get_model (GTK_TREE_VIEW (list)); - g_assert (model); + STFU g_assert (model); gtk_tree_model_iter_nth_child (model, &iter, NULL, list_elt); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (list)); gtk_tree_selection_select_iter (selection, &iter); @@ -1136,7 +1151,7 @@ hack_time_text (state *s, const char *line, Time *store, Bool sec_p) else { char c; - if (sscanf (line, "%u%c", &value, &c) != 1) + if (sscanf (line, "%d%c", &value, &c) != 1) value = -1; if (!sec_p) value *= 60; @@ -1506,7 +1521,7 @@ flush_popup_changes_and_save (state *s) else if (!strcasecmp (visual, "greyscale")) visual = "GrayScale"; else if (!strcasecmp (visual, "pseudocolor")) visual = "PseudoColor"; else if (!strcasecmp (visual, "directcolor")) visual = "DirectColor"; - else if (1 == sscanf (visual, " %ld %c", &id, &c)) ; + else if (1 == sscanf (visual, " %lu %c", &id, &c)) ; else if (1 == sscanf (visual, " 0x%lx %c", &id, &c)) ; else { @@ -1630,7 +1645,7 @@ list_activated_cb (GtkTreeView *list, char *str; int list_elt; - g_return_if_fail (!gdk_pointer_is_grabbed ()); + STFU g_return_if_fail (!gdk_pointer_is_grabbed ()); str = gtk_tree_path_to_string (path); list_elt = strtol (str, NULL, 10); @@ -3426,6 +3441,8 @@ launch_preview_subproc (state *s) { close (ConnectionNumber (GDK_DISPLAY())); + hack_subproc_environment (id, s->debug_p); + usleep (250000); /* pause for 1/4th second before launching, to give the previous program time to die and flush its X buffer, so we don't get leftover turds on the @@ -3516,6 +3533,29 @@ hack_environment (state *s) } +static void +hack_subproc_environment (Window preview_window_id, Bool debug_p) +{ + /* Store a window ID in $XSCREENSAVER_WINDOW -- this isn't strictly + necessary yet, but it will make programs work if we had invoked + them with "-root" and not with "-window-id" -- which, of course, + doesn't happen. + */ + char *nssw = (char *) malloc (40); + sprintf (nssw, "XSCREENSAVER_WINDOW=0x%X", (unsigned int) preview_window_id); + + /* Allegedly, BSD 4.3 didn't have putenv(), but nobody runs such systems + any more, right? It's not Posix, but everyone seems to have it. */ + if (putenv (nssw)) + abort (); + + if (debug_p) + fprintf (stderr, "%s: %s\n", blurb(), nssw); + + /* do not free(nssw) -- see above */ +} + + /* Called from a timer: Launches the currently-chosen subprocess, if it's not already running. If there's a different process running, kills it. @@ -3899,6 +3939,12 @@ g_log_handler (const gchar *log_domain, GLogLevelFlags log_level, } +#ifdef __GNUC__ + __extension__ /* shut up about "string length is greater than the length + ISO C89 compilers are required to support" when including + the .ad file... */ +#endif + static char *defaults[] = { #include "XScreenSaver_ad.h" 0 @@ -4015,6 +4061,7 @@ main (int argc, char **argv) Widget toplevel_shell; char *real_progname = argv[0]; char *window_title; + char *geom = 0; Bool crapplet_p = False; char *str; @@ -4109,6 +4156,21 @@ main (int argc, char **argv) argc--; i--; } + else if (argv[i] && + argc > i+1 && + *argv[i+1] && + (!strcmp(argv[i], "-geometry") || + !strcmp(argv[i], "-geom") || + !strcmp(argv[i], "-geo") || + !strcmp(argv[i], "-g"))) + { + int j; + geom = argv[i+1]; + for (j = i; j < argc; j++) /* remove them from the list */ + argv[j] = argv[j+2]; + argc -= 2; + i -= 2; + } else if (argv[i] && argc > i+1 && *argv[i+1] && @@ -4266,7 +4328,8 @@ main (int argc, char **argv) ; else { - fprintf (stderr, _("%s: unknown option: %s\n"), real_progname, argv[i]); + fprintf (stderr, _("%s: unknown option: %s\n"), real_progname, + argv[i]); fprintf (stderr, "%s: %s\n", real_progname, usage); exit (1); } @@ -4442,7 +4505,7 @@ main (int argc, char **argv) gtk_widget_ref (outer_vbox); gtk_container_remove (GTK_CONTAINER (s->toplevel_widget), outer_vbox); - GTK_OBJECT_SET_FLAGS (outer_vbox, GTK_FLOATING); + STFU GTK_OBJECT_SET_FLAGS (outer_vbox, GTK_FLOATING); gtk_container_add (GTK_CONTAINER (capplet), outer_vbox); /* Find the window above us, and set the title and close handler. */ @@ -4477,6 +4540,9 @@ main (int argc, char **argv) free (window_title); window_title = 0; + /* After picking the default size, allow -geometry to override it. */ + if (geom) + gtk_window_parse_geometry (GTK_WINDOW (s->toplevel_widget), geom); gtk_widget_show (s->toplevel_widget); init_icon (GTK_WIDGET (s->toplevel_widget)->window); /* after `show' */