use the X protocol to reconfigure instead of signals, works over the network too
This commit is contained in:
parent
191a0bc075
commit
e979b388d8
4 changed files with 25 additions and 19 deletions
|
@ -596,6 +596,11 @@ static void event_handle_root(XEvent *e)
|
||||||
screen_set_num_desktops(d);
|
screen_set_num_desktops(d);
|
||||||
} else if (msgtype == prop_atoms.net_showing_desktop) {
|
} else if (msgtype == prop_atoms.net_showing_desktop) {
|
||||||
screen_show_desktop(e->xclient.data.l[0] != 0);
|
screen_show_desktop(e->xclient.data.l[0] != 0);
|
||||||
|
} else if (msgtype == prop_atoms.ob_control) {
|
||||||
|
if ((Atom)e->xclient.data.l[0] == prop_atoms.ob_reconfigure)
|
||||||
|
action_run_string("reconfigure", NULL);
|
||||||
|
else if ((Atom)e->xclient.data.l[0] == prop_atoms.ob_restart)
|
||||||
|
action_run_string("restart", NULL);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PropertyNotify:
|
case PropertyNotify:
|
||||||
|
|
|
@ -86,7 +86,8 @@ static gchar *restart_path = NULL;
|
||||||
static Cursor cursors[OB_NUM_CURSORS];
|
static Cursor cursors[OB_NUM_CURSORS];
|
||||||
static KeyCode keys[OB_NUM_KEYS];
|
static KeyCode keys[OB_NUM_KEYS];
|
||||||
static gint exitcode = 0;
|
static gint exitcode = 0;
|
||||||
static gboolean reconfigure_and_exit = FALSE;
|
static gboolean message_and_exit = FALSE;
|
||||||
|
static Atom *message;
|
||||||
static gboolean being_replaced = FALSE;
|
static gboolean being_replaced = FALSE;
|
||||||
|
|
||||||
static void signal_handler(gint signal, gpointer data);
|
static void signal_handler(gint signal, gpointer data);
|
||||||
|
@ -116,7 +117,7 @@ gint main(gint argc, gchar **argv)
|
||||||
/* parse out command line args */
|
/* parse out command line args */
|
||||||
parse_args(argc, argv);
|
parse_args(argc, argv);
|
||||||
|
|
||||||
if (!reconfigure_and_exit) {
|
if (!message_and_exit) {
|
||||||
parse_paths_startup();
|
parse_paths_startup();
|
||||||
|
|
||||||
session_startup(argc, argv);
|
session_startup(argc, argv);
|
||||||
|
@ -128,24 +129,14 @@ gint main(gint argc, gchar **argv)
|
||||||
if (fcntl(ConnectionNumber(ob_display), F_SETFD, 1) == -1)
|
if (fcntl(ConnectionNumber(ob_display), F_SETFD, 1) == -1)
|
||||||
ob_exit_with_error("Failed to set display as close-on-exec.");
|
ob_exit_with_error("Failed to set display as close-on-exec.");
|
||||||
|
|
||||||
if (reconfigure_and_exit) {
|
if (message_and_exit) {
|
||||||
guint32 pid;
|
prop_startup();
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
prop_startup(); /* get atoms values for the display */
|
/* Send client message telling the OB process to reconfigure */
|
||||||
ret = PROP_GET32(RootWindow(ob_display, DefaultScreen(ob_display)),
|
prop_message(RootWindow(ob_display, ob_screen), prop_atoms.ob_control,
|
||||||
openbox_pid, cardinal, &pid);
|
*message, 0, 0, 0, SubstructureNotifyMask);
|
||||||
XCloseDisplay(ob_display);
|
XCloseDisplay(ob_display);
|
||||||
if (!ret) {
|
exit(0);
|
||||||
g_print("Openbox does not appear to be running on this "
|
|
||||||
"display.\n");
|
|
||||||
} else {
|
|
||||||
g_print("Telling the Openbox process # %u to reconfigure.\n", pid);
|
|
||||||
ret = (kill(pid, SIGUSR2) == 0);
|
|
||||||
if (!ret)
|
|
||||||
g_print("Error: %s.\n", strerror(errno));
|
|
||||||
}
|
|
||||||
exit(ret ? EXIT_SUCCESS : EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_main_loop = ob_main_loop_new(ob_display);
|
ob_main_loop = ob_main_loop_new(ob_display);
|
||||||
|
@ -441,7 +432,11 @@ static void parse_args(gint argc, gchar **argv)
|
||||||
} else if (!strcmp(argv[i], "--debug")) {
|
} else if (!strcmp(argv[i], "--debug")) {
|
||||||
ob_debug_show_output(TRUE);
|
ob_debug_show_output(TRUE);
|
||||||
} else if (!strcmp(argv[i], "--reconfigure")) {
|
} else if (!strcmp(argv[i], "--reconfigure")) {
|
||||||
reconfigure_and_exit = TRUE;
|
message_and_exit = TRUE;
|
||||||
|
message = &prop_atoms.ob_reconfigure;
|
||||||
|
} else if (!strcmp(argv[i], "--restart")) {
|
||||||
|
message_and_exit = TRUE;
|
||||||
|
message = &prop_atoms.ob_restart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,6 +152,9 @@ void prop_startup()
|
||||||
|
|
||||||
CREATE(openbox_pid, "_OPENBOX_PID");
|
CREATE(openbox_pid, "_OPENBOX_PID");
|
||||||
CREATE(ob_wm_state_undecorated, "_OB_WM_STATE_UNDECORATED");
|
CREATE(ob_wm_state_undecorated, "_OB_WM_STATE_UNDECORATED");
|
||||||
|
CREATE(ob_control, "_OB_CONTROL");
|
||||||
|
CREATE(ob_reconfigure, "_OB_RECONFIGURE");
|
||||||
|
CREATE(ob_restart, "_OB_RESTART");
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
|
|
|
@ -165,6 +165,9 @@ typedef struct Atoms {
|
||||||
|
|
||||||
Atom openbox_pid;
|
Atom openbox_pid;
|
||||||
Atom ob_wm_state_undecorated;
|
Atom ob_wm_state_undecorated;
|
||||||
|
Atom ob_control;
|
||||||
|
Atom ob_reconfigure;
|
||||||
|
Atom ob_restart;
|
||||||
} Atoms;
|
} Atoms;
|
||||||
Atoms prop_atoms;
|
Atoms prop_atoms;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue