~ctwm/ctwm/trunk

« back to all changes in this revision

Viewing changes to util.c

  • Committer: Matthew Fuller
  • Date: 2016-09-20 03:03:41 UTC
  • mto: This revision was merged to the branch mainline in revision 524.
  • Revision ID: fullermd@over-yonder.net-20160920030341-0mkwhdc71quyow43
Move MoveOutline() over to win_ops.

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
FILE *tracefile = NULL;
110
110
 
111
111
 
112
 
 
113
 
/***********************************************************************
114
 
 *
115
 
 *  Procedure:
116
 
 *      MoveOutline - move a window outline
117
 
 *
118
 
 *  Inputs:
119
 
 *      root        - the window we are outlining
120
 
 *      x           - upper left x coordinate
121
 
 *      y           - upper left y coordinate
122
 
 *      width       - the width of the rectangle
123
 
 *      height      - the height of the rectangle
124
 
 *      bw          - the border width of the frame
125
 
 *      th          - title height
126
 
 *
127
 
 ***********************************************************************
128
 
 */
129
 
 
130
 
/* ARGSUSED */
131
 
void MoveOutline(Window root,
132
 
                 int x, int y, int width, int height, int bw, int th)
133
 
{
134
 
        static int  lastx = 0;
135
 
        static int  lasty = 0;
136
 
        static int  lastWidth = 0;
137
 
        static int  lastHeight = 0;
138
 
        static int  lastBW = 0;
139
 
        static int  lastTH = 0;
140
 
        int         xl, xr, yt, yb, xinnerl, xinnerr, yinnert, yinnerb;
141
 
        int         xthird, ythird;
142
 
        XSegment    outline[18];
143
 
        XSegment   *r;
144
 
 
145
 
        if(x == lastx && y == lasty && width == lastWidth && height == lastHeight
146
 
                        && lastBW == bw && th == lastTH) {
147
 
                return;
148
 
        }
149
 
 
150
 
        r = outline;
151
 
 
152
 
#define DRAWIT() \
153
 
    if (lastWidth || lastHeight)                        \
154
 
    {                                                   \
155
 
        xl = lastx;                                     \
156
 
        xr = lastx + lastWidth - 1;                     \
157
 
        yt = lasty;                                     \
158
 
        yb = lasty + lastHeight - 1;                    \
159
 
        xinnerl = xl + lastBW;                          \
160
 
        xinnerr = xr - lastBW;                          \
161
 
        yinnert = yt + lastTH + lastBW;                 \
162
 
        yinnerb = yb - lastBW;                          \
163
 
        xthird = (xinnerr - xinnerl) / 3;               \
164
 
        ythird = (yinnerb - yinnert) / 3;               \
165
 
                                                        \
166
 
        r->x1 = xl;                                     \
167
 
        r->y1 = yt;                                     \
168
 
        r->x2 = xr;                                     \
169
 
        r->y2 = yt;                                     \
170
 
        r++;                                            \
171
 
                                                        \
172
 
        r->x1 = xl;                                     \
173
 
        r->y1 = yb;                                     \
174
 
        r->x2 = xr;                                     \
175
 
        r->y2 = yb;                                     \
176
 
        r++;                                            \
177
 
                                                        \
178
 
        r->x1 = xl;                                     \
179
 
        r->y1 = yt;                                     \
180
 
        r->x2 = xl;                                     \
181
 
        r->y2 = yb;                                     \
182
 
        r++;                                            \
183
 
                                                        \
184
 
        r->x1 = xr;                                     \
185
 
        r->y1 = yt;                                     \
186
 
        r->x2 = xr;                                     \
187
 
        r->y2 = yb;                                     \
188
 
        r++;                                            \
189
 
                                                        \
190
 
        r->x1 = xinnerl + xthird;                       \
191
 
        r->y1 = yinnert;                                \
192
 
        r->x2 = r->x1;                                  \
193
 
        r->y2 = yinnerb;                                \
194
 
        r++;                                            \
195
 
                                                        \
196
 
        r->x1 = xinnerl + (2 * xthird);                 \
197
 
        r->y1 = yinnert;                                \
198
 
        r->x2 = r->x1;                                  \
199
 
        r->y2 = yinnerb;                                \
200
 
        r++;                                            \
201
 
                                                        \
202
 
        r->x1 = xinnerl;                                \
203
 
        r->y1 = yinnert + ythird;                       \
204
 
        r->x2 = xinnerr;                                \
205
 
        r->y2 = r->y1;                                  \
206
 
        r++;                                            \
207
 
                                                        \
208
 
        r->x1 = xinnerl;                                \
209
 
        r->y1 = yinnert + (2 * ythird);                 \
210
 
        r->x2 = xinnerr;                                \
211
 
        r->y2 = r->y1;                                  \
212
 
        r++;                                            \
213
 
                                                        \
214
 
        if (lastTH != 0) {                              \
215
 
            r->x1 = xl;                                 \
216
 
            r->y1 = yt + lastTH;                        \
217
 
            r->x2 = xr;                                 \
218
 
            r->y2 = r->y1;                              \
219
 
            r++;                                        \
220
 
        }                                               \
221
 
    }
222
 
 
223
 
        /* undraw the old one, if any */
224
 
        DRAWIT();
225
 
 
226
 
        lastx = x;
227
 
        lasty = y;
228
 
        lastWidth = width;
229
 
        lastHeight = height;
230
 
        lastBW = bw;
231
 
        lastTH = th;
232
 
 
233
 
        /* draw the new one, if any */
234
 
        DRAWIT();
235
 
 
236
 
#undef DRAWIT
237
 
 
238
 
 
239
 
        if(r != outline) {
240
 
                XDrawSegments(dpy, root, Scr->DrawGC, outline, r - outline);
241
 
        }
242
 
}
243
 
 
244
 
 
245
112
/*
246
113
 * Rewrite this, possibly in terms of replace_substr().  Alternately, the
247
114
 * places it's being used might be better served by being preprocessed