diff options
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r-- | sway/desktop/output.c | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index d649100f..04c9b4f6 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -29,23 +29,13 @@ | |||
29 | #include "sway/tree/view.h" | 29 | #include "sway/tree/view.h" |
30 | #include "sway/tree/workspace.h" | 30 | #include "sway/tree/workspace.h" |
31 | 31 | ||
32 | struct sway_output *output_by_name(const char *name) { | 32 | struct sway_output *output_by_name_or_id(const char *name_or_id) { |
33 | for (int i = 0; i < root->outputs->length; ++i) { | 33 | for (int i = 0; i < root->outputs->length; ++i) { |
34 | struct sway_output *output = root->outputs->items[i]; | 34 | struct sway_output *output = root->outputs->items[i]; |
35 | if (strcasecmp(output->wlr_output->name, name) == 0) { | 35 | char identifier[128]; |
36 | return output; | 36 | output_get_identifier(identifier, sizeof(identifier), output); |
37 | } | 37 | if (strcasecmp(identifier, name_or_id) == 0 |
38 | } | 38 | || strcasecmp(output->wlr_output->name, name_or_id) == 0) { |
39 | return NULL; | ||
40 | } | ||
41 | |||
42 | struct sway_output *output_by_identifier(const char *identifier) { | ||
43 | for (int i = 0; i < root->outputs->length; ++i) { | ||
44 | struct sway_output *output = root->outputs->items[i]; | ||
45 | char output_identifier[128]; | ||
46 | snprintf(output_identifier, sizeof(output_identifier), "%s %s %s", output->wlr_output->make, | ||
47 | output->wlr_output->model, output->wlr_output->serial); | ||
48 | if (strcasecmp(output_identifier, identifier) == 0) { | ||
49 | return output; | 39 | return output; |
50 | } | 40 | } |
51 | } | 41 | } |
@@ -110,7 +100,7 @@ static bool get_surface_box(struct surface_iterator_data *data, | |||
110 | } | 100 | } |
111 | 101 | ||
112 | struct wlr_box rotated_box; | 102 | struct wlr_box rotated_box; |
113 | wlr_box_rotated_bounds(&box, data->rotation, &rotated_box); | 103 | wlr_box_rotated_bounds(&rotated_box, &box, data->rotation); |
114 | 104 | ||
115 | struct wlr_box output_box = { | 105 | struct wlr_box output_box = { |
116 | .width = output->width, | 106 | .width = output->width, |
@@ -118,7 +108,7 @@ static bool get_surface_box(struct surface_iterator_data *data, | |||
118 | }; | 108 | }; |
119 | 109 | ||
120 | struct wlr_box intersection; | 110 | struct wlr_box intersection; |
121 | return wlr_box_intersection(&output_box, &rotated_box, &intersection); | 111 | return wlr_box_intersection(&intersection, &output_box, &rotated_box); |
122 | } | 112 | } |
123 | 113 | ||
124 | static void output_for_each_surface_iterator(struct wlr_surface *surface, | 114 | static void output_for_each_surface_iterator(struct wlr_surface *surface, |
@@ -310,7 +300,7 @@ static int scale_length(int length, int offset, float scale) { | |||
310 | return round((offset + length) * scale) - round(offset * scale); | 300 | return round((offset + length) * scale) - round(offset * scale); |
311 | } | 301 | } |
312 | 302 | ||
313 | static void scale_box(struct wlr_box *box, float scale) { | 303 | void scale_box(struct wlr_box *box, float scale) { |
314 | box->width = scale_length(box->width, box->x, scale); | 304 | box->width = scale_length(box->width, box->x, scale); |
315 | box->height = scale_length(box->height, box->y, scale); | 305 | box->height = scale_length(box->height, box->y, scale); |
316 | box->x = round(box->x * scale); | 306 | box->x = round(box->x * scale); |
@@ -433,7 +423,7 @@ static void damage_surface_iterator(struct sway_output *output, | |||
433 | } | 423 | } |
434 | 424 | ||
435 | if (whole) { | 425 | if (whole) { |
436 | wlr_box_rotated_bounds(&box, rotation, &box); | 426 | wlr_box_rotated_bounds(&box, &box, rotation); |
437 | wlr_output_damage_add_box(output->damage, &box); | 427 | wlr_output_damage_add_box(output->damage, &box); |
438 | } | 428 | } |
439 | 429 | ||
@@ -568,6 +558,8 @@ void handle_new_output(struct wl_listener *listener, void *data) { | |||
568 | 558 | ||
569 | if (!oc || oc->enabled) { | 559 | if (!oc || oc->enabled) { |
570 | output_enable(output, oc); | 560 | output_enable(output, oc); |
561 | } else { | ||
562 | wlr_output_enable(output->wlr_output, false); | ||
571 | } | 563 | } |
572 | 564 | ||
573 | transaction_commit_dirty(); | 565 | transaction_commit_dirty(); |