diff options
Diffstat (limited to 'sway/desktop/xwayland.c')
-rw-r--r-- | sway/desktop/xwayland.c | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 0c0dbfff..a4d9687d 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -101,22 +101,32 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
101 | if (xsurface->mapped) { | 101 | if (xsurface->mapped) { |
102 | wl_list_remove(&sway_surface->view->unmanaged_view_link); | 102 | wl_list_remove(&sway_surface->view->unmanaged_view_link); |
103 | } | 103 | } |
104 | } else { | 104 | } |
105 | swayc_t *parent = destroy_view(sway_surface->view->swayc); | 105 | |
106 | swayc_t *parent = destroy_view(sway_surface->view->swayc); | ||
107 | if (parent) { | ||
106 | arrange_windows(parent, -1, -1); | 108 | arrange_windows(parent, -1, -1); |
107 | } | 109 | } |
110 | |||
108 | free(sway_surface->view); | 111 | free(sway_surface->view); |
109 | free(sway_surface); | 112 | free(sway_surface); |
110 | } | 113 | } |
111 | 114 | ||
112 | static void handle_unmap_notify(struct wl_listener *listener, void *data) { | 115 | static void handle_unmap_notify(struct wl_listener *listener, void *data) { |
113 | // TODO take the view out of the tree | ||
114 | struct sway_xwayland_surface *sway_surface = | 116 | struct sway_xwayland_surface *sway_surface = |
115 | wl_container_of(listener, sway_surface, unmap_notify); | 117 | wl_container_of(listener, sway_surface, unmap_notify); |
116 | struct wlr_xwayland_surface *xsurface = data; | 118 | struct wlr_xwayland_surface *xsurface = data; |
117 | if (xsurface->override_redirect) { | 119 | if (xsurface->override_redirect) { |
118 | wl_list_remove(&sway_surface->view->unmanaged_view_link); | 120 | wl_list_remove(&sway_surface->view->unmanaged_view_link); |
119 | } | 121 | } |
122 | |||
123 | // take it out of the tree | ||
124 | swayc_t *parent = destroy_view(sway_surface->view->swayc); | ||
125 | if (parent) { | ||
126 | arrange_windows(parent, -1, -1); | ||
127 | } | ||
128 | |||
129 | sway_surface->view->swayc = NULL; | ||
120 | sway_surface->view->surface = NULL; | 130 | sway_surface->view->surface = NULL; |
121 | } | 131 | } |
122 | 132 | ||
@@ -125,11 +135,26 @@ static void handle_map_notify(struct wl_listener *listener, void *data) { | |||
125 | struct sway_xwayland_surface *sway_surface = | 135 | struct sway_xwayland_surface *sway_surface = |
126 | wl_container_of(listener, sway_surface, map_notify); | 136 | wl_container_of(listener, sway_surface, map_notify); |
127 | struct wlr_xwayland_surface *xsurface = data; | 137 | struct wlr_xwayland_surface *xsurface = data; |
138 | |||
139 | sway_surface->view->surface = xsurface->surface; | ||
140 | |||
141 | // put it back into the tree | ||
128 | if (xsurface->override_redirect) { | 142 | if (xsurface->override_redirect) { |
129 | wl_list_insert(&root_container.sway_root->unmanaged_views, | 143 | wl_list_insert(&root_container.sway_root->unmanaged_views, |
130 | &sway_surface->view->unmanaged_view_link); | 144 | &sway_surface->view->unmanaged_view_link); |
145 | } else { | ||
146 | struct sway_view *view = sway_surface->view; | ||
147 | destroy_view(view->swayc); | ||
148 | |||
149 | swayc_t *parent = root_container.children->items[0]; | ||
150 | parent = parent->children->items[0]; // workspace | ||
151 | |||
152 | swayc_t *cont = new_view(parent, view); | ||
153 | view->swayc = cont; | ||
154 | |||
155 | arrange_windows(cont->parent, -1, -1); | ||
156 | sway_input_manager_set_focus(input_manager, cont); | ||
131 | } | 157 | } |
132 | sway_surface->view->surface = xsurface->surface; | ||
133 | } | 158 | } |
134 | 159 | ||
135 | static void handle_configure_request(struct wl_listener *listener, void *data) { | 160 | static void handle_configure_request(struct wl_listener *listener, void *data) { |
@@ -169,13 +194,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { | |||
169 | sway_view->iface.set_activated = set_activated; | 194 | sway_view->iface.set_activated = set_activated; |
170 | sway_view->wlr_xwayland_surface = xsurface; | 195 | sway_view->wlr_xwayland_surface = xsurface; |
171 | sway_view->sway_xwayland_surface = sway_surface; | 196 | sway_view->sway_xwayland_surface = sway_surface; |
172 | // TODO remove from the tree when the surface goes away (unmapped) | ||
173 | sway_view->surface = xsurface->surface; | 197 | sway_view->surface = xsurface->surface; |
174 | sway_surface->view = sway_view; | 198 | sway_surface->view = sway_view; |
175 | 199 | ||
176 | // TODO: | 200 | // TODO: |
177 | // - Wire up listeners | ||
178 | // - Handle popups | ||
179 | // - Look up pid and open on appropriate workspace | 201 | // - Look up pid and open on appropriate workspace |
180 | // - Set new view to maximized so it behaves nicely | 202 | // - Set new view to maximized so it behaves nicely |
181 | // - Criteria | 203 | // - Criteria |