Put first icon in bottom right.

Also drop use of IconUp and IconDown.
This commit is contained in:
Mike Small 2019-10-21 23:35:52 -04:00
parent 3830011bc5
commit b4207174da
5 changed files with 29 additions and 19 deletions

View File

@ -1,3 +1,10 @@
2019-10-21 Mike Small <smallm@sdf.org>
* 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 <smallm@sdf.org>
* src/icons.cc (PlaceIcon): stop hard coding the minimum x for

View File

@ -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)

View File

@ -32,7 +32,6 @@ in this Software without prior written authorization from The Open Group.
**********************************************************************/
#include <algorithm>
#include <stdio.h>
#include <vector>
#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 <iostream>
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<Span> 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) {

View File

@ -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 */

View File

@ -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);