aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/xdg_shell_v6.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/desktop/xdg_shell_v6.c')
-rw-r--r--sway/desktop/xdg_shell_v6.c46
1 files changed, 15 insertions, 31 deletions
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index 713437f2..77a35b13 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -82,29 +82,14 @@ static void handle_commit(struct wl_listener *listener, void *data) {
82static void handle_unmap(struct wl_listener *listener, void *data) { 82static void handle_unmap(struct wl_listener *listener, void *data) {
83 struct sway_xdg_surface_v6 *sway_surface = 83 struct sway_xdg_surface_v6 *sway_surface =
84 wl_container_of(listener, sway_surface, unmap); 84 wl_container_of(listener, sway_surface, unmap);
85 view_damage_whole(sway_surface->view); 85 view_unmap(sway_surface->view);
86 container_view_destroy(sway_surface->view->swayc);
87 sway_surface->view->swayc = NULL;
88 sway_surface->view->surface = NULL;
89} 86}
90 87
91static void handle_map(struct wl_listener *listener, void *data) { 88static void handle_map(struct wl_listener *listener, void *data) {
92 struct sway_xdg_surface_v6 *sway_surface = 89 struct sway_xdg_surface_v6 *sway_surface =
93 wl_container_of(listener, sway_surface, map); 90 wl_container_of(listener, sway_surface, map);
94 struct sway_view *view = sway_surface->view; 91 struct sway_view *view = sway_surface->view;
95 92 view_map(view, view->wlr_xdg_surface_v6->surface);
96 sway_surface->view->surface = view->wlr_xdg_surface_v6->surface;
97
98 container_view_destroy(view->swayc);
99
100 struct sway_seat *seat = input_manager_current_seat(input_manager);
101 struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container);
102 struct sway_container *cont = container_view_create(focus, view);
103 view->swayc = cont;
104 arrange_windows(cont->parent, -1, -1);
105 sway_input_manager_set_focus(input_manager, cont);
106
107 view_damage_whole(sway_surface->view);
108} 93}
109 94
110static void handle_destroy(struct wl_listener *listener, void *data) { 95static void handle_destroy(struct wl_listener *listener, void *data) {
@@ -112,8 +97,9 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
112 wl_container_of(listener, sway_xdg_surface, destroy); 97 wl_container_of(listener, sway_xdg_surface, destroy);
113 wl_list_remove(&sway_xdg_surface->commit.link); 98 wl_list_remove(&sway_xdg_surface->commit.link);
114 wl_list_remove(&sway_xdg_surface->destroy.link); 99 wl_list_remove(&sway_xdg_surface->destroy.link);
115 container_view_destroy(sway_xdg_surface->view->swayc); 100 wl_list_remove(&sway_xdg_surface->map.link);
116 free(sway_xdg_surface->view); 101 wl_list_remove(&sway_xdg_surface->unmap.link);
102 view_destroy(sway_xdg_surface->view);
117 free(sway_xdg_surface); 103 free(sway_xdg_surface);
118} 104}
119 105
@@ -138,23 +124,21 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
138 return; 124 return;
139 } 125 }
140 126
141 struct sway_view *sway_view = calloc(1, sizeof(struct sway_view)); 127 struct sway_view *view = view_create(SWAY_XDG_SHELL_V6_VIEW);
142 if (!sway_assert(sway_view, "Failed to allocate view!")) { 128 if (!sway_assert(view, "Failed to allocate view")) {
143 return; 129 return;
144 } 130 }
145 sway_view->type = SWAY_XDG_SHELL_V6_VIEW; 131 view->iface.get_prop = get_prop;
146 sway_view->iface.get_prop = get_prop; 132 view->iface.set_size = set_size;
147 sway_view->iface.set_size = set_size; 133 view->iface.set_position = set_position;
148 sway_view->iface.set_position = set_position; 134 view->iface.set_activated = set_activated;
149 sway_view->iface.set_activated = set_activated; 135 view->iface.close = close;
150 sway_view->iface.close = close; 136 view->wlr_xdg_surface_v6 = xdg_surface;
151 sway_view->wlr_xdg_surface_v6 = xdg_surface; 137 view->sway_xdg_surface_v6 = sway_surface;
152 sway_view->sway_xdg_surface_v6 = sway_surface; 138 sway_surface->view = view;
153 sway_surface->view = sway_view;
154 139
155 // TODO: 140 // TODO:
156 // - Look up pid and open on appropriate workspace 141 // - Look up pid and open on appropriate workspace
157 // - Set new view to maximized so it behaves nicely
158 // - Criteria 142 // - Criteria
159 143
160 sway_surface->commit.notify = handle_commit; 144 sway_surface->commit.notify = handle_commit;