]> Dogcows Code - chaz/openbox/commitdiff
add icons to the client-list-menu
authorDana Jansens <danakj@orodu.net>
Thu, 28 Aug 2003 08:08:18 +0000 (08:08 +0000)
committerDana Jansens <danakj@orodu.net>
Thu, 28 Aug 2003 08:08:18 +0000 (08:08 +0000)
openbox/menu.h
openbox/menuframe.c
plugins/menu/client_list_menu.c

index c91be82b67f3e3cdd76dd8d714d59876f8b6f9a9..c6058635978aa98c61ef4d41ff0a8569e8d8bfd8 100644 (file)
@@ -59,6 +59,11 @@ struct _ObNormalMenuEntry {
 
     /* List of ObActions */
     GSList *actions;
+
+    /* Icon shit */
+    gint icon_width;
+    gint icon_height;
+    RrPixel32 *icon_data;
 };
 
 struct _ObSubmenuMenuEntry {
index 8ffd27ad8b7618f33f6ccbcc8201fa8f73e5325d..8126b5d5fde8da8e70c66cf82cf234eed65e1cca 100644 (file)
@@ -134,7 +134,6 @@ void menu_entry_frame_free(ObMenuEntryFrame *self)
 
 void menu_frame_move(ObMenuFrame *self, gint x, gint y)
 {
-    /* XXX screen constraints */
     RECT_SET_POINT(self->area, x, y);
     XMoveWindow(ob_display, self->window, self->area.x, self->area.y);
 }
@@ -171,6 +170,7 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
     RrAppearance *item_a, *text_a;
     gint th; /* temp */
     ObMenu *sub;
+    ObClientIcon *icon;
 
     item_a = ((self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
                !self->entry->data.normal.enabled) ?
@@ -230,11 +230,17 @@ static void menu_entry_frame_render(ObMenuEntryFrame *self)
         break;
     }
 
-    /* XXX draw icons */
-    if (0) {
+    if (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL &&
+        self->entry->data.normal.icon_data)
+    {
         XMoveResizeWindow(ob_display, self->icon, 0, 0,
                           self->frame->item_h, self->frame->item_h);
-        /* XXX set the RGBA surface stuff */
+        self->a_icon->texture[0].data.rgba.width =
+            self->entry->data.normal.icon_width;
+        self->a_icon->texture[0].data.rgba.height =
+            self->entry->data.normal.icon_height;
+        self->a_icon->texture[0].data.rgba.data =
+            self->entry->data.normal.icon_data;
         self->a_icon->surface.parent = item_a;
         self->a_icon->surface.parentx = 0;
         self->a_icon->surface.parenty = 0;
@@ -314,7 +320,8 @@ static void menu_frame_render(ObMenuFrame *self)
             text_a->texture[0].data.text.string = e->entry->data.normal.label;
             RrMinsize(text_a, &tw, &th);
 
-            /* XXX has_icon = TRUE; */
+            if (e->entry->data.normal.icon_data)
+                has_icon = TRUE;
             break;
         case OB_MENU_ENTRY_TYPE_SUBMENU:
             sub = e->entry->data.submenu.submenu;
index 2f5c5f9fb8e24a3b880e368c32db40db5ca1490c..5b0141164f629e7112813ff0318a0b8f51b91f26 100644 (file)
@@ -29,20 +29,30 @@ static void desk_menu_update(ObMenuFrame *frame, gpointer data)
     ObMenu *menu = frame->menu;
     DesktopData *d = data;
     GList *it;
+    gint i;
 
     menu_clear_entries(menu->name);
 
-    for (it = focus_order[d->desktop]; it; it = g_list_next(it)) {
+    for (it = focus_order[d->desktop], i = 0; it; it = g_list_next(it), ++i) {
         ObClient *c = it->data;
         if (client_normal(c)) {
             GSList *acts;
             ObAction* act;
+            ObMenuEntry *e;
+            ObClientIcon *icon;
 
             act = action_from_string("activate");
             act->data.activate.c = c;
             acts = g_slist_prepend(NULL, act);
-            menu_add_normal(menu->name, 0,
+            menu_add_normal(menu->name, i,
                             (c->iconic ? c->icon_title : c->title), acts);
+
+            if ((icon = client_icon(c, 32, 32))) {
+                e = menu_find_entry_id(menu, i);
+                e->data.normal.icon_width = icon->width;
+                e->data.normal.icon_height = icon->height;
+                e->data.normal.icon_data = icon->data;
+            }
         }
     }
     
This page took 0.034266 seconds and 4 git commands to generate.