Fine tune the simple icon placement technique.
iconifying is working how I want it now.
This commit is contained in:
parent
740a9e9e79
commit
0bc3929750
38
src/icons.cc
38
src/icons.cc
@ -67,24 +67,32 @@ inline bool operator<(Span a, Span b)
|
||||
static void
|
||||
PlaceIcon(TwmWindow *tmp_win, int def_x, int def_y, int *final_x, int *final_y)
|
||||
{
|
||||
// Try to place in a gap on the right side.
|
||||
// Try to place in a gap along the right side of (current?) screen.
|
||||
|
||||
Window root, parent;
|
||||
Window* children;
|
||||
unsigned int nchildren;
|
||||
XWindowAttributes attr;
|
||||
int y = 0;
|
||||
if (XQueryTree(dpy, Scr->Root, &root, &parent, &children, &nchildren)) {
|
||||
XArray<Window> childarray(children, nchildren);
|
||||
vector<Span> occupied;
|
||||
for (Window w : childarray) {
|
||||
if (XGetWindowAttributes(dpy, w, &attr)) {
|
||||
// w looks like icon?
|
||||
if (attr.map_state != IsUnmapped
|
||||
&& attr.height <= 200 && attr.width <= 200
|
||||
&& attr.x >= icon_area_x) {
|
||||
for (TwmWindow* pw = Scr->TwmRoot.next; pw; pw = pw->next) {
|
||||
// Iconified means was it ever iconified.
|
||||
if (pw->iconified) {
|
||||
Window root;
|
||||
int icon_x, icon_y;
|
||||
unsigned icon_w, icon_h, border_width, depth;
|
||||
if (pw->icon_w
|
||||
&& XGetGeometry(dpy, pw->icon_w, &root,
|
||||
&icon_x, &icon_y, &icon_w, &icon_h,
|
||||
&border_width, &depth)) {
|
||||
if (icon_x >= icon_area_x)
|
||||
occupied.push_back({icon_y, icon_y + static_cast<int>(icon_h)});
|
||||
}
|
||||
}
|
||||
else {
|
||||
// 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.
|
||||
if (pw->frame_x >= icon_area_x
|
||||
&& pw->frame_width <= 150 && pw->frame_height <= 150) {
|
||||
|
||||
occupied.push_back({attr.y, attr.y + attr.height});
|
||||
occupied.push_back({pw->frame_y, pw->frame_y + pw->frame_height});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -105,7 +113,6 @@ PlaceIcon(TwmWindow *tmp_win, int def_x, int def_y, int *final_x, int *final_y)
|
||||
}
|
||||
prev = span.p2;
|
||||
}
|
||||
}
|
||||
|
||||
if (y) {
|
||||
*final_x = icon_area_x + 20; // TODO: stick the icon roughly in the center of the space.
|
||||
@ -114,7 +121,6 @@ PlaceIcon(TwmWindow *tmp_win, int def_x, int def_y, int *final_x, int *final_y)
|
||||
*final_x = def_x;
|
||||
*final_y = def_y;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user