Fix laggy move-resize for wl-shell views

master
emersion 7 years ago
parent 0153a0ed8f
commit 272e0858e4
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

@ -103,7 +103,9 @@ void view_resize(struct roots_view *view, uint32_t width, uint32_t height) {
void view_move_resize(struct roots_view *view, double x, double y, void view_move_resize(struct roots_view *view, double x, double y,
uint32_t width, uint32_t height) { uint32_t width, uint32_t height) {
if (x == view->x && y == view->y) { bool update_x = x != view->x;
bool update_y = y != view->y;
if (!update_x && !update_y) {
view_resize(view, width, height); view_resize(view, width, height);
return; return;
} }
@ -113,7 +115,13 @@ void view_move_resize(struct roots_view *view, double x, double y,
return; return;
} }
view_move(view, x, y); view->pending_move_resize.update_x = update_x;
view->pending_move_resize.update_y = update_y;
view->pending_move_resize.x = x;
view->pending_move_resize.y = y;
view->pending_move_resize.width = width;
view->pending_move_resize.height = height;
view_resize(view, width, height); view_resize(view, width, height);
} }

@ -71,7 +71,24 @@ static void handle_set_state(struct wl_listener *listener, void *data) {
} }
static void handle_surface_commit(struct wl_listener *listener, void *data) { static void handle_surface_commit(struct wl_listener *listener, void *data) {
// TODO do we need to do anything here? struct roots_wl_shell_surface *roots_surface =
wl_container_of(listener, roots_surface, surface_commit);
struct roots_view *view = roots_surface->view;
struct wlr_surface *wlr_surface = view->wlr_surface;
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 +
view->pending_move_resize.width - width;
view->pending_move_resize.update_x = false;
}
if (view->pending_move_resize.update_y) {
view->y = view->pending_move_resize.y +
view->pending_move_resize.height - height;
view->pending_move_resize.update_y = false;
}
} }
static void handle_destroy(struct wl_listener *listener, void *data) { static void handle_destroy(struct wl_listener *listener, void *data) {

@ -186,10 +186,10 @@ static void handle_surface_commit(struct wl_listener *listener, void *data) {
struct roots_xwayland_surface *roots_surface = struct roots_xwayland_surface *roots_surface =
wl_container_of(listener, roots_surface, surface_commit); wl_container_of(listener, roots_surface, surface_commit);
struct roots_view *view = roots_surface->view; struct roots_view *view = roots_surface->view;
struct wlr_xwayland_surface *xwayland_surface = view->xwayland_surface; struct wlr_surface *wlr_surface = view->wlr_surface;
int width = xwayland_surface->surface->current->width; int width = wlr_surface->current->width;
int height = xwayland_surface->surface->current->height; int height = wlr_surface->current->height;
if (view->pending_move_resize.update_x) { if (view->pending_move_resize.update_x) {
view->x = view->pending_move_resize.x + view->x = view->pending_move_resize.x +

Loading…
Cancel
Save