mirror of
https://github.com/labwc/labwc.git
synced 2026-03-07 04:33:54 -05:00
view: add view_get_string_prop()
This commit is contained in:
parent
40bd8f56d4
commit
806fdb08bd
5 changed files with 26 additions and 15 deletions
|
|
@ -362,6 +362,7 @@ void view_for_each_popup_surface(struct view *view,
|
||||||
wlr_surface_iterator_func_t iterator, void *data);
|
wlr_surface_iterator_func_t iterator, void *data);
|
||||||
void view_move_to_edge(struct view *view, const char *direction);
|
void view_move_to_edge(struct view *view, const char *direction);
|
||||||
void view_snap_to_edge(struct view *view, const char *direction);
|
void view_snap_to_edge(struct view *view, const char *direction);
|
||||||
|
const char *view_get_string_prop(struct view *view, const char *prop);
|
||||||
void view_update_title(struct view *view);
|
void view_update_title(struct view *view);
|
||||||
void view_update_app_id(struct view *view);
|
void view_update_app_id(struct view *view);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,14 @@ foreign_toplevel_handle_create(struct view *view)
|
||||||
view->server->foreign_toplevel_manager);
|
view->server->foreign_toplevel_manager);
|
||||||
if (!view->toplevel_handle) {
|
if (!view->toplevel_handle) {
|
||||||
wlr_log(WLR_ERROR, "cannot create foreign toplevel handle for (%s)",
|
wlr_log(WLR_ERROR, "cannot create foreign toplevel handle for (%s)",
|
||||||
view->impl->get_string_prop(view, "title"));
|
view_get_string_prop(view, "title"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_output *wlr_output = view_wlr_output(view);
|
struct wlr_output *wlr_output = view_wlr_output(view);
|
||||||
if (!wlr_output) {
|
if (!wlr_output) {
|
||||||
wlr_log(WLR_ERROR, "no wlr_output for (%s)",
|
wlr_log(WLR_ERROR, "no wlr_output for (%s)",
|
||||||
view->impl->get_string_prop(view, "title"));
|
view_get_string_prop(view, "title"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wlr_foreign_toplevel_handle_v1_output_enter(view->toplevel_handle,
|
wlr_foreign_toplevel_handle_v1_output_enter(view->toplevel_handle,
|
||||||
|
|
|
||||||
12
src/osd.c
12
src/osd.c
|
|
@ -29,11 +29,11 @@ is_title_different(struct view *view)
|
||||||
{
|
{
|
||||||
switch (view->type) {
|
switch (view->type) {
|
||||||
case LAB_XDG_SHELL_VIEW:
|
case LAB_XDG_SHELL_VIEW:
|
||||||
return strcmp(view->impl->get_string_prop(view, "title"),
|
return strcmp(view_get_string_prop(view, "title"),
|
||||||
view->impl->get_string_prop(view, "app_id"));
|
view_get_string_prop(view, "app_id"));
|
||||||
#if HAVE_XWAYLAND
|
#if HAVE_XWAYLAND
|
||||||
case LAB_XWAYLAND_VIEW:
|
case LAB_XWAYLAND_VIEW:
|
||||||
return strcmp(view->impl->get_string_prop(view, "title"),
|
return strcmp(view_get_string_prop(view, "title"),
|
||||||
view->xwayland_surface->class);
|
view->xwayland_surface->class);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -43,7 +43,7 @@ is_title_different(struct view *view)
|
||||||
static const char *
|
static const char *
|
||||||
get_formatted_app_id(struct view *view)
|
get_formatted_app_id(struct view *view)
|
||||||
{
|
{
|
||||||
char *s = (char *)view->impl->get_string_prop(view, "app_id");
|
char *s = (char *)view_get_string_prop(view, "app_id");
|
||||||
/* remove the first two nodes of 'org.' strings */
|
/* remove the first two nodes of 'org.' strings */
|
||||||
if (!strncmp(s, "org.", 4)) {
|
if (!strncmp(s, "org.", 4)) {
|
||||||
char *p = s + 4;
|
char *p = s + 4;
|
||||||
|
|
@ -156,14 +156,14 @@ osd_update(struct server *server)
|
||||||
#if HAVE_XWAYLAND
|
#if HAVE_XWAYLAND
|
||||||
case LAB_XWAYLAND_VIEW:
|
case LAB_XWAYLAND_VIEW:
|
||||||
buf_add(&buf, "[xwayland]\t");
|
buf_add(&buf, "[xwayland]\t");
|
||||||
buf_add(&buf, view->impl->get_string_prop(view, "class"));
|
buf_add(&buf, view_get_string_prop(view, "class"));
|
||||||
buf_add(&buf, "\t");
|
buf_add(&buf, "\t");
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_title_different(view)) {
|
if (is_title_different(view)) {
|
||||||
buf_add(&buf, view->impl->get_string_prop(view, "title"));
|
buf_add(&buf, view_get_string_prop(view, "title"));
|
||||||
}
|
}
|
||||||
|
|
||||||
pango_layout_set_text(layout, buf.buf, -1);
|
pango_layout_set_text(layout, buf.buf, -1);
|
||||||
|
|
|
||||||
12
src/ssd.c
12
src/ssd.c
|
|
@ -151,7 +151,8 @@ center_vertically(struct wlr_box *box, struct wlr_texture *texture)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
center_horizontally(struct view *view, struct wlr_box *box, struct wlr_texture *texture)
|
center_horizontally(struct view *view, struct wlr_box *box,
|
||||||
|
struct wlr_texture *texture)
|
||||||
{
|
{
|
||||||
if (!texture) {
|
if (!texture) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -160,7 +161,8 @@ center_horizontally(struct view *view, struct wlr_box *box, struct wlr_texture *
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
justify_right(struct view *view, struct wlr_box *box, struct wlr_texture *texture)
|
justify_right(struct view *view, struct wlr_box *box,
|
||||||
|
struct wlr_texture *texture)
|
||||||
{
|
{
|
||||||
if (!texture) {
|
if (!texture) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -193,7 +195,7 @@ ssd_visible_box(struct view *view, enum ssd_part_type type)
|
||||||
center_vertically(&box, view->title.active);
|
center_vertically(&box, view->title.active);
|
||||||
if (theme->window_label_text_justify == LAB_JUSTIFY_CENTER) {
|
if (theme->window_label_text_justify == LAB_JUSTIFY_CENTER) {
|
||||||
center_horizontally(view, &box, view->title.active);
|
center_horizontally(view, &box, view->title.active);
|
||||||
} else if (theme->window_label_text_justify == LAB_JUSTIFY_RIGHT) {
|
} else if (theme->window_label_text_justify == LAB_JUSTIFY_RIGHT) {
|
||||||
justify_right(view, &box, view->title.active);
|
justify_right(view, &box, view->title.active);
|
||||||
}
|
}
|
||||||
if (view->title.active) {
|
if (view->title.active) {
|
||||||
|
|
@ -313,11 +315,11 @@ ssd_update_title(struct view *view)
|
||||||
int max_width = part->box.width > 0 ? part->box.width : 1000;
|
int max_width = part->box.width > 0 ? part->box.width : 1000;
|
||||||
|
|
||||||
font_texture_create(view->server, &view->title.active, max_width,
|
font_texture_create(view->server, &view->title.active, max_width,
|
||||||
view->impl->get_string_prop(view, "title"),
|
view_get_string_prop(view, "title"),
|
||||||
&font, theme->window_active_label_text_color);
|
&font, theme->window_active_label_text_color);
|
||||||
|
|
||||||
font_texture_create(view->server, &view->title.inactive, max_width,
|
font_texture_create(view->server, &view->title.inactive, max_width,
|
||||||
view->impl->get_string_prop(view, "title"),
|
view_get_string_prop(view, "title"),
|
||||||
&font, theme->window_inactive_label_text_color);
|
&font, theme->window_inactive_label_text_color);
|
||||||
|
|
||||||
part->box = ssd_visible_box(view, part->type);
|
part->box = ssd_visible_box(view, part->type);
|
||||||
|
|
|
||||||
12
src/view.c
12
src/view.c
|
|
@ -398,10 +398,18 @@ view_snap_to_edge(struct view *view, const char *direction)
|
||||||
view_move_resize(view, dst);
|
view_move_resize(view, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
view_get_string_prop(struct view *view, const char *prop)
|
||||||
|
{
|
||||||
|
if (view->impl->get_string_prop) {
|
||||||
|
return view->impl->get_string_prop(view, "title");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
view_update_title(struct view *view)
|
view_update_title(struct view *view)
|
||||||
{
|
{
|
||||||
const char *title = view->impl->get_string_prop(view, "title");
|
const char *title = view_get_string_prop(view, "title");
|
||||||
if (!view->toplevel_handle || !title) {
|
if (!view->toplevel_handle || !title) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -412,7 +420,7 @@ view_update_title(struct view *view)
|
||||||
void
|
void
|
||||||
view_update_app_id(struct view *view)
|
view_update_app_id(struct view *view)
|
||||||
{
|
{
|
||||||
const char *app_id = view->impl->get_string_prop(view, "app_id");
|
const char *app_id = view_get_string_prop(view, "app_id");
|
||||||
if (!view->toplevel_handle || !app_id) {
|
if (!view->toplevel_handle || !app_id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue