diff options
author | Tony Crisci <tony@dubstepdish.com> | 2018-04-03 20:00:09 -0400 |
---|---|---|
committer | Tony Crisci <tony@dubstepdish.com> | 2018-04-03 20:00:09 -0400 |
commit | fa004dd0d78b922b75a6cc9c970824d18aa4e4aa (patch) | |
tree | 1e4468322ed60e5b0930b1e7b6e43c5fab970d99 /sway/tree/output.c | |
parent | move workspace create to workspace.c (diff) | |
download | sway-fa004dd0d78b922b75a6cc9c970824d18aa4e4aa.tar.gz sway-fa004dd0d78b922b75a6cc9c970824d18aa4e4aa.tar.zst sway-fa004dd0d78b922b75a6cc9c970824d18aa4e4aa.zip |
move output create to its own file
Diffstat (limited to 'sway/tree/output.c')
-rw-r--r-- | sway/tree/output.c | 73 |
1 files changed, 73 insertions, 0 deletions
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 | |||