sway: Add non-desktop-output type

Currently, when encountering a non-desktop display, sway offers the
output for leasing and returns without storing it in a sway specific
output type like `struct sway_output`.  Additionally, running
`swaymsg -t get_outputs` doesn't show non-desktop outputs.

This commit stores the non-desktop outputs into a struct called
`sway_output_non_desktop`, and adds them to a list on `sway_root`
master
Alex Maese 3 years ago committed by Simon Zeni
parent 1c368fbb5f
commit c015db4a9f

@ -57,6 +57,12 @@ struct sway_output {
struct wl_event_source *repaint_timer; struct wl_event_source *repaint_timer;
}; };
struct sway_output_non_desktop {
struct wlr_output *wlr_output;
struct wl_listener destroy;
};
struct sway_output *output_create(struct wlr_output *wlr_output); struct sway_output *output_create(struct wlr_output *wlr_output);
void output_destroy(struct sway_output *output); void output_destroy(struct sway_output *output);
@ -177,4 +183,6 @@ void handle_output_manager_test(struct wl_listener *listener, void *data);
void handle_output_power_manager_set_mode(struct wl_listener *listener, void handle_output_power_manager_set_mode(struct wl_listener *listener,
void *data); void *data);
struct sway_output_non_desktop *output_non_desktop_create(struct wlr_output *wlr_output);
#endif #endif

@ -28,6 +28,7 @@ struct sway_root {
double width, height; double width, height;
list_t *outputs; // struct sway_output list_t *outputs; // struct sway_output
list_t *non_desktop_outputs; // struct sway_output_non_desktop
list_t *scratchpad; // struct sway_container list_t *scratchpad; // struct sway_container
// For when there's no connected outputs // For when there's no connected outputs

@ -883,10 +883,12 @@ void handle_new_output(struct wl_listener *listener, void *data) {
if (wlr_output->non_desktop) { if (wlr_output->non_desktop) {
sway_log(SWAY_DEBUG, "Not configuring non-desktop output"); sway_log(SWAY_DEBUG, "Not configuring non-desktop output");
struct sway_output_non_desktop *non_desktop = output_non_desktop_create(wlr_output);
if (server->drm_lease_manager) { if (server->drm_lease_manager) {
wlr_drm_lease_v1_manager_offer_output(server->drm_lease_manager, wlr_drm_lease_v1_manager_offer_output(server->drm_lease_manager,
wlr_output); wlr_output);
} }
list_add(root->non_desktop_outputs, non_desktop);
return; return;
} }

@ -9,6 +9,7 @@
#include "sway/output.h" #include "sway/output.h"
#include "sway/tree/arrange.h" #include "sway/tree/arrange.h"
#include "sway/tree/workspace.h" #include "sway/tree/workspace.h"
#include "sway/server.h"
#include "log.h" #include "log.h"
#include "util.h" #include "util.h"
@ -390,6 +391,33 @@ void output_get_box(struct sway_output *output, struct wlr_box *box) {
box->height = output->height; box->height = output->height;
} }
static void handle_destroy_non_desktop(struct wl_listener *listener, void *data) {
struct sway_output_non_desktop *output =
wl_container_of(listener, output, destroy);
sway_log(SWAY_DEBUG, "Destroying non-desktop output '%s'", output->wlr_output->name);
int index = list_find(root->non_desktop_outputs, output);
list_del(root->non_desktop_outputs, index);
wl_list_remove(&output->destroy.link);
free(output);
}
struct sway_output_non_desktop *output_non_desktop_create(
struct wlr_output *wlr_output) {
struct sway_output_non_desktop *output =
calloc(1, sizeof(struct sway_output_non_desktop));
output->wlr_output = wlr_output;
wl_signal_add(&wlr_output->events.destroy, &output->destroy);
output->destroy.notify = handle_destroy_non_desktop;
return output;
}
enum sway_container_layout output_get_default_layout( enum sway_container_layout output_get_default_layout(
struct sway_output *output) { struct sway_output *output) {
if (config->default_orientation != L_NONE) { if (config->default_orientation != L_NONE) {

@ -38,6 +38,7 @@ struct sway_root *root_create(void) {
wl_list_init(&root->drag_icons); wl_list_init(&root->drag_icons);
wl_signal_init(&root->events.new_node); wl_signal_init(&root->events.new_node);
root->outputs = create_list(); root->outputs = create_list();
root->non_desktop_outputs = create_list();
root->scratchpad = create_list(); root->scratchpad = create_list();
root->output_layout_change.notify = output_layout_handle_change; root->output_layout_change.notify = output_layout_handle_change;

Loading…
Cancel
Save