]> Dogcows Code - chaz/openbox/commitdiff
simply the render interface by not requiring the setting of all the areas. only take...
authorDana Jansens <danakj@orodu.net>
Fri, 20 Jun 2003 02:17:23 +0000 (02:17 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 20 Jun 2003 02:17:23 +0000 (02:17 +0000)
15 files changed:
openbox/dock.c
openbox/frame.c
openbox/framerender.c
openbox/menu_render.c
openbox/popup.c
plugins/menu/client_menu.c
render/font.c
render/gradient.c
render/image.c
render/image.h
render/render.c
render/render.h
render/test.c
render/theme.c
render/theme.h

index 934d3d03bcd8072390b4bb587a2c153df06b5ad4..82efe0718075dc54ef53a34780f6a859a0256946 100644 (file)
@@ -349,11 +349,10 @@ void dock_configure()
     dock->h -= theme_bwidth * 2;
 
     if (dock->w > 0 && dock->h > 0) {
-        RECT_SET(dock->a_frame->area, 0, 0, dock->w, dock->h);
         XMoveResizeWindow(ob_display, dock->frame,
                           dock->x, dock->y, dock->w, dock->h);
 
-        paint(dock->frame, dock->a_frame);
+        paint(dock->frame, dock->a_frame, dock->w, dock->h);
         XMapWindow(ob_display, dock->frame);
     } else
         XUnmapWindow(ob_display, dock->frame);
index 358144dc7ead61c773969cbdd66fc83e42fe77d0..b47d064be7869d25c7de069ade2356a1a9300653 100644 (file)
@@ -14,65 +14,6 @@ static void layout_title(Frame *self);
 
 void frame_startup()
 {
-    RECT_SET(theme_a_focused_pressed_desk->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_focused_pressed_set_desk->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_focused_unpressed_desk->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_unfocused_pressed_desk->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_unfocused_pressed_set_desk->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_unfocused_unpressed_desk->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_focused_pressed_shade->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_focused_pressed_set_shade->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_focused_unpressed_shade->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_unfocused_pressed_shade->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_unfocused_pressed_set_shade->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_unfocused_unpressed_shade->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_focused_pressed_iconify->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_focused_unpressed_iconify->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_unfocused_pressed_iconify->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_unfocused_unpressed_iconify->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_unfocused_unpressed_iconify->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_focused_pressed_max->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_focused_pressed_set_max->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_focused_unpressed_max->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_unfocused_pressed_max->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_unfocused_pressed_set_max->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_unfocused_unpressed_max->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_focused_pressed_close->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_focused_unpressed_close->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_unfocused_pressed_close->area, 0, 0,
-             theme_button_size, theme_button_size);
-    RECT_SET(theme_a_unfocused_unpressed_close->area, 0, 0,
-             theme_button_size, theme_button_size);
-
-    RECT_SET(theme_a_focused_grip->area, 0, 0,
-             theme_grip_width, theme_handle_height);
-    RECT_SET(theme_a_unfocused_grip->area, 0, 0,
-             theme_grip_width, theme_handle_height);
 }
 
 void frame_shutdown()
@@ -287,11 +228,6 @@ void frame_adjust_area(Frame *self, gboolean moved, gboolean resized)
             self->innersize.top += theme_title_height + self->bwidth;
             XMapWindow(ob_display, self->title);
 
-            RECT_SET(self->a_focused_title->area, 0, 0,
-                     self->width, theme_title_height);
-            RECT_SET(self->a_unfocused_title->area, 0, 0,
-                     self->width, theme_title_height);
-
             /* layout the title bar elements */
             layout_title(self);
         } else
@@ -310,25 +246,11 @@ void frame_adjust_area(Frame *self, gboolean moved, gboolean resized)
                 self->bwidth;
             XMapWindow(ob_display, self->handle);
 
-            if (theme_a_focused_grip->surface.grad ==
-                Background_ParentRelative)
-                RECT_SET(self->a_focused_handle->area, 0, 0,
-                         self->width, theme_handle_height);
-            else
-                RECT_SET(self->a_focused_handle->area,
-                         theme_grip_width + self->bwidth, 0,
-                         self->width - (theme_grip_width + self->bwidth) * 2,
-                         theme_handle_height);
-            if (theme_a_unfocused_grip->surface.grad ==
-                Background_ParentRelative)
-                RECT_SET(self->a_unfocused_handle->area, 0, 0,
-                         self->width, theme_handle_height);
-            else
-                RECT_SET(self->a_unfocused_handle->area,
-                         theme_grip_width + self->bwidth, 0,
-                         self->width - (theme_grip_width + self->bwidth) * 2,
-                         theme_handle_height);
-
+            /* XXX make a subwindow with these dimentions?
+               theme_grip_width + self->bwidth, 0,
+               self->width - (theme_grip_width + self->bwidth) * 2,
+               theme_handle_height);
+            */
         } else
             XUnmapWindow(ob_display, self->handle);
     }
