diff options
Diffstat (limited to 'sway/desktop/xwayland.c')
-rw-r--r-- | sway/desktop/xwayland.c | 61 |
1 files changed, 18 insertions, 43 deletions
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 273ca2bf..e1c2ad08 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -102,56 +102,35 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
102 | static void handle_destroy(struct wl_listener *listener, void *data) { | 102 | static void handle_destroy(struct wl_listener *listener, void *data) { |
103 | struct sway_xwayland_surface *sway_surface = | 103 | struct sway_xwayland_surface *sway_surface = |
104 | wl_container_of(listener, sway_surface, destroy); | 104 | wl_container_of(listener, sway_surface, destroy); |
105 | |||
106 | wl_list_remove(&sway_surface->commit.link); | 105 | wl_list_remove(&sway_surface->commit.link); |
107 | wl_list_remove(&sway_surface->destroy.link); | 106 | wl_list_remove(&sway_surface->destroy.link); |
108 | wl_list_remove(&sway_surface->request_configure.link); | 107 | wl_list_remove(&sway_surface->request_configure.link); |
109 | wl_list_remove(&sway_surface->view->unmanaged_view_link); | 108 | wl_list_remove(&sway_surface->map.link); |
110 | container_view_destroy(sway_surface->view->swayc); | 109 | wl_list_remove(&sway_surface->unmap.link); |
111 | sway_surface->view->swayc = NULL; | 110 | view_destroy(sway_surface->view); |
112 | sway_surface->view->surface = NULL; | 111 | free(sway_surface); |
113 | } | 112 | } |
114 | 113 | ||
115 | static void handle_unmap(struct wl_listener *listener, void *data) { | 114 | static void handle_unmap(struct wl_listener *listener, void *data) { |
116 | struct sway_xwayland_surface *sway_surface = | 115 | struct sway_xwayland_surface *sway_surface = |
117 | wl_container_of(listener, sway_surface, unmap); | 116 | wl_container_of(listener, sway_surface, unmap); |
118 | view_damage_whole(sway_surface->view); | 117 | view_unmap(sway_surface->view); |
119 | wl_list_remove(&sway_surface->view->unmanaged_view_link); | ||
120 | wl_list_init(&sway_surface->view->unmanaged_view_link); | ||
121 | container_view_destroy(sway_surface->view->swayc); | ||
122 | sway_surface->view->swayc = NULL; | ||
123 | sway_surface->view->surface = NULL; | ||
124 | } | 118 | } |
125 | 119 | ||
126 | static void handle_map(struct wl_listener *listener, void *data) { | 120 | static void handle_map(struct wl_listener *listener, void *data) { |
127 | struct sway_xwayland_surface *sway_surface = | 121 | struct sway_xwayland_surface *sway_surface = |
128 | wl_container_of(listener, sway_surface, map); | 122 | wl_container_of(listener, sway_surface, map); |
129 | struct wlr_xwayland_surface *xsurface = data; | 123 | struct wlr_xwayland_surface *xsurface = data; |
130 | 124 | struct sway_view *view = sway_surface->view; | |
131 | sway_surface->view->surface = xsurface->surface; | ||
132 | 125 | ||
133 | // put it back into the tree | 126 | // put it back into the tree |
134 | if (wlr_xwayland_surface_is_unmanaged(xsurface) || | 127 | if (wlr_xwayland_surface_is_unmanaged(xsurface) || |
135 | xsurface->override_redirect) { | 128 | xsurface->override_redirect) { |
136 | wl_list_remove(&sway_surface->view->unmanaged_view_link); | 129 | view_map_unmanaged(view, xsurface->surface); |
137 | wl_list_insert(&root_container.sway_root->unmanaged_views, | ||
138 | &sway_surface->view->unmanaged_view_link); | ||
139 | } else { | 130 | } else { |
140 | struct sway_view *view = sway_surface->view; | ||
141 | container_view_destroy(view->swayc); | ||
142 | |||
143 | wlr_xwayland_surface_set_maximized(xsurface, true); | 131 | wlr_xwayland_surface_set_maximized(xsurface, true); |
144 | 132 | view_map(view, xsurface->surface); | |
145 | struct sway_seat *seat = input_manager_current_seat(input_manager); | ||
146 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, | ||
147 | &root_container); | ||
148 | struct sway_container *cont = container_view_create(focus, view); | ||
149 | view->swayc = cont; | ||
150 | arrange_windows(cont->parent, -1, -1); | ||
151 | sway_input_manager_set_focus(input_manager, cont); | ||
152 | } | 133 | } |
153 | |||
154 | view_damage_whole(sway_surface->view); | ||
155 | } | 134 | } |
156 | 135 | ||
157 | static void handle_request_configure(struct wl_listener *listener, void *data) { | 136 | static void handle_request_configure(struct wl_listener *listener, void *data) { |
@@ -180,25 +159,21 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { | |||
180 | return; | 159 | return; |
181 | } | 160 | } |
182 | 161 | ||
183 | struct sway_view *sway_view = calloc(1, sizeof(struct sway_view)); | 162 | struct sway_view *view = view_create(SWAY_XWAYLAND_VIEW); |
184 | if (!sway_assert(sway_view, "Failed to allocate view!")) { | 163 | if (!sway_assert(view, "Failed to allocate view")) { |
185 | return; | 164 | return; |
186 | } | 165 | } |
187 | sway_view->type = SWAY_XWAYLAND_VIEW; | 166 | view->iface.get_prop = get_prop; |
188 | sway_view->iface.get_prop = get_prop; | 167 | view->iface.set_size = set_size; |
189 | sway_view->iface.set_size = set_size; | 168 | view->iface.set_position = set_position; |
190 | sway_view->iface.set_position = set_position; | 169 | view->iface.set_activated = set_activated; |
191 | sway_view->iface.set_activated = set_activated; | 170 | view->iface.close = close_view; |
192 | sway_view->iface.close = close_view; | 171 | view->wlr_xwayland_surface = xsurface; |
193 | sway_view->wlr_xwayland_surface = xsurface; | 172 | view->sway_xwayland_surface = sway_surface; |
194 | sway_view->sway_xwayland_surface = sway_surface; | 173 | sway_surface->view = view; |
195 | sway_surface->view = sway_view; | ||
196 | |||
197 | wl_list_init(&sway_view->unmanaged_view_link); | ||
198 | 174 | ||
199 | // TODO: | 175 | // TODO: |
200 | // - Look up pid and open on appropriate workspace | 176 | // - Look up pid and open on appropriate workspace |
201 | // - Set new view to maximized so it behaves nicely | ||
202 | // - Criteria | 177 | // - Criteria |
203 | 178 | ||
204 | wl_signal_add(&xsurface->surface->events.commit, &sway_surface->commit); | 179 | wl_signal_add(&xsurface->surface->events.commit, &sway_surface->commit); |