1769
static void ReMapOne(TwmWindow *t, TwmWindow *leader)
1772
Zoom(t->icon->w, t->frame);
1774
else if(leader->icon) {
1775
Zoom(leader->icon->w, t->frame);
1779
XMapWindow(dpy, t->w);
1782
if(False && Scr->Root != Scr->CaptiveRoot) { /* XXX dubious test */
1783
ReparentWindow(dpy, t, WinWin, Scr->Root, t->frame_x, t->frame_y);
1785
if(!Scr->NoRaiseDeicon) {
1786
OtpRaise(t, WinWin);
1788
XMapWindow(dpy, t->frame);
1789
SetMapStateProp(t, NormalState);
1791
if(t->icon && t->icon->w) {
1792
XUnmapWindow(dpy, t->icon->w);
1794
if(Scr->ShrinkIconTitles) {
1795
t->icon->title_shrunk = true;
1798
if(t->iconmanagerlist) {
1801
for(wl = t->iconmanagerlist; wl != NULL; wl = wl->nextv) {
1802
XUnmapWindow(dpy, wl->icon);
1810
static void ReMapTransients(TwmWindow *tmp_win)
1814
/* find t such that it is a transient or group member window */
1815
for(t = Scr->FirstWindow; t != NULL; t = t->next) {
1817
((t->istransient && t->transientfor == tmp_win->w) ||
1818
(t->group == tmp_win->w && t->isicon))) {
1819
ReMapOne(t, tmp_win);
1824
void DeIconify(TwmWindow *tmp_win)
1826
TwmWindow *t = tmp_win;
1827
bool isicon = false;
1829
/* de-iconify the main window */
1830
if(Scr->WindowMask) {
1831
XRaiseWindow(dpy, Scr->WindowMask);
1833
if(tmp_win->isicon) {
1835
if(tmp_win->icon_on && tmp_win->icon && tmp_win->icon->w) {
1836
Zoom(tmp_win->icon->w, tmp_win->frame);
1838
else if(tmp_win->group != (Window) 0) {
1839
t = GetTwmWindow(tmp_win->group);
1840
if(t && t->icon_on && t->icon && t->icon->w) {
1841
Zoom(t->icon->w, tmp_win->frame);
1846
ReMapOne(tmp_win, t);
1850
LookInList(Scr->WarpCursorL, tmp_win->full_name, &tmp_win->class))) {
1851
WarpToWindow(tmp_win, false);
1854
/* now de-iconify any window group transients */
1855
ReMapTransients(tmp_win);
1857
if(! Scr->WindowMask && Scr->DeIconifyFunction.func != 0) {
1861
action = Scr->DeIconifyFunction.item ?
1862
Scr->DeIconifyFunction.item->action : NULL;
1863
ExecuteFunction(Scr->DeIconifyFunction.func, action,
1864
(Window) 0, tmp_win, &event, C_ROOT, false);
1870
UnmapTransients(TwmWindow *tmp_win, bool iconify, long eventMask)
1874
for(t = Scr->FirstWindow; t != NULL; t = t->next) {
1876
((t->istransient && t->transientfor == tmp_win->w) ||
1877
t->group == tmp_win->w)) {
1880
Zoom(t->icon->w, tmp_win->icon->w);
1882
else if(tmp_win->icon) {
1883
Zoom(t->frame, tmp_win->icon->w);
1888
* Prevent the receipt of an UnmapNotify, since that would
1889
* cause a transition to the Withdrawn state.
1894
* Note that here, we're setting masks relative to what we
1895
* were passed, which is that of the window these are
1896
* transient for, rather than relative to these windows'
1897
* current masks. I believe in practice it's the same thing,
1898
* and it saves getting attributes on each for masking.
1899
* Still, a little odd...
1901
mask_out_event_mask(t->w, StructureNotifyMask, eventMask);
1902
XUnmapWindow(dpy, t->w);
1903
XUnmapWindow(dpy, t->frame);
1904
restore_mask(t->w, eventMask);
1906
if(t->icon && t->icon->w) {
1907
XUnmapWindow(dpy, t->icon->w);
1909
SetMapStateProp(t, IconicState);
1910
if(t == Scr->Focus) {
1911
SetFocus(NULL, LastTimestamp());
1912
if(! Scr->ClickToFocus) {
1913
Scr->FocusRoot = true;
1916
if(t->iconmanagerlist) {
1917
XMapWindow(dpy, t->iconmanagerlist->icon);
1926
void Iconify(TwmWindow *tmp_win, int def_x, int def_y)
1932
Window leader = (Window) - 1;
1933
Window blanket = (Window) - 1;
1935
iconify = (!tmp_win->iconify_by_unmapping);
1937
if(tmp_win->istransient) {
1938
leader = tmp_win->transientfor;
1939
t = GetTwmWindow(leader);
1941
else if((leader = tmp_win->group) != 0 && leader != tmp_win->w) {
1942
t = GetTwmWindow(leader);
1944
if(t && t->icon_on) {
1948
if(!tmp_win->icon || !tmp_win->icon->w) {
1949
CreateIconWindow(tmp_win, def_x, def_y);
1954
if(visible(tmp_win)) {
1955
if(Scr->WindowMask) {
1956
OtpRaise(tmp_win, IconWin);
1957
XMapWindow(dpy, tmp_win->icon->w);
1960
OtpRaise(tmp_win, IconWin);
1961
XMapWindow(dpy, tmp_win->icon->w);
1965
if(tmp_win->iconmanagerlist) {
1966
for(wl = tmp_win->iconmanagerlist; wl != NULL; wl = wl->nextv) {
1967
XMapWindow(dpy, wl->icon);
1971
/* Don't mask anything yet, just get the current for various uses */
1972
eventMask = mask_out_event(tmp_win->w, 0);
1974
/* iconify transients and window group first */
1975
UnmapTransients(tmp_win, iconify, eventMask);
1978
Zoom(tmp_win->frame, tmp_win->icon->w);
1982
* Prevent the receipt of an UnmapNotify, since that would
1983
* cause a transition to the Withdrawn state.
1985
tmp_win->mapped = false;
1987
if((Scr->IconifyStyle != ICONIFY_NORMAL) && !Scr->WindowMask) {
1988
XWindowAttributes winattrs;
1989
XSetWindowAttributes attr;
1991
XGetWindowAttributes(dpy, tmp_win->frame, &winattrs);
1992
attr.backing_store = NotUseful;
1993
attr.save_under = False;
1994
blanket = XCreateWindow(dpy, Scr->Root, winattrs.x, winattrs.y,
1995
winattrs.width, winattrs.height, 0,
1996
CopyFromParent, CopyFromParent,
1997
CopyFromParent, CWBackingStore | CWSaveUnder, &attr);
1998
XMapWindow(dpy, blanket);
2001
mask_out_event_mask(tmp_win->w, StructureNotifyMask, eventMask);
2002
XUnmapWindow(dpy, tmp_win->w);
2003
XUnmapWindow(dpy, tmp_win->frame);
2004
restore_mask(tmp_win->w, eventMask);
2006
SetMapStateProp(tmp_win, IconicState);
2008
if((Scr->IconifyStyle != ICONIFY_NORMAL) && !Scr->WindowMask) {
2009
switch(Scr->IconifyStyle) {
2010
case ICONIFY_MOSAIC:
2011
MosaicFade(tmp_win, blanket);
2013
case ICONIFY_ZOOMIN:
2014
ZoomInWindow(tmp_win, blanket);
2016
case ICONIFY_ZOOMOUT:
2017
ZoomOutWindow(tmp_win, blanket);
2020
FadeWindow(tmp_win, blanket);
2023
SweepWindow(tmp_win, blanket);
2025
case ICONIFY_NORMAL:
2026
/* Placate insufficiently smart clang warning */
2029
XDestroyWindow(dpy, blanket);
2031
if(tmp_win == Scr->Focus) {
2032
SetFocus(NULL, LastTimestamp());
2033
if(! Scr->ClickToFocus) {
2034
Scr->FocusRoot = true;
2037
tmp_win->isicon = true;
2038
tmp_win->icon_on = iconify;
2039
WMapIconify(tmp_win);
2040
if(! Scr->WindowMask && Scr->IconifyFunction.func != 0) {
2044
action = Scr->IconifyFunction.item ? Scr->IconifyFunction.item->action : NULL;
2045
ExecuteFunction(Scr->IconifyFunction.func, action,
2046
(Window) 0, tmp_win, &event, C_ROOT, false);
2051
1763
void AutoSqueeze(TwmWindow *tmp_win)
2574
2286
Scr->SizeFont.ascent + SIZE_VINDENT , str, 13);
2577
static void MosaicFade(TwmWindow *tmp_win, Window blanket)
2584
XRectangle *rectangles;
2585
int width = tmp_win->frame_width;
2586
int height = tmp_win->frame_height;
2588
srect = (width < height) ? (width / 20) : (height / 20);
2589
mask = XCreatePixmap(dpy, blanket, width, height, 1);
2592
gc = XCreateGC(dpy, mask, GCForeground, &gcv);
2593
XFillRectangle(dpy, mask, gc, 0, 0, width, height);
2594
gcv.function = GXclear;
2595
XChangeGC(dpy, gc, GCFunction, &gcv);
2597
nrects = ((width * height) / (srect * srect)) / 10;
2598
rectangles = calloc(nrects, sizeof(XRectangle));
2599
for(j = 0; j < nrects; j++) {
2600
rectangles [j].width = srect;
2601
rectangles [j].height = srect;
2603
for(i = 0; i < 10; i++) {
2604
for(j = 0; j < nrects; j++) {
2605
rectangles [j].x = ((lrand48() % width) / srect) * srect;
2606
rectangles [j].y = ((lrand48() % height) / srect) * srect;
2608
XFillRectangles(dpy, mask, gc, rectangles, nrects);
2609
XShapeCombineMask(dpy, blanket, ShapeBounding, 0, 0, mask, ShapeSet);
2613
XFreePixmap(dpy, mask);
2618
static void ZoomInWindow(TwmWindow *tmp_win, Window blanket)
2625
int w = tmp_win->frame_width;
2626
int h = tmp_win->frame_height;
2627
int step = (MAX(w, h)) / (2.0 * nsteps);
2629
mask = XCreatePixmap(dpy, blanket, w, h, 1);
2631
gc = XCreateGC(dpy, mask, GCForeground, &gcv);
2632
gcv.function = GXclear;
2633
gcn = XCreateGC(dpy, mask, GCForeground | GCFunction, &gcv);
2635
for(i = 0; i < nsteps; i++) {
2636
XFillRectangle(dpy, mask, gcn, 0, 0, w, h);
2637
XFillArc(dpy, mask, gc, (w / 2) - ((nsteps - i) * step),
2638
(h / 2) - ((nsteps - i) * step),
2639
2 * (nsteps - i) * step,
2640
2 * (nsteps - i) * step,
2642
XShapeCombineMask(dpy, blanket, ShapeBounding, 0, 0, mask, ShapeSet);
2648
static void ZoomOutWindow(TwmWindow *tmp_win, Window blanket)
2655
int w = tmp_win->frame_width;
2656
int h = tmp_win->frame_height;
2657
int step = (MAX(w, h)) / (2.0 * nsteps);
2659
mask = XCreatePixmap(dpy, blanket, w, h, 1);
2661
gc = XCreateGC(dpy, mask, GCForeground, &gcv);
2662
XFillRectangle(dpy, mask, gc, 0, 0, w, h);
2663
gcv.function = GXclear;
2664
XChangeGC(dpy, gc, GCFunction, &gcv);
2666
for(i = 0; i < nsteps; i++) {
2667
XFillArc(dpy, mask, gc, (w / 2) - (i * step),
2668
(h / 2) - (i * step),
2672
XShapeCombineMask(dpy, blanket, ShapeBounding, 0, 0, mask, ShapeSet);
2678
void FadeWindow(TwmWindow *tmp_win, Window blanket)
2680
Pixmap mask, stipple;
2683
static unsigned char stipple_bits[] = { 0x0F, 0x0F,
2692
int w = tmp_win->frame_width;
2693
int h = tmp_win->frame_height;
2695
stipple = XCreateBitmapFromData(dpy, blanket, (char *)stipple_bits, 8, 8);
2696
mask = XCreatePixmap(dpy, blanket, w, h, 1);
2699
gcv.stipple = stipple;
2700
gcv.fill_style = FillOpaqueStippled;
2701
gc = XCreateGC(dpy, mask, GCBackground | GCForeground | GCFillStyle | GCStipple,
2703
XFillRectangle(dpy, mask, gc, 0, 0, w, h);
2705
XShapeCombineMask(dpy, blanket, ShapeBounding, 0, 0, mask, ShapeSet);
2708
XFreePixmap(dpy, stipple);
2712
static void SweepWindow(TwmWindow *tmp_win, Window blanket)
2716
int dir = 0, dist = tmp_win->frame_x, dist1;
2718
dist1 = tmp_win->frame_y;
2723
dist1 = tmp_win->vs->w - (tmp_win->frame_x + tmp_win->frame_width);
2728
dist1 = tmp_win->vs->h - (tmp_win->frame_y + tmp_win->frame_height);
2736
step = tmp_win->frame_x + tmp_win->frame_width;
2739
step = tmp_win->frame_y + tmp_win->frame_height;
2742
step = tmp_win->vs->w - tmp_win->frame_x;
2745
step = tmp_win->vs->h - tmp_win->frame_y;
2748
step /= (float) nsteps;
2749
step /= (float) nsteps;
2750
for(i = 0; i < 20; i++) {
2751
int x = tmp_win->frame_x;
2752
int y = tmp_win->frame_y;
2767
XMoveWindow(dpy, blanket, x, y);
2773
static void waitamoment(float timeout)
2775
struct timeval timeoutstruct;
2776
int usec = timeout * 1000000;
2777
timeoutstruct.tv_usec = usec % (unsigned long) 1000000;
2778
timeoutstruct.tv_sec = usec / (unsigned long) 1000000;
2779
select(0, NULL, NULL, NULL, &timeoutstruct);
2782
2290
void TryToPack(TwmWindow *tmp_win, int *x, int *y)