@@ -561,8 +483,6 @@ static void layout_title(Frame *self)
        case 'N':
            if (!n) break;
            self->icon_x = x;
-            RECT_SET(self->a_icon->area, 0, 0,
-                     theme_button_size + 2, theme_button_size + 2);
            XMapWindow(ob_display, self->icon);
            XMoveWindow(ob_display, self->icon, x, theme_bevel);
            x += theme_button_size + 2 + theme_bevel + 1;
@@ -611,11 +531,6 @@ static void layout_title(Frame *self)
            break;
        }
     }
-
-    RECT_SET(self->a_focused_label->area, 0, 0,
-             self->label_width, theme_label_height);
-    RECT_SET(self->a_unfocused_label->area, 0, 0,
-             self->label_width, theme_label_height);
 }
 
 Context frame_context_from_string(char *name)
index 11092333263858fc6791373151b1db88f403337a..d5d3ac8daa943e8af97e3fd8050e03ff07677ef2 100644 (file)
@@ -76,7 +76,7 @@ void framerender_frame(Frame *self)
               theme_a_unfocused_pressed_close :
               theme_a_unfocused_unpressed_close));
 
-        paint(self->title, t);
+        paint(self->title, t, self->width, theme_title_height);
 
         /* set parents for any parent relative guys */
         l->surface.parent = t;
@@ -121,38 +121,33 @@ void framerender_frame(Frame *self)
 
         h = (self->focused ?
              self->a_focused_handle : self->a_unfocused_handle);
+
+        paint(self->handle, h, self->width, theme_handle_height);
+
         g = (self->focused ?
              theme_a_focused_grip : theme_a_unfocused_grip);
 
-        if (g->surface.grad == Background_ParentRelative) {
+        if (g->surface.grad == Background_ParentRelative)
             g->surface.parent = h;
-            paint(self->handle, h);
-        } else
-            paint(self->handle, h);
 
         g->surface.parentx = 0;
         g->surface.parenty = 0;
 
-        paint(self->lgrip, g);
+        paint(self->lgrip, g, theme_grip_width, theme_handle_height);
 
         g->surface.parentx = self->width - theme_grip_width;
         g->surface.parenty = 0;
 
-        paint(self->rgrip, g);
+        paint(self->rgrip, g, theme_grip_width, theme_handle_height);
     }
 }
 
 static void framerender_label(Frame *self, Appearance *a)
 {
     if (self->label_x < 0) return;
-
-
     /* set the texture's text! */
     a->texture[0].data.text.string = self->client->title;
-    RECT_SET(a->texture[0].position, 0, 0,
-             self->label_width, theme_label_height);
-
-    paint(self->label, a);
+    paint(self->label, a, self->label_width, theme_label_height);
 }
 
 static void framerender_icon(Frame *self, Appearance *a)
@@ -166,55 +161,38 @@ static void framerender_icon(Frame *self, Appearance *a)
         a->texture[0].data.rgba.width = icon->width;
         a->texture[0].data.rgba.height = icon->height;
         a->texture[0].data.rgba.data = icon->data;
-        RECT_SET(self->a_icon->texture[0].position, 0, 0,
-                 theme_button_size + 2, theme_button_size + 2);
     } else
         a->texture[0].type = NoTexture;
 
-    paint(self->icon, a);
+    paint(self->icon, a, theme_button_size + 2, theme_button_size + 2);
 }
 
 static void framerender_max(Frame *self, Appearance *a)
 {
     if (self->max_x < 0) return;
-
-    RECT_SET(a->texture[0].position, 0, 0,
-             theme_button_size, theme_button_size);
-    paint(self->max, a);
+    paint(self->max, a, theme_button_size, theme_button_size);
 }
 
 static void framerender_iconify(Frame *self, Appearance *a)
 {
     if (self->iconify_x < 0) return;
-
-    RECT_SET(a->texture[0].position, 0, 0,
-             theme_button_size, theme_button_size);
-    paint(self->iconify, a);
+    paint(self->iconify, a, theme_button_size, theme_button_size);
 }
 
 static void framerender_desk(Frame *self, Appearance *a)
 {
     if (self->desk_x < 0) return;
-
-    RECT_SET(a->texture[0].position, 0, 0,
-             theme_button_size, theme_button_size);
-    paint(self->desk, a);
+    paint(self->desk, a, theme_button_size, theme_button_size);
 }
 
 static void framerender_shade(Frame *self, Appearance *a)
 {
     if (self->shade_x < 0) return;
-
-    RECT_SET(a->texture[0].position, 0, 0,
-             theme_button_size, theme_button_size);
-    paint(self->shade, a);
+    paint(self->shade, a, theme_button_size, theme_button_size);
 }
 
 static void framerender_close(Frame *self, Appearance *a)
 {
     if (self->close_x < 0) return;
-
-    RECT_SET(a->texture[0].position, 0, 0,
-             theme_button_size, theme_button_size);
-    paint(self->close, a);
+    paint(self->close, a, theme_button_size, theme_button_size);
 }
