Render menus only when they are invalid.
This commit is contained in:
parent
c61420b21d
commit
6a237b91bc
4 changed files with 84 additions and 65 deletions
|
@ -21,9 +21,10 @@ bin_PROGRAMS=$(binary)
|
||||||
openbox3_LDADD=@LIBINTL@ -lobrender -L../render
|
openbox3_LDADD=@LIBINTL@ -lobrender -L../render
|
||||||
openbox3_LDFLAGS=-export-dynamic
|
openbox3_LDFLAGS=-export-dynamic
|
||||||
openbox3_SOURCES=parse.tab.c parse.lex.c action.c client.c config.c \
|
openbox3_SOURCES=parse.tab.c parse.lex.c action.c client.c config.c \
|
||||||
extensions.c focus.c frame.c grab.c menu.c openbox.c \
|
extensions.c focus.c frame.c grab.c menu.c menu_render.c \
|
||||||
framerender.c parse.c plugin.c prop.c screen.c stacking.c \
|
openbox.c framerender.c parse.c plugin.c prop.c screen.c \
|
||||||
dispatch.c event.c group.c timer.c xerror.c moveresize.c
|
stacking.c dispatch.c event.c group.c timer.c xerror.c \
|
||||||
|
moveresize.c
|
||||||
|
|
||||||
noinst_HEADERS=action.h client.h config.h dispatch.h event.h extensions.h \
|
noinst_HEADERS=action.h client.h config.h dispatch.h event.h extensions.h \
|
||||||
focus.h frame.h framerender.h geom.h gettext.h grab.h group.h \
|
focus.h frame.h framerender.h geom.h gettext.h grab.h group.h \
|
||||||
|
|
|
@ -188,10 +188,6 @@ void menu_add_entry(Menu *menu, MenuEntry *entry)
|
||||||
void menu_show(char *name, int x, int y, Client *client)
|
void menu_show(char *name, int x, int y, Client *client)
|
||||||
{
|
{
|
||||||
Menu *self;
|
Menu *self;
|
||||||
GList *it;
|
|
||||||
int items_h;
|
|
||||||
int nitems = 0; /* each item, only one is used */
|
|
||||||
int item_y;
|
|
||||||
|
|
||||||
self = g_hash_table_lookup(menu_hash, name);
|
self = g_hash_table_lookup(menu_hash, name);
|
||||||
if (!self) {
|
if (!self) {
|
||||||
|
@ -199,67 +195,15 @@ void menu_show(char *name, int x, int y, Client *client)
|
||||||
name);
|
name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(self->invalid) {
|
||||||
|
menu_render(self);
|
||||||
|
}
|
||||||
|
|
||||||
|
XMoveWindow(ob_display, self->frame, x, y);
|
||||||
|
|
||||||
self->client = client;
|
self->client = client;
|
||||||
|
|
||||||
self->width = 1;
|
|
||||||
self->item_h = 0;
|
|
||||||
|
|
||||||
/* set texture data and size them mofos out */
|
|
||||||
self->a_title->texture[0].data.text.string = self->label;
|
|
||||||
appearance_minsize(self->a_title, &self->title_min_w, &self->title_h);
|
|
||||||
self->title_min_w += theme_bevel * 2;
|
|
||||||
self->title_h += theme_bevel * 2;
|
|
||||||
self->width = MAX(self->width, self->title_min_w);
|
|
||||||
|
|
||||||
for (it = self->entries; it; it = it->next) {
|
|
||||||
MenuEntry *e = it->data;
|
|
||||||
int h;
|
|
||||||
|
|
||||||
e->a_item->texture[0].data.text.string = e->label;
|
|
||||||
appearance_minsize(e->a_item, &e->min_w, &self->item_h);
|
|
||||||
self->width = MAX(self->width, e->min_w);
|
|
||||||
|
|
||||||
e->a_disabled->texture[0].data.text.string = e->label;
|
|
||||||
appearance_minsize(e->a_disabled, &e->min_w, &h);
|
|
||||||
self->item_h = MAX(self->item_h, h);
|
|
||||||
self->width = MAX(self->width, e->min_w);
|
|
||||||
|
|
||||||
e->a_hilite->texture[0].data.text.string = e->label;
|
|
||||||
appearance_minsize(e->a_hilite, &e->min_w, &h);
|
|
||||||
self->item_h = MAX(self->item_h, h);
|
|
||||||
self->width = MAX(self->width, e->min_w);
|
|
||||||
|
|
||||||
e->min_w += theme_bevel * 2;
|
|
||||||
++nitems;
|
|
||||||
}
|
|
||||||
self->bullet_w = self->item_h + theme_bevel;
|
|
||||||
self->width += 2 * self->bullet_w;
|
|
||||||
self->item_h += theme_bevel * 2;
|
|
||||||
items_h = self->item_h * nitems;
|
|
||||||
|
|
||||||
RECT_SET(self->a_title->area, 0, 0, self->width, self->title_h);
|
|
||||||
RECT_SET(self->a_title->texture[0].position, 0, 0, self->width,
|
|
||||||
self->title_h);
|
|
||||||
RECT_SET(self->a_items->area, 0, 0, self->width, items_h);
|
|
||||||
|
|
||||||
XMoveResizeWindow(ob_display, self->frame, x, y, self->width,
|
|
||||||
self->title_h + items_h);
|
|
||||||
XMoveResizeWindow(ob_display, self->title, -theme_bwidth, -theme_bwidth,
|
|
||||||
self->width, self->title_h);
|
|
||||||
XMoveResizeWindow(ob_display, self->items, 0, self->title_h + theme_bwidth,
|
|
||||||
self->width, items_h);
|
|
||||||
|
|
||||||
paint(self->title, self->a_title);
|
|
||||||
paint(self->items, self->a_items);
|
|
||||||
|
|
||||||
item_y = 0;
|
|
||||||
for (it = self->entries; it; it = it->next) {
|
|
||||||
((MenuEntry*)it->data)->y = item_y;
|
|
||||||
menu_entry_render(it->data);
|
|
||||||
item_y += self->item_h;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!self->shown) {
|
if (!self->shown) {
|
||||||
stacking_raise_internal(self->frame);
|
stacking_raise_internal(self->frame);
|
||||||
XMapWindow(ob_display, self->frame);
|
XMapWindow(ob_display, self->frame);
|
||||||
|
|
|
@ -101,4 +101,6 @@ void menu_entry_render(MenuEntry *self);
|
||||||
|
|
||||||
void menu_entry_fire(MenuEntry *self);
|
void menu_entry_fire(MenuEntry *self);
|
||||||
|
|
||||||
|
void menu_render(Menu *self);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
72
openbox/menu_render.c
Normal file
72
openbox/menu_render.c
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
// Functions for default rendering of menus. Might become pluginnable
|
||||||
|
|
||||||
|
#include "menu.h"
|
||||||
|
#include "openbox.h"
|
||||||
|
#include "render/theme.h"
|
||||||
|
|
||||||
|
void menu_render(Menu *self) {
|
||||||
|
GList *it;
|
||||||
|
int items_h;
|
||||||
|
int nitems = 0; /* each item, only one is used */
|
||||||
|
int item_y;
|
||||||
|
|
||||||
|
self->width = 1;
|
||||||
|
self->item_h = 0;
|
||||||
|
|
||||||
|
/* set texture data and size them mofos out */
|
||||||
|
self->a_title->texture[0].data.text.string = self->label;
|
||||||
|
appearance_minsize(self->a_title, &self->title_min_w, &self->title_h);
|
||||||
|
self->title_min_w += theme_bevel * 2;
|
||||||
|
self->title_h += theme_bevel * 2;
|
||||||
|
self->width = MAX(self->width, self->title_min_w);
|
||||||
|
|
||||||
|
for (it = self->entries; it; it = it->next) {
|
||||||
|
MenuEntry *e = it->data;
|
||||||
|
int h;
|
||||||
|
|
||||||
|
e->a_item->texture[0].data.text.string = e->label;
|
||||||
|
appearance_minsize(e->a_item, &e->min_w, &self->item_h);
|
||||||
|
self->width = MAX(self->width, e->min_w);
|
||||||
|
|
||||||
|
e->a_disabled->texture[0].data.text.string = e->label;
|
||||||
|
appearance_minsize(e->a_disabled, &e->min_w, &h);
|
||||||
|
self->item_h = MAX(self->item_h, h);
|
||||||
|
self->width = MAX(self->width, e->min_w);
|
||||||
|
|
||||||
|
e->a_hilite->texture[0].data.text.string = e->label;
|
||||||
|
appearance_minsize(e->a_hilite, &e->min_w, &h);
|
||||||
|
self->item_h = MAX(self->item_h, h);
|
||||||
|
self->width = MAX(self->width, e->min_w);
|
||||||
|
|
||||||
|
e->min_w += theme_bevel * 2;
|
||||||
|
++nitems;
|
||||||
|
}
|
||||||
|
self->bullet_w = self->item_h + theme_bevel;
|
||||||
|
self->width += 2 * self->bullet_w;
|
||||||
|
self->item_h += theme_bevel * 2;
|
||||||
|
items_h = self->item_h * nitems;
|
||||||
|
|
||||||
|
RECT_SET(self->a_title->area, 0, 0, self->width, self->title_h);
|
||||||
|
RECT_SET(self->a_title->texture[0].position, 0, 0, self->width,
|
||||||
|
self->title_h);
|
||||||
|
RECT_SET(self->a_items->area, 0, 0, self->width, items_h);
|
||||||
|
|
||||||
|
XResizeWindow(ob_display, self->frame, self->width,
|
||||||
|
self->title_h + items_h);
|
||||||
|
XMoveResizeWindow(ob_display, self->title, -theme_bwidth, -theme_bwidth,
|
||||||
|
self->width, self->title_h);
|
||||||
|
XMoveResizeWindow(ob_display, self->items, 0, self->title_h + theme_bwidth,
|
||||||
|
self->width, items_h);
|
||||||
|
|
||||||
|
paint(self->title, self->a_title);
|
||||||
|
paint(self->items, self->a_items);
|
||||||
|
|
||||||
|
item_y = 0;
|
||||||
|
for (it = self->entries; it; it = it->next) {
|
||||||
|
((MenuEntry*)it->data)->y = item_y;
|
||||||
|
menu_entry_render(it->data);
|
||||||
|
item_y += self->item_h;
|
||||||
|
}
|
||||||
|
|
||||||
|
self->invalid = FALSE;
|
||||||
|
}
|
Loading…
Reference in a new issue