From e67f3543332349e63b5099a241fdd85ce28ea54b Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 30 Apr 2018 21:24:13 +1000 Subject: Implement borders Implements rendering of borders. Title text is still to do. Implements the following configuration directives: * client.focused * client.focused_inactive * client.unfocused * client.urgent * border * default_border --- include/sway/tree/container.h | 2 +- include/sway/tree/view.h | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'include/sway/tree') diff --git a/include/sway/tree/container.h b/include/sway/tree/container.h index 9c921fc4..d092af49 100644 --- a/include/sway/tree/container.h +++ b/include/sway/tree/container.h @@ -72,8 +72,8 @@ struct sway_container { // For C_ROOT, this has no meaning // For C_OUTPUT, this is the output position in layout coordinates // For other types, this is the position in output-local coordinates + // Includes borders double x, y; - // does not include borders or gaps. double width, height; double saved_width, saved_height; diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index a4ad9971..352a62bc 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -41,9 +41,16 @@ struct sway_view { struct sway_container *swayc; // NULL for unmapped views struct wlr_surface *surface; // NULL for unmapped views + + // Geometry of the view itself (excludes borders) + double x, y; int width, height; + bool is_fullscreen; + enum sway_container_border border; + int border_thickness; + union { struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6; struct wlr_xwayland_surface *wlr_xwayland_surface; @@ -160,6 +167,8 @@ const char *view_get_instance(struct sway_view *view); void view_configure(struct sway_view *view, double ox, double oy, int width, int height); +void view_autoconfigure(struct sway_view *view); + void view_set_activated(struct sway_view *view, bool activated); void view_set_fullscreen_raw(struct sway_view *view, bool fullscreen); @@ -184,8 +193,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface); void view_unmap(struct sway_view *view); -void view_update_position(struct sway_view *view, double ox, double oy); - void view_update_size(struct sway_view *view, int width, int height); void view_child_init(struct sway_view_child *child, -- cgit v1.2.3 From abcad0ece9290233652832de17b3ad3e13263c29 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 1 May 2018 17:36:12 +1000 Subject: Move docblock and fix indenting of switch/case. --- include/sway/tree/view.h | 4 ++++ sway/tree/view.c | 42 +++++++++++++++++++----------------------- 2 files changed, 23 insertions(+), 23 deletions(-) (limited to 'include/sway/tree') diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 352a62bc..4395e94a 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -167,6 +167,10 @@ const char *view_get_instance(struct sway_view *view); void view_configure(struct sway_view *view, double ox, double oy, int width, int height); +/** + * Configure the view's position and size based on the swayc's position and + * size, taking borders into consideration. + */ void view_autoconfigure(struct sway_view *view); void view_set_activated(struct sway_view *view, bool activated); diff --git a/sway/tree/view.c b/sway/tree/view.c index 26e1a108..7d493af9 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -74,10 +74,6 @@ void view_configure(struct sway_view *view, double ox, double oy, int width, } } -/** - * Configure the view's position and size based on the swayc's position and - * size, taking borders into consideration. - */ void view_autoconfigure(struct sway_view *view) { if (!sway_assert(view->swayc, "Called view_autoconfigure() on a view without a swayc")) { @@ -93,25 +89,25 @@ void view_autoconfigure(struct sway_view *view) { double x, y, width, height; switch (view->border) { - case B_NONE: - x = view->swayc->x; - y = view->swayc->y; - width = view->swayc->width; - height = view->swayc->height; - break; - case B_PIXEL: - x = view->swayc->x + view->border_thickness; - y = view->swayc->y + view->border_thickness; - width = view->swayc->width - view->border_thickness * 2; - height = view->swayc->height - view->border_thickness * 2; - break; - case B_NORMAL: - // TODO: Size the title bar by checking the font - x = view->swayc->x + view->border_thickness; - y = view->swayc->y + 20; - width = view->swayc->width - view->border_thickness * 2; - height = view->swayc->height - view->border_thickness - 20; - break; + case B_NONE: + x = view->swayc->x; + y = view->swayc->y; + width = view->swayc->width; + height = view->swayc->height; + break; + case B_PIXEL: + x = view->swayc->x + view->border_thickness; + y = view->swayc->y + view->border_thickness; + width = view->swayc->width - view->border_thickness * 2; + height = view->swayc->height - view->border_thickness * 2; + break; + case B_NORMAL: + // TODO: Size the title bar by checking the font + x = view->swayc->x + view->border_thickness; + y = view->swayc->y + 20; + width = view->swayc->width - view->border_thickness * 2; + height = view->swayc->height - view->border_thickness - 20; + break; } view->x = x; -- cgit v1.2.3 From 6ef14e99eec0d741104be3a1483b7e92de870c96 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 1 May 2018 19:59:36 +1000 Subject: Restore view_update_position() --- include/sway/tree/view.h | 2 ++ sway/tree/view.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) (limited to 'include/sway/tree') diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index 4395e94a..21127ab1 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h @@ -197,6 +197,8 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface); void view_unmap(struct sway_view *view); +void view_update_position(struct sway_view *view, double ox, double oy); + void view_update_size(struct sway_view *view, int width, int height); void view_child_init(struct sway_view_child *child, diff --git a/sway/tree/view.c b/sway/tree/view.c index 7d493af9..80949c89 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c @@ -349,6 +349,19 @@ void view_unmap(struct sway_view *view) { arrange_children_of(parent); } +void view_update_position(struct sway_view *view, double ox, double oy) { + if (view->swayc->x == ox && view->swayc->y == oy) { + return; + } + + // TODO: Only allow this if the view is floating (this function will only be + // called in response to wayland clients wanting to reposition themselves). + view_damage(view, true); + view->swayc->x = ox; + view->swayc->y = oy; + view_damage(view, true); +} + void view_update_size(struct sway_view *view, int width, int height) { if (view->width == width && view->height == height) { return; -- cgit v1.2.3