aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandros Theodotou <alex@zrythm.org>2021-02-12 11:07:58 +0000
committerDavid Robillard <d@drobilla.net>2021-02-15 10:21:44 -0500
commit08ca5ba8003ba421566412675be4d9bebd85b82c (patch)
tree290415c2ecaf4a8a729a2aa8f4a029ac65a9ddfa
parentf235528015532bc0885330476f2a3b666c4c9a4a (diff)
downloadjalv-08ca5ba8003ba421566412675be4d9bebd85b82c.tar.gz
jalv-08ca5ba8003ba421566412675be4d9bebd85b82c.tar.bz2
jalv-08ca5ba8003ba421566412675be4d9bebd85b82c.zip
Pass ui:scaleFactor option to UIs
This option was added in LV2 1.18.0.
-rw-r--r--src/jalv.c12
-rw-r--r--src/jalv_console.c6
-rw-r--r--src/jalv_gtk.c15
-rw-r--r--src/jalv_gtkmm2.cpp6
-rw-r--r--src/jalv_internal.h8
-rw-r--r--src/jalv_qt.cpp6
-rw-r--r--wscript2
7 files changed, 53 insertions, 2 deletions
diff --git a/src/jalv.c b/src/jalv.c
index 25a49c3..78420fd 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -887,6 +887,7 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv)
jalv->urids.time_beatsPerMinute = symap_map(jalv->symap, LV2_TIME__beatsPerMinute);
jalv->urids.time_frame = symap_map(jalv->symap, LV2_TIME__frame);
jalv->urids.time_speed = symap_map(jalv->symap, LV2_TIME__speed);
+ jalv->urids.ui_scaleFactor = symap_map(jalv->symap, LV2_UI__scaleFactor);
jalv->urids.ui_updateRate = symap_map(jalv->symap, LV2_UI__updateRate);
#ifdef _WIN32
@@ -1105,11 +1106,20 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv)
jalv->ui_update_hz = MAX(1.0f, jalv->ui_update_hz);
}
+ if (jalv->opts.scale_factor == 0.0) {
+ /* Calculate the monitor's scale factor. */
+ jalv->ui_scale_factor = jalv_ui_scale_factor(jalv);
+ } else {
+ /* Use user-specified UI scale factor. */
+ jalv->ui_scale_factor = jalv->opts.scale_factor;
+ }
+
/* The UI can only go so fast, clamp to reasonable limits */
jalv->ui_update_hz = MIN(60, jalv->ui_update_hz);
jalv->opts.buffer_size = MAX(4096, jalv->opts.buffer_size);
fprintf(stderr, "Comm buffers: %u bytes\n", jalv->opts.buffer_size);
fprintf(stderr, "Update rate: %.01f Hz\n", jalv->ui_update_hz);
+ fprintf(stderr, "Scale factor: %.01f\n", jalv->ui_scale_factor);
/* Build options array to pass to plugin */
const LV2_Options_Option options[ARRAY_SIZE(jalv->features.options)] = {
@@ -1123,6 +1133,8 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv)
sizeof(int32_t), jalv->urids.atom_Int, &jalv->midi_buf_size },
{ LV2_OPTIONS_INSTANCE, 0, jalv->urids.ui_updateRate,
sizeof(float), jalv->urids.atom_Float, &jalv->ui_update_hz },
+ { LV2_OPTIONS_INSTANCE, 0, jalv->urids.ui_scaleFactor,
+ sizeof(float), jalv->urids.atom_Float, &jalv->ui_scale_factor },
{ LV2_OPTIONS_INSTANCE, 0, 0, 0, 0, NULL }
};
memcpy(jalv->features.options, options, sizeof(jalv->features.options));
diff --git a/src/jalv_console.c b/src/jalv_console.c
index ccfe916..a08f08a 100644
--- a/src/jalv_console.c
+++ b/src/jalv_console.c
@@ -266,6 +266,12 @@ jalv_ui_refresh_rate(Jalv* ZIX_UNUSED(jalv))
return 30.0f;
}
+float
+jalv_ui_scale_factor(Jalv* ZIX_UNUSED(jalv))
+{
+ return 1.0f;
+}
+
int
jalv_open_ui(Jalv* jalv)
{
diff --git a/src/jalv_gtk.c b/src/jalv_gtk.c
index 3403146..2e32c98 100644
--- a/src/jalv_gtk.c
+++ b/src/jalv_gtk.c
@@ -127,6 +127,8 @@ jalv_init(int* argc, char*** argv, JalvOptions* opts)
"Buffer size for plugin <=> UI communication", "SIZE"},
{ "update-frequency", 'r', 0, G_OPTION_ARG_DOUBLE, &opts->update_rate,
"UI update frequency", NULL},
+ { "scale-factor", 0, 0, G_OPTION_ARG_DOUBLE, &opts->scale_factor,
+ "UI scale factor", NULL},
{ "control", 'c', 0, G_OPTION_ARG_STRING_ARRAY, &opts->controls,
"Set control value (e.g. \"vol=1.4\")", NULL},
{ "print-controls", 'p', 0, G_OPTION_ARG_NONE, &opts->print_controls,
@@ -1222,6 +1224,19 @@ jalv_ui_refresh_rate(Jalv* ZIX_UNUSED(jalv))
#endif
}
+float
+jalv_ui_scale_factor(Jalv* ZIX_UNUSED(jalv))
+{
+#if GTK_MAJOR_VERSION == 2
+ return 1.0f;
+#else
+ GdkDisplay* const display = gdk_display_get_default();
+ GdkMonitor* const monitor = gdk_display_get_primary_monitor(display);
+
+ return (float)gdk_monitor_get_scale_factor(monitor);
+#endif
+}
+
int
jalv_open_ui(Jalv* jalv)
{
diff --git a/src/jalv_gtkmm2.cpp b/src/jalv_gtkmm2.cpp
index 9d88cd7..7c4c594 100644
--- a/src/jalv_gtkmm2.cpp
+++ b/src/jalv_gtkmm2.cpp
@@ -71,6 +71,12 @@ jalv_ui_refresh_rate(Jalv*)
return 30.0f;
}
+float
+jalv_ui_scale_factor(Jalv*)
+{
+ return 1.0f;
+}
+
int
jalv_open_ui(Jalv* jalv)
{
diff --git a/src/jalv_internal.h b/src/jalv_internal.h
index 40b22bd..e14dab6 100644
--- a/src/jalv_internal.h
+++ b/src/jalv_internal.h
@@ -180,6 +180,7 @@ typedef struct {
char** controls; ///< Control values
uint32_t buffer_size; ///< Plugin <= >UI communication buffer size
double update_rate; ///< UI update rate in Hz
+ double scale_factor; ///< UI scale factor
int dump; ///< Dump communication iff true
int trace; ///< Print trace log iff true
int generic_ui; ///< Use generic UI iff true
@@ -220,6 +221,7 @@ typedef struct {
LV2_URID time_beatsPerMinute;
LV2_URID time_frame;
LV2_URID time_speed;
+ LV2_URID ui_scaleFactor;
LV2_URID ui_updateRate;
} JalvURIDs;
@@ -292,7 +294,7 @@ typedef struct {
LV2_Feature state_sched_feature;
LV2_Log_Log llog;
LV2_Feature log_feature;
- LV2_Options_Option options[6];
+ LV2_Options_Option options[7];
LV2_Feature options_feature;
LV2_Feature safe_restore_feature;
LV2UI_Request_Value request_value;
@@ -345,6 +347,7 @@ struct Jalv {
uint32_t num_ports; ///< Size of the two following arrays:
uint32_t plugin_latency; ///< Latency reported by plugin (if any)
float ui_update_hz; ///< Frequency of UI updates
+ float ui_scale_factor; ///< UI scale factor
float sample_rate; ///< Sample rate
uint32_t event_delta_t; ///< Frames since last update sent to UI
uint32_t position; ///< Transport position in frames
@@ -414,6 +417,9 @@ jalv_discover_ui(Jalv* jalv);
float
jalv_ui_refresh_rate(Jalv* jalv);
+float
+jalv_ui_scale_factor(Jalv* jalv);
+
int
jalv_open_ui(Jalv* jalv);
diff --git a/src/jalv_qt.cpp b/src/jalv_qt.cpp
index ab528fd..2bf61f9 100644
--- a/src/jalv_qt.cpp
+++ b/src/jalv_qt.cpp
@@ -708,6 +708,12 @@ jalv_ui_refresh_rate(Jalv*)
return (float)QGuiApplication::primaryScreen()->refreshRate();
}
+float
+jalv_ui_scale_factor(Jalv*)
+{
+ return (float)QGuiApplication::primaryScreen()->devicePixelRatio();
+}
+
int
jalv_open_ui(Jalv* jalv)
{
diff --git a/wscript b/wscript
index c257ab1..dae6174 100644
--- a/wscript
+++ b/wscript
@@ -110,7 +110,7 @@ def configure(conf):
],
})
- conf.check_pkg('lv2 >= 1.17.2', uselib_store='LV2')
+ conf.check_pkg('lv2 >= 1.18.0', uselib_store='LV2')
conf.check_pkg('lilv-0 >= 0.24.0', uselib_store='LILV')
conf.check_pkg('serd-0 >= 0.24.0', uselib_store='SERD')
conf.check_pkg('sord-0 >= 0.14.0', uselib_store='SORD')