]> Dogcows Code - chaz/openbox/commitdiff
add support for a default icon, but no icon has been made yet.
authorDana Jansens <danakj@orodu.net>
Fri, 12 Sep 2003 01:11:33 +0000 (01:11 +0000)
committerDana Jansens <danakj@orodu.net>
Fri, 12 Sep 2003 01:11:33 +0000 (01:11 +0000)
Makefile.am
openbox/client.c
render/theme.c
render/theme.h

index c15b966547d3713791d8cfd7f0636706715747d8..cfe92200b20db2255bcc9012a1d78899642f9fa9 100644 (file)
@@ -54,6 +54,7 @@ render_libobrender_la_SOURCES = \
        render/geom.h \
        render/gradient.h \
        render/gradient.c \
+       render/icon.h \
        render/image.h \
        render/image.c \
        render/instance.h \
index 4ac234d73315a9d3137078f70c0643e3a99f4249..1cc8595b8df7dfe75e0f519481d43a4a3e6ef7a2 100644 (file)
@@ -1546,6 +1546,16 @@ void client_update_icons(ObClient *self)
         }
     }
 
+    if (!self->nicons) {
+        self->nicons++;
+        self->icons = g_new(ObClientIcon, self->nicons);
+        self->icons[self->nicons-1].width = 48;
+        self->icons[self->nicons-1].height = 48;
+        self->icons[self->nicons-1].data = g_memdup(ob_rr_theme->def_win_icon,
+                                                    sizeof(RrPixel32)
+                                                    * 48 * 48);
+    }
+
     if (self->frame)
        frame_adjust_icon(self->frame);
 }
@@ -2603,8 +2613,6 @@ ObClientIcon *client_icon(ObClient *self, int w, int h)
     /* li is the largest image < req */
     unsigned long size, smallest = 0xffffffff, largest = 0, si = 0, li = 0;
 
-    if (!self->nicons) return NULL;
-
     for (i = 0; i < self->nicons; ++i) {
         size = self->icons[i].width * self->icons[i].height;
         if (size < smallest && size >= (unsigned)(w * h)) {
index 3c2c8b2e0f7f0b87cd7ebc3d03dafe84e3a2012c..217b4e5130fe0661694a91a66a92a80438631b47 100644 (file)
@@ -3,6 +3,7 @@
 #include "font.h"
 #include "mask.h"
 #include "theme.h"
+#include "icon.h"
 
 #include <X11/Xlib.h>
 #include <X11/Xresource.h>
@@ -21,6 +22,7 @@ static gboolean read_mask(const RrInstance *inst,
 static gboolean read_appearance(XrmDatabase db, const RrInstance *inst,
                                 gchar *rname, RrAppearance *value,
                                 gboolean allow_trans);
+static RrPixel32* read_c_image(gint width, gint height, const guint8 *data);
 static void set_default_appearance(RrAppearance *a);
 
 RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
@@ -323,6 +325,10 @@ RrTheme* RrThemeNew(const RrInstance *inst, gchar *name)
         theme->iconify_hover_mask = RrPixmapMaskCopy(theme->iconify_mask);
     }
 
+    theme->def_win_icon = read_c_image(OB_DEFAULT_ICON_WIDTH,
+                                       OB_DEFAULT_ICON_HEIGHT,
+                                       OB_DEFAULT_ICON_pixel_data);
+
     if (read_mask(inst, "desk.xbm", theme, &theme->desk_mask)) {
         if (!read_mask(inst, "desk_pressed.xbm", theme,
                        &theme->desk_pressed_mask)) {
@@ -915,6 +921,8 @@ void RrThemeFree(RrTheme *theme)
         RrColorFree(theme->menu_disabled_color);
         RrColorFree(theme->menu_selected_color);
 
+        g_free(theme->def_win_icon);
+
         RrPixmapMaskFree(theme->max_mask);
         RrPixmapMaskFree(theme->max_toggled_mask);
         RrPixmapMaskFree(theme->max_disabled_mask);
@@ -1248,3 +1256,29 @@ static void set_default_appearance(RrAppearance *a)
     a->surface.primary = RrColorNew(a->inst, 0, 0, 0);
     a->surface.secondary = RrColorNew(a->inst, 0, 0, 0);
 }
+
+/* Reads the output from gimp's C-Source file format into valid RGBA data for
+   an RrTextureRGBA. */
+static RrPixel32* read_c_image(gint width, gint height, const guint8 *data)
+{
+    RrPixel32 *im, *p;
+    gint i;
+
+    p = im = g_memdup(OB_DEFAULT_ICON_pixel_data,
+                      OB_DEFAULT_ICON_WIDTH * OB_DEFAULT_ICON_HEIGHT *
+                      sizeof(RrPixel32));
+
+    for (i = 0; i < OB_DEFAULT_ICON_WIDTH*OB_DEFAULT_ICON_HEIGHT; ++i) {
+        guchar a = ((*p >> 24) & 0xff);
+        guchar b = ((*p >> 16) & 0xff);
+        guchar g = ((*p >>  8) & 0xff);
+        guchar r = ((*p >>  0) & 0xff);
+
+        *p++ = ((r << RrDefaultRedOffset) +
+                (g << RrDefaultGreenOffset) +
+                (b << RrDefaultBlueOffset) +
+                (a << RrDefaultAlphaOffset));
+    }
+
+    return im;
+}
index e52b16c4faa5beca8c9b4c32dd18f2ec6d367131..5c6507eb9e302493ed89ce24c679df8470cbaa8d 100644 (file)
@@ -55,6 +55,9 @@ struct _RrTheme {
     gint mfont_height;
     RrFont *mfont;
 
+    /* style settings - pics */
+    RrPixel32 *def_win_icon; /* 48x48 RGBA */
+
     /* style settings - masks */
     RrPixmapMask *max_mask;
     RrPixmapMask *max_toggled_mask;
This page took 0.035789 seconds and 4 git commands to generate.