aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Brendan Taylor <whateley@gmail.com>2011-09-13 08:51:43 +0000
committerGravatar Brendan Taylor <whateley@gmail.com>2011-09-13 08:51:43 +0000
commit6f8078781480ba1f08a9dcf9b6630b8f78641507 (patch)
tree148240c05f6184cc8ce34d007dcad477ecad98b6 /src
parentd9d2cf8190c0f5ac9ed5f009c8ef6b52f78912a7 (diff)
use process id as the default instance name
we were using the X window id, but this won't be unique if you have several displays on the same machine, and it doesn't exist if you're in plug mode.
Diffstat (limited to 'src')
-rw-r--r--src/uzbl-core.c42
-rw-r--r--src/uzbl-core.h4
2 files changed, 19 insertions, 27 deletions
diff --git a/src/uzbl-core.c b/src/uzbl-core.c
index 92ef746..5c4f3b7 100644
--- a/src/uzbl-core.c
+++ b/src/uzbl-core.c
@@ -246,7 +246,7 @@ expand(const char* s, guint recurse) {
void
clean_up(void) {
if (uzbl.info.pid_str) {
- send_event (INSTANCE_EXIT, NULL, TYPE_INT, getpid(), NULL);
+ send_event (INSTANCE_EXIT, NULL, TYPE_INT, uzbl.info.pid, NULL);
g_free(uzbl.info.pid_str);
uzbl.info.pid_str = NULL;
}
@@ -1046,30 +1046,26 @@ initialize(int argc, char** argv) {
/** -- MAIN -- **/
int
main (int argc, char* argv[]) {
+ Window xwin;
+
initialize(argc, argv);
- /* Embedded mode */
if (uzbl.state.plug_mode) {
+ /* Embedded mode */
uzbl.gui.plug = create_plug();
gtk_container_add (GTK_CONTAINER (uzbl.gui.plug), uzbl.gui.vbox);
- /* in xembed mode the window has no unique id and thus
- * socket/fifo names aren't unique either.
- * we use a custom randomizer to create a random id
- */
- struct timeval tv;
- gettimeofday(&tv, NULL);
- srand((unsigned int)tv.tv_sec*tv.tv_usec);
- uzbl.xwin = rand();
- }
-
- /* Windowed mode */
- else {
+ } else {
+ /* Windowed mode */
uzbl.gui.main_window = create_window();
gtk_container_add (GTK_CONTAINER (uzbl.gui.main_window), uzbl.gui.vbox);
+
/* We need to ensure there is a window, before we can get XID */
gtk_widget_realize (GTK_WIDGET (uzbl.gui.main_window));
+ xwin = GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (uzbl.gui.main_window)));
- uzbl.xwin = GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (uzbl.gui.main_window)));
+ gchar *xwin_str = g_strdup_printf("%d", (int)xwin);
+ g_setenv("UZBL_XID", xwin_str, TRUE);
+ g_free(xwin_str);
gtk_widget_grab_focus (GTK_WIDGET (uzbl.gui.web_view));
}
@@ -1088,17 +1084,14 @@ main (int argc, char* argv[]) {
"signal::changed", (GCallback)scroll_horiz_cb, NULL,
NULL);
- gchar *xwin = g_strdup_printf("%d", (int)uzbl.xwin);
- g_setenv("UZBL_XID", xwin, TRUE);
+ uzbl.info.pid = getpid();
+ uzbl.info.pid_str = g_strdup_printf("%d", uzbl.info.pid);
+ g_setenv("UZBL_PID", uzbl.info.pid_str, TRUE);
if(!uzbl.state.instance_name)
- uzbl.state.instance_name = g_strdup(xwin);
+ uzbl.state.instance_name = uzbl.info.pid_str;
- g_free(xwin);
-
- uzbl.info.pid_str = g_strdup_printf("%d", getpid());
- g_setenv("UZBL_PID", uzbl.info.pid_str, TRUE);
- send_event(INSTANCE_START, NULL, TYPE_INT, getpid(), NULL);
+ send_event(INSTANCE_START, NULL, TYPE_INT, uzbl.info.pid, NULL);
if (uzbl.state.plug_mode) {
send_event(PLUG_CREATED, NULL, TYPE_INT, gtk_plug_get_id (uzbl.gui.plug), NULL);
@@ -1155,13 +1148,12 @@ main (int argc, char* argv[]) {
if (uzbl.state.socket_id)
printf("plug_id %i\n", (int)gtk_plug_get_id(uzbl.gui.plug));
else
- printf("window_id %i\n",(int) uzbl.xwin);
+ printf("window_id %i\n",(int) xwin);
printf("pid %i\n", getpid ());
printf("name: %s\n", uzbl.state.instance_name);
printf("commit: %s\n", uzbl.info.commit);
}
-
gtk_main();
/* Cleanup and exit*/
diff --git a/src/uzbl-core.h b/src/uzbl-core.h
index 9aba992..b5afa3a 100644
--- a/src/uzbl-core.h
+++ b/src/uzbl-core.h
@@ -207,6 +207,8 @@ typedef struct {
int webkit_micro;
gchar* arch;
gchar* commit;
+
+ pid_t pid;
gchar* pid_str;
} Info;
@@ -219,8 +221,6 @@ typedef struct {
Behaviour behave;
Communication comm;
Info info;
-
- Window xwin;
} UzblCore;
extern UzblCore uzbl; /* Main Uzbl object */