From e5b4fb4c7c0cdaf32da87e0b05028ab2bbab363a Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Fri, 11 Sep 2020 15:39:05 +0100 Subject: [PATCH 1/8] CRTSwitchRes improvements and Core Load Chrash Fix --- gfx/display_servers/dispserv_x11.c | 300 ++++++++++++++++++++++------- 1 file changed, 228 insertions(+), 72 deletions(-) diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index 463d320bb4..958c111058 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -50,6 +50,7 @@ static char orig_output[256] = {0}; static char old_mode[256] = {0}; static char new_mode[256] = {0}; static XRRModeInfo crt_rrmode; +int g_monitor_index = 0; #endif static bool x11_display_server_using_global_dpy = false; @@ -106,6 +107,11 @@ static bool x11_display_server_set_resolution(void *data, int pwidth = 0; float roundw = 0.0f; float pixel_clock = 0; + bool crt_exists = false; + + g_monitor_index = monitor_index; + + XRRScreenResources *resources; crt_en = true; crt_name_id += 1; @@ -169,52 +175,81 @@ static bool x11_display_server_set_resolution(void *data, vbp = vmax; if (height < 300) - pixel_clock = (hmax * vmax * hz) / 1000000; + pixel_clock = (hmax * vmax * hz) ; if (height > 300) - pixel_clock = ((hmax * vmax * hz) / 1000000) / 2; + pixel_clock = (hmax * vmax * hz) / 2; /* above code is the modeline generator */ /* create interlaced newmode from modline variables */ if (height < 300) { - snprintf(xrandr, sizeof(xrandr), - "xrandr --newmode \"%s_%dx%d_%0.2f\" %f %d %d %d %d %d %d %d %d -hsync -vsync", - crt_name, width, height, hz, pixel_clock, width, hfp, hsp, hbp, height, vfp, vsp, vbp); - system(xrandr); + crt_mode_flag = 10; } /* create interlaced newmode from modline variables */ if (height > 300) { - snprintf(xrandr, sizeof(xrandr), - "xrandr --newmode \"%s_%dx%d_%0.2f\" %f %d %d %d %d %d %d %d %d interlace -hsync -vsync", - crt_name, width, height, hz, pixel_clock, width, hfp, hsp, hbp, height, vfp, vsp, vbp); - system(xrandr); + crt_mode_flag = 26; } - + snprintf(old_mode, sizeof(old_mode), "%s", new_mode); /* variable for new mode */ snprintf(new_mode, sizeof(new_mode), "%s_%dx%d_%0.2f", crt_name, width, height, hz); /* need to run loops for DVI0 - DVI-2 and VGA0 - VGA-2 outputs to * add and delete modes */ - crt_rrmode.id = crt_id; - crt_rrmode.width = width; - crt_rrmode.height = height; + + crt_rrmode.name = new_mode; + crt_rrmode.nameLength = strlen(crt_name); crt_rrmode.dotClock = pixel_clock; + crt_rrmode.width = width; crt_rrmode.hSyncStart = hfp; crt_rrmode.hSyncEnd = hsp; crt_rrmode.hTotal = hmax; - crt_rrmode.hSkew = 0; + crt_rrmode.height = height; crt_rrmode.vSyncStart = vfp; crt_rrmode.vSyncEnd = vsp; - crt_rrmode.vTotal = vmax; - crt_rrmode.name = new_mode; - crt_rrmode.nameLength = sizeof(new_mode); - crt_rrmode.modeFlags = 0; + crt_rrmode.vTotal = vbp; + crt_rrmode.modeFlags = crt_mode_flag; /* 10 for -hsync -vsync. 26 for -hsync -vsync interlaced */ + crt_rrmode.hSkew = 0; + XRRModeInfo *crt_xrrmode = &crt_rrmode; res = XRRGetScreenResources(dpy, window); + XSync(dpy, False); - if (monitor_index == 0) + resources = XRRGetScreenResourcesCurrent(dpy, window); + + for (int m = 0; m < resources->nmode; m++) + { + if (strcmp(resources->modes[m].name, new_mode) == 0) + { + + crt_exists = true; + break; + } + } + + XRRFreeScreenResources(resources); + + + if (crt_exists == false) + { + RRMode wMode = XRRCreateMode(dpy, window, &crt_rrmode); + } + + XRRModeInfo *swmode = NULL; + resources = XRRGetScreenResourcesCurrent(dpy, window); + + for (int m = 0; m < resources->nmode; m++) + { + if (strcmp(resources->modes[m].name, new_mode) == 0) + { + + swmode = &resources->modes[m]; + break; + } + } + + if (monitor_index == 20) { for (i = 0; i < res->noutput; i++) { @@ -222,52 +257,48 @@ static bool x11_display_server_set_resolution(void *data, if (outputs->connection == RR_Connected) { + XRRAddOutputMode(dpy, res->outputs[i], swmode->id); + XSync(dpy, False); snprintf(orig_output, sizeof(orig_output), "%s", outputs->name); + XRRCrtcInfo *crtc = XRRGetCrtcInfo(dpy, resources, outputs->crtc); + crtc->mode = swmode->id; + crtc->width = swmode->width; + crtc->height = swmode->height; + XRRSetCrtcConfig(dpy, res,res->crtcs[i], CurrentTime, 0, 0, None, RR_Rotate_0, NULL, 0); + XSync(dpy, False); + XRRSetScreenSize(dpy, window, width, height, (int) ((25.4 * width) / 96.0), (int) ((25.4 * height) / 96.0)); + XRRSetCrtcConfig(dpy, res, res->crtcs[i], CurrentTime, crtc->x, crtc->y, crtc->mode, crtc->rotation, crtc->outputs, crtc->noutput); + XSync(dpy, False); - snprintf(xrandr, sizeof(xrandr), - "xrandr --addmode \"%s\" \"%s\"", - outputs->name, new_mode); - system(xrandr); - snprintf(xrandr, sizeof(xrandr), - "xrandr --output \"%s\" --mode \"%s\"", - outputs->name, new_mode); - system(xrandr); - snprintf(xrandr, sizeof(xrandr), - "xrandr --delmode \"%s\" \"%s\"", - outputs->name, old_mode); - system(xrandr); - snprintf(xrandr, sizeof(xrandr), - "xrandr --rmmode \"%s\"", - old_mode); - system(xrandr); + XRRFreeCrtcInfo(crtc); + XRRFreeOutputInfo(outputs); } } + XRRFreeScreenResources(resources); } - else if (monitor_index > 0) + else if (monitor_index != 20) { XRROutputInfo *outputs = XRRGetOutputInfo(dpy, res, res->outputs[monitor_index]); if (outputs->connection == RR_Connected) { + XRRAddOutputMode(dpy, res->outputs[monitor_index], swmode->id); + XSync(dpy, False); snprintf(orig_output, sizeof(orig_output), "%s", outputs->name); + XRRCrtcInfo *crtc = XRRGetCrtcInfo(dpy, resources, outputs->crtc); + crtc->mode = swmode->id; + crtc->width = swmode->width; + crtc->height = swmode->height; + XRRSetCrtcConfig(dpy, res,res->crtcs[monitor_index], CurrentTime, 0, 0, None, RR_Rotate_0, NULL, 0); + XSync(dpy, False); + XRRSetScreenSize(dpy, window, width, height, (int) ((25.4 * width) / 96.0), (int) ((25.4 * height) / 96.0)); + XRRSetCrtcConfig(dpy, res, res->crtcs[monitor_index], CurrentTime, crtc->x, crtc->y, crtc->mode, crtc->rotation, crtc->outputs, crtc->noutput); + XSync(dpy, False); - snprintf(xrandr, sizeof(xrandr), - "xrandr --addmode \"%s\" \"%s\"", - outputs->name, new_mode); - system(xrandr); - snprintf(xrandr, sizeof(xrandr), - "xrandr --output \"%s\" --mode \"%s\"", - outputs->name, new_mode); - system(xrandr); - snprintf(xrandr, sizeof(xrandr), - "xrandr --delmode \"%s\" \"%s\"", - outputs->name, old_mode); - system(xrandr); - snprintf(xrandr, sizeof(xrandr), - "xrandr --rmmode \"%s\"", - old_mode); - system(xrandr); + XRRFreeCrtcInfo(crtc); } + XRRFreeOutputInfo(outputs); + XRRFreeScreenResources(resources); } return true; } @@ -440,27 +471,152 @@ static void x11_display_server_destroy(void *data) dispserv_x11_t *dispserv = (dispserv_x11_t*)data; #ifdef HAVE_XRANDR + int screen; + Window window; + XRRScreenResources *res = NULL; + Display *dpy = NULL; + XRRScreenResources *resources; + dpy = XOpenDisplay(0); + screen = DefaultScreen(dpy); + window = RootWindow(dpy, screen); + bool crt_exists = false; + char dmode[25] ={}; if (crt_en) { - snprintf(xrandr, sizeof(xrandr), - "xrandr --newmode 700x480_59.94 13.849698 700 742 801 867 480 490 496 533 interlace -hsync -vsync"); - system(xrandr); - snprintf(xrandr, sizeof(xrandr), - "xrandr --addmode \"%s\" 700x480_59.94", - orig_output); - system(xrandr); - snprintf(xrandr, sizeof(xrandr), - "xrandr --output \"%s\" --mode 700x480_59.94", - orig_output); - system(xrandr); - snprintf(xrandr, sizeof(xrandr), - "xrandr --delmode \"%s\" \"%s\"", - orig_output, old_mode); - system(xrandr); - snprintf(xrandr, sizeof(xrandr), - "xrandr --rmmode \"%s\"", - old_mode); - system(xrandr); + snprintf(dmode, sizeof(dmode), "%s", "d_mo"); + + crt_rrmode.name = dmode; + crt_rrmode.nameLength = strlen(crt_name); + crt_rrmode.dotClock = 13849698; + crt_rrmode.width = 700; + crt_rrmode.hSyncStart = 742; + crt_rrmode.hSyncEnd = 801; + crt_rrmode.hTotal = 867; + crt_rrmode.height = 480; + crt_rrmode.vSyncStart = 490; + crt_rrmode.vSyncEnd = 496; + crt_rrmode.vTotal = 533; + crt_rrmode.modeFlags = 26; /* 10 for -hsync -vsync. ?? for -hsync -vsync interlaced */ + crt_rrmode.hSkew = 0; + + + res = XRRGetScreenResources(dpy, window); + resources = XRRGetScreenResourcesCurrent(dpy, window); + XRRModeInfo *swoldmode = NULL; + XRRModeInfo *swdeskmode = NULL; + XSync(dpy, False); + + resources = XRRGetScreenResourcesCurrent(dpy, window); + + for (int m = 0; m < resources->nmode; m++) + { + if (strcmp(resources->modes[m].name, dmode) == 0) + { + + crt_exists = true; + break; + } + } + + XRRFreeScreenResources(resources); + + + if (crt_exists == false) + { + RRMode wMode = XRRCreateMode(dpy, window, &crt_rrmode); + } + + + resources = XRRGetScreenResourcesCurrent(dpy, window); + + for (int m = 0; m < resources->nmode; m++) + { + if (strcmp(resources->modes[m].name, dmode) == 0) + { + + swdeskmode = &resources->modes[m]; + break; + } + } + + + if (g_monitor_index == 20) + { + for (int i = 0; i < res->noutput; i++) + { + XRROutputInfo *outputs = XRRGetOutputInfo(dpy, res, res->outputs[i]); + + + if (outputs->connection == RR_Connected) + { + + XRRAddOutputMode(dpy, res->outputs[i], swdeskmode->id); + XSync(dpy, False); + snprintf(orig_output, sizeof(orig_output), "%s", outputs->name); + XRRCrtcInfo *crtc = XRRGetCrtcInfo(dpy, resources, outputs->crtc); + crtc->mode = swdeskmode->id; + crtc->width = swdeskmode->width; + crtc->height = swdeskmode->height; + XRRSetCrtcConfig(dpy, res,res->crtcs[i], CurrentTime, 0, 0, None, RR_Rotate_0, NULL, 0); + XSync(dpy, False); + XRRSetScreenSize(dpy, window, crt_rrmode.width, crt_rrmode.height, (int) ((25.4 * crt_rrmode.width) / 96.0), (int) ((25.4 * crt_rrmode.height) / 96.0)); + XRRSetCrtcConfig(dpy, res, res->crtcs[i], CurrentTime, crtc->x, crtc->y, crtc->mode, crtc->rotation, crtc->outputs, crtc->noutput); + XSync(dpy, False); + + XRRFreeCrtcInfo(crtc); + XRRFreeOutputInfo(outputs); + + } + } + XRRFreeScreenResources(resources); + } + else if (g_monitor_index != 20) + { + + XRROutputInfo *outputs = XRRGetOutputInfo(dpy, res, res->outputs[g_monitor_index]); + + if (outputs->connection == RR_Connected) + { + XRRAddOutputMode(dpy, res->outputs[g_monitor_index], swdeskmode->id); + XSync(dpy, False); + snprintf(orig_output, sizeof(orig_output), "%s", outputs->name); + XRRCrtcInfo *crtc = XRRGetCrtcInfo(dpy, resources, outputs->crtc); + crtc->mode = swdeskmode->id; + crtc->width = swdeskmode->width; + crtc->height = swdeskmode->height; + XRRSetCrtcConfig(dpy, res,res->crtcs[g_monitor_index], CurrentTime, 0, 0, None, RR_Rotate_0, NULL, 0); + XSync(dpy, False); + XRRSetScreenSize(dpy, window, crt_rrmode.width, crt_rrmode.height, (int) ((25.4 * crt_rrmode.width) / 96.0), (int) ((25.4 * crt_rrmode.height) / 96.0)); + XRRSetCrtcConfig(dpy, res, res->crtcs[g_monitor_index], CurrentTime, crtc->x, crtc->y, crtc->mode, crtc->rotation, crtc->outputs, crtc->noutput); + XSync(dpy, False); + + XRRFreeCrtcInfo(crtc); + } + } + + + + for (int m = 0; m < resources->nmode; m++) + { + for (int j = 0; j < res->noutput; j++) + { + for (int i = 1 ; i <= crt_name_id; i++ ) + { + XRROutputInfo *outputs = XRRGetOutputInfo(dpy, res, res->outputs[j]); + if (outputs->connection == RR_Connected) + { + snprintf(old_mode, sizeof(old_mode), "CRT%d", i); + if (strcmp(resources->modes[m].name, old_mode) == 0) + { + swoldmode = &resources->modes[m]; + XRRDeleteOutputMode(dpy, res->outputs[j], swoldmode->id); + XRRDestroyMode(dpy, swoldmode->id); + XSync(dpy, False); + } + } + } + } + } } #endif From 877408adda9133e016c61dfaf669669e267448d1 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Fri, 11 Sep 2020 15:57:56 +0100 Subject: [PATCH 2/8] Fixed Missing Variable --- gfx/display_servers/dispserv_x11.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index 958c111058..f99eacf09a 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -107,6 +107,7 @@ static bool x11_display_server_set_resolution(void *data, int pwidth = 0; float roundw = 0.0f; float pixel_clock = 0; + int crt_mode_flag = 0; bool crt_exists = false; g_monitor_index = monitor_index; From dc19dd3db4fcc6cfc22977fa67598cb458fb42a3 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Fri, 11 Sep 2020 16:17:46 +0100 Subject: [PATCH 3/8] Closing XDisp to reduce mem leaks --- gfx/display_servers/dispserv_x11.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index f99eacf09a..9d2188bb37 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -300,6 +300,7 @@ static bool x11_display_server_set_resolution(void *data, } XRRFreeOutputInfo(outputs); XRRFreeScreenResources(resources); + XCloseDisplay(dpy); } return true; } @@ -619,6 +620,8 @@ static void x11_display_server_destroy(void *data) } } } + XRRFreeScreenResources(resources); + XCloseDisplay(dpy); #endif if (dispserv) From afc3badd72cae452685a96198d36e060a2207893 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Fri, 11 Sep 2020 16:30:43 +0100 Subject: [PATCH 4/8] Fixed Crash On Core Load --- gfx/display_servers/dispserv_x11.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index 9d2188bb37..1647b5fd56 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -276,6 +276,7 @@ static bool x11_display_server_set_resolution(void *data, } } XRRFreeScreenResources(resources); + XCloseDisplay(dpy); } else if (monitor_index != 20) { @@ -619,9 +620,10 @@ static void x11_display_server_destroy(void *data) } } } + XRRFreeScreenResources(resources); + XCloseDisplay(dpy); } - XRRFreeScreenResources(resources); - XCloseDisplay(dpy); + #endif if (dispserv) From d7d03a87592c8ee39385668b52a2f00a27d2e94f Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Fri, 11 Sep 2020 16:59:38 +0100 Subject: [PATCH 5/8] Clean up resources to reduce memory leaks --- gfx/display_servers/dispserv_x11.c | 54 +++++++++++++++++++----------- 1 file changed, 35 insertions(+), 19 deletions(-) diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index 1647b5fd56..749a7d4099 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -271,11 +271,15 @@ static bool x11_display_server_set_resolution(void *data, XRRSetCrtcConfig(dpy, res, res->crtcs[i], CurrentTime, crtc->x, crtc->y, crtc->mode, crtc->rotation, crtc->outputs, crtc->noutput); XSync(dpy, False); - XRRFreeCrtcInfo(crtc); - XRRFreeOutputInfo(outputs); + } + XRRFreeCrtcInfo(crtc); + XRRFreeOutputInfo(outputs); } + XRRFreeCrtcInfo(crtc); + XRRFreeOutputInfo(outputs); XRRFreeScreenResources(resources); + XRRFreeScreenResources(res); XCloseDisplay(dpy); } else if (monitor_index != 20) @@ -296,11 +300,12 @@ static bool x11_display_server_set_resolution(void *data, XRRSetScreenSize(dpy, window, width, height, (int) ((25.4 * width) / 96.0), (int) ((25.4 * height) / 96.0)); XRRSetCrtcConfig(dpy, res, res->crtcs[monitor_index], CurrentTime, crtc->x, crtc->y, crtc->mode, crtc->rotation, crtc->outputs, crtc->noutput); XSync(dpy, False); - + XRRFreeOutputInfo(outputs); XRRFreeCrtcInfo(crtc); } - XRRFreeOutputInfo(outputs); + XRRFreeScreenResources(resources); + XRRFreeScreenResources(res); XCloseDisplay(dpy); } return true; @@ -474,19 +479,20 @@ static void x11_display_server_destroy(void *data) dispserv_x11_t *dispserv = (dispserv_x11_t*)data; #ifdef HAVE_XRANDR - int screen; - Window window; - XRRScreenResources *res = NULL; - Display *dpy = NULL; - XRRScreenResources *resources; - dpy = XOpenDisplay(0); - screen = DefaultScreen(dpy); - window = RootWindow(dpy, screen); - bool crt_exists = false; - char dmode[25] ={}; if (crt_en) { - snprintf(dmode, sizeof(dmode), "%s", "d_mo"); + int screen; + Window window; + XRRScreenResources *res = NULL; + Display *dpy = NULL; + XRRScreenResources *resources; + dpy = XOpenDisplay(0); + screen = DefaultScreen(dpy); + window = RootWindow(dpy, screen); + bool crt_exists = false; + char dmode[25] ={}; + + snprintf(dmode, sizeof(dmode), "%s", "d_mo"); crt_rrmode.name = dmode; crt_rrmode.nameLength = strlen(crt_name); @@ -566,12 +572,16 @@ static void x11_display_server_destroy(void *data) XRRSetCrtcConfig(dpy, res, res->crtcs[i], CurrentTime, crtc->x, crtc->y, crtc->mode, crtc->rotation, crtc->outputs, crtc->noutput); XSync(dpy, False); + XRRFreeCrtcInfo(crtc); - XRRFreeOutputInfo(outputs); - } + XRRFreeOutputInfo(outputs); } - XRRFreeScreenResources(resources); + + XRRFreeScreenResources(resources); + XRRFreeScreenResources(res); + XCloseDisplay(dpy); + } else if (g_monitor_index != 20) { @@ -593,8 +603,13 @@ static void x11_display_server_destroy(void *data) XRRSetCrtcConfig(dpy, res, res->crtcs[g_monitor_index], CurrentTime, crtc->x, crtc->y, crtc->mode, crtc->rotation, crtc->outputs, crtc->noutput); XSync(dpy, False); - XRRFreeCrtcInfo(crtc); + XRRFreeCrtcInfo(crtc); } + + XRRFreeOutputInfo(outputs); + XRRFreeScreenResources(resources); + XRRFreeScreenResources(res); + XCloseDisplay(dpy); } @@ -621,6 +636,7 @@ static void x11_display_server_destroy(void *data) } } XRRFreeScreenResources(resources); + XRRFreeScreenResources(res); XCloseDisplay(dpy); } From 7b2588c7216d659199efa1864cd19e7e69c357c1 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Fri, 11 Sep 2020 17:31:17 +0100 Subject: [PATCH 6/8] Fix mem compile errors --- gfx/display_servers/dispserv_x11.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index 749a7d4099..cec73a2962 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -270,14 +270,14 @@ static bool x11_display_server_set_resolution(void *data, XRRSetScreenSize(dpy, window, width, height, (int) ((25.4 * width) / 96.0), (int) ((25.4 * height) / 96.0)); XRRSetCrtcConfig(dpy, res, res->crtcs[i], CurrentTime, crtc->x, crtc->y, crtc->mode, crtc->rotation, crtc->outputs, crtc->noutput); XSync(dpy, False); - + + XRRFreeCrtcInfo(crtc); } - XRRFreeCrtcInfo(crtc); + XRRFreeOutputInfo(outputs); } - XRRFreeCrtcInfo(crtc); - XRRFreeOutputInfo(outputs); + XRRFreeScreenResources(resources); XRRFreeScreenResources(res); XCloseDisplay(dpy); @@ -300,10 +300,11 @@ static bool x11_display_server_set_resolution(void *data, XRRSetScreenSize(dpy, window, width, height, (int) ((25.4 * width) / 96.0), (int) ((25.4 * height) / 96.0)); XRRSetCrtcConfig(dpy, res, res->crtcs[monitor_index], CurrentTime, crtc->x, crtc->y, crtc->mode, crtc->rotation, crtc->outputs, crtc->noutput); XSync(dpy, False); - XRRFreeOutputInfo(outputs); + + XRRFreeCrtcInfo(crtc); } - + XRRFreeOutputInfo(outputs); XRRFreeScreenResources(resources); XRRFreeScreenResources(res); XCloseDisplay(dpy); From 897ea6aff376091a55d0fb333fb26aabb9b2bc45 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Fri, 11 Sep 2020 18:04:40 +0100 Subject: [PATCH 7/8] Fix for bad res name --- gfx/display_servers/dispserv_x11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index cec73a2962..63100990a4 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -194,7 +194,7 @@ static bool x11_display_server_set_resolution(void *data, } snprintf(old_mode, sizeof(old_mode), "%s", new_mode); /* variable for new mode */ - snprintf(new_mode, sizeof(new_mode), "%s_%dx%d_%0.2f", crt_name, width, height, hz); + snprintf(new_mode, sizeof(new_mode), "%s", crt_name); /* need to run loops for DVI0 - DVI-2 and VGA0 - VGA-2 outputs to * add and delete modes */ From cb404b676d5e33360a30f249fdd71bb38a8636c2 Mon Sep 17 00:00:00 2001 From: alphanu1 <37101891+alphanu1@users.noreply.github.com> Date: Fri, 11 Sep 2020 18:54:17 +0100 Subject: [PATCH 8/8] Fix seg faults --- gfx/display_servers/dispserv_x11.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/gfx/display_servers/dispserv_x11.c b/gfx/display_servers/dispserv_x11.c index 63100990a4..cf7bd53754 100644 --- a/gfx/display_servers/dispserv_x11.c +++ b/gfx/display_servers/dispserv_x11.c @@ -279,7 +279,6 @@ static bool x11_display_server_set_resolution(void *data, } XRRFreeScreenResources(resources); - XRRFreeScreenResources(res); XCloseDisplay(dpy); } else if (monitor_index != 20) @@ -306,7 +305,6 @@ static bool x11_display_server_set_resolution(void *data, } XRRFreeOutputInfo(outputs); XRRFreeScreenResources(resources); - XRRFreeScreenResources(res); XCloseDisplay(dpy); } return true; @@ -579,9 +577,7 @@ static void x11_display_server_destroy(void *data) XRRFreeOutputInfo(outputs); } - XRRFreeScreenResources(resources); - XRRFreeScreenResources(res); - XCloseDisplay(dpy); + } else if (g_monitor_index != 20) @@ -608,9 +604,7 @@ static void x11_display_server_destroy(void *data) } XRRFreeOutputInfo(outputs); - XRRFreeScreenResources(resources); - XRRFreeScreenResources(res); - XCloseDisplay(dpy); + }