index fcaf6869c0cd39a15e961b9c9ad1de76019d7f11..a03f2caab526f78026e9513c02cc845450eb89c9 100644 (file)
@@ -61,15 +61,6 @@ void menu_render_full(Menu *self) {
     self->item_h += theme_bevel * 2;
     items_h = self->item_h * MAX(nitems, 1);
 
-    if (self->label) {
-       RECT_SET(self->a_title->area, 0, 0, self->size.width, 
-                self->title_h);
-       RECT_SET(self->a_title->texture[0].position, 0, 0, self->size.width,
-                self->title_h);
-    }
-
-    RECT_SET(self->a_items->area, 0, 0, self->size.width, items_h);
-
     XResizeWindow(ob_display, self->frame, self->size.width,
                  MAX(self->title_h + items_h, 1));
     if (self->label)
@@ -81,8 +72,8 @@ void menu_render_full(Menu *self) {
                      items_h);
 
     if (self->label)
-       paint(self->title, self->a_title);
-    paint(self->items, self->a_items);
+       paint(self->title, self->a_title, self->size.width, self->title_h);
+    paint(self->items, self->a_items, self->size.width, items_h);
 
     item_y = 0;
     for (it = self->entries; it; it = it->next) {
@@ -125,17 +116,12 @@ void menu_entry_render(MenuEntry *self)
        break;
     }
 
-    RECT_SET(a->area, 0, 0, menu->size.width,
-             menu->item_h);
-    RECT_SET(a->texture[0].position, menu->bullet_w,
-             0, menu->size.width - 2 * menu->bullet_w,
-             menu->item_h);
-
     XMoveResizeWindow(ob_display, self->item, 0, self->y,
                       menu->size.width, menu->item_h);
+
     a->surface.parent = menu->a_items;
     a->surface.parentx = 0;
     a->surface.parenty = self->y;
 
-    paint(self->item, a);
+    paint(self->item, a, menu->size.width, menu->item_h);
 }
index 7406d2f10a4159b777084c12615755497875a213..48c40f28a0b985e08fa76ea1afca0efa8fac3bc4 100644 (file)
@@ -189,12 +189,8 @@ void popup_show(Popup *self, char *text, Icon *icon)
     }
 
     /* set the windows/appearances up */
-    RECT_SET(self->a_bg->area, 0, 0, w, h);
     XMoveResizeWindow(ob_display, self->bg, x, y, w, h);
 
-    RECT_SET(self->a_text->area, 0, 0, textw, texth); 
-    RECT_SET(self->a_text->texture[0].position, theme_bevel, theme_bevel,
-             textw - theme_bevel * 2, texth - theme_bevel * 2);
     self->a_text->surface.parent = self->a_bg;
     self->a_text->surface.parentx = iconw +
         theme_bevel * (self->hasicon ? 2 : 1);
@@ -205,8 +201,6 @@ void popup_show(Popup *self, char *text, Icon *icon)
 
     if (self->hasicon) {
         if (iconw < 1) iconw = 1; /* sanity check for crashes */
-        RECT_SET(self->a_icon->area, 0, 0, iconw, texth);
-        RECT_SET(self->a_icon->texture[0].position, 0, 0, iconw, texth);
         self->a_icon->surface.parent = self->a_bg;
         self->a_icon->surface.parentx = theme_bevel;
         self->a_icon->surface.parenty = theme_bevel;
@@ -214,10 +208,10 @@ void popup_show(Popup *self, char *text, Icon *icon)
                           theme_bevel, theme_bevel, iconw, texth);
     }
 
-    paint(self->bg, self->a_bg);
-    paint(self->text, self->a_text);
+    paint(self->bg, self->a_bg, w, h);
+    paint(self->text, self->a_text, textw, texth);
     if (self->hasicon)
