Fixed migration of old window coordinates, fixes #2550.
This commit is contained in:
96
src/config.c
96
src/config.c
@@ -72,6 +72,9 @@
|
|||||||
#include <86box/snd_opl.h>
|
#include <86box/snd_opl.h>
|
||||||
|
|
||||||
|
|
||||||
|
static int cx, cy, cw, ch;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _list_ {
|
typedef struct _list_ {
|
||||||
struct _list_ *next;
|
struct _list_ *next;
|
||||||
} list_t;
|
} list_t;
|
||||||
@@ -616,6 +619,40 @@ load_general(void)
|
|||||||
video_framerate = config_get_int(cat, "video_gl_framerate", -1);
|
video_framerate = config_get_int(cat, "video_gl_framerate", -1);
|
||||||
video_vsync = config_get_int(cat, "video_gl_vsync", 0);
|
video_vsync = config_get_int(cat, "video_gl_vsync", 0);
|
||||||
strncpy(video_shader, config_get_string(cat, "video_gl_shader", ""), sizeof(video_shader));
|
strncpy(video_shader, config_get_string(cat, "video_gl_shader", ""), sizeof(video_shader));
|
||||||
|
|
||||||
|
window_remember = config_get_int(cat, "window_remember", 0);
|
||||||
|
if (window_remember) {
|
||||||
|
p = config_get_string(cat, "window_coordinates", NULL);
|
||||||
|
if (p == NULL)
|
||||||
|
p = "0, 0, 0, 0";
|
||||||
|
sscanf(p, "%i, %i, %i, %i", &cw, &ch, &cx, &cy);
|
||||||
|
} else {
|
||||||
|
cw = ch = cx = cy = 0;
|
||||||
|
config_delete_var(cat, "window_remember");
|
||||||
|
}
|
||||||
|
|
||||||
|
config_delete_var(cat, "window_coordinates");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Load monitor section. */
|
||||||
|
static void
|
||||||
|
load_monitor(int monitor_index)
|
||||||
|
{
|
||||||
|
char cat[512], temp[512];
|
||||||
|
char *p = NULL;
|
||||||
|
|
||||||
|
sprintf(cat, "Monitor #%i", monitor_index + 1);
|
||||||
|
sprintf(temp, "%i, %i, %i, %i", cx, cy, cw, ch);
|
||||||
|
|
||||||
|
p = config_get_string(cat, "window_coordinates", NULL);
|
||||||
|
|
||||||
|
if (p == NULL)
|
||||||
|
p = temp;
|
||||||
|
|
||||||
|
if (window_remember)
|
||||||
|
sscanf(p, "%i, %i, %i, %i",
|
||||||
|
&monitor_settings[monitor_index].mon_window_x, &monitor_settings[monitor_index].mon_window_y,
|
||||||
|
&monitor_settings[monitor_index].mon_window_w, &monitor_settings[monitor_index].mon_window_h);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load "Machine" section. */
|
/* Load "Machine" section. */
|
||||||
@@ -938,47 +975,6 @@ load_video(void)
|
|||||||
gfxcard_2 = video_get_video_from_internal_name(p);
|
gfxcard_2 = video_get_video_from_internal_name(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
load_monitor(int monitor_index)
|
|
||||||
{
|
|
||||||
char monitor_config_name[sizeof("Monitor #") + 12] = { [0] = 0 };
|
|
||||||
char *ptr = NULL;
|
|
||||||
|
|
||||||
if (monitor_index == 0) {
|
|
||||||
/* Migrate configs */
|
|
||||||
ptr = config_get_string("General", "window_coordinates", NULL);
|
|
||||||
|
|
||||||
config_delete_var("General", "window_coordinates");
|
|
||||||
}
|
|
||||||
snprintf(monitor_config_name, sizeof(monitor_config_name), "Monitor #%i", monitor_index + 1);
|
|
||||||
if (!ptr)
|
|
||||||
ptr = config_get_string(monitor_config_name, "window_coordinates", "0, 0, 0, 0");
|
|
||||||
if (window_remember || (vid_resize & 2))
|
|
||||||
sscanf(ptr, "%i, %i, %i, %i",
|
|
||||||
&monitor_settings[monitor_index].mon_window_x, &monitor_settings[monitor_index].mon_window_y,
|
|
||||||
&monitor_settings[monitor_index].mon_window_w, &monitor_settings[monitor_index].mon_window_h);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
save_monitor(int monitor_index)
|
|
||||||
{
|
|
||||||
char monitor_config_name[sizeof("Monitor #") + 12] = { [0] = 0 };
|
|
||||||
char saved_coordinates[12 * 4 + 8 + 1] = { [0] = 0 };
|
|
||||||
|
|
||||||
snprintf(monitor_config_name, sizeof(monitor_config_name), "Monitor #%i", monitor_index + 1);
|
|
||||||
if (!(monitor_settings[monitor_index].mon_window_x == 0
|
|
||||||
&& monitor_settings[monitor_index].mon_window_y == 0
|
|
||||||
&& monitor_settings[monitor_index].mon_window_w == 0
|
|
||||||
&& monitor_settings[monitor_index].mon_window_h == 0)
|
|
||||||
&& (window_remember || (vid_resize & 2))) {
|
|
||||||
snprintf(saved_coordinates, sizeof(saved_coordinates), "%i, %i, %i, %i", monitor_settings[monitor_index].mon_window_x, monitor_settings[monitor_index].mon_window_y,
|
|
||||||
monitor_settings[monitor_index].mon_window_w, monitor_settings[monitor_index].mon_window_h);
|
|
||||||
|
|
||||||
config_set_string(monitor_config_name, "window_coordinates", saved_coordinates);
|
|
||||||
} else
|
|
||||||
config_delete_var(monitor_config_name, "window_coordinates");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Load "Input Devices" section. */
|
/* Load "Input Devices" section. */
|
||||||
static void
|
static void
|
||||||
load_input_devices(void)
|
load_input_devices(void)
|
||||||
@@ -2403,6 +2399,24 @@ save_general(void)
|
|||||||
delete_section_if_empty(cat);
|
delete_section_if_empty(cat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Save monitor section. */
|
||||||
|
static void
|
||||||
|
save_monitor(int monitor_index)
|
||||||
|
{
|
||||||
|
char cat[sizeof("Monitor #") + 12] = { [0] = 0 };
|
||||||
|
char temp[512];
|
||||||
|
|
||||||
|
snprintf(cat, sizeof(cat), "Monitor #%i", monitor_index + 1);
|
||||||
|
if (window_remember) {
|
||||||
|
sprintf(temp, "%i, %i, %i, %i",
|
||||||
|
monitor_settings[monitor_index].mon_window_x, monitor_settings[monitor_index].mon_window_y,
|
||||||
|
monitor_settings[monitor_index].mon_window_w, monitor_settings[monitor_index].mon_window_h);
|
||||||
|
|
||||||
|
config_set_string(cat, "window_coordinates", temp);
|
||||||
|
} else
|
||||||
|
config_delete_var(cat, "window_coordinates");
|
||||||
|
}
|
||||||
|
|
||||||
/* Save "Machine" section. */
|
/* Save "Machine" section. */
|
||||||
static void
|
static void
|
||||||
save_machine(void)
|
save_machine(void)
|
||||||
|
Reference in New Issue
Block a user