]> git.mdlowis.com Git - projs/tide.git/commitdiff
fixed a bug where windows get registered with null paths and those paths are matched...
authorMichael D. Lowis <mike.lowis@gentex.com>
Mon, 7 Jan 2019 18:05:43 +0000 (13:05 -0500)
committerMichael D. Lowis <mike.lowis@gentex.com>
Mon, 7 Jan 2019 18:05:43 +0000 (13:05 -0500)
TODO.md
src/registrar.c

diff --git a/TODO.md b/TODO.md
index 5d0835a87873cbb9c6383bc5098534659018d7c8..03222f85b214718e1d55a1be68b345393b4690df 100644 (file)
--- a/TODO.md
+++ b/TODO.md
@@ -12,7 +12,6 @@
 * tide: Line - Get the current line number(s) containing the selection
 * tide: Kill - add a 'Kill' tag to kill the most recent job
 * tide: gap buffer does not handle UTF-8 currently
-* edit: hangs after launching an empty tide instance then trying to open already open file
 
 ## BACKLOG
 
index 9b69ee7dc6664f4a24eb0ffceb8b7df3d17afc17..b6c6f624de0c930208d0f00b1b51f53ee8863586 100644 (file)
@@ -1,3 +1,4 @@
+#include <stdc.h>
 #include <x11.h>
 #include <unistd.h>
 #include "config.h"
@@ -24,10 +25,12 @@ char* readprop(XConf* x, Window win, char* prop, size_t* length) {
 }
 
 void win_add(XConf* x, Window id) {
+    char* path = readprop(x, id, "FILE", 0);
+    if (!path) return;
     TWindow* win = calloc(1, sizeof(TWindow));
     win->win = id;
     win->next = Windows;
-    win->path = readprop(x, id, "FILE", 0);
+    win->path = path;
     Windows = win;
 }
 
@@ -64,7 +67,7 @@ void win_open(XConf* x, Window winid, char* path, char* addr) {
     if (!path) return;
     /* search for an existing window */
     for (TWindow* win = Windows; win; win = win->next) {
-        if (!strcmp(win->path, path)) {
+        if (win->path && !strcmp(win->path, path)) {
             win_send(x, win->win, x->root, SubstructureRedirectMask|SubstructureNotifyMask,  "_NET_ACTIVE_WINDOW", 0);
             XMapRaised(x->display, win->win);
             win_send(x, x->self, win->win, 0,  "GOTO", strtoul(addr, NULL, 0));
@@ -133,8 +136,14 @@ int daemonize(void) {
     return 0;
 }
 
-int main(void) {
-    if (daemonize() != 0) return 1;
+char* ARGV0;
+int Foreground = 0;
+
+int main(int argc, char** argv) {
+    OPTBEGIN {
+        case 'F': Foreground = 1; break;
+    } OPTEND;
+    if (!Foreground && daemonize() != 0) return 1;
     XConf x = {0};
     x11_init(&x);
     x11_mkwin(&x, 1, 1, PropertyChangeMask);