ref: 1ee61ee58ef158458a8727f31e3a94de3447412f
parent: 97cdca10bf57c2640feca790d302327b00d3d33f
author: aap <aap@papnet.eu>
date: Mon Sep 9 09:29:51 EDT 2024
only close opened fids. delete all tabs when deleting windows.
--- a/fs.c
+++ b/fs.c
@@ -199,7 +199,7 @@
}
w = tcreate(w->w, cmd.scrolling);
}else
- w = wcreate(cmd.r, cmd.hidden, cmd.scrolling);
+ w = wtcreate(cmd.r, cmd.hidden, cmd.scrolling);
if(w == nil){
respond(r, Ewindow);
return;
@@ -475,6 +475,7 @@
rd = fid->omode==ORDWR || fid->omode==OREAD;
wr = fid->omode==ORDWR || fid->omode==OWRITE;
+ if(fid->omode != -1)
switch(QFILE(fid->qid.path)){
/* replace snarf buffer when /dev/snarf is closed */
case Qsnarf:
--- a/inc.h
+++ b/inc.h
@@ -268,6 +268,7 @@
extern Window *focused, *cursorwin;
extern Point screenoff;
+Window *wcreate(Rectangle r, bool hidden);
int wcolsel(Window *w);
void wtitlectl(Window *w);
void wdecor(Window *w);
@@ -286,7 +287,6 @@
int wunhide(Window *w);
void wmovemouse(Window *w, Point pt, bool force);
-WinTab *wcreate(Rectangle r, bool hidden, bool scrolling);
void wrelease(WinTab *w);
void wsendmsg(WinTab *w, int type);
WinTab *wfind(int id);
@@ -304,6 +304,8 @@
void tmigrate(WinTab *t, Window *w);
void tmoveleft(WinTab *t);
void tmoveright(WinTab *t);
+
+WinTab *wtcreate(Rectangle r, bool hidden, bool scrolling);
void screenoffset(int offx, int offy);
--- a/main.c
+++ b/main.c
@@ -147,7 +147,7 @@
{
WinTab *w;
- w = wcreate(r, FALSE, scrolling);
+ w = wtcreate(r, FALSE, scrolling);
assert(w);
if(wincmd(w, 0, nil, rcargv) == 0)
return nil;
@@ -647,9 +647,6 @@
screenoffset(ssel.x*dx, ssel.y*dy);
}
-// TODO: header
-Window *wcreate_(Rectangle r, bool hidden);
-
static void
wtabctl(Window *w)
{
@@ -697,7 +694,7 @@
ww = wpointto(mctl->xy);
if(ww == nil){
r = rectaddpt(w->rect, subpt(mctl->xy, pt));
- ww = wcreate_(r, 0);
+ ww = wcreate(r, 0);
tmigrate(t, ww);
}
}
--- a/wctl.c
+++ b/wctl.c
@@ -430,7 +430,7 @@
refresh();
return nil;
case New:
- w = wcreate(cmd.r, cmd.hidden, cmd.scrolling);
+ w = wtcreate(cmd.r, cmd.hidden, cmd.scrolling);
if(w == nil)
return "window creation failed";
return wctlnew(w, cmd);
--- a/wind.c
+++ b/wind.c
@@ -202,7 +202,7 @@
static int id = 1;
Window*
-wcreate_(Rectangle r, bool hidden)
+wcreate(Rectangle r, bool hidden)
{
Window *w;
@@ -277,9 +277,9 @@
}
WinTab*
-wcreate(Rectangle r, bool hidden, bool scrolling)
+wtcreate(Rectangle r, bool hidden, bool scrolling)
{
- return tcreate(wcreate_(r, hidden), scrolling);
+ return tcreate(wcreate(r, hidden), scrolling);
}
/* called from winthread when it exits */
@@ -599,8 +599,8 @@
{
wremove(w);
wunfocus(w);
- for(WinTab *t = w->tab; t; t = t->next)
- wsendmsg(t, Deleted);
+ while(w->tab)
+ tdelete(w->tab);
}
static void
@@ -1029,12 +1029,9 @@
Text *x;
int i;
- if(type == Deleted){
+ if(type == Deleted)
if(w->notefd >= 0)
write(w->notefd, "hangup", 6);
- tclose(w);
- return;
- }
if(w->deleted)
return;