}
void edit_file(XConf* x, Window registrar, char* path, char* addr, int force) {
+ char host[8192];
char* rpath = realpath(path, NULL);
prop_set(x, x->self, "FILE", (rpath ? rpath : path));
prop_set(x, x->self, "ADDR", addr);
+ if (!gethostname(host, sizeof(host)))
+ prop_set(x, x->self, "HOST", host);
free(rpath);
XChangeProperty(
x->display, registrar, XA_OPEN, XA_WINDOW, 32, PropModeAppend,
struct TWindow* next;
Window win;
char* path;
+ char* host;
} TWindow;
char* ARGV0;
win->win = id;
win->next = Windows;
win->path = path;
+ win->host = readprop(x, id, "HOST", XA_STRING, NULL);
Windows = win;
}
if (w && w->next) {
TWindow* deadite = w->next;
w->next = deadite->next;
+ free(deadite->path), deadite->path = NULL;
+ free(deadite->host), deadite->host = NULL;
free(deadite);
}
}
XSendEvent(x->display, to, False, mask, &ev);
}
-void win_open(XConf* x, Window winid, char* path, char* addr) {
+void win_open(XConf* x, Window winid, char* path, char* addr, char* host) {
if (!path) return;
/* search for an existing window */
for (TWindow* win = Windows; win; win = win->next) {
char* file = readprop(x, win->win, "FILE", XA_STRING, NULL);
win->path = (file ? file : NULL);
- if (win->path && !strcmp(win->path, path)) {
+ if (win->host && !strcmp(win->host, host) &&
+ win->path && !strcmp(win->path, path)) {
/* double check that the window id didnt get reassigned to a non-tide window */
printf("found open window: 0x%x '%s'\n", (unsigned int)win->win, win->path);
x11_error_clear();
char* type = readprop(x, win->win, "TIDE", XA_STRING, 0);
if (!type || x11_error_get()) {
puts("window invalid, marking for cleanup");
- free(win->path);
- win->path = NULL;
+ free(win->path), win->path = NULL;
+ free(win->host), win->host = NULL;
free(type);
break;
} else {
for (Window* win = (Window*)data; datalen && win && *win; win++, datalen--) {
char* file = readprop(x, *win, "FILE", XA_STRING, NULL);
char* addr = readprop(x, *win, "ADDR", XA_STRING, NULL);
- win_open(x, *win, file, (addr ? addr : "0"));
+ char* host = readprop(x, *win, "HOST", XA_STRING, NULL);
+ win_open(x, *win, file, (addr ? addr : "0"), host);
if(file) XFree(file);
if(addr) XFree(addr);
}