window.c: Don't put titlebars on menu windows
This commit is contained in:
+1
-1
@@ -4456,7 +4456,7 @@ window_show_menu(struct display *display,
|
|||||||
window_set_buffer_scale (menu->window, window_get_buffer_scale (parent));
|
window_set_buffer_scale (menu->window, window_get_buffer_scale (parent));
|
||||||
window_set_buffer_transform (menu->window, window_get_buffer_transform (parent));
|
window_set_buffer_transform (menu->window, window_get_buffer_transform (parent));
|
||||||
menu->frame = frame_create(window->display->theme, 0, 0,
|
menu->frame = frame_create(window->display->theme, 0, 0,
|
||||||
FRAME_BUTTON_NONE, "Menu");
|
FRAME_BUTTON_NONE, NULL);
|
||||||
menu->entries = entries;
|
menu->entries = entries;
|
||||||
menu->count = count;
|
menu->count = count;
|
||||||
menu->release_count = 0;
|
menu->release_count = 0;
|
||||||
|
|||||||
+16
-4
@@ -418,7 +418,7 @@ theme_render_frame(struct theme *t,
|
|||||||
cairo_text_extents_t extents;
|
cairo_text_extents_t extents;
|
||||||
cairo_font_extents_t font_extents;
|
cairo_font_extents_t font_extents;
|
||||||
cairo_surface_t *source;
|
cairo_surface_t *source;
|
||||||
int x, y, margin;
|
int x, y, margin, top_margin;
|
||||||
|
|
||||||
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
|
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
|
||||||
cairo_set_source_rgba(cr, 0, 0, 0, 0);
|
cairo_set_source_rgba(cr, 0, 0, 0, 0);
|
||||||
@@ -439,11 +439,17 @@ theme_render_frame(struct theme *t,
|
|||||||
else
|
else
|
||||||
source = t->inactive_frame;
|
source = t->inactive_frame;
|
||||||
|
|
||||||
|
if (title)
|
||||||
|
top_margin = t->titlebar_height;
|
||||||
|
else
|
||||||
|
top_margin = t->width;
|
||||||
|
|
||||||
tile_source(cr, source,
|
tile_source(cr, source,
|
||||||
margin, margin,
|
margin, margin,
|
||||||
width - margin * 2, height - margin * 2,
|
width - margin * 2, height - margin * 2,
|
||||||
t->width, t->titlebar_height);
|
t->width, top_margin);
|
||||||
|
|
||||||
|
if (title) {
|
||||||
cairo_rectangle (cr, margin + t->width, margin,
|
cairo_rectangle (cr, margin + t->width, margin,
|
||||||
width - (margin + t->width) * 2,
|
width - (margin + t->width) * 2,
|
||||||
t->titlebar_height - t->width);
|
t->titlebar_height - t->width);
|
||||||
@@ -474,6 +480,7 @@ theme_render_frame(struct theme *t,
|
|||||||
cairo_set_source_rgb(cr, 0.4, 0.4, 0.4);
|
cairo_set_source_rgb(cr, 0.4, 0.4, 0.4);
|
||||||
cairo_show_text(cr, title);
|
cairo_show_text(cr, title);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum theme_location
|
enum theme_location
|
||||||
@@ -482,10 +489,15 @@ theme_get_location(struct theme *t, int x, int y,
|
|||||||
{
|
{
|
||||||
int vlocation, hlocation, location;
|
int vlocation, hlocation, location;
|
||||||
const int grip_size = 8;
|
const int grip_size = 8;
|
||||||
int margin;
|
int margin, top_margin;
|
||||||
|
|
||||||
margin = (flags & THEME_FRAME_MAXIMIZED) ? 0 : t->margin;
|
margin = (flags & THEME_FRAME_MAXIMIZED) ? 0 : t->margin;
|
||||||
|
|
||||||
|
if (flags & THEME_FRAME_NO_TITLE)
|
||||||
|
top_margin = t->width;
|
||||||
|
else
|
||||||
|
top_margin = t->titlebar_height;
|
||||||
|
|
||||||
if (x < margin)
|
if (x < margin)
|
||||||
hlocation = THEME_LOCATION_EXTERIOR;
|
hlocation = THEME_LOCATION_EXTERIOR;
|
||||||
else if (margin <= x && x < margin + grip_size)
|
else if (margin <= x && x < margin + grip_size)
|
||||||
@@ -512,7 +524,7 @@ theme_get_location(struct theme *t, int x, int y,
|
|||||||
if (location & THEME_LOCATION_EXTERIOR)
|
if (location & THEME_LOCATION_EXTERIOR)
|
||||||
location = THEME_LOCATION_EXTERIOR;
|
location = THEME_LOCATION_EXTERIOR;
|
||||||
if (location == THEME_LOCATION_INTERIOR &&
|
if (location == THEME_LOCATION_INTERIOR &&
|
||||||
y < margin + t->titlebar_height)
|
y < margin + top_margin)
|
||||||
location = THEME_LOCATION_TITLEBAR;
|
location = THEME_LOCATION_TITLEBAR;
|
||||||
else if (location == THEME_LOCATION_INTERIOR)
|
else if (location == THEME_LOCATION_INTERIOR)
|
||||||
location = THEME_LOCATION_CLIENT_AREA;
|
location = THEME_LOCATION_CLIENT_AREA;
|
||||||
|
|||||||
+2
-1
@@ -60,7 +60,8 @@ theme_destroy(struct theme *t);
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
THEME_FRAME_ACTIVE = 1,
|
THEME_FRAME_ACTIVE = 1,
|
||||||
THEME_FRAME_MAXIMIZED,
|
THEME_FRAME_MAXIMIZED = 2,
|
||||||
|
THEME_FRAME_NO_TITLE = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
+22
-10
@@ -291,11 +291,14 @@ frame_create(struct theme *t, int32_t width, int32_t height, uint32_t buttons,
|
|||||||
wl_list_init(&frame->pointers);
|
wl_list_init(&frame->pointers);
|
||||||
wl_list_init(&frame->touches);
|
wl_list_init(&frame->touches);
|
||||||
|
|
||||||
button = frame_button_create(frame, DATADIR "/weston/icon_window.png",
|
if (title) {
|
||||||
|
button = frame_button_create(frame,
|
||||||
|
DATADIR "/weston/icon_window.png",
|
||||||
FRAME_STATUS_MENU,
|
FRAME_STATUS_MENU,
|
||||||
FRAME_BUTTON_CLICK_DOWN);
|
FRAME_BUTTON_CLICK_DOWN);
|
||||||
if (!button)
|
if (!button)
|
||||||
goto free_frame;
|
goto free_frame;
|
||||||
|
}
|
||||||
|
|
||||||
if (buttons & FRAME_BUTTON_CLOSE) {
|
if (buttons & FRAME_BUTTON_CLOSE) {
|
||||||
button = frame_button_create(frame,
|
button = frame_button_create(frame,
|
||||||
@@ -400,15 +403,20 @@ void
|
|||||||
frame_resize_inside(struct frame *frame, int32_t width, int32_t height)
|
frame_resize_inside(struct frame *frame, int32_t width, int32_t height)
|
||||||
{
|
{
|
||||||
struct theme *t = frame->theme;
|
struct theme *t = frame->theme;
|
||||||
int decoration_width, decoration_height;
|
int decoration_width, decoration_height, titlebar_height;
|
||||||
|
|
||||||
|
if (frame->title)
|
||||||
|
titlebar_height = t->titlebar_height;
|
||||||
|
else
|
||||||
|
titlebar_height = t->width;
|
||||||
|
|
||||||
if (frame->flags & FRAME_FLAG_MAXIMIZED) {
|
if (frame->flags & FRAME_FLAG_MAXIMIZED) {
|
||||||
decoration_width = t->width * 2;
|
decoration_width = t->width * 2;
|
||||||
decoration_height = t->width + t->titlebar_height;
|
decoration_height = t->width + titlebar_height;
|
||||||
} else {
|
} else {
|
||||||
decoration_width = (t->width + t->margin) * 2;
|
decoration_width = (t->width + t->margin) * 2;
|
||||||
decoration_height = t->width +
|
decoration_height = t->width +
|
||||||
t->titlebar_height + t->margin * 2;
|
titlebar_height + t->margin * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
frame_resize(frame, width + decoration_width,
|
frame_resize(frame, width + decoration_width,
|
||||||
@@ -432,18 +440,23 @@ frame_refresh_geometry(struct frame *frame)
|
|||||||
{
|
{
|
||||||
struct frame_button *button;
|
struct frame_button *button;
|
||||||
struct theme *t = frame->theme;
|
struct theme *t = frame->theme;
|
||||||
int x_l, x_r, y, w, h;
|
int x_l, x_r, y, w, h, titlebar_height;
|
||||||
int32_t decoration_width, decoration_height;
|
int32_t decoration_width, decoration_height;
|
||||||
|
|
||||||
if (!frame->geometry_dirty)
|
if (!frame->geometry_dirty)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (frame->title)
|
||||||
|
titlebar_height = t->titlebar_height;
|
||||||
|
else
|
||||||
|
titlebar_height = t->width;
|
||||||
|
|
||||||
if (frame->flags & FRAME_FLAG_MAXIMIZED) {
|
if (frame->flags & FRAME_FLAG_MAXIMIZED) {
|
||||||
decoration_width = t->width * 2;
|
decoration_width = t->width * 2;
|
||||||
decoration_height = t->width + t->titlebar_height;
|
decoration_height = t->width + titlebar_height;
|
||||||
|
|
||||||
frame->interior.x = t->width;
|
frame->interior.x = t->width;
|
||||||
frame->interior.y = t->titlebar_height;
|
frame->interior.y = titlebar_height;
|
||||||
frame->interior.width = frame->width - decoration_width;
|
frame->interior.width = frame->width - decoration_width;
|
||||||
frame->interior.height = frame->height - decoration_height;
|
frame->interior.height = frame->height - decoration_height;
|
||||||
|
|
||||||
@@ -451,11 +464,10 @@ frame_refresh_geometry(struct frame *frame)
|
|||||||
frame->shadow_margin = 0;
|
frame->shadow_margin = 0;
|
||||||
} else {
|
} else {
|
||||||
decoration_width = (t->width + t->margin) * 2;
|
decoration_width = (t->width + t->margin) * 2;
|
||||||
decoration_height = t->width +
|
decoration_height = t->width + titlebar_height + t->margin * 2;
|
||||||
t->titlebar_height + t->margin * 2;
|
|
||||||
|
|
||||||
frame->interior.x = t->width + t->margin;
|
frame->interior.x = t->width + t->margin;
|
||||||
frame->interior.y = t->titlebar_height + t->margin;
|
frame->interior.y = titlebar_height + t->margin;
|
||||||
frame->interior.width = frame->width - decoration_width;
|
frame->interior.width = frame->width - decoration_width;
|
||||||
frame->interior.height = frame->height - decoration_height;
|
frame->interior.height = frame->height - decoration_height;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user