Implement per-monitor window geometry settings
This commit is contained in:
@@ -139,10 +139,6 @@ char log_path[1024] = { '\0'}; /* (O) full path of logfile */
|
||||
char vm_name[1024] = { '\0'}; /* (O) display name of the VM */
|
||||
|
||||
/* Configuration values. */
|
||||
int window_w; /* (C) window size and */
|
||||
int window_h; /* position info */
|
||||
int window_x;
|
||||
int window_y;
|
||||
int window_remember;
|
||||
int vid_resize; /* (C) allow resizing */
|
||||
int invert_display = 0; /* (C) invert the display */
|
||||
@@ -1325,9 +1321,7 @@ set_screen_size(int x, int y)
|
||||
break;
|
||||
}
|
||||
|
||||
/* If the resolution has changed, let the main thread handle it. */
|
||||
if ((owsx != scrnsz_x) || (owsy != scrnsz_y))
|
||||
atomic_flag_clear(&doresize_monitors[monitor_index_global]);
|
||||
atomic_flag_clear(&doresize_monitors[monitor_index_global]);
|
||||
}
|
||||
|
||||
|
||||
|
44
src/config.c
44
src/config.c
@@ -552,14 +552,8 @@ load_general(void)
|
||||
if (window_remember || (vid_resize & 2)) {
|
||||
if (!window_remember)
|
||||
config_delete_var(cat, "window_remember");
|
||||
|
||||
p = config_get_string(cat, "window_coordinates", NULL);
|
||||
if (p == NULL)
|
||||
p = "0, 0, 0, 0";
|
||||
sscanf(p, "%i, %i, %i, %i", &window_w, &window_h, &window_x, &window_y);
|
||||
} else {
|
||||
config_delete_var(cat, "window_remember");
|
||||
config_delete_var(cat, "window_coordinates");
|
||||
|
||||
window_w = window_h = window_x = window_y = 0;
|
||||
}
|
||||
@@ -940,11 +934,19 @@ static void
|
||||
load_monitor(int monitor_index)
|
||||
{
|
||||
char monitor_config_name[sizeof("Monitor #") + 12] = { [0] = 0 };
|
||||
snprintf(monitor_config_name, sizeof(monitor_config_name), "Monitor #%i", monitor_index + 1);
|
||||
char* ptr = NULL;
|
||||
|
||||
char* ptr = config_get_string(monitor_config_name, "window_coordinates", "0, 0, 0, 0");
|
||||
sscanf(ptr, "%i, %i, %i, %i", &monitors[monitor_index].mon_window_x, &monitors[monitor_index].mon_window_y,
|
||||
&monitors[monitor_index].mon_window_w, &monitors[monitor_index].mon_window_h);
|
||||
if (monitor_index == 0) {
|
||||
/* Migrate configs */
|
||||
ptr = config_get_string("General", "window_coordinates", "0, 0, 0, 0");
|
||||
|
||||
config_delete_var("General", "window_coordinates");
|
||||
}
|
||||
if (!ptr) ptr = config_get_string(monitor_config_name, "window_coordinates", "0, 0, 0, 0");
|
||||
snprintf(monitor_config_name, sizeof(monitor_config_name), "Monitor #%i", monitor_index + 1);
|
||||
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
|
||||
@@ -954,12 +956,12 @@ save_monitor(int monitor_index)
|
||||
char saved_coordinates[12 * 4 + 8 + 1] = { [0] = 0 };
|
||||
|
||||
snprintf(monitor_config_name, sizeof(monitor_config_name), "Monitor #%i", monitor_index + 1);
|
||||
if (!(monitors[monitor_index].mon_window_x == 0
|
||||
&& monitors[monitor_index].mon_window_y == 0
|
||||
&& monitors[monitor_index].mon_window_w == 0
|
||||
&& monitors[monitor_index].mon_window_h == 0)) {
|
||||
snprintf(saved_coordinates, sizeof(saved_coordinates), "%i, %i, %i, %i", monitors[monitor_index].mon_window_x, monitors[monitor_index].mon_window_y,
|
||||
monitors[monitor_index].mon_window_w, monitors[monitor_index].mon_window_h);
|
||||
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);
|
||||
}
|
||||
@@ -2188,6 +2190,8 @@ config_load(void)
|
||||
config_log("Config file not present or invalid!\n");
|
||||
} else {
|
||||
load_general(); /* General */
|
||||
for (i = 0; i < MONITORS_NUM; i++)
|
||||
load_monitor(i);
|
||||
load_machine(); /* Machine */
|
||||
load_video(); /* Video */
|
||||
load_input_devices(); /* Input devices */
|
||||
@@ -2297,12 +2301,8 @@ save_general(void)
|
||||
config_set_int(cat, "window_remember", window_remember);
|
||||
else
|
||||
config_delete_var(cat, "window_remember");
|
||||
|
||||
sprintf(temp, "%i, %i, %i, %i", window_w, window_h, window_x, window_y);
|
||||
config_set_string(cat, "window_coordinates", temp);
|
||||
} else {
|
||||
config_delete_var(cat, "window_remember");
|
||||
config_delete_var(cat, "window_coordinates");
|
||||
}
|
||||
|
||||
if (vid_resize & 2) {
|
||||
@@ -3116,7 +3116,11 @@ save_other_removable_devices(void)
|
||||
void
|
||||
config_save(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
save_general(); /* General */
|
||||
for (i = 0; i < MONITORS_NUM; i++)
|
||||
save_monitor(i);
|
||||
save_machine(); /* Machine */
|
||||
save_video(); /* Video */
|
||||
save_input_devices(); /* Input devices */
|
||||
|
@@ -80,9 +80,11 @@ extern char log_path[1024]; /* (O) full path of logfile */
|
||||
extern char vm_name[1024]; /* (O) display name of the VM */
|
||||
|
||||
|
||||
extern int window_w, window_h, /* (C) window size and */
|
||||
window_x, window_y, /* position info */
|
||||
window_remember,
|
||||
#define window_x monitor_settings[0].mon_window_x
|
||||
#define window_y monitor_settings[0].mon_window_y
|
||||
#define window_w monitor_settings[0].mon_window_w
|
||||
#define window_h monitor_settings[0].mon_window_h
|
||||
extern int window_remember,
|
||||
vid_resize, /* (C) allow resizing */
|
||||
invert_display, /* (C) invert the display */
|
||||
suppress_overscan; /* (C) suppress overscans */
|
||||
|
@@ -109,10 +109,6 @@ typedef struct monitor_t
|
||||
mon_video_timing_write_l;
|
||||
int mon_overscan_x;
|
||||
int mon_overscan_y;
|
||||
int mon_window_x;
|
||||
int mon_window_y;
|
||||
int mon_window_w;
|
||||
int mon_window_h;
|
||||
int mon_force_resize;
|
||||
int mon_fullchange;
|
||||
int mon_changeframecount;
|
||||
@@ -126,8 +122,16 @@ typedef struct monitor_t
|
||||
struct blit_data_struct* mon_blit_data_ptr;
|
||||
} monitor_t;
|
||||
|
||||
typedef struct monitor_settings_t {
|
||||
int mon_window_x; /* (C) window size and position info. */
|
||||
int mon_window_y;
|
||||
int mon_window_w;
|
||||
int mon_window_h;
|
||||
} monitor_settings_t;
|
||||
|
||||
#define MONITORS_NUM 8
|
||||
extern monitor_t monitors[MONITORS_NUM];
|
||||
extern monitor_settings_t monitor_settings[MONITORS_NUM];
|
||||
extern atomic_flag doresize_monitors[MONITORS_NUM];
|
||||
extern int monitor_index_global;
|
||||
extern int herc_enabled;
|
||||
|
@@ -240,6 +240,7 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
connect(this, &MainWindow::resizeContentsMonitor, this, [this](int w, int h, int monitor_index)
|
||||
{
|
||||
if (!QApplication::platformName().contains("eglfs") && vid_resize != 1) {
|
||||
qDebug() << "Resize";
|
||||
w = (w / (!dpi_scale ? util::screenOfWidget(renderers[monitor_index].get())->devicePixelRatio() : 1.));
|
||||
|
||||
int modifiedHeight = (h / (!dpi_scale ? util::screenOfWidget(renderers[monitor_index].get())->devicePixelRatio() : 1.));
|
||||
@@ -574,6 +575,12 @@ void MainWindow::initRendererMonitorSlot(int monitor_index)
|
||||
});
|
||||
secondaryRenderer->setWindowFlags(Qt::CustomizeWindowHint | Qt::WindowTitleHint);
|
||||
secondaryRenderer->setWindowTitle(QObject::tr("86Box Monitor #") + QString::number(monitor_index + 1));
|
||||
if (window_remember) {
|
||||
secondaryRenderer->setGeometry(monitor_settings[monitor_index].mon_window_w,
|
||||
monitor_settings[monitor_index].mon_window_h,
|
||||
monitor_settings[monitor_index].mon_window_x,
|
||||
monitor_settings[monitor_index].mon_window_y);
|
||||
}
|
||||
if (vid_resize == 2) {
|
||||
secondaryRenderer->setFixedSize(fixed_size_x, fixed_size_y);
|
||||
}
|
||||
@@ -586,6 +593,13 @@ void MainWindow::initRendererMonitorSlot(int monitor_index)
|
||||
void MainWindow::destroyRendererMonitorSlot(int monitor_index)
|
||||
{
|
||||
if (this->renderers[monitor_index]) {
|
||||
if (window_remember) {
|
||||
monitor_settings[monitor_index].mon_window_w = renderers[monitor_index]->geometry().width();
|
||||
monitor_settings[monitor_index].mon_window_h = renderers[monitor_index]->geometry().height();
|
||||
monitor_settings[monitor_index].mon_window_x = renderers[monitor_index]->geometry().x();
|
||||
monitor_settings[monitor_index].mon_window_y = renderers[monitor_index]->geometry().y();
|
||||
}
|
||||
config_save();
|
||||
this->renderers[monitor_index].release()->deleteLater();
|
||||
}
|
||||
}
|
||||
|
@@ -102,6 +102,7 @@ static const video_timings_t *vid_timings;
|
||||
static uint32_t cga_2_table[16];
|
||||
static uint8_t thread_run = 0;
|
||||
monitor_t monitors[MONITORS_NUM];
|
||||
monitor_settings_t monitor_settings[MONITORS_NUM];
|
||||
atomic_flag doresize_monitors[MONITORS_NUM] =
|
||||
{
|
||||
[0] = ATOMIC_FLAG_INIT,
|
||||
@@ -942,6 +943,8 @@ video_monitor_init(int index)
|
||||
monitors[index].mon_blit_data_ptr->monitor_index = index;
|
||||
monitors[index].mon_pal_lookup = calloc(sizeof(uint32_t), 256);
|
||||
monitors[index].mon_cga_palette = calloc(1, sizeof(int));
|
||||
monitors[index].mon_force_resize = 1;
|
||||
monitors[index].mon_vid_type = VIDEO_FLAG_TYPE_NONE;
|
||||
if (index >= 1) ui_init_monitor(index);
|
||||
monitors[index].mon_blit_data_ptr->blit_thread = thread_create(blit_thread, monitors[index].mon_blit_data_ptr);
|
||||
}
|
||||
|
Reference in New Issue
Block a user