-        paint(self->icon, self->a_icon);
+        paint(self->icon, self->a_icon, iconw, texth);
 
     if (!self->mapped) {
         XMapWindow(ob_display, self->bg);
index 9905291edf245066902cec4c1e2c507cc707a5ce..142c665427b4401c4a96942c58c8e1d0c633c3d3 100644 (file)
@@ -47,8 +47,7 @@ void client_menu_show(Menu *self, int x, int y, Client *client)
     g_assert(!self->invalid);
     g_assert(client);
     
-    newy = MAX(client->frame->area.y +
-               client->frame->a_focused_title->area.height + theme_bwidth,
+    newy = MAX(client->frame->area.y + client->frame->size.top,
                y - theme_bwidth);
     
     POINT_SET(self->location, 
index 22722245439f1a31bfa70df13b4cb9a7c81f2028..274743041a35322ed05b3b15414a68025b7cb32d 100644 (file)
@@ -1,4 +1,5 @@
 #include "font.h"
+#include "theme.h"
 #include "kernel/openbox.h"
 #include "kernel/geom.h"
 #include "kernel/gettext.h"
@@ -102,7 +103,7 @@ int font_max_char_width(ObFont *f)
     return (signed) f->xftfont->max_advance_width;
 }
 
-void font_draw(XftDraw *d, TextureText *t, Rect *position)
+void font_draw(XftDraw *d, TextureText *t, Rect *area)
 {
     int x,y,w,h;
     XftColor c;
@@ -111,20 +112,22 @@ void font_draw(XftDraw *d, TextureText *t, Rect *position)
     size_t l;
     gboolean shortened = FALSE;
 
-    y = position->y;
-    w = position->width;
-    h = position->height;
+    /* center vertically */
+    y = area->y +
+        (area->height - font_height(t->font, t->shadow, t->offset)) / 2;
+    w = area->width;
+    h = area->height;
 
     text = g_string_new(t->string);
     l = g_utf8_strlen(text->str, -1);
     font_measure_full(t->font, text->str, t->shadow, t->offset, &mw, &mh);
-    while (l && mw > position->width) {
+    while (l && mw > area->width) {
         shortened = TRUE;
         /* remove a character from the middle */
         text = g_string_erase(text, l-- / 2, 1);
         em = ELIPSES_LENGTH(t->font, t->shadow, t->offset);
         /* if the elipses are too large, don't show them at all */
-        if (em > position->width)
+        if (em > area->width)
             shortened = FALSE;
         font_measure_full(t->font, text->str, t->shadow, t->offset, &mw, &mh);
         mw += em;
@@ -135,18 +138,15 @@ void font_draw(XftDraw *d, TextureText *t, Rect *position)
     }
     if (!l) return;
 
-    /* center vertically */
-    y -= ((t->font->xftfont->ascent + t->font->xftfont->descent) - mh) / 2;
-
     switch (t->justify) {
     case Justify_Left:
-        x = position->x;
+        x = area->x + theme_bevel;
         break;
     case Justify_Right:
-        x = position->x + (w - mw);
+        x = area->x + (w - mw) - theme_bevel;
         break;
     case Justify_Center:
-        x = position->x + (w - mw) / 2;
+        x = area->x + (w - mw) / 2;
         break;
     }
 
index b6661bbc21b976461442dc41951fac43f66be4c1..ebfdb3bbf6f3ab7001b77c6c72a1539b9baa2113 100644 (file)
@@ -295,9 +295,9 @@ void gradient_solid(Appearance *l, int x, int y, int w, int h)
         + (sp->primary->g << default_green_offset)
         + (sp->primary->b << default_blue_offset);
 
-    for (a = 0; a < l->area.width; a++)
-        for (b = 0; b < l->area.height; b++)
-            sp->pixel_data[a + b*l->area.width] = pix;
+    for (a = 0; a < w; a++)
+        for (b = 0; b < h; b++)
+            sp->pixel_data[a + b * w] = pix;
 
     XFillRectangle(ob_display, l->pixmap, sp->primary->gc,
                    x, y, w, h);
index feb259703d3d96bc6be2f62b4044c0879b11917c..351a831d655643edff0aaeead2bba86b7206f824 100644 (file)
@@ -2,18 +2,12 @@
 #include "../kernel/geom.h"
 #include "image.h"
 
-void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *position,
-                Rect *surarea)
+void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *area)
 {
     pixel32 *draw = rgba->data;
     guint c, i, e, t, sfw, sfh;
-    sfw = position->width;
-    sfh = position->height;
-
-    /* it would be nice if this worked, but this function is well broken in
-       these circumstances. */
-    g_assert(position->width == surarea->width &&
-             position->height == surarea->height);
+    sfw = area->width;
+    sfh = area->height;
 
     g_assert(rgba->data != NULL);
 
@@ -28,7 +22,7 @@ void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *position,
         /* scale it and cache it */
         if (rgba->cache != NULL)
             g_free(rgba->cache);
-        rgba->cache = g_new(unsigned long, sfw * sfh);
+        rgba->cache = g_new(pixel32, sfw * sfh);
         rgba->cwidth = sfw;
         rgba->cheight = sfh;
         for (i = 0, c = 0, e = sfw*sfh; i < e; ++i) {
@@ -47,7 +41,7 @@ void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *position,
             draw = rgba->cache;
 
         /* apply the alpha channel */
-        for (i = 0, c = 0, t = position->x, e = sfw*sfh; i < e; ++i, ++t) {
+        for (i = 0, c = 0, t = area->x, e = sfw*sfh; i < e; ++i, ++t) {
             guchar alpha, r, g, b, bgr, bgg, bgb;
 
             alpha = draw[i] >> default_alpha_offset;
@@ -57,7 +51,7 @@ void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *position,
 
             if (c >= sfw) {
                 c = 0;
-                t += surarea->width - sfw;
+                t += area->width - sfw;
             }
 
             /* background color */
index 84f61d770374066a2df6925cb931938a25daf180..7dd48e7d4dd298784732814b24868692111753f3 100644 (file)
@@ -4,7 +4,6 @@
 #include "render.h"
 #include "../kernel/geom.h"
 
-void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *position,
-                Rect *surarea);
+void image_draw(pixel32 *target, TextureRGBA *rgba, Rect *area);
 
 #endif
index 3a1290120fd3c52b39d3ad207419052d3568baeb..b2575c634683a16634a75a2407ad23ea2f48cac3 100644 (file)
@@ -1,10 +1,6 @@
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 
-#ifdef USE_GL
-# include <GL/glx.h>
-#endif
-
 #include <glib.h>
 #include "render.h"
 #include "gradient.h"
@@ -30,122 +26,26 @@ int render_red_shift, render_green_shift, render_blue_shift;
 int render_red_mask, render_green_mask, render_blue_mask;
 
 
-#ifdef USE_GL
-
-GLXContext render_glx_context;
-
-int render_glx_rating(XVisualInfo *v)
-{
-    int er;
-    int rating = 0;
-    int val;
-    printf("evaluating visual %d\n", v->visualid);
-    glXGetConfig(ob_display, v, GLX_BUFFER_SIZE, &val);
-    printf("buffer size %d\n", val);
-
-    switch (val) {
-    case 32:
-        rating += 300;
-    break;
-    case 24:
-        rating += 200;
-    break;
-    case 16:
-        rating += 100;
-    break;
-    }
-
-    glXGetConfig(ob_display, v, GLX_LEVEL, &val);
-    printf("level %d\n", val);
-    if (val != 0)
-        rating = -10000;
-
-    glXGetConfig(ob_display, v, GLX_DEPTH_SIZE, &val);
-    printf("depth size %d\n", val);
-    switch (val) {
-    case 32:
-        rating += 30;
-    break;
-    case 24:
-        rating += 20;
-    break;
-    case 16:
-        rating += 10;
-    break;
-    case 0:
-        rating -= 10000;
-    }
-
-    glXGetConfig(ob_display, v, GLX_DOUBLEBUFFER, &val);
-    printf("double buffer %d\n", val);
-    if (val)
-        rating++;
-    return rating;
-}
-#endif /* USE_GL */
-
 void render_startup(void)
 {
-    int count, i = 0, val, best = 0, rate = 0, temp;
-    XVisualInfo vimatch, *vilist;
-    paint = x_paint;
-
     render_depth = DefaultDepth(ob_display, ob_screen);
     render_visual = DefaultVisual(ob_display, ob_screen);
     render_colormap = DefaultColormap(ob_display, ob_screen);
 
-#ifdef USE_GL
-    vimatch.screen = ob_screen;
-    vimatch.class = TrueColor;
-    vilist = XGetVisualInfo(ob_display, VisualScreenMask | VisualClassMask,
-                            &vimatch, &count);
-
-    if (vilist) {
-        printf("looking for a GL visualin %d visuals\n", count);
-        for (i = 0; i < count; i++) {
-            glXGetConfig(ob_display, &vilist[i], GLX_USE_GL, &val);
-            if (val) {
-                temp = render_glx_rating(&vilist[i]);
-                if (temp > rate) {
-                    best = i;
-                    rate = temp;
-                }
-            }
-        }
-    }
-    if (rate > 0) {
-        printf("picked visual %d with rating %d\n", best, rate);
-        render_depth = vilist[best].depth;
-        render_visual = vilist[best].visual;
-        render_colormap = XCreateColormap(ob_display, ob_root, 
-                                          render_visual, AllocNone);
-        render_visual_info = vilist[best];
-        render_glx_context = glXCreateContext(ob_display, &render_visual_info,
-                                              NULL, True);
-        if (render_glx_context == NULL)
-            printf("sadness\n");
-        else {
-            paint = gl_paint;
-        }
+    switch (render_visual->class) {
+    case TrueColor:
+        truecolor_startup();
+        break;
+    case PseudoColor:
+    case StaticColor:
+    case GrayScale:
+    case StaticGray:
+        pseudocolor_startup();
+        break;
+    default:
+        g_critical("unsupported visual class.\n");
+        exit(EXIT_FAILURE);
     }
-#endif /*USE_GL*/
-
-
-  switch (render_visual->class) {
-  case TrueColor:
-    truecolor_startup();
-    break;
-  case PseudoColor:
-  case StaticColor:
-  case GrayScale:
-  case StaticGray:
-    pseudocolor_startup();
-    break;
-  default:
-    g_critical("unsupported visual class.\n");
-    exit(EXIT_FAILURE);
-
-  }
 }
 
 void truecolor_startup(void)
@@ -259,22 +159,27 @@ void pseudocolor_startup(void)
   }
 }
 
-void x_paint(Window win, Appearance *l)
+void paint(Window win, Appearance *l, int w, int h)
 {
     int i, transferred = 0, sw;
     pixel32 *source, *dest;
     Pixmap oldp;
-    int x = l->area.x;
-    int y = l->area.y;
-    int w = l->area.width;
-    int h = l->area.height;
     Rect tarea; /* area in which to draw textures */
+    gboolean resized;
 
-    if (w <= 0 || h <= 0 || x+w <= 0 || y+h <= 0) return;
+    if (w <= 0 || h <= 0) return;
+
+    resized = (l->w != w || l->h != h);
+
+    if (resized) {
+        oldp = l->pixmap; /* save to free after changing the visible pixmap */
+        l->pixmap = XCreatePixmap(ob_display, ob_root, w, h, render_depth);
+    } else
+        oldp = None;
 
-    oldp = l->pixmap; /* save to free after changing the visible pixmap */
-    l->pixmap = XCreatePixmap(ob_display, ob_root, x+w, y+h, render_depth);
     g_assert(l->pixmap != None);
+    l->w = w;
+    l->h = h;
 
     if (l->xftdraw != NULL)
         XftDrawDestroy(l->xftdraw);
@@ -285,72 +190,72 @@ void x_paint(Window win, Appearance *l)
     g_free(l->surface.pixel_data);
     l->surface.pixel_data = g_new(pixel32, w * h);
 
-
     if (l->surface.grad == Background_ParentRelative) {
-        sw = l->surface.parent->area.width;
-        source = l->surface.parent->surface.pixel_data
-            + l->surface.parentx
-            + sw * l->surface.parenty;
+        g_assert (l->surface.parent);
+        g_assert (l->surface.parent->w);
+
+        sw = l->surface.parent->w;
+        source = (l->surface.parent->surface.pixel_data + l->surface.parentx +
+                  sw * l->surface.parenty);
         dest = l->surface.pixel_data;
         for (i = 0; i < h; i++, source += sw, dest += w) {
             memcpy(dest, source, w * sizeof(pixel32));
         }
     }
     else if (l->surface.grad == Background_Solid)
-        gradient_solid(l, x, y, w, h);
+        gradient_solid(l, 0, 0, w, h);
     else gradient_render(&l->surface, w, h);
 
-    for (i = 0; i < l->textures; i++) {
-        tarea = l->texture[i].position;
-        if (l->surface.grad != Background_ParentRelative) {
-            if (l->surface.relief != Flat) {
-                switch (l->surface.bevel) {
-                case Bevel1:
-                    tarea.x += 1; tarea.y += 1;
-                    tarea.width -= 2; tarea.height -= 2;
-                    break;
-                case Bevel2:
-                    tarea.x += 2; tarea.y += 2;
-                    tarea.width -= 4; tarea.height -= 4;
-                    break;
-                }
-            } else if (l->surface.border) {
+    RECT_SET(tarea, 0, 0, w, h);
+    if (l->surface.grad != Background_ParentRelative) {
+        if (l->surface.relief != Flat) {
+            switch (l->surface.bevel) {
+            case Bevel1:
                 tarea.x += 1; tarea.y += 1;
                 tarea.width -= 2; tarea.height -= 2;
+                break;
+            case Bevel2:
+                tarea.x += 2; tarea.y += 2;
+                tarea.width -= 4; tarea.height -= 4;
+                break;
             }
+        } else if (l->surface.border) {
+            tarea.x += 1; tarea.y += 1;
+            tarea.width -= 2; tarea.height -= 2;
         }
+    }
 
+    for (i = 0; i < l->textures; i++) {
         switch (l->texture[i].type) {
+        case NoTexture:
+            break;
         case Text:
             if (!transferred) {
                 transferred = 1;
                 if (l->surface.grad != Background_Solid)
                     pixel32_to_pixmap(l->surface.pixel_data, 
-                                      l->pixmap,x,y,w,h);
+                                      l->pixmap, 0, 0, w, h);
             }
             if (l->xftdraw == NULL) {
                 l->xftdraw = XftDrawCreate(ob_display, l->pixmap, 
                                         render_visual, render_colormap);
             }
-            font_draw(l->xftdraw, &l->texture[i].data.text, 
-                      &tarea);
+            font_draw(l->xftdraw, &l->texture[i].data.text, &tarea);
         break;
         case Bitmask:
             if (!transferred) {
                 transferred = 1;
                 if (l->surface.grad != Background_Solid)
                     pixel32_to_pixmap(l->surface.pixel_data, 
-                                      l->pixmap,x,y,w,h);
+                                      l->pixmap, 0, 0, w, h);
             }
             if (l->texture[i].data.mask.color->gc == None)
                 color_allocate_gc(l->texture[i].data.mask.color);
-            mask_draw(l->pixmap, &l->texture[i].data.mask,
-                      &tarea);
+            mask_draw(l->pixmap, &l->texture[i].data.mask, &tarea);
         break;
         case RGBA:
-            image_draw(l->surface.pixel_data, 
-                       &l->texture[i].data.rgba,
-                       &tarea, &l->area);
+            image_draw(l->surface.pixel_data,
+                       &l->texture[i].data.rgba, &tarea);
         break;
         }
     }
@@ -358,14 +263,13 @@ void x_paint(Window win, Appearance *l)
     if (!transferred) {
         transferred = 1;
         if (l->surface.grad != Background_Solid)
-            pixel32_to_pixmap(l->surface.pixel_data, l->pixmap
-                              ,x,y,w,h);
+            pixel32_to_pixmap(l->surface.pixel_data, l->pixmap, 0, 0, w, h);
     }
 
 
     XSetWindowBackgroundPixmap(ob_display, win, l->pixmap);
     XClearWindow(ob_display, win);
-    if (oldp != None) XFreePixmap(ob_display, oldp);
+    if (oldp) XFreePixmap(ob_display, oldp);
 }
 
 void render_shutdown(void)
@@ -383,6 +287,7 @@ Appearance *appearance_new(int numtex)
   if (numtex) out->texture = g_new0(Texture, numtex);
   else out->texture = NULL;
   out->pixmap = None;
+  out->w = out->h = 0;
 
   p = &out->surface;
   p->primary = NULL;
@@ -442,6 +347,7 @@ Appearance *appearance_copy(Appearance *orig)
     copy->texture = g_memdup(orig->texture, orig->textures * sizeof(Texture));
     copy->pixmap = None;
     copy->xftdraw = NULL;
+    copy->w = copy->h = 0;
     return copy;
 }
 
@@ -491,45 +397,52 @@ void appearance_minsize(Appearance *l, int *w, int *h)
 {
     int i;
     int m;
-    *w = *h = 1;
-
-    if (l->surface.relief != Flat) {
-        switch (l->surface.bevel) {
-        case Bevel1:
-            *w = *h = 2;
-            break;
-        case Bevel2:
-            *w = *h = 4;
-            break;
-        }
-    } else if (l->surface.border)
-        *w = *h = 2;
+    *w = *h = 0;
 
     for (i = 0; i < l->textures; ++i) {
         switch (l->texture[i].type) {
         case Bitmask:
-            *w += l->texture[i].data.mask.mask->w;
-            *h += l->texture[i].data.mask.mask->h;
+            *w = MAX(*w, l->texture[i].data.mask.mask->w);
+            *h = MAX(*h, l->texture[i].data.mask.mask->h);
             break;
         case Text:
             m = font_measure_string(l->texture[i].data.text.font,
                                     l->texture[i].data.text.string,
                                     l->texture[i].data.text.shadow,
                                     l->texture[i].data.text.offset);
-            *w += m;
+            *w = MAX(*w, m);
             m = font_height(l->texture[i].data.text.font,
                             l->texture[i].data.text.shadow,
                             l->texture[i].data.text.offset);
-            *h += m;
+            *h += MAX(*h, m);
             break;
         case RGBA:
-            *w += l->texture[i].data.rgba.width;
-            *h += l->texture[i].data.rgba.height;
+            *w += MAX(*w, l->texture[i].data.rgba.width);
+            *h += MAX(*h, l->texture[i].data.rgba.height);
             break;
         case NoTexture:
             break;
         }
     }
+
+    if (l->surface.relief != Flat) {
+        switch (l->surface.bevel) {
+        case Bevel1:
+            *w += 2;
+            *h += 2;
+            break;
+        case Bevel2:
+            *w += 4;
+            *h += 4;
+            break;
+        }
+    } else if (l->surface.border) {
+        *w += 2;
+        *h += 2;
+    }
+
+    if (*w < 1) *w = 1;
+    if (*h < 1) *h = 1;
 }
 
 gboolean render_pixmap_to_rgba(Pixmap pmap, Pixmap mask,
@@ -579,54 +492,3 @@ gboolean render_pixmap_to_rgba(Pixmap pmap, Pixmap mask,
 
     return TRUE;
 }
-
-#ifdef USE_GL
-void gl_paint(Window win, Appearance *l)
-{
-    int err;
-    Window root, child;
-    int i, transferred = 0, sw, b, d;
-    pixel32 *source, *dest;
-    Pixmap oldp;
-    int tempx, tempy, absx, absy, absw, absh;
-    int x = l->area.x;
-    int y = l->area.y;
-    int w = l->area.width;
-    int h = l->area.height;
-    Rect tarea; /* area in which to draw textures */
-    if (w <= 0 || h <= 0 || x+w <= 0 || y+h <= 0) return;
-
-    g_assert(l->surface.type == Surface_Planar);
-
-printf("making %p, %p, %p current\n", ob_display, win, render_glx_context);
-    err = glXMakeCurrent(ob_display, win, render_glx_context);
-g_assert(err != 0);
-
-            glMatrixMode(GL_MODELVIEW);
-            glLoadIdentity();
-            glMatrixMode(GL_PROJECTION);
-            glLoadIdentity();
-            glOrtho(0, 1376, 1032, 0, 0, 10);
-    if (XGetGeometry(ob_display, win, &root, &tempx, &tempy,
-                     &absw, &absh,  &b, &d) &&
-        XTranslateCoordinates(ob_display, win, root, tempx, tempy, 
-        &absx, &absy, &child))
-        printf("window at %d, %d (%d,%d)\n", absx, absy, absw, absh);
-    else
-        return;
-
-    glViewport(0, 0, 1376, 1032);
-    glMatrixMode(GL_MODELVIEW);
-    glTranslatef(-absx, 1032-absh-absy, 0);
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-
-    if (l->surface.grad == Background_ParentRelative) {
-        printf("crap\n");
-    } else
-        render_gl_gradient(&l->surface, absx+x, absy+y, absw, absh);
-
-    glXSwapBuffers(ob_display, win);
-}
-
-#endif /* USE_GL */
index 1b1cce1d323393934b7bdbbe2622760fd4500f21..31e62ee7be596eadd2924b81a868a2eea02330d3 100644 (file)
@@ -59,7 +59,6 @@ typedef struct Surface {
 
 typedef struct {
     XftFont *xftfont;
-    int height;
     int elipses_length;
 } ObFont;
 
@@ -107,18 +106,19 @@ typedef union {
 } TextureData;
 
 typedef struct Texture {
-    Rect position;
     TextureType type;
     TextureData data;
 } Texture;
 
 typedef struct Appearance {
     Surface surface;
-    Rect area;
     int textures;
     Texture *texture;
     Pixmap pixmap;
     XftDraw *xftdraw;
+
+    /* cached for internal use */
+    int w, h;
 } Appearance;
 
 extern Visual *render_visual;
@@ -126,12 +126,9 @@ extern XVisualInfo render_visual_info;
 extern int render_depth;
 extern Colormap render_colormap;
 
-void (*paint)(Window win, Appearance *l);
-
 void render_startup(void);
 void init_appearance(Appearance *l);
-void x_paint(Window win, Appearance *l);
-void gl_paint(Window win, Appearance *l);
+void paint(Window win, Appearance *l, int w, int h);
 void render_shutdown(void);
 Appearance *appearance_new(int numtex);
 Appearance *appearance_copy(Appearance *a);
index 4dfed619061e22e95bab56e7c1753290b493cfba..9ae7eada2215e3978e8e3adf53fb52fc0d30a6d9 100644 (file)
@@ -21,25 +21,19 @@ Window ob_root;
 int main()
 {
        Window win;
-       GC gc;
-       Pixmap pm;
        Appearance *look;
 
-       int grabbed = 0;
        Window root;
-        XGCValues values;
        XEvent report;
-       int h = 500, w = 500, tmp;
-       XVisualInfo *vi;
-       int i;
+       int h = 500, w = 500;
 
        ob_display = XOpenDisplay(NULL);
        XSetErrorHandler(x_error_handler);
        ob_screen = DefaultScreen(ob_display);
        ob_root = RootWindow(ob_display, ob_screen);
        win =
-           XCreateWindow(ob_display, RootWindow(ob_display, 0)
-                          10, 10, w, h, 10, 
+           XCreateWindow(ob_display, RootWindow(ob_display, 0),
+                          10, 10, w, h, 10, 
                           CopyFromParent,      /* depth */
                          CopyFromParent,       /* class */
                          CopyFromParent,       /* visual */
@@ -55,25 +49,21 @@ int main()
        look->surface.secondary = color_parse("Yellow");
        look->surface.primary = color_parse("Blue");
         look->surface.interlaced = FALSE;
-        look->area.x = 0;
-        look->area.y = 0;
-        look->area.width = 500;
-        look->area.height = 500;
        if (ob_display == NULL) {
                fprintf(stderr, "couldn't connect to X server :0\n");
                return 0;
        }
 
-       paint(win, look);
+       paint(win, look, w, h);
        while (1) {
                XNextEvent(ob_display, &report);
                switch (report.type) {
                case Expose:
                break;
                case ConfigureNotify:
-                       look->area.width = report.xconfigure.width;
-                       look->area.height = report.xconfigure.height;
-                       paint(win, look);
+                       paint(win, look,
+                              report.xconfigure.width,
+                              report.xconfigure.height);
                break;
                }
 
index 2ebcead3bf2925f106af93658a3cbf34b1b99c76..12e54377c9a3f866dd7274dc4ec5b0395bbce0ee 100644 (file)
@@ -515,7 +515,7 @@ char *theme_load(char *theme)
     }
 
     /* load the font stuff */
-    font_str = "arial:bold:pixelsize=10:minsize";
+    font_str = "arial:bold:pixelsize=10";
 
     theme_winfont_shadow = FALSE;
     if (read_string(db, "window.xft.flags", &str)) {
index 2a93c8dff5414a5a9fa3675ce5f5912aaece8502..0f87b80867ef1077631f19b050ef83c6a3f95c78 100644 (file)
@@ -11,7 +11,7 @@ extern int theme_handle_height;
 extern int theme_bwidth;
 extern int theme_cbwidth;
 
-#define theme_label_height (theme_winfont_height + 2)
+#define theme_label_height (theme_winfont_height)
 #define theme_title_height (theme_label_height + theme_bevel * 2)
 #define theme_button_size  (theme_label_height - 2)
 #define theme_grip_width   (theme_button_size * 2)
This page took 0.055428 seconds and 4 git commands to generate.