summaryrefslogtreecommitdiff
path: root/libtk
diff options
context:
space:
mode:
authorforsyth <forsyth@vitanuova.com>2010-08-22 13:59:46 +0100
committerforsyth <forsyth@vitanuova.com>2010-08-22 13:59:46 +0100
commitc9c0d12ef55c878b0e361f9f6936bbb4c67b40fb (patch)
tree51b281d84a574b539803d8c0a68873b77b2408fd /libtk
parent43d5f895e7e089a8ca755eca0a19386de5f59f61 (diff)
20100822-1358
Diffstat (limited to 'libtk')
-rw-r--r--libtk/canvu.c6
-rw-r--r--libtk/cwind.c53
-rw-r--r--libtk/textw.c4
-rw-r--r--libtk/textw.h1
-rw-r--r--libtk/twind.c31
-rw-r--r--libtk/windw.c1
6 files changed, 33 insertions, 63 deletions
diff --git a/libtk/canvu.c b/libtk/canvu.c
index 8671a11a..9281303d 100644
--- a/libtk/canvu.c
+++ b/libtk/canvu.c
@@ -338,16 +338,14 @@ tkcvsanchor(Point dp, int w, int h, int anchor)
if(anchor & Tknorth)
o.y = dp.y;
- else
- if(anchor & Tksouth)
+ else if(anchor & Tksouth)
o.y = dp.y - h;
else
o.y = dp.y - h/2;
if(anchor & Tkwest)
o.x = dp.x;
- else
- if(anchor & Tkeast)
+ else if(anchor & Tkeast)
o.x = dp.x - w;
else
o.x = dp.x - w/2;
diff --git a/libtk/cwind.c b/libtk/cwind.c
index ffdb3626..d8180847 100644
--- a/libtk/cwind.c
+++ b/libtk/cwind.c
@@ -105,17 +105,6 @@ if(0)print("tkcsvsforget sub %p %q focus %p %q\n", sub, tkname(sub), tk, tkname(
}
}
-static int
-tkcvschkwfocus(TkCwind *w, Tk *tk)
-{
- if(w->focus == tk)
- return 1;
- for(tk = tk->slave; tk; tk = tk->next)
- if(tkcvschkwfocus(w, tk))
- return 1;
- return 0;
-}
-
static void
tkcvswindgeom(Tk *sub, int x, int y, int w, int h)
{
@@ -137,12 +126,6 @@ tkcvswindgeom(Tk *sub, int x, int y, int w, int h)
}
}
- if(win->focus != nil) {
-if(0)print("check focus %p %q %p %q\n", win, tkname(win->focus), sub, tkname(sub));
- if(tkcvschkwfocus(win, sub) == 0)
- win->focus = nil;
- }
-
tkbbmax(&c->update, &i->p.bb);
if((win->flags & Tksetwidth) == 0)
@@ -172,29 +155,23 @@ tkcvssubdestry(Tk *sub)
if(0)print("tkcvssubdestry %p %q\n", sub, tkname(sub));
i = tkcvsfindwin(sub);
- if(i != nil){
- win = TKobj(TkCwind, i);
- if(win->sub != sub){
+ if(i == nil)
+ return;
+ win = TKobj(TkCwind, i);
+ if(win->sub != sub){
+ if(win->sub != nil)
print("inconsistent tkcvssubdestry %p %q\n", sub, tkname(sub));
- }
+ return;
}
c = TKobj(TkCanvas, tk);
- for(i = c->head; i; i = i->next) {
- if(i->type == TkCVwindow) {
- win = TKobj(TkCwind, i);
- if(win->sub == sub) {
- tkbbmax(&c->update, &i->p.bb);
- tkcvssetdirty(tk);
-
- win->focus = nil;
- win->sub = nil;
- sub->parent = nil;
- sub->geom = nil;
- return;
- }
- }
- }
+ tkbbmax(&c->update, &i->p.bb);
+ tkcvssetdirty(tk);
+
+ win->focus = nil;
+ win->sub = nil;
+ sub->parent = nil;
+ sub->geom = nil;
}
Point
@@ -386,13 +363,13 @@ tkcvswindfree(TkCitem *i)
w = TKobj(TkCwind, i);
sub = w->sub;
- if(w->focus == sub)
- w->focus = nil;
if(sub != nil) {
sub->parent = nil;
sub->geom = nil;
sub->destroyed = nil;
}
+ w->focus = nil;
+ w->sub = nil;
}
void
diff --git a/libtk/textw.c b/libtk/textw.c
index 8a5edde3..141273fb 100644
--- a/libtk/textw.c
+++ b/libtk/textw.c
@@ -3693,5 +3693,7 @@ TkMethod textmethod = {
tktrelpos,
tktextevent,
nil, /* XXX need to implement textsee */
- tktinwindow
+ tktinwindow,
+ nil,
+ tktxtforgetsub,
};
diff --git a/libtk/textw.h b/libtk/textw.h
index 3326cdcc..1ce76b26 100644
--- a/libtk/textw.h
+++ b/libtk/textw.h
@@ -227,3 +227,4 @@ extern void tkttagopts(Tk*, TkTitem*, int*, TkEnv*, TkTtabstop **, int);
extern char* tkttagparse(Tk*, char**, TkTtaginfo**);
extern int tkttagset(TkTitem*, int);
extern int tktxyind(Tk*, int, int, TkTindex*);
+extern void tktxtforgetsub(Tk*, Tk*);
diff --git a/libtk/twind.c b/libtk/twind.c
index 19ea7afd..f08d1b0e 100644
--- a/libtk/twind.c
+++ b/libtk/twind.c
@@ -101,21 +101,19 @@ tktwindsize(Tk *tk, TkTindex *ix)
tktextsize(tk, 1);
}
-/*
- * check that w->focus is a window packed under tk.
- * XXX couldn't this be done more simply by traversing
- * directly upwards from w->focus and seeing whether
- * it hits tk? (same applies to tkcvschkwfocus in cwind.c)
- */
-static int
-tktchkwfocus(TkTwind *w, Tk *tk)
+void
+tktxtforgetsub(Tk *sub, Tk *tk)
{
- if(w->focus == tk)
- return 1;
- for(tk = tk->slave; tk; tk = tk->next)
- if(tktchkwfocus(w, tk))
- return 1;
- return 0;
+ TkTwind *w;
+ TkTindex ix;
+
+ if(!tktfindsubitem(sub, &ix))
+ return;
+ w = ix.item->iwin;
+ if(w->focus == tk) {
+if(0)print("tktxtforget sub %p %q focus %p %q\n", sub, tkname(sub), tk, tkname(tk));
+ w->focus = nil;
+ }
}
static void
@@ -136,11 +134,6 @@ tktwingeom(Tk *sub, int x, int y, int w, int h)
win = ix.item->iwin;
- if(win->focus != nil) {
- if(tktchkwfocus(win, sub) == 0)
- win->focus = nil;
- }
-
win->width = w;
win->height = h;
diff --git a/libtk/windw.c b/libtk/windw.c
index d11e8af1..cf54c86f 100644
--- a/libtk/windw.c
+++ b/libtk/windw.c
@@ -150,7 +150,6 @@ tkinwindow(Tk *tk, Point p, int descend)
return tk;
tk = f;
}
- return nil; /* for compiler */
}
Tk*