diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-01-15 09:38:05 -0500 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-01-15 09:38:05 -0500 |
commit | ddc49ede4636b01dad8d8bfb7d0314bf1eb88258 (patch) | |
tree | a8b8e1a5a92a4203503ead496d8d50fd72fcf850 | |
parent | render override redirect (diff) | |
download | sway-ddc49ede4636b01dad8d8bfb7d0314bf1eb88258.tar.gz sway-ddc49ede4636b01dad8d8bfb7d0314bf1eb88258.tar.zst sway-ddc49ede4636b01dad8d8bfb7d0314bf1eb88258.zip |
xwm handle map and unmap
-rw-r--r-- | sway/desktop/output.c | 4 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 36 |
2 files changed, 33 insertions, 7 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 21c8513f..0f00222b 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -180,6 +180,10 @@ static void output_frame_view(swayc_t *view, void *data) { | |||
180 | struct sway_view *sway_view = view->sway_view; | 180 | struct sway_view *sway_view = view->sway_view; |
181 | struct wlr_surface *surface = sway_view->surface; | 181 | struct wlr_surface *surface = sway_view->surface; |
182 | 182 | ||
183 | if (!surface) { | ||
184 | return; | ||
185 | } | ||
186 | |||
183 | switch (sway_view->type) { | 187 | switch (sway_view->type) { |
184 | case SWAY_XDG_SHELL_V6_VIEW: { | 188 | case SWAY_XDG_SHELL_V6_VIEW: { |
185 | int window_offset_x = view->sway_view->wlr_xdg_surface_v6->geometry->x; | 189 | int window_offset_x = view->sway_view->wlr_xdg_surface_v6->geometry->x; |
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 |