void frame_adjust_area(struct wm_frame *self, gboolean moved, gboolean resized, gboolean fake) { if(resized) { self->max_horz = self->client->max_horz; self->max_vert = self->client->max_vert; if(self->max_horz) {//XXX!!!!! self->width = self->client->area.width; } else self->width = self->client->area.width ; STRUT_SET(self->size, 0, 0, 0, 0); } RECT_SET_SIZE(self->area, self->client->area.width + self->size.left + self->size.right, self->client->area.height + self->size.top + self->size.bottom); if((moved || resized) && !fake) { self->area.x = self->client->area.x; self->area.y = self->client->area.y; } if(!fake) { XMoveResizeWindow(t_display, self->window, self->area.x, self->area.y, self->area.width, self->area.height); XMoveWindow(t_display, self->client->window, self->size.left, self->size.top); if(resized) { frame_adjust_shape(self); } if(!STRUT_EQUAL(self->size, self->oldsize)) { gulong vals[4]; vals[0] = self->size.left; vals[1] = self->size.right; vals[2] = self->size.top; vals[3] = self->size.bottom; self->oldsize = self->size; } if(focus_cycle_target == self->client) focus_cycle_update_indicator(self->client); } }
void menu_frame_render(ObMenuFrame *self) { gint w = 0, h = 0; gint tw, th; /* temps */ GList *it; gboolean has_icon = FALSE; ObMenu *sub; ObMenuEntryFrame *e; /* find text dimensions */ STRUT_SET(self->item_margin, 0, 0, 0, 0); if (self->entries) { gint l, t, r, b; e = self->entries->data; ob_rr_theme->a_menu_text_normal->texture[0].data.text.string = ""; tw = RrMinWidth(ob_rr_theme->a_menu_text_normal); tw += 2*PADDING; th = ITEM_HEIGHT; RrMargins(ob_rr_theme->a_menu_normal, &l, &t, &r, &b); STRUT_SET(self->item_margin, MAX(self->item_margin.left, l), MAX(self->item_margin.top, t), MAX(self->item_margin.right, r), MAX(self->item_margin.bottom, b)); RrMargins(ob_rr_theme->a_menu_selected, &l, &t, &r, &b); STRUT_SET(self->item_margin, MAX(self->item_margin.left, l), MAX(self->item_margin.top, t), MAX(self->item_margin.right, r), MAX(self->item_margin.bottom, b)); RrMargins(ob_rr_theme->a_menu_disabled, &l, &t, &r, &b); STRUT_SET(self->item_margin, MAX(self->item_margin.left, l), MAX(self->item_margin.top, t), MAX(self->item_margin.right, r), MAX(self->item_margin.bottom, b)); RrMargins(ob_rr_theme->a_menu_disabled_selected, &l, &t, &r, &b); STRUT_SET(self->item_margin, MAX(self->item_margin.left, l), MAX(self->item_margin.top, t), MAX(self->item_margin.right, r), MAX(self->item_margin.bottom, b)); } /* render the entries */ for (it = self->entries; it; it = g_list_next(it)) { RrAppearance *text_a; e = it->data; /* if the first entry is a labeled separator, then make its border overlap with the menu's outside border */ if (it == self->entries && e->entry->type == OB_MENU_ENTRY_TYPE_SEPARATOR && e->entry->data.separator.label) { h -= ob_rr_theme->mbwidth; } if (e->entry->type == OB_MENU_ENTRY_TYPE_SEPARATOR && e->entry->data.separator.label) { e->border = ob_rr_theme->mbwidth; } RECT_SET_POINT(e->area, 0, h+e->border); XMoveWindow(obt_display, e->window, e->area.x-e->border, e->area.y-e->border); XSetWindowBorderWidth(obt_display, e->window, e->border); XSetWindowBorder(obt_display, e->window, RrColorPixel(ob_rr_theme->menu_border_color)); text_a = (e->entry->type == OB_MENU_ENTRY_TYPE_NORMAL && !e->entry->data.normal.enabled ? /* disabled */ (e == self->selected ? ob_rr_theme->a_menu_text_disabled_selected : ob_rr_theme->a_menu_text_disabled) : /* enabled */ (e == self->selected ? ob_rr_theme->a_menu_text_selected : ob_rr_theme->a_menu_text_normal)); switch (e->entry->type) { case OB_MENU_ENTRY_TYPE_NORMAL: text_a->texture[0].data.text.string = e->entry->data.normal.label; tw = RrMinWidth(text_a); tw = MIN(tw, MAX_MENU_WIDTH); th = ob_rr_theme->menu_font_height; if (e->entry->data.normal.icon || e->entry->data.normal.mask) has_icon = TRUE; break; case OB_MENU_ENTRY_TYPE_SUBMENU: sub = e->entry->data.submenu.submenu; text_a->texture[0].data.text.string = sub ? sub->title : ""; tw = RrMinWidth(text_a); tw = MIN(tw, MAX_MENU_WIDTH); th = ob_rr_theme->menu_font_height; if (e->entry->data.normal.icon || e->entry->data.normal.mask) has_icon = TRUE; tw += ITEM_HEIGHT - PADDING; break; case OB_MENU_ENTRY_TYPE_SEPARATOR: if (e->entry->data.separator.label != NULL) { ob_rr_theme->a_menu_text_title->texture[0].data.text.string = e->entry->data.separator.label; tw = RrMinWidth(ob_rr_theme->a_menu_text_title) + 2*ob_rr_theme->paddingx; tw = MIN(tw, MAX_MENU_WIDTH); th = ob_rr_theme->menu_title_height + (ob_rr_theme->mbwidth - PADDING) *2; } else { tw = 0; th = ob_rr_theme->menu_sep_width + 2*ob_rr_theme->menu_sep_paddingy - 2*PADDING; } break; default: g_assert_not_reached(); } tw += 2*PADDING; th += 2*PADDING; w = MAX(w, tw); h += th; } /* if the last entry is a labeled separator, then make its border overlap with the menu's outside border */ it = g_list_last(self->entries); e = it ? it->data : NULL; if (e && e->entry->type == OB_MENU_ENTRY_TYPE_SEPARATOR && e->entry->data.separator.label) { h -= ob_rr_theme->mbwidth; } self->text_x = PADDING; self->text_w = w; if (self->entries) { if (has_icon) { w += ITEM_HEIGHT + PADDING; self->text_x += ITEM_HEIGHT + PADDING; } } if (!w) w = 10; if (!h) h = 3; XResizeWindow(obt_display, self->window, w, h); self->inner_w = w; RrPaint(self->a_items, self->window, w, h); for (it = self->entries; it; it = g_list_next(it)) menu_entry_frame_render(it->data); w += ob_rr_theme->mbwidth * 2; h += ob_rr_theme->mbwidth * 2; RECT_SET_SIZE(self->area, w, h); XFlush(obt_display); }
static void menu_entry_frame_render(ObMenuEntryFrame *self) { RrAppearance *item_a, *text_a; gint th; /* temp */ ObMenu *sub; ObMenuFrame *frame = self->frame; switch (self->entry->type) { case OB_MENU_ENTRY_TYPE_NORMAL: case OB_MENU_ENTRY_TYPE_SUBMENU: item_a = (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL && !self->entry->data.normal.enabled ? /* disabled */ (self == self->frame->selected ? ob_rr_theme->a_menu_disabled_selected : ob_rr_theme->a_menu_disabled) : /* enabled */ (self == self->frame->selected ? ob_rr_theme->a_menu_selected : ob_rr_theme->a_menu_normal)); th = ITEM_HEIGHT; break; case OB_MENU_ENTRY_TYPE_SEPARATOR: if (self->entry->data.separator.label) { item_a = ob_rr_theme->a_menu_title; th = ob_rr_theme->menu_title_height; } else { item_a = ob_rr_theme->a_menu_normal; th = ob_rr_theme->menu_sep_width + 2*ob_rr_theme->menu_sep_paddingy; } break; default: g_assert_not_reached(); } RECT_SET_SIZE(self->area, self->frame->inner_w, th); XResizeWindow(obt_display, self->window, self->area.width, self->area.height); item_a->surface.parent = self->frame->a_items; item_a->surface.parentx = self->area.x; item_a->surface.parenty = self->area.y; RrPaint(item_a, self->window, self->area.width, self->area.height); switch (self->entry->type) { case OB_MENU_ENTRY_TYPE_NORMAL: text_a = (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL && !self->entry->data.normal.enabled ? /* disabled */ (self == self->frame->selected ? ob_rr_theme->a_menu_text_disabled_selected : ob_rr_theme->a_menu_text_disabled) : /* enabled */ (self == self->frame->selected ? ob_rr_theme->a_menu_text_selected : ob_rr_theme->a_menu_text_normal)); text_a->texture[0].data.text.string = self->entry->data.normal.label; if (self->entry->data.normal.shortcut && (self->frame->menu->show_all_shortcuts || self->entry->data.normal.shortcut_always_show || self->entry->data.normal.shortcut_position > 0)) { text_a->texture[0].data.text.shortcut = TRUE; text_a->texture[0].data.text.shortcut_pos = self->entry->data.normal.shortcut_position; } else text_a->texture[0].data.text.shortcut = FALSE; break; case OB_MENU_ENTRY_TYPE_SUBMENU: text_a = (self == self->frame->selected ? ob_rr_theme->a_menu_text_selected : ob_rr_theme->a_menu_text_normal); sub = self->entry->data.submenu.submenu; text_a->texture[0].data.text.string = sub ? sub->title : ""; if (sub && sub->shortcut && (self->frame->menu->show_all_shortcuts || sub->shortcut_always_show || sub->shortcut_position > 0)) { text_a->texture[0].data.text.shortcut = TRUE; text_a->texture[0].data.text.shortcut_pos = sub->shortcut_position; } else text_a->texture[0].data.text.shortcut = FALSE; break; case OB_MENU_ENTRY_TYPE_SEPARATOR: if (self->entry->data.separator.label != NULL) { text_a = ob_rr_theme->a_menu_text_title; text_a->texture[0].data.text.string = self->entry->data.separator.label; } else text_a = ob_rr_theme->a_menu_text_normal; break; default: g_assert_not_reached(); } switch (self->entry->type) { case OB_MENU_ENTRY_TYPE_NORMAL: XMoveResizeWindow(obt_display, self->text, self->frame->text_x, PADDING, self->frame->text_w, ITEM_HEIGHT - 2*PADDING); text_a->surface.parent = item_a; text_a->surface.parentx = self->frame->text_x; text_a->surface.parenty = PADDING; RrPaint(text_a, self->text, self->frame->text_w, ITEM_HEIGHT - 2*PADDING); break; case OB_MENU_ENTRY_TYPE_SUBMENU: XMoveResizeWindow(obt_display, self->text, self->frame->text_x, PADDING, self->frame->text_w - ITEM_HEIGHT, ITEM_HEIGHT - 2*PADDING); text_a->surface.parent = item_a; text_a->surface.parentx = self->frame->text_x; text_a->surface.parenty = PADDING; RrPaint(text_a, self->text, self->frame->text_w - ITEM_HEIGHT, ITEM_HEIGHT - 2*PADDING); break; case OB_MENU_ENTRY_TYPE_SEPARATOR: if (self->entry->data.separator.label != NULL) { /* labeled separator */ XMoveResizeWindow(obt_display, self->text, ob_rr_theme->paddingx, ob_rr_theme->paddingy, self->area.width - 2*ob_rr_theme->paddingx, ob_rr_theme->menu_title_height - 2*ob_rr_theme->paddingy); text_a->surface.parent = item_a; text_a->surface.parentx = ob_rr_theme->paddingx; text_a->surface.parenty = ob_rr_theme->paddingy; RrPaint(text_a, self->text, self->area.width - 2*ob_rr_theme->paddingx, ob_rr_theme->menu_title_height - 2*ob_rr_theme->paddingy); } else { gint i; /* unlabeled separator */ XMoveResizeWindow(obt_display, self->text, 0, 0, self->area.width, ob_rr_theme->menu_sep_width + 2*ob_rr_theme->menu_sep_paddingy); a_sep->surface.parent = item_a; a_sep->surface.parentx = 0; a_sep->surface.parenty = 0; for (i = 0; i < ob_rr_theme->menu_sep_width; ++i) { a_sep->texture[i].data.lineart.x1 = ob_rr_theme->menu_sep_paddingx; a_sep->texture[i].data.lineart.y1 = ob_rr_theme->menu_sep_paddingy + i; a_sep->texture[i].data.lineart.x2 = self->area.width - ob_rr_theme->menu_sep_paddingx - 1; a_sep->texture[i].data.lineart.y2 = ob_rr_theme->menu_sep_paddingy + i; } RrPaint(a_sep, self->text, self->area.width, ob_rr_theme->menu_sep_width + 2*ob_rr_theme->menu_sep_paddingy); } break; default: g_assert_not_reached(); } if (((self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL) || (self->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU)) && self->entry->data.normal.icon) { RrAppearance *clear; XMoveResizeWindow(obt_display, self->icon, PADDING, frame->item_margin.top, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom); clear = ob_rr_theme->a_clear_tex; RrAppearanceClearTextures(clear); clear->texture[0].type = RR_TEXTURE_IMAGE; clear->texture[0].data.image.image = self->entry->data.normal.icon; clear->texture[0].data.image.alpha = self->entry->data.normal.icon_alpha; clear->surface.parent = item_a; clear->surface.parentx = PADDING; clear->surface.parenty = frame->item_margin.top; RrPaint(clear, self->icon, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom); XMapWindow(obt_display, self->icon); } else if (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL && self->entry->data.normal.mask) { RrColor *c; RrAppearance *clear; XMoveResizeWindow(obt_display, self->icon, PADDING, frame->item_margin.top, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom); clear = ob_rr_theme->a_clear_tex; RrAppearanceClearTextures(clear); clear->texture[0].type = RR_TEXTURE_MASK; clear->texture[0].data.mask.mask = self->entry->data.normal.mask; c = (self->entry->type == OB_MENU_ENTRY_TYPE_NORMAL && !self->entry->data.normal.enabled ? /* disabled */ (self == self->frame->selected ? self->entry->data.normal.mask_disabled_selected_color : self->entry->data.normal.mask_disabled_color) : /* enabled */ (self == self->frame->selected ? self->entry->data.normal.mask_selected_color : self->entry->data.normal.mask_normal_color)); clear->texture[0].data.mask.color = c; clear->surface.parent = item_a; clear->surface.parentx = PADDING; clear->surface.parenty = frame->item_margin.top; RrPaint(clear, self->icon, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom, ITEM_HEIGHT - frame->item_margin.top - frame->item_margin.bottom); XMapWindow(obt_display, self->icon); } else XUnmapWindow(obt_display, self->icon); if (self->entry->type == OB_MENU_ENTRY_TYPE_SUBMENU) { RrAppearance *bullet_a; XMoveResizeWindow(obt_display, self->bullet, self->frame->text_x + self->frame->text_w - ITEM_HEIGHT + PADDING, PADDING, ITEM_HEIGHT - 2*PADDING, ITEM_HEIGHT - 2*PADDING); bullet_a = (self == self->frame->selected ? ob_rr_theme->a_menu_bullet_selected : ob_rr_theme->a_menu_bullet_normal); bullet_a->surface.parent = item_a; bullet_a->surface.parentx = self->frame->text_x + self->frame->text_w - ITEM_HEIGHT + PADDING; bullet_a->surface.parenty = PADDING; RrPaint(bullet_a, self->bullet, ITEM_HEIGHT - 2*PADDING, ITEM_HEIGHT - 2*PADDING); XMapWindow(obt_display, self->bullet); } else XUnmapWindow(obt_display, self->bullet); XFlush(obt_display); }