Author: kelnos Date: 2008-05-12 00:23:51 +0000 (Mon, 12 May 2008) New Revision: 26948
Modified: xfconf/trunk/TODO xfconf/trunk/xfsettingsd/main.c Log: make xfsettingsd manage all screens Modified: xfconf/trunk/TODO =================================================================== --- xfconf/trunk/TODO 2008-05-12 00:17:09 UTC (rev 26947) +++ xfconf/trunk/TODO 2008-05-12 00:23:51 UTC (rev 26948) @@ -20,7 +20,6 @@ + what happens if a channel isn't loaded into memory and its backing file changes? load it and send PropertyChanged for all properties? that could be very bad. -* multi-screen support for xfsettingsd * libxfce4mcs-client dummy implementation that forwards to libxfconf (?) * maybe validate channel/prop names in libxfconf too to generate an error without a roundtrip to the server (?) Modified: xfconf/trunk/xfsettingsd/main.c =================================================================== --- xfconf/trunk/xfsettingsd/main.c 2008-05-12 00:17:09 UTC (rev 26947) +++ xfconf/trunk/xfsettingsd/main.c 2008-05-12 00:23:51 UTC (rev 26948) @@ -39,11 +39,13 @@ #define XF_DEBUG(str) \ if (debug) g_print (str) -gboolean version = FALSE; -gboolean force_replace = FALSE; -gboolean running = FALSE; -gboolean debug = FALSE; +static gboolean version = FALSE; +static gboolean force_replace = FALSE; +static gboolean running = FALSE; +static gboolean debug = FALSE; +static GList *registries = NULL; + static GOptionEntry entries[] = { { "version", 'v', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &version, @@ -75,7 +77,10 @@ if (xsettings_registry_process_event(registry, xevent)) { - gtk_main_quit(); + g_object_unref(G_OBJECT(registry)); + registries = g_list_remove(registries, registry); + if(!registries) + gtk_main_quit(); return GDK_FILTER_REMOVE; } else @@ -112,8 +117,10 @@ main(int argc, char **argv) { GError *cli_error = NULL; - gint screen; - Window window = None; + GdkDisplay *gdpy; + gint n_screens, screen; + gboolean keep_running = FALSE; + XfconfChannel *channel; xfce_textdomain(GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); @@ -133,51 +140,67 @@ return 0; } - xfconf_init(NULL); + if(!xfconf_init(&cli_error)) + { + g_printerr("Failed to connect to Xfconf daemon: %s\n", + cli_error->message); + return 1; + } - screen = DefaultScreen(gdk_display); - - running = settings_daemon_check_running(GDK_DISPLAY(), DefaultScreen(GDK_DISPLAY())); + channel = xfconf_channel_new("xsettings"); - if (running) + gdpy = gdk_display_get_default(); + n_screens = gdk_display_get_n_screens(gdpy); + + for(screen = 0; screen < n_screens; ++screen) { - XF_DEBUG("XSETTINGS Daemon running\n"); - if (force_replace) + XSettingsRegistry *registry; + + running = settings_daemon_check_running(GDK_DISPLAY_XDISPLAY(gdpy), + screen); + + if (running) { - XF_DEBUG("Replacing XSETTINGS daemon\n"); + XF_DEBUG("XSETTINGS Daemon running\n"); + if (force_replace) + { + XF_DEBUG("Replacing XSETTINGS daemon\n"); + keep_running = TRUE; + } + else + { + continue; + } } - else - { - XF_DEBUG("Aborting...\n"); - return 1; - } - } - if ((running && force_replace) || (!running)) - { - XfconfChannel *channel; - XSettingsRegistry *registry; - XF_DEBUG("Initializing...\n"); - channel = xfconf_channel_new("xsettings"); - - registry = xsettings_registry_new(channel, gdk_display, screen); + registry = xsettings_registry_new(channel, + GDK_DISPLAY_XDISPLAY(gdpy), + screen); + registries = g_list_append(registries, registry); xsettings_registry_load(registry, debug); xsettings_registry_notify(registry); gdk_window_add_filter(NULL, manager_event_filter, registry); + + keep_running = TRUE; } + if(!keep_running) + { + XF_DEBUG("Not replacing existing XSETTINGS manager\n"); + return 1; + } + if(!debug) /* If not in debug mode, fork to background */ { if(!fork()) { gtk_main(); - XDestroyWindow (gdk_display, window); xfconf_shutdown(); } } @@ -185,7 +208,6 @@ { gtk_main(); - XDestroyWindow (gdk_display, window); xfconf_shutdown(); } _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits