all repos — tint2 @ f438ef712bbb673d58a448774446f148ebec4d8d

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Ignore monitors with size 0
o9000 mrovi9000@gmail.com
commit

f438ef712bbb673d58a448774446f148ebec4d8d

parent

0392c34e71e85d6b52771fa0e363d22ea18bbb03

1 files changed, 18 insertions(+), 22 deletions(-)

jump to
M src/server.csrc/server.c

@@ -317,38 +317,34 @@ RROutput primary_output = XRRGetOutputPrimary(server.display, server.root_win);

if (res && res->ncrtc >= num_monitors) { // use xrandr to identify monitors (does not work with proprietery nvidia drivers) - - // Workaround for issue https://gitlab.com/o9000/tint2/issues/353 - // on some recent configs, XRRGetScreenResourcesCurrent returns a fantom monitor at last position - { - int i = res->ncrtc - 1; - XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(server.display, res, res->crtcs[i]); - if (!(crtc_info->x || crtc_info->y || crtc_info->width || crtc_info->height)) { - res->ncrtc -= 1; - } - XRRFreeCrtcInfo(crtc_info); - } - printf("xRandr: Found crtc's: %d\n", res->ncrtc); server.monitors = calloc(res->ncrtc, sizeof(Monitor)); + num_monitors = 0; for (int i = 0; i < res->ncrtc; ++i) { XRRCrtcInfo *crtc_info = XRRGetCrtcInfo(server.display, res, res->crtcs[i]); - server.monitors[i].x = crtc_info->x; - server.monitors[i].y = crtc_info->y; - server.monitors[i].width = crtc_info->width; - server.monitors[i].height = crtc_info->height; - server.monitors[i].names = calloc((crtc_info->noutput + 1), sizeof(gchar *)); + // Ignore empty crtc + if (!crtc_info->width || !crtc_info->height) { + printf("xRandr: crtc %d seems disabled\n", i); + XRRFreeCrtcInfo(crtc_info); + continue; + } + int i_monitor = num_monitors; + num_monitors++; + server.monitors[i_monitor].x = crtc_info->x; + server.monitors[i_monitor].y = crtc_info->y; + server.monitors[i_monitor].width = crtc_info->width; + server.monitors[i_monitor].height = crtc_info->height; + server.monitors[i_monitor].names = calloc((crtc_info->noutput + 1), sizeof(gchar *)); for (int j = 0; j < crtc_info->noutput; ++j) { XRROutputInfo *output_info = XRRGetOutputInfo(server.display, res, crtc_info->outputs[j]); printf("xRandr: Linking output %s with crtc %d\n", output_info->name, i); - server.monitors[i].names[j] = g_strdup(output_info->name); + server.monitors[i_monitor].names[j] = g_strdup(output_info->name); XRRFreeOutputInfo(output_info); - server.monitors[i].primary = crtc_info->outputs[j] == primary_output; + server.monitors[i_monitor].primary = crtc_info->outputs[j] == primary_output; } - server.monitors[i].names[crtc_info->noutput] = NULL; + server.monitors[i_monitor].names[crtc_info->noutput] = NULL; XRRFreeCrtcInfo(crtc_info); } - num_monitors = res->ncrtc; } else if (info && num_monitors > 0) { server.monitors = calloc(num_monitors, sizeof(Monitor)); for (int i = 0; i < num_monitors; i++) {

@@ -356,7 +352,7 @@ server.monitors[i].x = info[i].x_org;

server.monitors[i].y = info[i].y_org; server.monitors[i].width = info[i].width; server.monitors[i].height = info[i].height; - server.monitors[i].names = 0; + server.monitors[i].names = NULL; } }