#include "window-rules.h"
#include "workspaces.h"
-#define OSD_ITEM_HEIGHT (20)
-#define OSD_ITEM_WIDTH (600)
-#define OSD_ITEM_PADDING (10)
-
/* is title different from app_id/class? */
static int
is_title_different(struct view *view)
if (!isfocusable(view) || skip == LAB_PROP_TRUE) {
continue;
}
- height += OSD_ITEM_HEIGHT;
+ height += rc.theme->osd_window_switcher_item_height;
}
height += 2 * rc.theme->osd_border_width;
return height;
draw_cairo_border(cairo, w, h, theme->osd_border_width);
/* Set up text rendering */
+ int item_width = w - 2 * theme->osd_border_width;
set_cairo_color(cairo, theme->osd_label_text_color);
PangoLayout *layout = pango_cairo_create_layout(cairo);
- pango_layout_set_width(layout,
- (OSD_ITEM_WIDTH - 2 * OSD_ITEM_PADDING) * PANGO_SCALE);
pango_layout_set_ellipsize(layout, PANGO_ELLIPSIZE_END);
PangoFontDescription *desc = font_to_pango_desc(&rc.font_osd);
int y = theme->osd_border_width;
- /* Center text entries on the y axis */
- int y_offset = (OSD_ITEM_HEIGHT - font_height(&rc.font_osd)) / 2;
- y += y_offset;
-
/* Draw workspace indicator */
if (show_workspace) {
/* Center workspace indicator on the x axis */
int x = font_width(&rc.font_osd, workspace_name);
- x = (OSD_ITEM_WIDTH - x) / 2;
+ x = (theme->osd_window_switcher_width - x) / 2;
cairo_move_to(cairo, x, y);
PangoWeight weight = pango_font_description_get_weight(desc);
pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
pango_cairo_show_layout(cairo, layout);
pango_font_description_set_weight(desc, weight);
pango_layout_set_font_description(layout, desc);
- y += OSD_ITEM_HEIGHT;
+ y += theme->osd_window_switcher_item_height;
}
pango_font_description_free(desc);
continue;
}
- int x = theme->osd_border_width + OSD_ITEM_PADDING;
+ int x = theme->osd_border_width + theme->osd_window_switcher_item_padding_x;
struct window_switcher_field *field;
wl_list_for_each(field, &rc.window_switcher.fields, link) {
buf.len = 0;
- cairo_move_to(cairo, x, y);
+ cairo_move_to(cairo, x, y + theme->osd_window_switcher_item_padding_y - 1);
switch (field->content) {
case LAB_FIELD_TYPE:
default:
break;
}
- int field_width = field->width / 100.0 * OSD_ITEM_WIDTH;
+ int field_width = field->width / 100.0 * item_width
+ - 2 * theme->osd_window_switcher_item_padding_x;
pango_layout_set_width(layout, field_width * PANGO_SCALE);
pango_layout_set_text(layout, buf.buf, -1);
pango_cairo_show_layout(cairo, layout);
- x += field_width;
+ x += field_width + theme->osd_window_switcher_item_padding_x;
}
if (view == cycle_view) {
/* Highlight current window */
- cairo_rectangle(cairo, theme->osd_border_width,
- y - y_offset, OSD_ITEM_WIDTH, OSD_ITEM_HEIGHT);
+ cairo_rectangle(cairo, theme->osd_border_width, y,
+ theme->osd_window_switcher_width - 2 * theme->osd_border_width,
+ theme->osd_window_switcher_item_height);
cairo_stroke(cairo);
}
- y += OSD_ITEM_HEIGHT;
+ y += theme->osd_window_switcher_item_height;
}
free(buf.buf);
g_object_unref(layout);
display_osd(struct output *output)
{
struct server *server = output->server;
+ struct theme *theme = server->theme;
struct wl_list *node_list =
&server->workspace_current->tree->children;
bool show_workspace = wl_list_length(&rc.workspace_config.workspaces) > 1;
const char *workspace_name = server->workspace_current->name;
float scale = output->wlr_output->scale;
- int w = OSD_ITEM_WIDTH + (2 * server->theme->osd_border_width);
+ int w = theme->osd_window_switcher_width;
int h = get_osd_height(node_list);
if (show_workspace) {
/* workspace indicator */
- h += OSD_ITEM_HEIGHT;
+ h += theme->osd_window_switcher_item_height;
}
/* Reset buffer */
theme->menu_separator_padding_height = 3;
parse_hexstr("#888888", theme->menu_separator_color);
+ theme->osd_window_switcher_width = 600;
+ theme->osd_window_switcher_item_padding_x = 10;
+ theme->osd_window_switcher_item_padding_y = 6;
+
/* inherit settings in post_processing() if not set elsewhere */
theme->osd_bg_color[0] = FLT_MIN;
theme->osd_border_width = INT_MIN;
if (match_glob(key, "osd.border.color")) {
parse_hexstr(value, theme->osd_border_color);
}
+ if (match_glob(key, "osd.window-switcher.width")) {
+ theme->osd_window_switcher_width = atoi(value);
+ }
+ if (match_glob(key, "osd.window-switcher.item.padding.x")) {
+ theme->osd_window_switcher_item_padding_x = atoi(value);
+ }
+ if (match_glob(key, "osd.window-switcher.item.padding.y")) {
+ theme->osd_window_switcher_item_padding_y = atoi(value);
+ }
if (match_glob(key, "osd.label.text.color")) {
parse_hexstr(value, theme->osd_label_text_color);
}
{
theme->title_height = font_height(&rc.font_activewindow)
+ 2 * theme->padding_height;
+ theme->osd_window_switcher_item_height = font_height(&rc.font_osd)
+ + 2 * theme->osd_window_switcher_item_padding_y;
if (rc.corner_radius >= theme->title_height) {
theme->title_height = rc.corner_radius + 1;