aboutsummaryrefslogtreecommitdiff
path: root/rootston
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-01-18 12:25:39 +0100
committeremersion <contact@emersion.fr>2018-01-18 12:25:39 +0100
commit01bcc2ab01715df1f105ab972041134c878612e0 (patch)
tree1329ae691cd7caddced42bf0ed84dbe209a91932 /rootston
parent5089f2d9fbcbc76c985e3a93b6fb694b57f116aa (diff)
rootston: damage views when moved
Diffstat (limited to 'rootston')
-rw-r--r--rootston/desktop.c26
-rw-r--r--rootston/output.c8
-rw-r--r--rootston/wl_shell.c9
-rw-r--r--rootston/xdg_shell_v6.c11
-rw-r--r--rootston/xwayland.c24
5 files changed, 49 insertions, 29 deletions
diff --git a/rootston/desktop.c b/rootston/desktop.c
index 3b8e6602..94350359 100644
--- a/rootston/desktop.c
+++ b/rootston/desktop.c
@@ -61,8 +61,7 @@ void view_move(struct roots_view *view, double x, double y) {
if (view->move) {
view->move(view, x, y);
} else {
- view->x = x;
- view->y = y;
+ view_update_position(view, x, y);
}
view_update_output(view, &before);
}
@@ -268,6 +267,7 @@ void view_destroy(struct roots_view *view) {
void view_init(struct roots_view *view, struct roots_desktop *desktop) {
view->desktop = desktop;
wl_signal_init(&view->events.destroy);
+ view_damage(view);
}
void view_setup(struct roots_view *view) {
@@ -282,6 +282,20 @@ void view_setup(struct roots_view *view) {
view_update_output(view, NULL);
}
+void view_damage(struct roots_view *view) {
+ struct roots_output *output;
+ wl_list_for_each(output, &view->desktop->outputs, link) {
+ output_damage_view(output, view);
+ }
+}
+
+void view_update_position(struct roots_view *view, double x, double y) {
+ view_damage(view);
+ view->x = x;
+ view->y = y;
+ view_damage(view);
+}
+
static bool view_at(struct roots_view *view, double lx, double ly,
struct wlr_surface **surface, double *sx, double *sy) {
if (view->type == ROOTS_WL_SHELL_VIEW &&
@@ -522,11 +536,3 @@ struct roots_output *desktop_output_from_wlr_output(
}
return NULL;
}
-
-void desktop_damage_surface(struct roots_desktop *desktop,
- struct wlr_surface *surface, double lx, double ly) {
- struct roots_output *output;
- wl_list_for_each(output, &desktop->outputs, link) {
- output_damage_surface(output, surface, lx, ly);
- }
-}
diff --git a/rootston/output.c b/rootston/output.c
index a700ea07..5ccd9eb7 100644
--- a/rootston/output.c
+++ b/rootston/output.c
@@ -337,7 +337,7 @@ static int handle_repaint(void *data) {
return 0;
}
-void output_damage_surface(struct roots_output *output,
+static void output_damage_surface(struct roots_output *output,
struct wlr_surface *surface, double lx, double ly) {
if (!wlr_surface_has_buffer(surface)) {
return;
@@ -355,6 +355,12 @@ void output_damage_surface(struct roots_output *output,
box.width, box.height);
}
+void output_damage_view(struct roots_output *output, struct roots_view *view) {
+ output_damage_surface(output, view->wlr_surface, view->x, view->y);
+
+ // TODO: subsurfaces, popups, etc
+}
+
static void set_mode(struct wlr_output *output,
struct roots_output_config *oc) {
int mhz = (int)(oc->mode.refresh_rate * 1000);
diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c
index 65067920..e1dea82b 100644
--- a/rootston/wl_shell.c
+++ b/rootston/wl_shell.c
@@ -90,17 +90,20 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
int width = wlr_surface->current->width;
int height = wlr_surface->current->height;
-
if (view->pending_move_resize.update_x) {
- view->x = view->pending_move_resize.x +
+ double x = view->pending_move_resize.x +
view->pending_move_resize.width - width;
+ view_update_position(view, x, view->y);
view->pending_move_resize.update_x = false;
}
if (view->pending_move_resize.update_y) {
- view->y = view->pending_move_resize.y +
+ double y = view->pending_move_resize.y +
view->pending_move_resize.height - height;
+ view_update_position(view, view->x, y);
view->pending_move_resize.update_y = false;
}
+
+ view_damage(view);
}
static void handle_destroy(struct wl_listener *listener, void *data) {
diff --git a/rootston/xdg_shell_v6.c b/rootston/xdg_shell_v6.c
index e915d1a6..259b62a5 100644
--- a/rootston/xdg_shell_v6.c
+++ b/rootston/xdg_shell_v6.c
@@ -102,8 +102,7 @@ static void move_resize(struct roots_view *view, double x, double y,
if (serial > 0) {
roots_surface->pending_move_resize_configure_serial = serial;
} else {
- view->x = x;
- view->y = y;
+ view_update_position(view, x, y);
}
}
@@ -205,12 +204,14 @@ static void handle_commit(struct wl_listener *listener, void *data) {
get_size(view, &size);
if (view->pending_move_resize.update_x) {
- view->x = view->pending_move_resize.x +
+ double x = view->pending_move_resize.x +
view->pending_move_resize.width - size.width;
+ view_update_position(view, x, view->y);
}
if (view->pending_move_resize.update_y) {
- view->y = view->pending_move_resize.y +
+ double y = view->pending_move_resize.y +
view->pending_move_resize.height - size.height;
+ view_update_position(view, view->x, y);
}
if (pending_serial == surface->configure_serial) {
@@ -218,7 +219,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
}
}
- desktop_damage_surface(view->desktop, view->wlr_surface, view->x, view->y);
+ view_damage(view);
}
static void handle_destroy(struct wl_listener *listener, void *data) {
diff --git a/rootston/xwayland.c b/rootston/xwayland.c
index 3d84dc19..b3cf409c 100644
--- a/rootston/xwayland.c
+++ b/rootston/xwayland.c
@@ -18,8 +18,7 @@ static void activate(struct roots_view *view, bool active) {
static void move(struct roots_view *view, double x, double y) {
assert(view->type == ROOTS_XWAYLAND_VIEW);
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface;
- view->x = x;
- view->y = y;
+ view_update_position(view, x, y);
wlr_xwayland_surface_configure(xwayland_surface, x, y,
xwayland_surface->width, xwayland_surface->height);
}
@@ -133,8 +132,7 @@ static void handle_request_configure(struct wl_listener *listener, void *data) {
roots_surface->view->xwayland_surface;
struct wlr_xwayland_surface_configure_event *event = data;
- roots_surface->view->x = (double)event->x;
- roots_surface->view->y = (double)event->y;
+ view_update_position(roots_surface->view, event->x, event->y);
wlr_xwayland_surface_configure(xwayland_surface, event->x, event->y,
event->width, event->height);
@@ -210,15 +208,19 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
int height = wlr_surface->current->height;
if (view->pending_move_resize.update_x) {
- view->x = view->pending_move_resize.x +
+ double x = view->pending_move_resize.x +
view->pending_move_resize.width - width;
+ view_update_position(view, x, view->y);
view->pending_move_resize.update_x = false;
}
if (view->pending_move_resize.update_y) {
- view->y = view->pending_move_resize.y +
+ double y = view->pending_move_resize.y +
view->pending_move_resize.height - height;
+ view_update_position(view, view->x, y);
view->pending_move_resize.update_y = false;
}
+
+ view_damage(view);
}
static void handle_map_notify(struct wl_listener *listener, void *data) {
@@ -229,8 +231,9 @@ static void handle_map_notify(struct wl_listener *listener, void *data) {
struct roots_desktop *desktop = view->desktop;
view->wlr_surface = xsurface->surface;
- view->x = (double)xsurface->x;
- view->y = (double)xsurface->y;
+ view->x = xsurface->x;
+ view->y = xsurface->y;
+ view_damage(view);
roots_surface->surface_commit.notify = handle_surface_commit;
wl_signal_add(&xsurface->surface->events.commit,
@@ -242,10 +245,11 @@ static void handle_map_notify(struct wl_listener *listener, void *data) {
static void handle_unmap_notify(struct wl_listener *listener, void *data) {
struct roots_xwayland_surface *roots_surface =
wl_container_of(listener, roots_surface, unmap_notify);
- roots_surface->view->wlr_surface = NULL;
- wl_list_remove(&roots_surface->surface_commit.link);
+ view_damage(roots_surface->view);
+ roots_surface->view->wlr_surface = NULL;
+ wl_list_remove(&roots_surface->surface_commit.link);
wl_list_remove(&roots_surface->view->link);
}