view interface
This commit is contained in:
parent
1156523ccf
commit
0e3eae4baa
|
@ -99,4 +99,20 @@ struct sway_view {
|
||||||
struct wl_list unmanaged_view_link; // sway_root::unmanaged views
|
struct wl_list unmanaged_view_link; // sway_root::unmanaged views
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const char *view_get_title(struct sway_view *view);
|
||||||
|
|
||||||
|
const char *view_get_app_id(struct sway_view *view);
|
||||||
|
|
||||||
|
const char *view_get_class(struct sway_view *view);
|
||||||
|
|
||||||
|
const char *view_get_instance(struct sway_view *view);
|
||||||
|
|
||||||
|
void view_set_size(struct sway_view *view, int width, int height);
|
||||||
|
|
||||||
|
void view_set_position(struct sway_view *view, double ox, double oy);
|
||||||
|
|
||||||
|
void view_set_activated(struct sway_view *view, bool activated);
|
||||||
|
|
||||||
|
void view_close(struct sway_view *view);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,8 +15,8 @@ struct cmd_results *cmd_kill(int argc, char **argv) {
|
||||||
struct sway_view *view =
|
struct sway_view *view =
|
||||||
config->handler_context.current_container->sway_view;
|
config->handler_context.current_container->sway_view;
|
||||||
|
|
||||||
if (view && view->iface.close) {
|
if (view) {
|
||||||
view->iface.close(view);
|
view_close(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
|
|
@ -299,13 +299,8 @@ static bool criteria_test(swayc_t *cont, list_t *tokens) {
|
||||||
case CRIT_ID: // TODO
|
case CRIT_ID: // TODO
|
||||||
break;
|
break;
|
||||||
case CRIT_APP_ID:
|
case CRIT_APP_ID:
|
||||||
if (!view->iface.get_prop) {
|
{
|
||||||
break;
|
const char *app_id = view_get_app_id(cont->sway_view);
|
||||||
}
|
|
||||||
|
|
||||||
const char *app_id =
|
|
||||||
cont->sway_view->iface.get_prop(view, VIEW_PROP_APP_ID);
|
|
||||||
|
|
||||||
if (!app_id) {
|
if (!app_id) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -314,6 +309,7 @@ static bool criteria_test(swayc_t *cont, list_t *tokens) {
|
||||||
matches++;
|
matches++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case CRIT_INSTANCE: // TODO
|
case CRIT_INSTANCE: // TODO
|
||||||
break;
|
break;
|
||||||
case CRIT_TILING: // TODO
|
case CRIT_TILING: // TODO
|
||||||
|
|
|
@ -214,7 +214,7 @@ void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container) {
|
||||||
|
|
||||||
if (container) {
|
if (container) {
|
||||||
struct sway_view *view = container->sway_view;
|
struct sway_view *view = container->sway_view;
|
||||||
view->iface.set_activated(view, true);
|
view_set_activated(view, true);
|
||||||
wl_signal_add(&container->events.destroy, &seat->focus_destroy);
|
wl_signal_add(&container->events.destroy, &seat->focus_destroy);
|
||||||
seat->focus_destroy.notify = handle_focus_destroy;
|
seat->focus_destroy.notify = handle_focus_destroy;
|
||||||
|
|
||||||
|
@ -234,8 +234,7 @@ void sway_seat_set_focus(struct sway_seat *seat, swayc_t *container) {
|
||||||
if (last_focus &&
|
if (last_focus &&
|
||||||
!sway_input_manager_has_focus(seat->input, last_focus)) {
|
!sway_input_manager_has_focus(seat->input, last_focus)) {
|
||||||
struct sway_view *view = last_focus->sway_view;
|
struct sway_view *view = last_focus->sway_view;
|
||||||
view->iface.set_activated(view, false);
|
view_set_activated(view, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ sway_sources = files(
|
||||||
'security.c',
|
'security.c',
|
||||||
'tree/container.c',
|
'tree/container.c',
|
||||||
'tree/layout.c',
|
'tree/layout.c',
|
||||||
|
'tree/view.c',
|
||||||
'tree/workspace.c',
|
'tree/workspace.c',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -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")) {
|
if (!sway_assert(sibling, "new_view called with NULL sibling/parent")) {
|
||||||
return NULL;
|
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);
|
swayc_t *swayc = new_swayc(C_VIEW);
|
||||||
wlr_log(L_DEBUG, "Adding new view %p:%s to container %p %d",
|
wlr_log(L_DEBUG, "Adding new view %p:%s to container %p %d",
|
||||||
swayc, title, sibling, sibling ? sibling->type : 0);
|
swayc, title, sibling, sibling ? sibling->type : 0);
|
||||||
|
|
|
@ -191,7 +191,7 @@ void arrange_windows(swayc_t *container, double width, double height) {
|
||||||
{
|
{
|
||||||
container->width = width;
|
container->width = width;
|
||||||
container->height = height;
|
container->height = height;
|
||||||
container->sway_view->iface.set_size(container->sway_view,
|
view_set_size(container->sway_view,
|
||||||
container->width, container->height);
|
container->width, container->height);
|
||||||
wlr_log(L_DEBUG, "Set view to %.f x %.f @ %.f, %.f",
|
wlr_log(L_DEBUG, "Set view to %.f x %.f @ %.f, %.f",
|
||||||
container->width, container->height,
|
container->width, container->height,
|
||||||
|
@ -251,7 +251,7 @@ static void apply_horiz_layout(swayc_t *container,
|
||||||
wlr_log(L_DEBUG,
|
wlr_log(L_DEBUG,
|
||||||
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
||||||
child, child->type, width, scale);
|
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) {
|
if (i == end - 1) {
|
||||||
double remaining_width = x + width - child_x;
|
double remaining_width = x + width - child_x;
|
||||||
|
@ -301,7 +301,7 @@ void apply_vert_layout(swayc_t *container,
|
||||||
wlr_log(L_DEBUG,
|
wlr_log(L_DEBUG,
|
||||||
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
||||||
child, child->type, height, scale);
|
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) {
|
if (i == end - 1) {
|
||||||
double remaining_height = y + height - child_y;
|
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…
Reference in a new issue