summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorBrian Tarricone <brian@tarricone.org>2005-06-02 02:53:28 +0000
committerBrian Tarricone <brian@tarricone.org>2005-06-02 02:53:28 +0000
commiteb41b3fb41dcbaced2ff6a0beea12d6f3c501191 (patch)
treefb9f58e7de9ab889c69b4d69032b50a6b0cf6ebb /src/main.c
parent92e3ec2183e74d8b349c7772bd5c61000490d09a (diff)
downloadxfdesktop-eb41b3fb41dcbaced2ff6a0beea12d6f3c501191.tar.gz
i'm not too sure how i feel about this yet, since it's kinda hacky. add a
check button "Allow Xfce to manage the desktop" to the backdrop settings panel. this is mainly here to let people easily restore xfdesktop when it dies because of nautilus or some other reason. unfortunately, there's no way to pull it out of the session entirely, because xfce4-session needs to save the session on logout, which depends on the user actually doing that. i suppose adding an MCS setting for this option could work too, and xfdesktop could check it on startup, and quit if it's set. not too sure about that yet, though. (Old svn revision: 14631)
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c68
1 files changed, 12 insertions, 56 deletions
diff --git a/src/main.c b/src/main.c
index f911d42f..f21a7da7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -58,10 +58,6 @@
#include "windowlist.h"
#include "settings.h"
-#define RELOAD_MESSAGE "reload"
-#define MENU_MESSAGE "menu"
-#define WINDOWLIST_MESSAGE "windowlist"
-
SessionClient *client_session = NULL;
gboolean is_session_managed = FALSE;
@@ -174,28 +170,6 @@ button_cb(GtkWidget *w, GdkEventButton *evt, gpointer user_data)
return TRUE;
}
-static void
-send_client_message(Window xid, const gchar *msg)
-{
- GdkEventClient gev;
- GtkWidget *win;
-
- win = gtk_invisible_new();
- gtk_widget_realize(win);
-
- gev.type = GDK_CLIENT_EVENT;
- gev.window = win->window;
- gev.send_event = TRUE;
- gev.message_type = gdk_atom_intern("STRING", FALSE);
- gev.data_format = 8;
- strcpy(gev.data.b, msg);
-
- gdk_event_send_client_message((GdkEvent *)&gev, (GdkNativeWindow)xid);
- gdk_flush();
-
- gtk_widget_destroy(win);
-}
-
static gboolean
reload_idle_cb(gpointer data)
{
@@ -217,38 +191,15 @@ client_message_received(GtkWidget *w, GdkEventClient *evt, gpointer user_data)
} else if(!strcmp(WINDOWLIST_MESSAGE, evt->data.b)) {
popup_windowlist(gtk_widget_get_screen(w), 0, GDK_CURRENT_TIME);
return TRUE;
+ } else if(!strcmp(QUIT_MESSAGE, evt->data.b)) {
+ gtk_main_quit();
+ return TRUE;
}
}
return FALSE;
}
-static gboolean
-check_is_running(Window *xid)
-{
- const gchar *display = g_getenv("DISPLAY");
- gchar *p;
- gint xscreen = -1;
- gchar selection_name[100];
- Atom selection_atom;
-
- if(display) {
- if((p=g_strrstr(display, ".")))
- xscreen = atoi(p);
- }
- if(xscreen == -1)
- xscreen = 0;
-
- g_snprintf(selection_name, 100, XFDESKTOP_SELECTION_FMT, xscreen);
- selection_atom = XInternAtom(GDK_DISPLAY(), selection_name, False);
-
- if((*xid = XGetSelectionOwner(GDK_DISPLAY(), selection_atom)))
- return TRUE;
-
- return FALSE;
-}
-
-
static void
sighandler_cb(int sig)
{
@@ -287,21 +238,24 @@ main(int argc, char **argv)
gtk_init(&argc, &argv);
- if(check_is_running(&xid)) {
+ if(xfdesktop_check_is_running(&xid)) {
DBG("xfdesktop is running");
if(argc <= 1 || strcmp("-reload", argv[1]) == 0)
- send_client_message(xid, RELOAD_MESSAGE);
+ xfdesktop_send_client_message(xid, RELOAD_MESSAGE);
else if(strcmp("-menu", argv[1]) == 0)
- send_client_message(xid, MENU_MESSAGE);
+ xfdesktop_send_client_message(xid, MENU_MESSAGE);
else if(strcmp("-windowlist", argv[1]) == 0)
- send_client_message(xid, WINDOWLIST_MESSAGE);
+ xfdesktop_send_client_message(xid, WINDOWLIST_MESSAGE);
+ else if(strcmp("-quit", argv[1]) == 0)
+ xfdesktop_send_client_message(xid, QUIT_MESSAGE);
else {
g_printerr(_("%s: Unknown option: %s\n"), PACKAGE, argv[1]);
g_printerr(_("Options are:\n"));
g_printerr(_(" -reload Reload all settings, refresh image list\n"));
g_printerr(_(" -menu Pop up the menu (at the current mouse position)\n"));
g_printerr(_(" -windowlist Pop up the window list (at the current mouse position)\n"));
+ g_printerr(_(" -quit Cause xfdesktop to quit\n"));
return 1;
}
@@ -331,6 +285,8 @@ main(int argc, char **argv)
gdk_window_lower(desktops[i]->window);
}
+ signal(SIGPIPE, SIG_IGN);
+
client_session = client_session_new(argc, argv, NULL,
SESSION_RESTART_IF_RUNNING, 35);
client_session->die = session_die;