mirror of
https://github.com/swaywm/sway.git
synced 2025-11-12 13:29:56 -05:00
view interface
This commit is contained in:
parent
1156523ccf
commit
0e3eae4baa
8 changed files with 88 additions and 23 deletions
|
|
@ -157,7 +157,7 @@ swayc_t *new_view(swayc_t *sibling, struct sway_view *sway_view) {
|
|||
if (!sway_assert(sibling, "new_view called with NULL sibling/parent")) {
|
||||
return NULL;
|
||||
}
|
||||
const char *title = sway_view->iface.get_prop(sway_view, VIEW_PROP_TITLE);
|
||||
const char *title = view_get_title(sway_view);
|
||||
swayc_t *swayc = new_swayc(C_VIEW);
|
||||
wlr_log(L_DEBUG, "Adding new view %p:%s to container %p %d",
|
||||
swayc, title, sibling, sibling ? sibling->type : 0);
|
||||
|
|
|
|||
|
|
@ -191,8 +191,8 @@ void arrange_windows(swayc_t *container, double width, double height) {
|
|||
{
|
||||
container->width = width;
|
||||
container->height = height;
|
||||
container->sway_view->iface.set_size(container->sway_view,
|
||||
container->width, container->height);
|
||||
view_set_size(container->sway_view,
|
||||
container->width, container->height);
|
||||
wlr_log(L_DEBUG, "Set view to %.f x %.f @ %.f, %.f",
|
||||
container->width, container->height,
|
||||
container->x, container->y);
|
||||
|
|
@ -251,7 +251,7 @@ static void apply_horiz_layout(swayc_t *container,
|
|||
wlr_log(L_DEBUG,
|
||||
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
||||
child, child->type, width, scale);
|
||||
child->sway_view->iface.set_position(child->sway_view, child_x, y);
|
||||
view_set_position(child->sway_view, child_x, y);
|
||||
|
||||
if (i == end - 1) {
|
||||
double remaining_width = x + width - child_x;
|
||||
|
|
@ -301,7 +301,7 @@ void apply_vert_layout(swayc_t *container,
|
|||
wlr_log(L_DEBUG,
|
||||
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
||||
child, child->type, height, scale);
|
||||
child->sway_view->iface.set_position(child->sway_view, x, child_y);
|
||||
view_set_position(child->sway_view, x, child_y);
|
||||
|
||||
if (i == end - 1) {
|
||||
double remaining_height = y + height - child_y;
|
||||
|
|
|
|||
53
sway/tree/view.c
Normal file
53
sway/tree/view.c
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#include "sway/view.h"
|
||||
|
||||
const char *view_get_title(struct sway_view *view) {
|
||||
if (view->iface.get_prop) {
|
||||
return view->iface.get_prop(view, VIEW_PROP_TITLE);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *view_get_app_id(struct sway_view *view) {
|
||||
if (view->iface.get_prop) {
|
||||
return view->iface.get_prop(view, VIEW_PROP_APP_ID);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *view_get_class(struct sway_view *view) {
|
||||
if (view->iface.get_prop) {
|
||||
return view->iface.get_prop(view, VIEW_PROP_CLASS);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const char *view_get_instance(struct sway_view *view) {
|
||||
if (view->iface.get_prop) {
|
||||
return view->iface.get_prop(view, VIEW_PROP_INSTANCE);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void view_set_size(struct sway_view *view, int width, int height) {
|
||||
if (view->iface.set_size) {
|
||||
view->iface.set_size(view, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
void view_set_position(struct sway_view *view, double ox, double oy) {
|
||||
if (view->iface.set_position) {
|
||||
view->iface.set_position(view, ox, oy);
|
||||
}
|
||||
}
|
||||
|
||||
void view_set_activated(struct sway_view *view, bool activated) {
|
||||
if (view->iface.set_activated) {
|
||||
view->iface.set_activated(view, activated);
|
||||
}
|
||||
}
|
||||
|
||||
void view_close(struct sway_view *view) {
|
||||
if (view->iface.close) {
|
||||
view->iface.close(view);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue