summaryrefslogtreecommitdiffstats
path: root/sway/desktop
diff options
context:
space:
mode:
authorLibravatar Tony Crisci <tony@dubstepdish.com>2017-12-16 07:33:23 -0500
committerLibravatar Tony Crisci <tony@dubstepdish.com>2017-12-16 07:33:23 -0500
commit9fa70ce426a78921fa61f25f8b30a73a2a7d9ad7 (patch)
tree823cce0da3f7e0dc21c26bef7e639e8370e29b3d /sway/desktop
parentkeyboard cleanup (diff)
parentMerge pull request #1503 from emersion/output-config (diff)
downloadsway-9fa70ce426a78921fa61f25f8b30a73a2a7d9ad7.tar.gz
sway-9fa70ce426a78921fa61f25f8b30a73a2a7d9ad7.tar.zst
sway-9fa70ce426a78921fa61f25f8b30a73a2a7d9ad7.zip
Merge branch 'wlroots' into feature/input
Diffstat (limited to 'sway/desktop')
-rw-r--r--sway/desktop/output.c48
-rw-r--r--sway/desktop/xwayland.c6
2 files changed, 32 insertions, 22 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index af067326..3b87c2e7 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -88,8 +88,7 @@ static void output_frame_view(swayc_t *view, void *data) {
88} 88}
89 89
90static void output_frame_notify(struct wl_listener *listener, void *data) { 90static void output_frame_notify(struct wl_listener *listener, void *data) {
91 struct sway_output *soutput = wl_container_of( 91 struct sway_output *soutput = wl_container_of(listener, soutput, frame);
92 listener, soutput, frame);
93 struct wlr_output *wlr_output = data; 92 struct wlr_output *wlr_output = data;
94 struct sway_server *server = soutput->server; 93 struct sway_server *server = soutput->server;
95 94
@@ -108,42 +107,53 @@ static void output_frame_notify(struct wl_listener *listener, void *data) {
108 soutput->last_frame = now; 107 soutput->last_frame = now;
109} 108}
110 109
111static void output_resolution_notify(struct wl_listener *listener, void *data) {
112 struct sway_output *soutput = wl_container_of(
113 listener, soutput, resolution);
114 arrange_windows(soutput->swayc, -1, -1);
115}
116
117void output_add_notify(struct wl_listener *listener, void *data) { 110void output_add_notify(struct wl_listener *listener, void *data) {
118 struct sway_server *server = wl_container_of(listener, server, output_add); 111 struct sway_server *server = wl_container_of(listener, server, output_add);
119 struct wlr_output *wlr_output = data; 112 struct wlr_output *wlr_output = data;
120 sway_log(L_DEBUG, "New output %p: %s", wlr_output, wlr_output->name); 113 sway_log(L_DEBUG, "New output %p: %s", wlr_output, wlr_output->name);
121 114
122 struct sway_output *output = calloc(1, sizeof(struct sway_output)); 115 struct sway_output *output = calloc(1, sizeof(struct sway_output));
116 if (!output) {
117 return;
118 }
123 output->wlr_output = wlr_output; 119 output->wlr_output = wlr_output;
124 output->server = server; 120 output->server = server;
125 output->swayc = new_output(output);
126 121
127 if (wl_list_length(&wlr_output->modes) > 0) { 122 if (!wl_list_empty(&wlr_output->modes)) {
128 struct wlr_output_mode *mode = NULL; 123 struct wlr_output_mode *mode =
129 mode = wl_container_of((&wlr_output->modes)->prev, mode, link); 124 wl_container_of(wlr_output->modes.prev, mode, link);
130 wlr_output_set_mode(wlr_output, mode); 125 wlr_output_set_mode(wlr_output, mode);
131 } 126 }
132 127
133 output->frame.notify = output_frame_notify; 128 output->swayc = new_output(output);
134 wl_signal_add(&wlr_output->events.frame, &output->frame); 129 if (!output->swayc) {
135 130 free(output);
136 output->resolution.notify = output_resolution_notify; 131 return;
137 wl_signal_add(&wlr_output->events.resolution, &output->resolution); 132 }
138 133
139 sway_input_manager_configure_xcursor(input_manager); 134 sway_input_manager_configure_xcursor(input_manager);
140 135
141 arrange_windows(output->swayc, -1, -1); 136 output->frame.notify = output_frame_notify;
137 wl_signal_add(&wlr_output->events.frame, &output->frame);
142} 138}
143 139
144void output_remove_notify(struct wl_listener *listener, void *data) { 140void output_remove_notify(struct wl_listener *listener, void *data) {
145 struct sway_server *server = wl_container_of(listener, server, output_remove); 141 struct sway_server *server = wl_container_of(listener, server, output_remove);
146 struct wlr_output *wlr_output = data; 142 struct wlr_output *wlr_output = data;
147 sway_log(L_DEBUG, "Output %p %s removed", wlr_output, wlr_output->name); 143 sway_log(L_DEBUG, "Output %p %s removed", wlr_output, wlr_output->name);
148 // TODO 144
145 swayc_t *output_container = NULL;
146 for (int i = 0 ; i < root_container.children->length; ++i) {
147 swayc_t *child = root_container.children->items[i];
148 if (child->type == C_OUTPUT &&
149 child->sway_output->wlr_output == wlr_output) {
150 output_container = child;
151 break;
152 }
153 }
154 if (!output_container) {
155 return;
156 }
157
158 destroy_output(output_container);
149} 159}
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index a7e84aa1..29bed955 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -57,7 +57,7 @@ static void set_position(struct sway_view *view, double ox, double oy) {
57 if (!sway_assert(root, "output must be within tree to set position")) { 57 if (!sway_assert(root, "output must be within tree to set position")) {
58 return; 58 return;
59 } 59 }
60 struct wlr_output_layout *layout = root->output_layout; 60 struct wlr_output_layout *layout = root->sway_root->output_layout;
61 struct wlr_output_layout_output *loutput = 61 struct wlr_output_layout_output *loutput =
62 wlr_output_layout_get(layout, output->sway_output->wlr_output); 62 wlr_output_layout_get(layout, output->sway_output->wlr_output);
63 if (!sway_assert(loutput, "output must be within layout to set position")) { 63 if (!sway_assert(loutput, "output must be within layout to set position")) {
@@ -149,14 +149,14 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
149 // TODO remove from the tree when the surface goes away (unmapped) 149 // TODO remove from the tree when the surface goes away (unmapped)
150 sway_view->surface = xsurface->surface; 150 sway_view->surface = xsurface->surface;
151 sway_surface->view = sway_view; 151 sway_surface->view = sway_view;
152 152
153 // TODO: 153 // TODO:
154 // - Wire up listeners 154 // - Wire up listeners
155 // - Handle popups 155 // - Handle popups
156 // - Look up pid and open on appropriate workspace 156 // - Look up pid and open on appropriate workspace
157 // - Set new view to maximized so it behaves nicely 157 // - Set new view to maximized so it behaves nicely
158 // - Criteria 158 // - Criteria
159 159
160 sway_surface->commit.notify = handle_commit; 160 sway_surface->commit.notify = handle_commit;
161 wl_signal_add(&xsurface->surface->events.commit, &sway_surface->commit); 161 wl_signal_add(&xsurface->surface->events.commit, &sway_surface->commit);
162 sway_surface->destroy.notify = handle_destroy; 162 sway_surface->destroy.notify = handle_destroy;