xwm: Deal with title in a smarter way when there isn't enough space
The title in X11 windows and Wayland application using Weston toy
toolkit were placing the title in a very naive fashion. It was
only try to center the string in the title bar. This patch:
* Makes sure the title isn't renderer underneath buttons;
* Move the title to the left if the titlebar isn't large enough;
* Clip the end of the title if needed.
Signed-off-by: Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
diff --git a/shared/frame.c b/shared/frame.c
index eb0cd77..5ca7e08 100644
--- a/shared/frame.c
+++ b/shared/frame.c
@@ -98,6 +98,8 @@
int opaque_margin;
int geometry_dirty;
+ cairo_rectangle_int_t title_rect;
+
uint32_t status;
struct wl_list buttons;
@@ -532,6 +534,11 @@
}
}
+ frame->title_rect.x = x_l;
+ frame->title_rect.y = y;
+ frame->title_rect.width = x_r - x_l;
+ frame->title_rect.height = titlebar_height;
+
frame->geometry_dirty = 0;
}
@@ -938,7 +945,8 @@
cairo_save(cr);
theme_render_frame(frame->theme, cr, frame->width, frame->height,
- frame->title, &frame->buttons, flags);
+ frame->title, &frame->title_rect,
+ &frame->buttons, flags);
cairo_restore(cr);
wl_list_for_each(button, &frame->buttons, link)