aboutsummaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2018-10-09 00:02:36 +0200
committerLibravatar GitHub <noreply@github.com>2018-10-09 00:02:36 +0200
commit4bebee620f1160d6531d9aaa9b528029f75cecf4 (patch)
tree14fb50168c3ba60446b11b786ea69b8fa07b767f /sway/tree/view.c
parentMerge pull request #2782 from RyanDwyer/popup-during-fullscreen (diff)
parentHandle subsurfaces in view_child_damage (diff)
downloadsway-4bebee620f1160d6531d9aaa9b528029f75cecf4.tar.gz
sway-4bebee620f1160d6531d9aaa9b528029f75cecf4.tar.zst
sway-4bebee620f1160d6531d9aaa9b528029f75cecf4.zip
Merge pull request #2772 from RyanDwyer/improve-popup-damage
Only damage popups when popups have damage
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c56
1 files changed, 47 insertions, 9 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 97525d6b..1f00452d 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -15,6 +15,7 @@
15#include "log.h" 15#include "log.h"
16#include "sway/criteria.h" 16#include "sway/criteria.h"
17#include "sway/commands.h" 17#include "sway/commands.h"
18#include "sway/desktop.h"
18#include "sway/desktop/transaction.h" 19#include "sway/desktop/transaction.h"
19#include "sway/input/cursor.h" 20#include "sway/input/cursor.h"
20#include "sway/ipc-server.h" 21#include "sway/ipc-server.h"
@@ -639,6 +640,25 @@ void view_update_size(struct sway_view *view, int width, int height) {
639 container_set_geometry_from_floating_view(view->container); 640 container_set_geometry_from_floating_view(view->container);
640} 641}
641 642
643static void subsurface_get_root_coords(struct sway_view_child *child,
644 int *root_sx, int *root_sy) {
645 struct wlr_surface *surface = child->surface;
646 *root_sx = -child->view->geometry.x;
647 *root_sy = -child->view->geometry.y;
648
649 while (surface && wlr_surface_is_subsurface(surface)) {
650 struct wlr_subsurface *subsurface =
651 wlr_subsurface_from_wlr_surface(surface);
652 *root_sx += subsurface->current.x;
653 *root_sy += subsurface->current.y;
654 surface = subsurface->parent;
655 }
656}
657
658static const struct sway_view_child_impl subsurface_impl = {
659 .get_root_coords = subsurface_get_root_coords,
660};
661
642static void view_subsurface_create(struct sway_view *view, 662static void view_subsurface_create(struct sway_view *view,
643 struct wlr_subsurface *subsurface) { 663 struct wlr_subsurface *subsurface) {
644 struct sway_view_child *child = calloc(1, sizeof(struct sway_view_child)); 664 struct sway_view_child *child = calloc(1, sizeof(struct sway_view_child));
@@ -646,15 +666,21 @@ static void view_subsurface_create(struct sway_view *view,
646 wlr_log(WLR_ERROR, "Allocation failed"); 666 wlr_log(WLR_ERROR, "Allocation failed");
647 return; 667 return;
648 } 668 }
649 view_child_init(child, NULL, view, subsurface->surface); 669 view_child_init(child, &subsurface_impl, view, subsurface->surface);
670}
671
672static void view_child_damage(struct sway_view_child *child, bool whole) {
673 int sx, sy;
674 child->impl->get_root_coords(child, &sx, &sy);
675 desktop_damage_surface(child->surface,
676 child->view->x + sx, child->view->y + sy, whole);
650} 677}
651 678
652static void view_child_handle_surface_commit(struct wl_listener *listener, 679static void view_child_handle_surface_commit(struct wl_listener *listener,
653 void *data) { 680 void *data) {
654 struct sway_view_child *child = 681 struct sway_view_child *child =
655 wl_container_of(listener, child, surface_commit); 682 wl_container_of(listener, child, surface_commit);
656 // TODO: only accumulate damage from the child 683 view_child_damage(child, false);
657 view_damage_from(child->view);
658} 684}
659 685
660static void view_child_handle_surface_new_subsurface( 686static void view_child_handle_surface_new_subsurface(
@@ -687,6 +713,20 @@ static void view_init_subsurfaces(struct sway_view *view,
687 } 713 }
688} 714}
689 715
716static void view_child_handle_surface_map(struct wl_listener *listener,
717 void *data) {
718 struct sway_view_child *child =
719 wl_container_of(listener, child, surface_map);
720 view_child_damage(child, true);
721}
722
723static void view_child_handle_surface_unmap(struct wl_listener *listener,
724 void *data) {
725 struct sway_view_child *child =
726 wl_container_of(listener, child, surface_unmap);
727 view_child_damage(child, true);
728}
729
690void view_child_init(struct sway_view_child *child, 730void view_child_init(struct sway_view_child *child,
691 const struct sway_view_child_impl *impl, struct sway_view *view, 731 const struct sway_view_child_impl *impl, struct sway_view *view,
692 struct wlr_surface *surface) { 732 struct wlr_surface *surface) {
@@ -702,6 +742,10 @@ void view_child_init(struct sway_view_child *child,
702 view_child_handle_surface_new_subsurface; 742 view_child_handle_surface_new_subsurface;
703 wl_signal_add(&surface->events.destroy, &child->surface_destroy); 743 wl_signal_add(&surface->events.destroy, &child->surface_destroy);
704 child->surface_destroy.notify = view_child_handle_surface_destroy; 744 child->surface_destroy.notify = view_child_handle_surface_destroy;
745
746 child->surface_map.notify = view_child_handle_surface_map;
747 child->surface_unmap.notify = view_child_handle_surface_unmap;
748
705 wl_signal_add(&view->events.unmap, &child->view_unmap); 749 wl_signal_add(&view->events.unmap, &child->view_unmap);
706 child->view_unmap.notify = view_child_handle_view_unmap; 750 child->view_unmap.notify = view_child_handle_view_unmap;
707 751
@@ -709,15 +753,9 @@ void view_child_init(struct sway_view_child *child,
709 wlr_surface_send_enter(child->surface, output->wlr_output); 753 wlr_surface_send_enter(child->surface, output->wlr_output);
710 754
711 view_init_subsurfaces(child->view, surface); 755 view_init_subsurfaces(child->view, surface);
712
713 // TODO: only damage the whole child
714 container_damage_whole(child->view->container);
715} 756}
716 757
717void view_child_destroy(struct sway_view_child *child) { 758void view_child_destroy(struct sway_view_child *child) {
718 // TODO: only damage the whole child
719 container_damage_whole(child->view->container);
720
721 wl_list_remove(&child->surface_commit.link); 759 wl_list_remove(&child->surface_commit.link);
722 wl_list_remove(&child->surface_destroy.link); 760 wl_list_remove(&child->surface_destroy.link);
723 wl_list_remove(&child->view_unmap.link); 761 wl_list_remove(&child->view_unmap.link);