wayland: Add better detection for the current output

When there's only one output, just return that output.
This commit is contained in:
fwsmit 2021-04-30 21:46:52 +02:00
parent db5e6ce8f4
commit e69adcefea

View File

@ -341,20 +341,29 @@ static void add_seat_to_idle_handler(struct wl_seat *seat) {
// Warning, can return NULL // Warning, can return NULL
static struct dunst_output *get_configured_output() { static struct dunst_output *get_configured_output() {
switch (settings.f_mode){
case FOLLOW_NONE: ; // this semicolon is neccesary
int n = 0; int n = 0;
int target_monitor = settings.monitor; int target_monitor = settings.monitor;
struct dunst_output *output; struct dunst_output *first_output = NULL, *configured_output = NULL,
wl_list_for_each(output, &ctx.outputs, link) { *tmp_output = NULL;
wl_list_for_each(tmp_output, &ctx.outputs, link) {
if (n == 0)
first_output = tmp_output;
if (n == target_monitor) if (n == target_monitor)
return output; configured_output = tmp_output;
n++; n++;
} }
// There's only 1 output, so return that
if (n == 1)
return first_output;
switch (settings.f_mode){
case FOLLOW_NONE: ; // this semicolon is neccesary
if (!configured_output) {
LOG_W("Monitor %i doesn't exist, using focused monitor", settings.monitor); LOG_W("Monitor %i doesn't exist, using focused monitor", settings.monitor);
return NULL; }
return configured_output;
case FOLLOW_MOUSE: case FOLLOW_MOUSE:
// fallthrough // fallthrough
case FOLLOW_KEYBOARD: case FOLLOW_KEYBOARD: