mirror of
https://github.com/labwc/labwc.git
synced 2026-06-13 14:33:18 -04:00
Merge abb7431a72 into d5b5b765c7
This commit is contained in:
commit
22ab20e93b
1 changed files with 36 additions and 2 deletions
38
src/output.c
38
src/output.c
|
|
@ -1099,6 +1099,24 @@ output_from_name(const char *name)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct output *
|
||||||
|
output_get_usable_mirror(struct output *output)
|
||||||
|
{
|
||||||
|
struct output *mirror;
|
||||||
|
struct wlr_box mirror_box, output_box;
|
||||||
|
wlr_output_layout_get_box(server.output_layout, output->wlr_output, &output_box);
|
||||||
|
wl_list_for_each(mirror, &server.outputs, link) {
|
||||||
|
if (!output_is_usable(mirror) || output->id_bit == mirror->id_bit) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
wlr_output_layout_get_box(server.output_layout, mirror->wlr_output, &mirror_box);
|
||||||
|
if (wlr_box_equal(&output_box, &mirror_box)) {
|
||||||
|
return mirror;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
struct output *
|
struct output *
|
||||||
output_nearest_to(int lx, int ly)
|
output_nearest_to(int lx, int ly)
|
||||||
{
|
{
|
||||||
|
|
@ -1107,7 +1125,7 @@ output_nearest_to(int lx, int ly)
|
||||||
&closest_x, &closest_y);
|
&closest_x, &closest_y);
|
||||||
|
|
||||||
return output_from_wlr_output(wlr_output_layout_output_at(server.output_layout,
|
return output_from_wlr_output(wlr_output_layout_output_at(server.output_layout,
|
||||||
closest_x, closest_y));
|
closest_x, closest_y));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct output *
|
struct output *
|
||||||
|
|
@ -1258,12 +1276,28 @@ handle_output_power_manager_set_mode(struct wl_listener *listener, void *data)
|
||||||
struct wlr_output_power_v1_set_mode_event *event = data;
|
struct wlr_output_power_v1_set_mode_event *event = data;
|
||||||
struct output *output = event->output->data;
|
struct output *output = event->output->data;
|
||||||
assert(output);
|
assert(output);
|
||||||
|
struct output *mirror = output_get_usable_mirror(output);
|
||||||
switch (event->mode) {
|
switch (event->mode) {
|
||||||
case ZWLR_OUTPUT_POWER_V1_MODE_OFF:
|
case ZWLR_OUTPUT_POWER_V1_MODE_OFF:
|
||||||
if (!event->output->enabled) {
|
if (!event->output->enabled) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (mirror) {
|
||||||
|
struct view *view;
|
||||||
|
for_each_view(view, &server.views, LAB_VIEW_CRITERIA_NONE) {
|
||||||
|
if (view->output == output) {
|
||||||
|
view->output = mirror;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Send the output that was turned off to the end of the list
|
||||||
|
* so wlr_output_* functions pick the mirror first
|
||||||
|
*/
|
||||||
|
struct wlr_output_layout_output *layout_output =
|
||||||
|
wlr_output_layout_get(server.output_layout, output->wlr_output);
|
||||||
|
wl_list_remove(&layout_output->link);
|
||||||
|
wl_list_insert(server.output_layout->outputs.prev, &layout_output->link);
|
||||||
|
}
|
||||||
wlr_output_state_set_enabled(&output->pending, false);
|
wlr_output_state_set_enabled(&output->pending, false);
|
||||||
output_state_commit(output);
|
output_state_commit(output);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue