diff options
-rw-r--r-- | include/sway/tree/output.h | 0 | ||||
-rw-r--r-- | sway/meson.build | 1 | ||||
-rw-r--r-- | sway/tree/container.c | 66 | ||||
-rw-r--r-- | sway/tree/output.c | 73 |
4 files changed, 74 insertions, 66 deletions
diff --git a/include/sway/tree/output.h b/include/sway/tree/output.h new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/include/sway/tree/output.h | |||
diff --git a/sway/meson.build b/sway/meson.build index 87d882d2..91aab0a0 100644 --- a/sway/meson.build +++ b/sway/meson.build | |||
@@ -88,6 +88,7 @@ sway_sources = files( | |||
88 | 'tree/layout.c', | 88 | 'tree/layout.c', |
89 | 'tree/view.c', | 89 | 'tree/view.c', |
90 | 'tree/workspace.c', | 90 | 'tree/workspace.c', |
91 | 'tree/output.c', | ||
91 | ) | 92 | ) |
92 | 93 | ||
93 | sway_deps = [ | 94 | sway_deps = [ |
diff --git a/sway/tree/container.c b/sway/tree/container.c index 8ed30b44..7f55ad90 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -7,7 +7,6 @@ | |||
7 | #include <wayland-server.h> | 7 | #include <wayland-server.h> |
8 | #include <wlr/types/wlr_output_layout.h> | 8 | #include <wlr/types/wlr_output_layout.h> |
9 | #include <wlr/types/wlr_wl_shell.h> | 9 | #include <wlr/types/wlr_wl_shell.h> |
10 | #include "log.h" | ||
11 | #include "sway/config.h" | 10 | #include "sway/config.h" |
12 | #include "sway/input/input-manager.h" | 11 | #include "sway/input/input-manager.h" |
13 | #include "sway/input/seat.h" | 12 | #include "sway/input/seat.h" |
@@ -312,71 +311,6 @@ struct sway_container *container_close(struct sway_container *con) { | |||
312 | return parent; | 311 | return parent; |
313 | } | 312 | } |
314 | 313 | ||
315 | struct sway_container *output_create( | ||
316 | struct sway_output *sway_output) { | ||
317 | struct wlr_box size; | ||
318 | wlr_output_effective_resolution(sway_output->wlr_output, &size.width, | ||
319 | &size.height); | ||
320 | |||
321 | const char *name = sway_output->wlr_output->name; | ||
322 | char identifier[128]; | ||
323 | output_get_identifier(identifier, sizeof(identifier), sway_output); | ||
324 | |||
325 | struct output_config *oc = NULL, *all = NULL; | ||
326 | for (int i = 0; i < config->output_configs->length; ++i) { | ||
327 | struct output_config *cur = config->output_configs->items[i]; | ||
328 | |||
329 | if (strcasecmp(name, cur->name) == 0 || | ||
330 | strcasecmp(identifier, cur->name) == 0) { | ||
331 | wlr_log(L_DEBUG, "Matched output config for %s", name); | ||
332 | oc = cur; | ||
333 | } | ||
334 | if (strcasecmp("*", cur->name) == 0) { | ||
335 | wlr_log(L_DEBUG, "Matched wildcard output config for %s", name); | ||
336 | all = cur; | ||
337 | } | ||
338 | |||
339 | if (oc && all) { | ||
340 | break; | ||
341 | } | ||
342 | } | ||
343 | if (!oc) { | ||
344 | oc = all; | ||
345 | } | ||
346 | |||
347 | if (oc && !oc->enabled) { | ||
348 | return NULL; | ||
349 | } | ||
350 | |||
351 | struct sway_container *output = container_create(C_OUTPUT); | ||
352 | output->sway_output = sway_output; | ||
353 | output->name = strdup(name); | ||
354 | if (output->name == NULL) { | ||
355 | container_destroy(output); | ||
356 | return NULL; | ||
357 | } | ||
358 | |||
359 | apply_output_config(oc, output); | ||
360 | container_add_child(&root_container, output); | ||
361 | load_swaybars(); | ||
362 | |||
363 | // Create workspace | ||
364 | char *ws_name = workspace_next_name(output->name); | ||
365 | wlr_log(L_DEBUG, "Creating default workspace %s", ws_name); | ||
366 | struct sway_container *ws = workspace_create(output, ws_name); | ||
367 | // Set each seat's focus if not already set | ||
368 | struct sway_seat *seat = NULL; | ||
369 | wl_list_for_each(seat, &input_manager->seats, link) { | ||
370 | if (!seat->has_focus) { | ||
371 | seat_set_focus(seat, ws); | ||
372 | } | ||
373 | } | ||
374 | |||
375 | free(ws_name); | ||
376 | container_create_notify(output); | ||
377 | return output; | ||
378 | } | ||
379 | |||
380 | struct sway_container *container_view_create(struct sway_container *sibling, | 314 | struct sway_container *container_view_create(struct sway_container *sibling, |
381 | struct sway_view *sway_view) { | 315 | struct sway_view *sway_view) { |
382 | if (!sway_assert(sibling, | 316 | if (!sway_assert(sibling, |
diff --git a/sway/tree/output.c b/sway/tree/output.c new file mode 100644 index 00000000..6c7044a2 --- /dev/null +++ b/sway/tree/output.c | |||
@@ -0,0 +1,73 @@ | |||
1 | #define _POSIX_C_SOURCE 200809L | ||
2 | #include <string.h> | ||
3 | #include <strings.h> | ||
4 | #include "sway/output.h" | ||
5 | #include "sway/tree/output.h" | ||
6 | #include "sway/tree/workspace.h" | ||
7 | #include "log.h" | ||
8 | |||
9 | struct sway_container *output_create( | ||
10 | struct sway_output *sway_output) { | ||
11 | struct wlr_box size; | ||
12 | wlr_output_effective_resolution(sway_output->wlr_output, &size.width, | ||
13 | &size.height); | ||
14 | |||
15 | const char *name = sway_output->wlr_output->name; | ||
16 | char identifier[128]; | ||
17 | output_get_identifier(identifier, sizeof(identifier), sway_output); | ||
18 | |||
19 | struct output_config *oc = NULL, *all = NULL; | ||
20 | for (int i = 0; i < config->output_configs->length; ++i) { | ||
21 | struct output_config *cur = config->output_configs->items[i]; | ||
22 | |||
23 | if (strcasecmp(name, cur->name) == 0 || | ||
24 | strcasecmp(identifier, cur->name) == 0) { | ||
25 | wlr_log(L_DEBUG, "Matched output config for %s", name); | ||
26 | oc = cur; | ||
27 | } | ||
28 | if (strcasecmp("*", cur->name) == 0) { | ||
29 | wlr_log(L_DEBUG, "Matched wildcard output config for %s", name); | ||
30 | all = cur; | ||
31 | } | ||
32 | |||
33 | if (oc && all) { | ||
34 | break; | ||
35 | } | ||
36 | } | ||
37 | if (!oc) { | ||
38 | oc = all; | ||
39 | } | ||
40 | |||
41 | if (oc && !oc->enabled) { | ||
42 | return NULL; | ||
43 | } | ||
44 | |||
45 | struct sway_container *output = container_create(C_OUTPUT); | ||
46 | output->sway_output = sway_output; | ||
47 | output->name = strdup(name); | ||
48 | if (output->name == NULL) { | ||
49 | container_destroy(output); | ||
50 | return NULL; | ||
51 | } | ||
52 | |||
53 | apply_output_config(oc, output); | ||
54 | container_add_child(&root_container, output); | ||
55 | load_swaybars(); | ||
56 | |||
57 | // Create workspace | ||
58 | char *ws_name = workspace_next_name(output->name); | ||
59 | wlr_log(L_DEBUG, "Creating default workspace %s", ws_name); | ||
60 | struct sway_container *ws = workspace_create(output, ws_name); | ||
61 | // Set each seat's focus if not already set | ||
62 | struct sway_seat *seat = NULL; | ||
63 | wl_list_for_each(seat, &input_manager->seats, link) { | ||
64 | if (!seat->has_focus) { | ||
65 | seat_set_focus(seat, ws); | ||
66 | } | ||
67 | } | ||
68 | |||
69 | free(ws_name); | ||
70 | container_create_notify(output); | ||
71 | return output; | ||
72 | } | ||
73 | |||