diff options
author | 2018-03-31 17:49:40 -0400 | |
---|---|---|
committer | 2018-03-31 17:49:40 -0400 | |
commit | b2c2ee693b6f1cdaeb204a1469c0fa1b775a498c (patch) | |
tree | 1fd4a806d0ab7ba780d5fb93acb741b9b1dc3f85 /sway/desktop/wl_shell.c | |
parent | Merge pull request #1684 from swaywm/follow-warp (diff) | |
download | sway-b2c2ee693b6f1cdaeb204a1469c0fa1b775a498c.tar.gz sway-b2c2ee693b6f1cdaeb204a1469c0fa1b775a498c.tar.zst sway-b2c2ee693b6f1cdaeb204a1469c0fa1b775a498c.zip |
Introduce common functions to create, map, unmap, destroy views
Diffstat (limited to 'sway/desktop/wl_shell.c')
-rw-r--r-- | sway/desktop/wl_shell.c | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c index 4fcc6317..ab969b17 100644 --- a/sway/desktop/wl_shell.c +++ b/sway/desktop/wl_shell.c | |||
@@ -75,15 +75,13 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
75 | wl_container_of(listener, sway_surface, destroy); | 75 | wl_container_of(listener, sway_surface, destroy); |
76 | wl_list_remove(&sway_surface->commit.link); | 76 | wl_list_remove(&sway_surface->commit.link); |
77 | wl_list_remove(&sway_surface->destroy.link); | 77 | wl_list_remove(&sway_surface->destroy.link); |
78 | struct sway_container *parent = container_view_destroy(sway_surface->view->swayc); | 78 | view_destroy(sway_surface->view); |
79 | free(sway_surface->view); | ||
80 | free(sway_surface); | 79 | free(sway_surface); |
81 | arrange_windows(parent, -1, -1); | ||
82 | } | 80 | } |
83 | 81 | ||
84 | void handle_wl_shell_surface(struct wl_listener *listener, void *data) { | 82 | void handle_wl_shell_surface(struct wl_listener *listener, void *data) { |
85 | struct sway_server *server = wl_container_of( | 83 | struct sway_server *server = wl_container_of(listener, server, |
86 | listener, server, wl_shell_surface); | 84 | wl_shell_surface); |
87 | struct wlr_wl_shell_surface *shell_surface = data; | 85 | struct wlr_wl_shell_surface *shell_surface = data; |
88 | 86 | ||
89 | if (shell_surface->state == WLR_WL_SHELL_SURFACE_STATE_POPUP) { | 87 | if (shell_surface->state == WLR_WL_SHELL_SURFACE_STATE_POPUP) { |
@@ -103,20 +101,18 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { | |||
103 | return; | 101 | return; |
104 | } | 102 | } |
105 | 103 | ||
106 | struct sway_view *sway_view = calloc(1, sizeof(struct sway_view)); | 104 | struct sway_view *view = view_create(SWAY_WL_SHELL_VIEW); |
107 | if (!sway_assert(sway_view, "Failed to allocate view!")) { | 105 | if (!sway_assert(view, "Failed to allocate view")) { |
108 | return; | 106 | return; |
109 | } | 107 | } |
110 | sway_view->type = SWAY_WL_SHELL_VIEW; | 108 | view->iface.get_prop = get_prop; |
111 | sway_view->iface.get_prop = get_prop; | 109 | view->iface.set_size = set_size; |
112 | sway_view->iface.set_size = set_size; | 110 | view->iface.set_position = set_position; |
113 | sway_view->iface.set_position = set_position; | 111 | view->iface.set_activated = set_activated; |
114 | sway_view->iface.set_activated = set_activated; | 112 | view->iface.close = close; |
115 | sway_view->iface.close = close; | 113 | view->wlr_wl_shell_surface = shell_surface; |
116 | sway_view->wlr_wl_shell_surface = shell_surface; | 114 | view->sway_wl_shell_surface = sway_surface; |
117 | sway_view->sway_wl_shell_surface = sway_surface; | 115 | sway_surface->view = view; |
118 | sway_view->surface = shell_surface->surface; | ||
119 | sway_surface->view = sway_view; | ||
120 | 116 | ||
121 | // TODO: | 117 | // TODO: |
122 | // - Wire up listeners | 118 | // - Wire up listeners |
@@ -132,11 +128,5 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { | |||
132 | sway_surface->destroy.notify = handle_destroy; | 128 | sway_surface->destroy.notify = handle_destroy; |
133 | wl_signal_add(&shell_surface->events.destroy, &sway_surface->destroy); | 129 | wl_signal_add(&shell_surface->events.destroy, &sway_surface->destroy); |
134 | 130 | ||
135 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 131 | view_map(view, shell_surface->surface); |
136 | struct sway_container *focus = sway_seat_get_focus_inactive(seat, &root_container); | ||
137 | struct sway_container *cont = container_view_create(focus, sway_view); | ||
138 | sway_view->swayc = cont; | ||
139 | |||
140 | arrange_windows(cont->parent, -1, -1); | ||
141 | sway_input_manager_set_focus(input_manager, cont); | ||
142 | } | 132 | } |