mirror of
https://github.com/labwc/labwc.git
synced 2025-11-07 13:30:06 -05:00
ssd: add application title to title bar
This commit is contained in:
parent
5ecf0e1e7e
commit
f857aea8f4
7 changed files with 55 additions and 7 deletions
|
|
@ -321,7 +321,7 @@ cursor_button(struct wl_listener *listener, void *data)
|
|||
desktop_focus_view(&server->seat, view);
|
||||
damage_all_outputs(server);
|
||||
|
||||
if (is_double_click(500) && view_area == LAB_SSD_PART_TITLE) {
|
||||
if (is_double_click(500) && view_area == LAB_SSD_PART_TITLEBAR) {
|
||||
view_toggle_maximize(view);
|
||||
return;
|
||||
}
|
||||
|
|
@ -339,7 +339,7 @@ cursor_button(struct wl_listener *listener, void *data)
|
|||
case LAB_SSD_BUTTON_ICONIFY:
|
||||
view_minimize(view, true);
|
||||
break;
|
||||
case LAB_SSD_PART_TITLE:
|
||||
case LAB_SSD_PART_TITLEBAR:
|
||||
interactive_begin(view, LAB_INPUT_STATE_MOVE, 0);
|
||||
break;
|
||||
case LAB_SSD_BUTTON_MAXIMIZE:
|
||||
|
|
|
|||
|
|
@ -23,6 +23,12 @@ foreign_toplevel_handle_create(struct view *view)
|
|||
{
|
||||
view->toplevel_handle = wlr_foreign_toplevel_handle_v1_create(
|
||||
view->server->foreign_toplevel_manager);
|
||||
if (!view->toplevel_handle) {
|
||||
wlr_log(WLR_ERROR, "cannot create foreign toplevel handle for (%s)",
|
||||
view->impl->get_string_prop(view, "title"));
|
||||
return;
|
||||
}
|
||||
|
||||
view_update_title(view);
|
||||
wlr_foreign_toplevel_handle_v1_output_enter(view->toplevel_handle,
|
||||
view_wlr_output(view));
|
||||
|
|
@ -35,4 +41,5 @@ foreign_toplevel_handle_create(struct view *view)
|
|||
handle_toplevel_handle_request_minimize;
|
||||
wl_signal_add(&view->toplevel_handle->events.request_minimize,
|
||||
&view->toplevel_handle_request_minimize);
|
||||
// TODO: hook up remaining signals
|
||||
}
|
||||
|
|
|
|||
|
|
@ -488,7 +488,7 @@ render_deco(struct view *view, struct output *output,
|
|||
*(part->texture.inactive);
|
||||
render_texture_helper(output, output_damage, &part->box,
|
||||
texture);
|
||||
} else {
|
||||
} else if (part->color.active && part->color.inactive) {
|
||||
float *color = focused ?
|
||||
part->color.active :
|
||||
part->color.inactive;
|
||||
|
|
|
|||
45
src/ssd.c
45
src/ssd.c
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include "config/rcxml.h"
|
||||
#include "common/font.h"
|
||||
#include "labwc.h"
|
||||
#include "theme.h"
|
||||
#include "ssd.h"
|
||||
|
|
@ -63,7 +64,7 @@ ssd_interactive_box(struct view *view, enum ssd_part_type type)
|
|||
box.width = theme->title_height;
|
||||
box.height = theme->title_height;
|
||||
break;
|
||||
case LAB_SSD_PART_TITLE:
|
||||
case LAB_SSD_PART_TITLEBAR:
|
||||
box.x = view->x;
|
||||
box.y = view->y - theme->title_height;
|
||||
box.width = view->w;
|
||||
|
|
@ -138,11 +139,20 @@ ssd_box(struct view *view, enum ssd_part_type type)
|
|||
case LAB_SSD_BUTTON_ICONIFY:
|
||||
box = ssd_interactive_box(view, type);
|
||||
break;
|
||||
case LAB_SSD_PART_TITLE:
|
||||
case LAB_SSD_PART_TITLEBAR:
|
||||
box = ssd_interactive_box(view, type);
|
||||
box.x += theme->title_height;
|
||||
box.width -= 2 * theme->title_height;
|
||||
break;
|
||||
case LAB_SSD_PART_TITLE:
|
||||
box = ssd_box(view, LAB_SSD_PART_TITLEBAR);
|
||||
if (view->title) {
|
||||
/* center align title vertically within allocated box */
|
||||
box.y += (box.height - view->title->height) / 2;
|
||||
box.width = view->title->width;
|
||||
box.height = view->title->height;
|
||||
}
|
||||
break;
|
||||
case LAB_SSD_PART_CORNER_TOP_LEFT:
|
||||
box = ssd_interactive_box(view, type);
|
||||
box.x += INVISIBLE_MARGIN;
|
||||
|
|
@ -231,6 +241,27 @@ add_part(struct view *view, enum ssd_part_type type)
|
|||
return part;
|
||||
}
|
||||
|
||||
void
|
||||
ssd_update_title(struct view *view)
|
||||
{
|
||||
struct theme *theme = view->server->theme;
|
||||
|
||||
/* TODO: use window.active.label.text.color here */
|
||||
/* TODO: set max_width propertly */
|
||||
font_texture_create(view->server, &view->title, 200,
|
||||
view->impl->get_string_prop(view, "title"),
|
||||
rc.font_name_activewindow,
|
||||
theme->menu_items_active_text_color);
|
||||
|
||||
struct ssd_part *part;
|
||||
wl_list_for_each(part, &view->ssd.parts, link) {
|
||||
if (part->type == LAB_SSD_PART_TITLE) {
|
||||
part->box = ssd_box(view, part->type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ssd_create(struct view *view)
|
||||
{
|
||||
|
|
@ -257,11 +288,17 @@ ssd_create(struct view *view)
|
|||
}
|
||||
|
||||
/* titlebar */
|
||||
part = add_part(view, LAB_SSD_PART_TITLE);
|
||||
part->box = ssd_box(view, LAB_SSD_PART_TITLE);
|
||||
part = add_part(view, LAB_SSD_PART_TITLEBAR);
|
||||
part->box = ssd_box(view, LAB_SSD_PART_TITLEBAR);
|
||||
part->color.active = theme->window_active_title_bg_color;
|
||||
part->color.inactive = theme->window_inactive_title_bg_color;
|
||||
|
||||
/* title text */
|
||||
part = add_part(view, LAB_SSD_PART_TITLE);
|
||||
ssd_update_title(view);
|
||||
part->texture.active = &view->title;
|
||||
part->texture.inactive = &view->title;
|
||||
|
||||
/* titlebar top-left corner */
|
||||
part = add_part(view, LAB_SSD_PART_CORNER_TOP_LEFT);
|
||||
part->box = ssd_box(view, part->type);
|
||||
|
|
|
|||
|
|
@ -173,5 +173,6 @@ view_update_title(struct view *view)
|
|||
if (!view->toplevel_handle || !title) {
|
||||
return;
|
||||
}
|
||||
ssd_update_title(view);
|
||||
wlr_foreign_toplevel_handle_v1_set_title(view->toplevel_handle, title);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue