diff --git a/ChangeLog b/ChangeLog index 034d16f..dda6e15 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2019-10-21 Mike Small + + * src/icons.h: Remove IconUp and IconDown from icons interface + and remove callers. + + * src/icons.cc (PlaceIcon): put first icon in bottom right. + 2019-10-12 Mike Small * src/icons.cc (PlaceIcon): stop hard coding the minimum x for diff --git a/src/events.c b/src/events.c index 1233dd1..82d0168 100644 --- a/src/events.c +++ b/src/events.c @@ -1196,7 +1196,6 @@ HandleDestroyNotify(void) XDestroyWindow(dpy, Tmp_win->frame); if (Tmp_win->icon_w && !Tmp_win->icon_not_ours) { XDestroyWindow(dpy, Tmp_win->icon_w); - IconDown (Tmp_win); } Tmp_win->prev->next = Tmp_win->next; if (Tmp_win->next != NULL) diff --git a/src/icons.cc b/src/icons.cc index d3f5925..6356e21 100644 --- a/src/icons.cc +++ b/src/icons.cc @@ -32,7 +32,6 @@ in this Software without prior written authorization from The Open Group. **********************************************************************/ #include -#include #include #include "twm.h" #include "screen.h" @@ -41,6 +40,8 @@ in this Software without prior written authorization from The Open Group. #include "parse.h" #include "util.h" +// DEBUG +#include using namespace std; const int icon_area_w = 70; @@ -76,9 +77,11 @@ PlaceIcon(TwmWindow *tmp_win, int def_x, int def_y, int *final_x, int *final_y) int y = 0; vector occupied; + cerr << "tmp_win: " << tmp_win->name << '\n'; for (TwmWindow* pw = Scr->TwmRoot.next; pw; pw = pw->next) { // Iconified means was it ever iconified. if (pw->iconified) { + cerr << "pw, iconfified: " << pw->name << '\n'; Window root; int icon_x, icon_y; unsigned icon_w, icon_h, border_width, depth; @@ -91,6 +94,8 @@ PlaceIcon(TwmWindow *tmp_win, int def_x, int def_y, int *final_x, int *final_y) } } else { + cerr << "pw, non-iconfified: " << pw->name << '\n'; + // A small non-iconified window sitting where an icon would? E.g. xclock. // I assume here that non-iconified windows that look like icons won't // ever be iconified, making this an either or decision. @@ -103,17 +108,22 @@ PlaceIcon(TwmWindow *tmp_win, int def_x, int def_y, int *final_x, int *final_y) } const int h = tmp_win->icon_w_height ? tmp_win->icon_w_height : 64; - sort(occupied.begin(), occupied.end()); - int prev = 0; - for (auto span : occupied) { - if (span.p1 - prev >= h) { - if (span.p1 - prev >= h + 2*icon_pad) - y = prev + icon_pad; - else - y = prev; - break; + if (occupied.size() == 0) { + y = Scr->MyDisplayHeight - h; + } + else { + sort(occupied.begin(), occupied.end()); + int prev = 0; + for (auto span : occupied) { + if (span.p1 - prev >= h) { + if (span.p1 - prev >= h + 2*icon_pad) + y = prev + icon_pad; + else + y = prev; + break; + } + prev = span.p2; } - prev = span.p2; } if (y) { diff --git a/src/icons.h b/src/icons.h index 8fb1cf9..4deb57b 100644 --- a/src/icons.h +++ b/src/icons.h @@ -40,8 +40,6 @@ in this Software without prior written authorization from The Open Group. #define EXTERN extern #endif -EXTERN void IconUp ( TwmWindow *tmp_win ); -EXTERN void IconDown ( TwmWindow *tmp_win ); -EXTERN void CreateIconWindow ( TwmWindow *tmp_win, int def_x, int def_y ); +EXTERN void CreateIconWindow(TwmWindow *tmp_win, int def_x, int def_y); #endif /* ICONS_H */ diff --git a/src/menus.c b/src/menus.c index 2dc3169..a60f2be 100644 --- a/src/menus.c +++ b/src/menus.c @@ -2310,7 +2310,6 @@ DeIconify(TwmWindow *tmp_win) if (tmp_win->icon_w) { XUnmapWindow(dpy, tmp_win->icon_w); - IconDown (tmp_win); } if ((Scr->WarpCursor || LookInList(Scr->WarpCursorL, tmp_win->full_name, &tmp_win->classh)) && @@ -2340,7 +2339,6 @@ DeIconify(TwmWindow *tmp_win) if (t->icon_w) { XUnmapWindow(dpy, t->icon_w); - IconDown (t); } t->icon = FALSE; t->icon_on = FALSE; @@ -2361,8 +2359,6 @@ Iconify(TwmWindow *tmp_win, int def_x, int def_y) if (tmp_win->icon_w == (Window) 0) CreateIconWindow(tmp_win, def_x, def_y); - else - IconUp(tmp_win); XMapRaised(dpy, tmp_win->icon_w); XGetWindowAttributes(dpy, tmp_win->w, &winattrs);