diff options
Diffstat (limited to 'sway/desktop/xdg_shell_v6.c')
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 01f38d16..713437f2 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -76,6 +76,35 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
76 | // TODO: Let floating views do whatever | 76 | // TODO: Let floating views do whatever |
77 | view->width = sway_surface->pending_width; | 77 | view->width = sway_surface->pending_width; |
78 | view->height = sway_surface->pending_height; | 78 | view->height = sway_surface->pending_height; |
79 | view_damage_from(view); | ||
80 | } | ||
81 | |||
82 | static void handle_unmap(struct wl_listener *listener, void *data) { | ||
83 | struct sway_xdg_surface_v6 *sway_surface = | ||
84 | wl_container_of(listener, sway_surface, unmap); | ||
85 | view_damage_whole(sway_surface->view); | ||
86 | container_view_destroy(sway_surface->view->swayc); | ||
87 | sway_surface->view->swayc = NULL; | ||
88 | sway_surface->view->surface = NULL; | ||
89 | } | ||
90 | |||
91 | static void handle_map(struct wl_listener *listener, void *data) { | ||
92 | struct sway_xdg_surface_v6 *sway_surface = | ||
93 | wl_container_of(listener, sway_surface, map); | ||
94 | struct sway_view *view = sway_surface->view; | ||
95 | |||
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); | ||
79 | } | 108 | } |
80 | 109 | ||
81 | static void handle_destroy(struct wl_listener *listener, void *data) { | 110 | static void handle_destroy(struct wl_listener *listener, void *data) { |
@@ -121,26 +150,22 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { | |||
121 | sway_view->iface.close = close; | 150 | sway_view->iface.close = close; |
122 | sway_view->wlr_xdg_surface_v6 = xdg_surface; | 151 | sway_view->wlr_xdg_surface_v6 = xdg_surface; |
123 | sway_view->sway_xdg_surface_v6 = sway_surface; | 152 | sway_view->sway_xdg_surface_v6 = sway_surface; |
124 | sway_view->surface = xdg_surface->surface; | ||
125 | sway_surface->view = sway_view; | 153 | sway_surface->view = sway_view; |
126 | 154 | ||
127 | // TODO: | 155 | // TODO: |
128 | // - Look up pid and open on appropriate workspace | 156 | // - Look up pid and open on appropriate workspace |
129 | // - Set new view to maximized so it behaves nicely | 157 | // - Set new view to maximized so it behaves nicely |
130 | // - Criteria | 158 | // - Criteria |
131 | 159 | ||
132 | sway_surface->commit.notify = handle_commit; | 160 | sway_surface->commit.notify = handle_commit; |
133 | wl_signal_add(&xdg_surface->surface->events.commit, &sway_surface->commit); | 161 | wl_signal_add(&xdg_surface->surface->events.commit, &sway_surface->commit); |
134 | 162 | ||
135 | sway_surface->destroy.notify = handle_destroy; | 163 | sway_surface->map.notify = handle_map; |
136 | wl_signal_add(&xdg_surface->events.destroy, &sway_surface->destroy); | 164 | wl_signal_add(&xdg_surface->events.map, &sway_surface->map); |
137 | 165 | ||
138 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 166 | sway_surface->unmap.notify = handle_unmap; |
139 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); | 167 | wl_signal_add(&xdg_surface->events.unmap, &sway_surface->unmap); |
140 | struct sway_container *cont = container_view_create(focus, sway_view); | ||
141 | sway_view->swayc = cont; | ||
142 | |||
143 | arrange_windows(cont->parent, -1, -1); | ||
144 | 168 | ||
145 | sway_input_manager_set_focus(input_manager, cont); | 169 | sway_surface->destroy.notify = handle_destroy; |
170 | wl_signal_add(&xdg_surface->events.destroy, &sway_surface->destroy); | ||
146 | } | 171 | } |