/[oroborus]/oroborus/src/frame.c
ViewVC logotype

Diff of /oroborus/src/frame.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by dreamind, Sun Jul 7 03:17:41 2002 UTC revision 1.4 by dreamind, Mon Jul 15 08:23:07 2002 UTC
# Line 25  int Line 25  int
25  frameLeft (Client * c)  frameLeft (Client * c)
26  {  {
27  #ifdef DEBUG  #ifdef DEBUG
28    printf ("entering frameLeft\n");          printf ("entering frameLeft\n");
29  #endif  #endif
30    
31    if (c->has_border)          if (c->has_border)
32      return sides[SIDE_LEFT][ACTIVE].width;                  return sides[SIDE_LEFT][ACTIVE].width;
33    else          else
34      return 0;                  return 0;
35  }  }
36    
37  int  int
38  frameRight (Client * c)  frameRight (Client * c)
39  {  {
40  #ifdef DEBUG  #ifdef DEBUG
41    printf ("entering frameRight\n");          printf ("entering frameRight\n");
42  #endif  #endif
43    
44    if (c->has_border)          if (c->has_border)
45      return sides[SIDE_RIGHT][ACTIVE].width;                  return sides[SIDE_RIGHT][ACTIVE].width;
46    else          else
47      return 0;                  return 0;
48  }  }
49    
50  int  int
51  frameTop (Client * c)  frameTop (Client * c)
52  {  {
53  #ifdef DEBUG  #ifdef DEBUG
54    printf ("entering frameTop\n");          printf ("entering frameTop\n");
55  #endif  #endif
56    
57    if (c->has_border)          if (c->has_border)
58      return title[TITLE_3][ACTIVE].height;                  return title[TITLE_3][ACTIVE].height;
59    else          else
60      return 0;                  return 0;
61  }  }
62    
63  int  int
64  frameBottom (Client * c)  frameBottom (Client * c)
65  {  {
66  #ifdef DEBUG  #ifdef DEBUG
67    printf ("entering frameBottom\n");          printf ("entering frameBottom\n");
68  #endif  #endif
69    
70    if (c->has_border)          if (c->has_border)
71      return sides[SIDE_BOTTOM][ACTIVE].height;                  return sides[SIDE_BOTTOM][ACTIVE].height;
72    else          else
73      return 0;                  return 0;
74  }  }
75    
76  int  int
77  frameX (Client * c)  frameX (Client * c)
78  {  {
79  #ifdef DEBUG  #ifdef DEBUG
80    printf ("entering frameX\n");          printf ("entering frameX\n");
81  #endif  #endif
82    
83    if (c->has_border)          if (c->has_border)
84      return c->x - frameLeft (c);                  return c->x - frameLeft (c);
85    else          else
86      return c->x;                  return c->x;
87  }  }
88    
89  int  int
90  frameY (Client * c)  frameY (Client * c)
91  {  {
92  #ifdef DEBUG  #ifdef DEBUG
93    printf ("entering frameY\n");          printf ("entering frameY\n");
94  #endif  #endif
95    
96    if (c->has_border)          if (c->has_border)
97      return c->y - frameTop (c);                  return c->y - frameTop (c);
98    else          else
99      return c->y;                  return c->y;
100  }  }
101    
102  int  int
103  frameWidth (Client * c)  frameWidth (Client * c)
104  {  {
105  #ifdef DEBUG  #ifdef DEBUG
106    printf ("entering frameWidth\n");          printf ("entering frameWidth\n");
107  #endif  #endif
108    
109    if (c->has_border)          if (c->has_border)
110      return c->width + frameLeft (c) + frameRight (c);                  return c->width + frameLeft (c) + frameRight (c);
111    else          else
112      return c->width;                  return c->width;
113  }  }
114    
115  int  int
116  frameHeight (Client * c)  frameHeight (Client * c)
117  {  {
118  #ifdef DEBUG  #ifdef DEBUG
119    printf ("entering frameHeight\n");          printf ("entering frameHeight\n");
120  #endif  #endif
121    
122    if (c->has_border && c->win_state & WIN_STATE_SHADED)          if (c->has_border && c->win_state & WIN_STATE_SHADED)
123      return frameTop (c) + frameBottom (c) - 1;                  return frameTop (c) + frameBottom (c) - 1;
124    else if (c->has_border)          else if (c->has_border)
125      return c->height + frameTop (c) + frameBottom (c);                  return c->height + frameTop (c) + frameBottom (c);
126    else          else
127      return c->height;                  return c->height;
128  }  }
129    
130  void  void
131  fillRectangle (Display * dpy, Drawable d, Pixmap pm, int x, int y,  fillRectangle (Display * dpy, Drawable d, Pixmap pm, int x, int y,
132                 int width, int height)                                                           int width, int height)
133  {  {
134    XGCValues gv;          XGCValues gv;
135    GC gc;          GC gc;
136    unsigned long mask;          unsigned long mask;
137    
138  #ifdef DEBUG  #ifdef DEBUG
139    printf ("entering fillRectangle\n");          printf ("entering fillRectangle\n");
140  #endif  #endif
141    
142    gv.fill_style = FillTiled;          gv.fill_style = FillTiled;
143    gv.tile = pm;          gv.tile = pm;
144    gv.ts_x_origin = x;          gv.ts_x_origin = x;
145    gv.ts_y_origin = y;          gv.ts_y_origin = y;
146    gv.foreground = WhitePixel (dpy, DefaultScreen (dpy));          gv.foreground = WhitePixel (dpy, DefaultScreen (dpy));
147    if (gv.tile != None)          if (gv.tile != None)
148      mask = GCTile | GCFillStyle | GCTileStipXOrigin;                  mask = GCTile | GCFillStyle | GCTileStipXOrigin;
149    else          else
150      mask = GCForeground;                  mask = GCForeground;
151    gc = XCreateGC (dpy, d, mask, &gv);          gc = XCreateGC (dpy, d, mask, &gv);
152    
153    XFillRectangle (dpy, d, gc, x, y, width, height);          XFillRectangle (dpy, d, gc, x, y, width, height);
154    XFreeGC (dpy, gc);          XFreeGC (dpy, gc);
155  }  }
156    
157  void  void
158  frameCreateTitlePixmap (Client * c, int state, int left, int right,  frameCreateTitlePixmap (Client * c, int state, int left, int right,
159                          MyPixmap * pm)                                                                                                  MyPixmap * pm)
160  {  {
161    int width, x = 0, tp = 0, w1 = 0, w2, w3, w4, w5, temp;          int width, x = 0, tp = 0, w1 = 0, w2, w3, w4, w5, temp;
162    MyPixmap title1, title3, title5;          MyPixmap title1, title3, title5;
163    
164  #ifdef DEBUG  #ifdef DEBUG
165    printf ("entering frameCreateTitlePixmap\n");          printf ("entering frameCreateTitlePixmap\n");
166  #endif  #endif
167    
168    if (left > right)          if (left > right)
169      {                  {
170        temp = left;                          temp = left;
171        left = right;                          left = right;
172        right = temp;                          right = temp;
173      }                  }
174    
175    width =          width =
176      frameWidth (c) - corners[CORNER_TOP_LEFT][ACTIVE].width -                  frameWidth (c) - corners[CORNER_TOP_LEFT][ACTIVE].width -
177      corners[CORNER_TOP_RIGHT][ACTIVE].width;                  corners[CORNER_TOP_RIGHT][ACTIVE].width;
178    if (left < corners[CORNER_TOP_LEFT][ACTIVE].width)          if (left < corners[CORNER_TOP_LEFT][ACTIVE].width)
179      left = corners[CORNER_TOP_LEFT][ACTIVE].width;                  left = corners[CORNER_TOP_LEFT][ACTIVE].width;
180    if (right > frameWidth (c) - corners[CORNER_TOP_RIGHT][ACTIVE].width)          if (right > frameWidth (c) - corners[CORNER_TOP_RIGHT][ACTIVE].width)
181      right = frameWidth (c) - corners[CORNER_TOP_RIGHT][ACTIVE].width;                  right = frameWidth (c) - corners[CORNER_TOP_RIGHT][ACTIVE].width;
182    if (right < corners[CORNER_TOP_LEFT][ACTIVE].width)          if (right < corners[CORNER_TOP_LEFT][ACTIVE].width)
183      right = corners[CORNER_TOP_LEFT][ACTIVE].width;                  right = corners[CORNER_TOP_LEFT][ACTIVE].width;
184    
185    left = left - corners[CORNER_TOP_LEFT][ACTIVE].width;          left = left - corners[CORNER_TOP_LEFT][ACTIVE].width;
186    right = right - corners[CORNER_TOP_LEFT][ACTIVE].width;          right = right - corners[CORNER_TOP_LEFT][ACTIVE].width;
187    
188    w2 = title[TITLE_2][ACTIVE].width;          w2 = title[TITLE_2][ACTIVE].width;
189    w4 = title[TITLE_4][ACTIVE].width;          w4 = title[TITLE_4][ACTIVE].width;
190    if (full_width_title)          if (full_width_title)
191      {                  {
192        w1 = left;                          w1 = left;
193        w5 = width - right;                          w5 = width - right;
194        w3 = width - w1 - w2 - w4 - w5;                          w3 = width - w1 - w2 - w4 - w5;
195        if (w3 < 0)                          if (w3 < 0)
196          w3 = 0;                                  w3 = 0;
197        switch (title_alignment)                          switch (title_alignment)
198          {                                  {
199          case ALIGN_RIGHT:                                  case ALIGN_RIGHT:
200            tp = w3 - getTextWidth (c->name, &title_font);                                          tp = w3 - getTextWidth (c->name, &title_font);
201            break;                                          break;
202          case ALIGN_CENTER:                                  case ALIGN_CENTER:
203            tp = (w3 / 2) - (getTextWidth (c->name, &title_font) / 2);                                          tp = (w3 / 2) - (getTextWidth (c->name, &title_font) / 2);
204            break;                                          break;
205          }                                  }
206        if (tp < 0)                          if (tp < 0)
207          tp = 0;                                  tp = 0;
208      }                  }
209    else          else
210      {                  {
211        w3 = getTextWidth (c->name, &title_font);                          w3 = getTextWidth (c->name, &title_font);
212        w5 = width;                          w5 = width;
213        if (w3 > width - w2 - w4)                          if (w3 > width - w2 - w4)
214          w3 = width - w2 - w4;                                  w3 = width - w2 - w4;
215        if (w3 < 0)                          if (w3 < 0)
216          w3 = 0;                                  w3 = 0;
217        switch (title_alignment)                          switch (title_alignment)
218          {                                  {
219          case ALIGN_LEFT:                                  case ALIGN_LEFT:
220            w1 = left;                                          w1 = left;
221            break;                                          break;
222          case ALIGN_RIGHT:                                  case ALIGN_RIGHT:
223            w1 = right - w2 - w3 - w4;                                          w1 = right - w2 - w3 - w4;
224            break;                                          break;
225          case ALIGN_CENTER:                                  case ALIGN_CENTER:
226            w1 = left + ((right - left) / 2) - (w3 / 2) - w2;                                          w1 = left + ((right - left) / 2) - (w3 / 2) - w2;
227            break;                                          break;
228          }                                  }
229        if (w1 < left)                          if (w1 < left)
230          w1 = left;                                  w1 = left;
231      }                  }
232    
233    pm->pixmap = XCreatePixmap (dpy, root, width, frameTop (c), depth);          pm->pixmap = XCreatePixmap (dpy, root, width, frameTop (c), depth);
234    pm->mask = XCreatePixmap (dpy, pm->pixmap, width, frameTop (c), 1);          pm->mask = XCreatePixmap (dpy, pm->pixmap, width, frameTop (c), 1);
235    
236    if (w1 > 0)          if (w1 > 0)
237      {                  {
238        scalePixmap (dpy, &title[TITLE_1][state], &title1, w1, frameTop (c));                          scalePixmap (dpy, &title[TITLE_1][state], &title1, w1, frameTop (c));
239        fillRectangle (dpy, pm->pixmap, title1.pixmap, 0, 0, w1, frameTop (c));                          fillRectangle (dpy, pm->pixmap, title1.pixmap, 0, 0, w1, frameTop (c));
240        fillRectangle (dpy, pm->mask, title1.mask, 0, 0, w1, frameTop (c));                          fillRectangle (dpy, pm->mask, title1.mask, 0, 0, w1, frameTop (c));
241        x = x + w1;                          x = x + w1;
242      }                  }
243    
244    fillRectangle (dpy, pm->pixmap, title[TITLE_2][state].pixmap, x, 0, w2,          fillRectangle (dpy, pm->pixmap, title[TITLE_2][state].pixmap, x, 0, w2,
245                   frameTop (c));                                                                   frameTop (c));
246    fillRectangle (dpy, pm->mask, title[TITLE_2][state].mask, x, 0, w2,          fillRectangle (dpy, pm->mask, title[TITLE_2][state].mask, x, 0, w2,
247                   frameTop (c));                                                                   frameTop (c));
248    x = x + w2;          x = x + w2;
249    
250    if (w3 > 0)          if (w3 > 0)
251      {                  {
252        scalePixmap (dpy, &title[TITLE_3][state], &title3, w3, frameTop (c));                          scalePixmap (dpy, &title[TITLE_3][state], &title3, w3, frameTop (c));
253        fillRectangle (dpy, pm->pixmap, title3.pixmap, x, 0, w3, frameTop (c));                          fillRectangle (dpy, pm->pixmap, title3.pixmap, x, 0, w3, frameTop (c));
254        fillRectangle (dpy, pm->mask, title3.mask, x, 0, w3, frameTop (c));                          fillRectangle (dpy, pm->mask, title3.mask, x, 0, w3, frameTop (c));
255        drawString (dpy, pm->pixmap, &title_font, title_gc[state], x + tp,                          drawString (dpy, pm->pixmap, &title_font, title_gc[state], x + tp,
256                    title_font.ascent + (frameTop (c) - title_font.height) / 2,                                                                          title_font.ascent + (frameTop (c) - title_font.height) / 2,
257                    c->name);                                                                          c->name);
258        x = x + w3;                          x = x + w3;
259      }                  }
260    
261    if (x > right - w4)          if (x > right - w4)
262      x = right - w4;                  x = right - w4;
263    fillRectangle (dpy, pm->pixmap, title[TITLE_4][state].pixmap, x, 0, w4,          fillRectangle (dpy, pm->pixmap, title[TITLE_4][state].pixmap, x, 0, w4,
264                   frameTop (c));                                                                   frameTop (c));
265    fillRectangle (dpy, pm->mask, title[TITLE_4][state].mask, x, 0, w4,          fillRectangle (dpy, pm->mask, title[TITLE_4][state].mask, x, 0, w4,
266                   frameTop (c));                                                                   frameTop (c));
267    x = x + w4;          x = x + w4;
268    
269    if (w5 > 0)          if (w5 > 0)
270      {                  {
271        scalePixmap (dpy, &title[TITLE_5][state], &title5, w5, frameTop (c));                          scalePixmap (dpy, &title[TITLE_5][state], &title5, w5, frameTop (c));
272        fillRectangle (dpy, pm->pixmap, title5.pixmap, x, 0, w5, frameTop (c));                          fillRectangle (dpy, pm->pixmap, title5.pixmap, x, 0, w5, frameTop (c));
273        fillRectangle (dpy, pm->mask, title5.mask, x, 0, w5, frameTop (c));                          fillRectangle (dpy, pm->mask, title5.mask, x, 0, w5, frameTop (c));
274      }                  }
275    freePixmap (dpy, &title1);          freePixmap (dpy, &title1);
276    freePixmap (dpy, &title3);          freePixmap (dpy, &title3);
277    freePixmap (dpy, &title5);          freePixmap (dpy, &title5);
278  }  }
279    
280  int  int
281  getButtonFromLetter (char c)  getButtonFromLetter (char c)
282  {  {
283    int b;          int b;
284    
285  #ifdef DEBUG  #ifdef DEBUG
286    printf ("entering getButtonFromLetter\n");          printf ("entering getButtonFromLetter\n");
287  #endif  #endif
288    
289    switch (c)          switch (c)
290      {                  {
291      case 'H':                  case 'H':
292        b = HIDE_BUTTON;                          b = HIDE_BUTTON;
293        break;                          break;
294      case 'C':                  case 'C':
295        b = CLOSE_BUTTON;                          b = CLOSE_BUTTON;
296        break;                          break;
297      case 'M':                  case 'M':
298        b = MAXIMIZE_BUTTON;                          b = MAXIMIZE_BUTTON;
299        break;                          break;
300      case 'S':                  case 'S':
301        b = SHADE_BUTTON;                          b = SHADE_BUTTON;
302        break;                          break;
303      default:                  default:
304        b = -1;                          b = -1;
305      }                  }
306    return b;          return b;
307  }  }
308    
309  char  char
310  getLetterFromButton (int b)  getLetterFromButton (int b)
311  {  {
312    char c;          char c;
313    
314  #ifdef DEBUG  #ifdef DEBUG
315    printf ("entering getLetterFromButton\n");          printf ("entering getLetterFromButton\n");
316  #endif  #endif
317    
318    switch (b)          switch (b)
319      {                  {
320      case HIDE_BUTTON:                  case HIDE_BUTTON:
321        c = 'H';                          c = 'H';
322        break;                          break;
323      case CLOSE_BUTTON:                  case CLOSE_BUTTON:
324        c = 'C';                          c = 'C';
325        break;                          break;
326      case MAXIMIZE_BUTTON:                  case MAXIMIZE_BUTTON:
327        c = 'M';                          c = 'M';
328        break;                          break;
329      case SHADE_BUTTON:                  case SHADE_BUTTON:
330        c = 'S';                          c = 'S';
331        break;                          break;
332      default:                  default:
333        c = 0;                          c = 0;
334      }                  }
335    return c;          return c;
336  }  }
337    
338  void  void
339  frameSetShape (Client * c, int state, MyPixmap * title,  frameSetShape (Client * c, int state, MyPixmap * title,
340                 MyPixmap pm_sides[3], int button_x[BUTTON_COUNT])                                                           MyPixmap pm_sides[3], int button_x[BUTTON_COUNT])
341  {  {
342    Window temp;          Window temp;
343    int i;          int i;
344    XRectangle rect;          XRectangle rect;
345    
346  #ifdef DEBUG  #ifdef DEBUG
347    printf ("entering frameSetShape\n");          printf ("entering frameSetShape\n");
348    printf ("setting shape for client (%#lx)\n", c->window);          printf ("setting shape for client (%#lx)\n", c->window);
349  #endif  #endif
350    
351    if (!shape)          if (!shape)
352      return;                  return;
353    
354    temp =          temp =
355      XCreateSimpleWindow (dpy, root, 0, 0, frameWidth (c), frameHeight (c),                  XCreateSimpleWindow (dpy, root, 0, 0, frameWidth (c), frameHeight (c),
356                           0, 0, 0);                                                                                                   0, 0, 0);
357    
358    if (c->win_state & WIN_STATE_SHADED)          if (c->win_state & WIN_STATE_SHADED)
359      {                  {
360        rect.x = 0;                          rect.x = 0;
361        rect.y = 0;                          rect.y = 0;
362        rect.width = frameWidth (c);                          rect.width = frameWidth (c);
363        rect.height = frameHeight (c);                          rect.height = frameHeight (c);
364        XShapeCombineRectangles (dpy, temp, ShapeBounding, 0, 0, &rect, 1,                          XShapeCombineRectangles (dpy, temp, ShapeBounding, 0, 0, &rect, 1,
365                                 ShapeSubtract, 0);                                                                                                                           ShapeSubtract, 0);
366      }                  }
367    else          else
368      XShapeCombineShape (dpy, temp, ShapeBounding, frameLeft (c), frameTop (c),                  XShapeCombineShape (dpy, temp, ShapeBounding, frameLeft (c), frameTop (c),
369                          c->window, ShapeBounding, ShapeSet);                                                                                                  c->window, ShapeBounding, ShapeSet);
370    if (c->has_border)          if (c->has_border)
371      {                  {
372        XShapeCombineMask (dpy, c->title, ShapeBounding, 0, 0,                          XShapeCombineMask (dpy, c->title, ShapeBounding, 0, 0,
373                           title->mask, ShapeSet);                                                                                                   title->mask, ShapeSet);
374        for (i = 0; i < 3; i++)                          for (i = 0; i < 3; i++)
375          XShapeCombineMask (dpy, c->sides[i], ShapeBounding, 0, 0,                                  XShapeCombineMask (dpy, c->sides[i], ShapeBounding, 0, 0,
376                             pm_sides[i].mask, ShapeSet);                                                                                                           pm_sides[i].mask, ShapeSet);
377        for (i = 0; i < 4; i++)                          for (i = 0; i < 4; i++)
378          XShapeCombineMask (dpy, c->corners[i], ShapeBounding, 0, 0,                                  XShapeCombineMask (dpy, c->corners[i], ShapeBounding, 0, 0,
379                             corners[i][state].mask, ShapeSet);                                                                                                           corners[i][state].mask, ShapeSet);
380        for (i = 0; i < BUTTON_COUNT; i++)                          for (i = 0; i < BUTTON_COUNT; i++)
381          {                                  {
382            if (c->button_pressed[i])                                          if (c->button_pressed[i])
383              XShapeCombineMask (dpy, c->buttons[i], ShapeBounding,                                                  XShapeCombineMask (dpy, c->buttons[i], ShapeBounding,
384                                 0, 0, buttons[i][PRESSED].mask, ShapeSet);                                                                                                                           0, 0, buttons[i][PRESSED].mask, ShapeSet);
385            else                                          else
386              XShapeCombineMask (dpy, c->buttons[i], ShapeBounding,                                                  XShapeCombineMask (dpy, c->buttons[i], ShapeBounding,
387                                 0, 0, buttons[i][state].mask, ShapeSet);                                                                                                                           0, 0, buttons[i][state].mask, ShapeSet);
388          }                                  }
389    
390        if (corners[CORNER_TOP_LEFT][ACTIVE].height >                          if (corners[CORNER_TOP_LEFT][ACTIVE].height >
391            frameHeight (c) - frameBottom (c) + 1)                                          frameHeight (c) - frameBottom (c) + 1)
392          {                                  {
393            rect.x = 0;                                          rect.x = 0;
394            rect.y = frameHeight (c) - frameBottom (c) + 1;                                          rect.y = frameHeight (c) - frameBottom (c) + 1;
395            rect.width = corners[CORNER_TOP_LEFT][ACTIVE].width;                                          rect.width = corners[CORNER_TOP_LEFT][ACTIVE].width;
396            rect.height =                                          rect.height =
397              corners[CORNER_TOP_LEFT][ACTIVE].height - (frameHeight (c) -                                                  corners[CORNER_TOP_LEFT][ACTIVE].height - (frameHeight (c) -
398                                                         frameBottom (c) + 1);                                                                                                                                                                                                                           frameBottom (c) + 1);
399            XShapeCombineRectangles (dpy, c->corners[CORNER_TOP_LEFT],                                          XShapeCombineRectangles (dpy, c->corners[CORNER_TOP_LEFT],
400                                     ShapeBounding, 0, 0, &rect, 1,                                                                                                                                           ShapeBounding, 0, 0, &rect, 1,
401                                     ShapeSubtract, 0);                                                                                                                                           ShapeSubtract, 0);
402          }                                  }
403        if (corners[CORNER_TOP_RIGHT][ACTIVE].height >                          if (corners[CORNER_TOP_RIGHT][ACTIVE].height >
404            frameHeight (c) - frameBottom (c) + 1)                                          frameHeight (c) - frameBottom (c) + 1)
405          {                                  {
406            rect.x = 0;                                          rect.x = 0;
407            rect.y = frameHeight (c) - frameBottom (c) + 1;                                          rect.y = frameHeight (c) - frameBottom (c) + 1;
408            rect.width = corners[CORNER_TOP_RIGHT][ACTIVE].width;                                          rect.width = corners[CORNER_TOP_RIGHT][ACTIVE].width;
409            rect.height =                                          rect.height =
410              corners[CORNER_TOP_RIGHT][ACTIVE].height - (frameHeight (c) -                                                  corners[CORNER_TOP_RIGHT][ACTIVE].height - (frameHeight (c) -
411                                                          frameBottom (c) + 1);                                                                                                                                                                                                                                  frameBottom (c) + 1);
412            XShapeCombineRectangles (dpy, c->corners[CORNER_TOP_RIGHT],                                          XShapeCombineRectangles (dpy, c->corners[CORNER_TOP_RIGHT],
413                                     ShapeBounding, 0, 0, &rect, 1,                                                                                                                                           ShapeBounding, 0, 0, &rect, 1,
414                                     ShapeSubtract, 0);                                                                                                                                           ShapeSubtract, 0);
415          }                                  }
416        if (corners[CORNER_BOTTOM_LEFT][ACTIVE].height >                          if (corners[CORNER_BOTTOM_LEFT][ACTIVE].height >
417            frameHeight (c) - frameTop (c) + 1)                                          frameHeight (c) - frameTop (c) + 1)
418          {                                  {
419            rect.x = 0;                                          rect.x = 0;
420            rect.y = 0;                                          rect.y = 0;
421            rect.width = corners[CORNER_BOTTOM_LEFT][ACTIVE].width;                                          rect.width = corners[CORNER_BOTTOM_LEFT][ACTIVE].width;
422            rect.height =                                          rect.height =
423              corners[CORNER_BOTTOM_LEFT][ACTIVE].height - (frameHeight (c) -                                                  corners[CORNER_BOTTOM_LEFT][ACTIVE].height - (frameHeight (c) -
424                                                            frameTop (c) + 1);                                                                                                                                                                                                                                          frameTop (c) + 1);
425            XShapeCombineRectangles (dpy, c->corners[CORNER_BOTTOM_LEFT],                                          XShapeCombineRectangles (dpy, c->corners[CORNER_BOTTOM_LEFT],
426                                     ShapeBounding, 0, 0, &rect, 1,                                                                                                                                           ShapeBounding, 0, 0, &rect, 1,
427                                     ShapeSubtract, 0);                                                                                                                                           ShapeSubtract, 0);
428          }                                  }
429        if (corners[CORNER_BOTTOM_RIGHT][ACTIVE].height >                          if (corners[CORNER_BOTTOM_RIGHT][ACTIVE].height >
430            frameHeight (c) - frameTop (c) + 1)                                          frameHeight (c) - frameTop (c) + 1)
431          {                                  {
432            rect.x = 0;                                          rect.x = 0;
433            rect.y = 0;                                          rect.y = 0;
434            rect.width = corners[CORNER_BOTTOM_RIGHT][ACTIVE].width;                                          rect.width = corners[CORNER_BOTTOM_RIGHT][ACTIVE].width;
435            rect.height =                                          rect.height =
436              corners[CORNER_BOTTOM_RIGHT][ACTIVE].height - (frameHeight (c) -                                                  corners[CORNER_BOTTOM_RIGHT][ACTIVE].height - (frameHeight (c) -
437                                                             frameTop (c) + 1);                                                                                                                                                                                                                                           frameTop (c) + 1);
438            XShapeCombineRectangles (dpy, c->corners[CORNER_BOTTOM_RIGHT],                                          XShapeCombineRectangles (dpy, c->corners[CORNER_BOTTOM_RIGHT],
439                                     ShapeBounding, 0, 0, &rect, 1,                                                                                                                                           ShapeBounding, 0, 0, &rect, 1,
440                                     ShapeSubtract, 0);                                                                                                                                           ShapeSubtract, 0);
441          }                                  }
442    
443        XShapeCombineShape (dpy, temp, ShapeBounding, 0, frameTop (c),                          XShapeCombineShape (dpy, temp, ShapeBounding, 0, frameTop (c),
444                            c->sides[SIDE_LEFT], ShapeBounding, ShapeUnion);                                                                                                          c->sides[SIDE_LEFT], ShapeBounding, ShapeUnion);
445        XShapeCombineShape (dpy, temp, ShapeBounding,                          XShapeCombineShape (dpy, temp, ShapeBounding,
446                            frameWidth (c) - frameRight (c), frameTop (c),                                                                                                          frameWidth (c) - frameRight (c), frameTop (c),
447                            c->sides[SIDE_RIGHT], ShapeBounding, ShapeUnion);                                                                                                          c->sides[SIDE_RIGHT], ShapeBounding, ShapeUnion);
448        XShapeCombineShape (dpy, temp, ShapeBounding,                          XShapeCombineShape (dpy, temp, ShapeBounding,
449                            corners[CORNER_TOP_LEFT][ACTIVE].width, 0, c->title,                                                                                                          corners[CORNER_TOP_LEFT][ACTIVE].width, 0, c->title,
450                            ShapeBounding, ShapeUnion);                                                                                                          ShapeBounding, ShapeUnion);
451        XShapeCombineShape (dpy, temp, ShapeBounding,                          XShapeCombineShape (dpy, temp, ShapeBounding,
452                            corners[CORNER_BOTTOM_LEFT][ACTIVE].width,                                                                                                          corners[CORNER_BOTTOM_LEFT][ACTIVE].width,
453                            frameHeight (c) - frameBottom (c),                                                                                                          frameHeight (c) - frameBottom (c),
454                            c->sides[SIDE_BOTTOM], ShapeBounding, ShapeUnion);                                                                                                          c->sides[SIDE_BOTTOM], ShapeBounding, ShapeUnion);
455        XShapeCombineShape (dpy, temp, ShapeBounding, 0,                          XShapeCombineShape (dpy, temp, ShapeBounding, 0,
456                            frameHeight (c) -                                                                                                          frameHeight (c) -
457                            corners[CORNER_BOTTOM_LEFT][ACTIVE].height,                                                                                                          corners[CORNER_BOTTOM_LEFT][ACTIVE].height,
458                            c->corners[CORNER_BOTTOM_LEFT], ShapeBounding,                                                                                                          c->corners[CORNER_BOTTOM_LEFT], ShapeBounding,
459                            ShapeUnion);                                                                                                          ShapeUnion);
460        XShapeCombineShape (dpy, temp, ShapeBounding,                          XShapeCombineShape (dpy, temp, ShapeBounding,
461                            frameWidth (c) -                                                                                                          frameWidth (c) -
462                            corners[CORNER_BOTTOM_RIGHT][ACTIVE].width,                                                                                                          corners[CORNER_BOTTOM_RIGHT][ACTIVE].width,
463                            frameHeight (c) -                                                                                                          frameHeight (c) -
464                            corners[CORNER_BOTTOM_RIGHT][ACTIVE].height,                                                                                                          corners[CORNER_BOTTOM_RIGHT][ACTIVE].height,
465                            c->corners[CORNER_BOTTOM_RIGHT], ShapeBounding,                                                                                                          c->corners[CORNER_BOTTOM_RIGHT], ShapeBounding,
466                            ShapeUnion);                                                                                                          ShapeUnion);
467        XShapeCombineShape (dpy, temp, ShapeBounding, 0, 0,                          XShapeCombineShape (dpy, temp, ShapeBounding, 0, 0,
468                            c->corners[CORNER_TOP_LEFT], ShapeBounding,                                                                                                          c->corners[CORNER_TOP_LEFT], ShapeBounding,
469                            ShapeUnion);                                                                                                          ShapeUnion);
470        XShapeCombineShape (dpy, temp, ShapeBounding,                          XShapeCombineShape (dpy, temp, ShapeBounding,
471                            frameWidth (c) -                                                                                                          frameWidth (c) -
472                            corners[CORNER_TOP_RIGHT][ACTIVE].width, 0,                                                                                                          corners[CORNER_TOP_RIGHT][ACTIVE].width, 0,
473                            c->corners[CORNER_TOP_RIGHT], ShapeBounding,                                                                                                          c->corners[CORNER_TOP_RIGHT], ShapeBounding,
474                            ShapeUnion);                                                                                                          ShapeUnion);
475        for (i = 0; i < BUTTON_COUNT; i++)                          for (i = 0; i < BUTTON_COUNT; i++)
476          if (strchr (button_layout, getLetterFromButton (i)))                                  if (strchr (button_layout, getLetterFromButton (i)))
477            XShapeCombineShape (dpy, temp, ShapeBounding, button_x[i],                                          XShapeCombineShape (dpy, temp, ShapeBounding, button_x[i],
478                                (frameTop (c) -                                                                                                                          (frameTop (c) -
479                                 buttons[i][ACTIVE].height) / 2,                                                                                                                           buttons[i][ACTIVE].height) / 2,
480                                c->buttons[i], ShapeBounding, ShapeUnion);                                                                                                                          c->buttons[i], ShapeBounding, ShapeUnion);
481      }                  }
482    XShapeCombineShape (dpy, c->frame, ShapeBounding, 0, 0, temp, ShapeBounding,          XShapeCombineShape (dpy, c->frame, ShapeBounding, 0, 0, temp, ShapeBounding,
483                        ShapeSet);                                                                                          ShapeSet);
484    XDestroyWindow (dpy, temp);          XDestroyWindow (dpy, temp);
485  }  }
486    
487  void  void
488  frameDraw (Client * c)  frameDraw (Client * c)
489  {  {
490    int state =          int state =
491      ACTIVE, i, x, button, left, right, top_width,                  ACTIVE, i, x, button, left, right, top_width,
492      bottom_width, left_height, right_height, button_x[4];                  bottom_width, left_height, right_height, button_x[4];
493    MyPixmap pm_title, pm_sides[3];          MyPixmap pm_title, pm_sides[3];
494    
495  #ifdef DEBUG  #ifdef DEBUG
496    printf ("entering frameDraw\n");          printf ("entering frameDraw\n");
497  #endif  #endif
498    
499    if (c != clientGetFocus ())          if (c != clientGetFocus ())
500      state = INACTIVE;                  state = INACTIVE;
501    
502    if (c->has_border)          if (c->has_border)
503      {                  {
504        XMapWindow (dpy, c->title);                          XMapWindow (dpy, c->title);
505        for (i = 0; i < 3; i++)                          for (i = 0; i < 3; i++)
506          XMapWindow (dpy, c->sides[i]);                                  XMapWindow (dpy, c->sides[i]);
507        for (i = 0; i < 4; i++)                          for (i = 0; i < 4; i++)
508          XMapWindow (dpy, c->corners[i]);                                  XMapWindow (dpy, c->corners[i]);
509        for (i = 0; i < 4; i++)                          for (i = 0; i < 4; i++)
510          {                                  {
511            if (strchr (button_layout, getLetterFromButton (i)))                                          if (strchr (button_layout, getLetterFromButton (i)))
512              XMapWindow (dpy, c->buttons[i]);                                                  XMapWindow (dpy, c->buttons[i]);
513            else                                          else
514              XUnmapWindow (dpy, c->buttons[i]);                                                  XUnmapWindow (dpy, c->buttons[i]);
515          }                                  }
516    
517        x = frameLeft (c) - 1 + button_offset;                          x = frameLeft (c) - 1 + button_offset;
518        for (i = 0; i < strlen (button_layout); i++)                          for (i = 0; i < strlen (button_layout); i++)
519          {                                  {
520            button = getButtonFromLetter (button_layout[i]);                                          button = getButtonFromLetter (button_layout[i]);
521            if (button >= 0)                                          if (button >= 0)
522              {                                                  {
523                XMoveResizeWindow (dpy, c->buttons[button], x,                                                          XMoveResizeWindow (dpy, c->buttons[button], x,
524                                   (frameTop (c) -                                                                                                                                   (frameTop (c) -
525                                    buttons[button][ACTIVE].height) / 2,                                                                                                                                          buttons[button][ACTIVE].height) / 2,
526                                   buttons[button][ACTIVE].width,                                                                                                                                   buttons[button][ACTIVE].width,
527                                   buttons[button][ACTIVE].height);                                                                                                                                   buttons[button][ACTIVE].height);
528                button_x[button] = x;                                                          button_x[button] = x;
529                x = x + buttons[button][ACTIVE].width + button_spacing;                                                          x = x + buttons[button][ACTIVE].width + button_spacing;
530              }                                                  }
531            else                                          else
532              break;                                                  break;
533          }                                  }
534        left = x - button_spacing;                          left = x - button_spacing;
535    
536        x =                          x =
537          frameWidth (c) - frameRight (c) + 1 + button_spacing - button_offset;                                  frameWidth (c) - frameRight (c) + 1 + button_spacing - button_offset;
538        for (i = strlen (button_layout) - 1; i >= 0; i--)                          for (i = strlen (button_layout) - 1; i >= 0; i--)
539          {                                  {
540            button = getButtonFromLetter (button_layout[i]);                                          button = getButtonFromLetter (button_layout[i]);
541            if (button >= 0)                                          if (button >= 0)
542              {                                                  {
543                x = x - buttons[button][ACTIVE].width - button_spacing;                                                          x = x - buttons[button][ACTIVE].width - button_spacing;
544                XMoveResizeWindow (dpy, c->buttons[button], x,                                                          XMoveResizeWindow (dpy, c->buttons[button], x,
545                                   (frameTop (c) -                                                                                                                                   (frameTop (c) -
546                                    buttons[button][ACTIVE].height) / 2,                                                                                                                                          buttons[button][ACTIVE].height) / 2,
547                                   buttons[button][ACTIVE].width,                                                                                                                                   buttons[button][ACTIVE].width,
548                                   buttons[button][ACTIVE].height);                                                                                                                                   buttons[button][ACTIVE].height);
549                button_x[button] = x;                                                          button_x[button] = x;
550              }                                                  }
551            else                                          else
552              break;                                                  break;
553          }                                  }
554        right = x;                          right = x;
555    
556        top_width =                          top_width =
557          frameWidth (c) - corners[CORNER_TOP_LEFT][ACTIVE].width -                                  frameWidth (c) - corners[CORNER_TOP_LEFT][ACTIVE].width -
558          corners[CORNER_TOP_RIGHT][ACTIVE].width;                                  corners[CORNER_TOP_RIGHT][ACTIVE].width;
559        bottom_width =                          bottom_width =
560          frameWidth (c) - corners[CORNER_BOTTOM_LEFT][ACTIVE].width -                                  frameWidth (c) - corners[CORNER_BOTTOM_LEFT][ACTIVE].width -
561          corners[CORNER_BOTTOM_RIGHT][ACTIVE].width;                                  corners[CORNER_BOTTOM_RIGHT][ACTIVE].width;
562        left_height =                          left_height =
563          frameHeight (c) - frameTop (c) -                                  frameHeight (c) - frameTop (c) -
564          corners[CORNER_BOTTOM_LEFT][ACTIVE].height;                                  corners[CORNER_BOTTOM_LEFT][ACTIVE].height;
565        right_height =                          right_height =
566          frameHeight (c) - frameTop (c) -                                  frameHeight (c) - frameTop (c) -
567          corners[CORNER_BOTTOM_RIGHT][ACTIVE].height;                                  corners[CORNER_BOTTOM_RIGHT][ACTIVE].height;
568    
569        frameCreateTitlePixmap (c, state, left, right, &pm_title);                          frameCreateTitlePixmap (c, state, left, right, &pm_title);
570        scalePixmap (dpy, &sides[SIDE_LEFT][state], &pm_sides[SIDE_LEFT],                          scalePixmap (dpy, &sides[SIDE_LEFT][state], &pm_sides[SIDE_LEFT],
571                     frameLeft (c), left_height);                                                                           frameLeft (c), left_height);
572        scalePixmap (dpy, &sides[SIDE_RIGHT][state], &pm_sides[SIDE_RIGHT],                          scalePixmap (dpy, &sides[SIDE_RIGHT][state], &pm_sides[SIDE_RIGHT],
573                     frameRight (c), right_height);                                                                           frameRight (c), right_height);
574        scalePixmap (dpy, &sides[SIDE_BOTTOM][state], &pm_sides[SIDE_BOTTOM],                          scalePixmap (dpy, &sides[SIDE_BOTTOM][state], &pm_sides[SIDE_BOTTOM],
575                     bottom_width, frameBottom (c));                                                                           bottom_width, frameBottom (c));
576    
577        XSetWindowBackgroundPixmap (dpy, c->title, pm_title.pixmap);                          XSetWindowBackgroundPixmap (dpy, c->title, pm_title.pixmap);
578        for (i = 0; i < 3; i++)                          for (i = 0; i < 3; i++)
579          XSetWindowBackgroundPixmap (dpy, c->sides[i], pm_sides[i].pixmap);                                  XSetWindowBackgroundPixmap (dpy, c->sides[i], pm_sides[i].pixmap);
580        for (i = 0; i < 4; i++)                          for (i = 0; i < 4; i++)
581          XSetWindowBackgroundPixmap (dpy, c->corners[i],                                  XSetWindowBackgroundPixmap (dpy, c->corners[i],
582                                      corners[i][state].pixmap);                                                                                                                                                  corners[i][state].pixmap);
583        for (i = 0; i < BUTTON_COUNT; i++)                          for (i = 0; i < BUTTON_COUNT; i++)
584          {                                  {
585            if (c->button_pressed[i])                                          if (c->button_pressed[i])
586              XSetWindowBackgroundPixmap (dpy, c->buttons[i],                                                  XSetWindowBackgroundPixmap (dpy, c->buttons[i],
587                                          buttons[i][PRESSED].pixmap);                                                                                                                                                                  buttons[i][PRESSED].pixmap);
588            else                                          else
589              XSetWindowBackgroundPixmap (dpy, c->buttons[i],                                                  XSetWindowBackgroundPixmap (dpy, c->buttons[i],
590                                          buttons[i][state].pixmap);                                                                                                                                                                  buttons[i][state].pixmap);
591          }                                  }
592    
593        XMoveResizeWindow (dpy, c->title,                          XMoveResizeWindow (dpy, c->title,
594                           corners[CORNER_TOP_LEFT][ACTIVE].width, 0,                                                                                                   corners[CORNER_TOP_LEFT][ACTIVE].width, 0,
595                           top_width < 1 ? 1 : top_width, frameTop (c));                                                                                                   top_width < 1 ? 1 : top_width, frameTop (c));
596        XMoveResizeWindow (dpy, c->sides[SIDE_BOTTOM],                          XMoveResizeWindow (dpy, c->sides[SIDE_BOTTOM],
597                           corners[CORNER_BOTTOM_LEFT][ACTIVE].width,                                                                                                   corners[CORNER_BOTTOM_LEFT][ACTIVE].width,
598                           frameHeight (c) - frameBottom (c),                                                                                                   frameHeight (c) - frameBottom (c),
599                           bottom_width < 1 ? 1 : bottom_width,                                                                                                   bottom_width < 1 ? 1 : bottom_width,
600                           frameBottom (c));                                                                                                   frameBottom (c));
601        XMoveResizeWindow (dpy, c->sides[SIDE_LEFT], 0, frameTop (c),                          XMoveResizeWindow (dpy, c->sides[SIDE_LEFT], 0, frameTop (c),
602                           frameLeft (c), left_height < 1 ? 1 : left_height);                                                                                                   frameLeft (c), left_height < 1 ? 1 : left_height);
603        XMoveResizeWindow (dpy, c->sides[SIDE_RIGHT],                          XMoveResizeWindow (dpy, c->sides[SIDE_RIGHT],
604                           frameWidth (c) - frameRight (c), frameTop (c),                                                                                                   frameWidth (c) - frameRight (c), frameTop (c),
605                           frameRight (c), right_height < 1 ? 1 : right_height);                                                                                                   frameRight (c), right_height < 1 ? 1 : right_height);
606    
607        XMoveResizeWindow (dpy, c->corners[CORNER_TOP_LEFT], 0, 0,                          XMoveResizeWindow (dpy, c->corners[CORNER_TOP_LEFT], 0, 0,
608                           corners[CORNER_TOP_LEFT][ACTIVE].width,                                                                                                   corners[CORNER_TOP_LEFT][ACTIVE].width,
609                           corners[CORNER_TOP_LEFT][ACTIVE].height);                                                                                                   corners[CORNER_TOP_LEFT][ACTIVE].height);
610        XMoveResizeWindow (dpy, c->corners[CORNER_TOP_RIGHT],                          XMoveResizeWindow (dpy, c->corners[CORNER_TOP_RIGHT],
611                           frameWidth (c) -                                                                                                   frameWidth (c) -
612                           corners[CORNER_TOP_RIGHT][ACTIVE].width, 0,                                                                                                   corners[CORNER_TOP_RIGHT][ACTIVE].width, 0,
613                           corners[CORNER_TOP_RIGHT][ACTIVE].width,                                                                                                   corners[CORNER_TOP_RIGHT][ACTIVE].width,
614                           corners[CORNER_TOP_RIGHT][ACTIVE].height);                                                                                                   corners[CORNER_TOP_RIGHT][ACTIVE].height);
615        XMoveResizeWindow (dpy, c->corners[CORNER_BOTTOM_LEFT], 0,                          XMoveResizeWindow (dpy, c->corners[CORNER_BOTTOM_LEFT], 0,
616                           frameHeight (c) -                                                                                                   frameHeight (c) -
617                           corners[CORNER_BOTTOM_LEFT][ACTIVE].height,                                                                                                   corners[CORNER_BOTTOM_LEFT][ACTIVE].height,
618                           corners[CORNER_BOTTOM_LEFT][ACTIVE].width,                                                                                                   corners[CORNER_BOTTOM_LEFT][ACTIVE].width,
619                           corners[CORNER_BOTTOM_LEFT][ACTIVE].height);                                                                                                   corners[CORNER_BOTTOM_LEFT][ACTIVE].height);
620        XMoveResizeWindow (dpy, c->corners[CORNER_BOTTOM_RIGHT],                          XMoveResizeWindow (dpy, c->corners[CORNER_BOTTOM_RIGHT],
621                           frameWidth (c) -                                                                                                   frameWidth (c) -
622                           corners[CORNER_BOTTOM_RIGHT][ACTIVE].width,                                                                                                   corners[CORNER_BOTTOM_RIGHT][ACTIVE].width,
623                           frameHeight (c) -                                                                                                   frameHeight (c) -
624                           corners[CORNER_BOTTOM_RIGHT][ACTIVE].height,                                                                                                   corners[CORNER_BOTTOM_RIGHT][ACTIVE].height,
625                           corners[CORNER_BOTTOM_RIGHT][ACTIVE].width,                                                                                                   corners[CORNER_BOTTOM_RIGHT][ACTIVE].width,
626                           corners[CORNER_BOTTOM_RIGHT][ACTIVE].height);                                                                                                   corners[CORNER_BOTTOM_RIGHT][ACTIVE].height);
627    
628        XClearWindow (dpy, c->title);                          XClearWindow (dpy, c->title);
629        for (i = 0; i < 3; i++)                          for (i = 0; i < 3; i++)
630          XClearWindow (dpy, c->sides[i]);                                  XClearWindow (dpy, c->sides[i]);
631        for (i = 0; i < 4; i++)                          for (i = 0; i < 4; i++)
632          XClearWindow (dpy, c->corners[i]);                                  XClearWindow (dpy, c->corners[i]);
633        for (i = 0; i < BUTTON_COUNT; i++)                          for (i = 0; i < BUTTON_COUNT; i++)
634          XClearWindow (dpy, c->buttons[i]);                                  XClearWindow (dpy, c->buttons[i]);
635        frameSetShape (c, state, &pm_title, pm_sides, button_x);                          frameSetShape (c, state, &pm_title, pm_sides, button_x);
636        freePixmap (dpy, &pm_title);                          freePixmap (dpy, &pm_title);
637        for (i = 0; i < 3; i++)                          for (i = 0; i < 3; i++)
638          freePixmap (dpy, &pm_sides[i]);                                  freePixmap (dpy, &pm_sides[i]);
639      }                  }
640    else          else
641      {                  {
642        for (i = 0; i < 3; i++)                          for (i = 0; i < 3; i++)
643          XUnmapWindow (dpy, c->sides[i]);                                  XUnmapWindow (dpy, c->sides[i]);
644        for (i = 0; i < 4; i++)                          for (i = 0; i < 4; i++)
645          XUnmapWindow (dpy, c->corners[i]);                                  XUnmapWindow (dpy, c->corners[i]);
646        for (i = 0; i < BUTTON_COUNT; i++)                          for (i = 0; i < BUTTON_COUNT; i++)
647          XUnmapWindow (dpy, c->buttons[i]);                                  XUnmapWindow (dpy, c->buttons[i]);
648        frameSetShape (c, 0, NULL, NULL, NULL);                          frameSetShape (c, 0, NULL, NULL, NULL);
649      }                  }
650  }  }
651    
652  /**This must remain at the end of the file.**********  /**This must remain at the end of the file.**********
653   * vim600:set sw=2 ts=8:                            *   * vim600:set sw=2 ts=2:                            *
654   * vim600:set cindent cinoptions={1s,>2s,^-1s,n-1s: *   * vim600:set cindent cinoptions={1s,>2s,^-1s,n-1s: *
655   * vim600:set foldmethod=marker:                    *   * vim600:set foldmethod=marker:                    *
656   ****************************************************/   ****************************************************/

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26