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

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.2

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