Revert "Turn g_monitor_index into static global"

This reverts commit 65f5544a7ecd4782c00ebb5156a36e9e9f992ca7.
This commit is contained in:
twinaphex 2020-09-11 15:14:11 +02:00
parent c6fa9c6720
commit 6fd1485c34

View File

@ -51,7 +51,7 @@ static char old_mode[256] = {0};
static char new_mode[256] = {0}; static char new_mode[256] = {0};
static XRRModeInfo crt_rrmode; static XRRModeInfo crt_rrmode;
static XRRModeInfo crt_rroldmode; static XRRModeInfo crt_rroldmode;
static int x11_monitor_index = 0; int g_monitor_index = 0;
#endif #endif
@ -118,7 +118,7 @@ static bool x11_display_server_set_resolution(void *data,
int screen = DefaultScreen(dpy); int screen = DefaultScreen(dpy);
Window window = RootWindow(dpy, screen); Window window = RootWindow(dpy, screen);
x11_monitor_index = monitor_index; g_monitor_index = monitor_index;
crt_en = true; crt_en = true;
crt_name_id += 1; crt_name_id += 1;
@ -549,7 +549,7 @@ static void x11_display_server_destroy(void *data)
if (crt_en) if (crt_en)
{ {
if (x11_monitor_index == 20) if (g_monitor_index == 20)
{ {
int i; int i;
for (i = 0; i < res->noutput; i++) for (i = 0; i < res->noutput; i++)
@ -587,24 +587,24 @@ static void x11_display_server_destroy(void *data)
} }
XRRFreeScreenResources(resources); XRRFreeScreenResources(resources);
} }
else if (x11_monitor_index != 20) else if (g_monitor_index != 20)
{ {
XRROutputInfo *outputs = XRRGetOutputInfo(dpy, res, res->outputs[x11_monitor_index]); XRROutputInfo *outputs = XRRGetOutputInfo(dpy, res, res->outputs[g_monitor_index]);
if (outputs->connection == RR_Connected) if (outputs->connection == RR_Connected)
{ {
XRRCrtcInfo *crtc; XRRCrtcInfo *crtc;
XRRAddOutputMode(dpy, res->outputs[x11_monitor_index], swdeskmode->id); XRRAddOutputMode(dpy, res->outputs[g_monitor_index], swdeskmode->id);
XSync(dpy, False); XSync(dpy, False);
strlcpy(orig_output, outputs->name, sizeof(orig_output)); strlcpy(orig_output, outputs->name, sizeof(orig_output));
crtc = XRRGetCrtcInfo(dpy, resources, outputs->crtc); crtc = XRRGetCrtcInfo(dpy, resources, outputs->crtc);
crtc->mode = swdeskmode->id; crtc->mode = swdeskmode->id;
crtc->width = swdeskmode->width; crtc->width = swdeskmode->width;
crtc->height = swdeskmode->height; crtc->height = swdeskmode->height;
XRRSetCrtcConfig(dpy, res,res->crtcs[x11_monitor_index], CurrentTime, 0, 0, None, RR_Rotate_0, NULL, 0); XRRSetCrtcConfig(dpy, res,res->crtcs[g_monitor_index], CurrentTime, 0, 0, None, RR_Rotate_0, NULL, 0);
XSync(dpy, False); 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)); 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[x11_monitor_index], CurrentTime, crtc->x, crtc->y, crtc->mode, crtc->rotation, crtc->outputs, crtc->noutput); XRRSetCrtcConfig(dpy, res, res->crtcs[g_monitor_index], CurrentTime, crtc->x, crtc->y, crtc->mode, crtc->rotation, crtc->outputs, crtc->noutput);
XSync(dpy, False); XSync(dpy, False);
XRRFreeCrtcInfo(crtc); XRRFreeCrtcInfo(crtc);