diff options
author | Quentin Glidic <sardemff7+git@sardemff7.net> | 2016-06-23 18:55:24 +0200 |
---|---|---|
committer | Daniel Stone <daniels@collabora.com> | 2016-11-21 18:18:04 +0000 |
commit | e7ed60fabe0a4f5e33f0b79364a6f4449b6cfd5c (patch) | |
tree | 08169c78c7eb0afb9763e32a8c08faeb12b9ce09 | |
parent | 51c2c37e0e5bb543f670ee55730ad3edc0861095 (diff) |
desktop-shell/client: Add left/right panel position (basic) support
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
Reviewed-by: Daniel Stone <daniels@collabora.com>
-rw-r--r-- | clients/desktop-shell.c | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/clients/desktop-shell.c b/clients/desktop-shell.c index 49257c2c..a1cf51df 100644 --- a/clients/desktop-shell.c +++ b/clients/desktop-shell.c @@ -98,6 +98,7 @@ struct panel { struct wl_list launcher_list; struct panel_clock *clock; int painted; + enum weston_desktop_shell_panel_position panel_position; enum clock_format clock_format; uint32_t color; }; @@ -470,20 +471,28 @@ panel_resize_handler(struct widget *widget, { struct panel_launcher *launcher; struct panel *panel = data; + int bx = width / 2; int by = height / 2; int spacing = 10; int x = spacing; int y = spacing; int w, h; + int horizontal = panel->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP || panel->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_BOTTOM; wl_list_for_each(launcher, &panel->launcher_list, link) { w = cairo_image_surface_get_width(launcher->icon); h = cairo_image_surface_get_height(launcher->icon); + if (horizontal) y = by - h / 2; + else + x = bx - w / 2; widget_set_allocation(launcher->widget, x, y, w + 1, h + 1); + if (horizontal) x += w + spacing; + else + y += h + spacing; } h = 20; @@ -493,8 +502,13 @@ panel_resize_handler(struct widget *widget, else /* CLOCK_FORMAT_MINUTES */ w = 170; + if (horizontal) { x = width - w - spacing; y = by - h / 2; + } else { + x = bx - w / 2; + y = height - h - spacing; + } if (panel->clock) widget_set_allocation(panel->clock->widget, @@ -507,10 +521,30 @@ panel_configure(void *data, uint32_t edges, struct window *window, int32_t width, int32_t height) { + struct desktop *desktop = data; struct surface *surface = window_get_user_data(window); struct panel *panel = container_of(surface, struct panel, base); + switch (desktop->panel_position) { + case WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP: + case WESTON_DESKTOP_SHELL_PANEL_POSITION_BOTTOM: height = 32; + break; + case WESTON_DESKTOP_SHELL_PANEL_POSITION_LEFT: + case WESTON_DESKTOP_SHELL_PANEL_POSITION_RIGHT: + switch (desktop->clock_format) { + case CLOCK_FORMAT_NONE: + width = 32; + break; + case CLOCK_FORMAT_MINUTES: + width = 170; + break; + case CLOCK_FORMAT_SECONDS: + width = 190; + break; + } + break; + } window_schedule_resize(panel->window, width, height); } @@ -568,6 +602,7 @@ panel_create(struct desktop *desktop) widget_set_redraw_handler(panel->widget, panel_redraw_handler); widget_set_resize_handler(panel->widget, panel_resize_handler); + panel->panel_position = desktop->panel_position; panel->clock_format = desktop->clock_format; if (panel->clock_format != CLOCK_FORMAT_NONE) panel_add_clock(panel); @@ -1343,11 +1378,10 @@ parse_panel_position(struct desktop *desktop, struct weston_config_section *s) free(position); if (desktop->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_TOP - || desktop->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_BOTTOM) { + || desktop->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_BOTTOM + || desktop->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_LEFT + || desktop->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_RIGHT) { desktop->want_panel = 1; - } else if (desktop->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_LEFT - || desktop->panel_position == WESTON_DESKTOP_SHELL_PANEL_POSITION_RIGHT) { - fprintf(stderr, "Unsupported panel position\n"); } } |