Skip to contentSkip to conversation

the org.qemu.Display1.UIInfo interface design

RFC PATCH Superseded Chengyang Zhu 2 participants 3 messages Aug 18

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover the org.qemu.Display1.UIInfo interface design

Currently, the SetUIInfo method cannot set a refresh rate. Simply adding a refresh_rate argument would break the method signature.

This RFC adds the UIInfo interface containing
* properties as staged display settings.
* the method Apply applying staged settings.
* the method Reload reloading settings from the console.

This patch needs further discussion on:
* public API
* necessary test suite

Changes since v1:
* redesigned public API

Test results:
* qemu:qtest-x86_64/dbus-display-test passed
* qemu:qtest-x86_64/dbus-vmstate-test passed
* qemu:qtest-x86_64/dbus-vnc-test SKIP
* manually created a virtual machine
and successfully set its refresh rate and resolution via UIInfo

Chengyang Zhu (1):
ui/dbus: add org.qemu.Display1.UIInfo interface

 ui/dbus-console.c    | 86 ++++++++++++++++++++++++++++++++++++++++++++
 ui/dbus-display1.xml | 32 +++++++++++++++++
 2 files changed, 118 insertions(+)
Signature · 1 line
2.55.0
#1 lore raw

RFC PATCH v2 1/1 ui/dbus: add org.qemu.Display1.UIInfo interface

Currently, the SetUIInfo method cannot set a refresh rate. Simply adding a refresh_rate argument would break the method signature.

This patch adds the UIInfo interface containing
* properties as staged display settings.
* the method Apply applying staged settings.
* the method Reload reloading settings from the console.

---
 ui/dbus-console.c    | 86 ++++++++++++++++++++++++++++++++++++++++++++
 ui/dbus-display1.xml | 32 +++++++++++++++++
 2 files changed, 118 insertions(+)
ui/dbus-console.c +86 -0
index e1ac06814b..dc5c991f80 100644
@@ -55,6 +55,8 @@ struct _DBusDisplayConsole {
     guint last_x;
     guint last_y;
     Notifier mouse_mode_notifier;
+
+    QemuDBusDisplay1UIInfo *iface_ui_info;
 };
 
 G_DEFINE_TYPE(DBusDisplayConsole,
@@ -155,6 +157,7 @@ dbus_display_console_dispose(GObject *object)
     qemu_input_led_notifier_remove(&ddc->led_notifier);
     qemu_console_unregister_listener(&ddc->dcl);
     qemu_remove_mouse_mode_change_notifier(&ddc->mouse_mode_notifier);
+    g_clear_object(&ddc->iface_ui_info);
     g_clear_object(&ddc->iface_touch);
     g_clear_object(&ddc->iface_mouse);
     g_clear_object(&ddc->iface_kbd);
@@ -528,6 +531,80 @@ dbus_mouse_mode_change(Notifier *notify, void *data)
     dbus_mouse_update_is_absolute(ddc);
 }
 
+static gboolean
+dbus_ui_info_reload(DBusDisplayConsole *ddc,
+                    GDBusMethodInvocation *invocation)
+{
+    if (!qemu_console_ui_info_supported(ddc->dcl.con)) {
+        g_dbus_method_invocation_return_error(invocation,
+                                              DBUS_DISPLAY_ERROR,
+                                              DBUS_DISPLAY_ERROR_UNSUPPORTED,
+                                              "UIInfo is not supported");
+        return DBUS_METHOD_INVOCATION_HANDLED;
+    }
+
+    QemuUIInfo ui_info = *qemu_console_get_ui_info(ddc->dcl.con);
+
+    g_object_set(ddc->iface_ui_info,
+                "width-mm", ui_info.width_mm,
+                "height-mm", ui_info.height_mm,
+                "xoff", ui_info.xoff,
+                "yoff", ui_info.yoff,
+                "width", ui_info.width,
+                "height", ui_info.height,
+                "refresh-rate", ui_info.refresh_rate,
+                NULL);
+
+    qemu_dbus_display1_uiinfo_complete_reload(ddc->iface_ui_info, invocation);
+    return DBUS_METHOD_INVOCATION_HANDLED;
+}
+
+static gboolean
+dbus_ui_info_apply(DBusDisplayConsole *ddc,
+                   GDBusMethodInvocation *invocation)
+{
+    if (!qemu_console_ui_info_supported(ddc->dcl.con)) {
+        g_dbus_method_invocation_return_error(invocation,
+                                              DBUS_DISPLAY_ERROR,
+                                              DBUS_DISPLAY_ERROR_UNSUPPORTED,
+                                              "UIInfo is not supported");
+        return DBUS_METHOD_INVOCATION_HANDLED;
+    }
+
+    guint width_mm;
+    guint height_mm;
+    gint xoff;
+    gint yoff;
+    guint width;
+    guint height;
+    guint refresh_rate;
+
+    g_object_get(G_OBJECT(ddc->iface_ui_info),
+                "width-mm", &width_mm,
+                "height-mm", &height_mm,
+                "xoff", &xoff,
+                "yoff", &yoff,
+                "width", &width,
+                "height", &height,
+                "refresh-rate", &refresh_rate,
+                NULL);
+
+    QemuUIInfo ui_info = {
+        .width_mm = (uint16_t)width_mm,
+        .height_mm = (uint16_t)height_mm,
+        .xoff = (int)xoff,
+        .yoff = (int)yoff,
+        .width = (uint32_t)width,
+        .height = (uint32_t)height,
+        .refresh_rate = (uint32_t)refresh_rate
+    };
+
+    qemu_console_set_ui_info(ddc->dcl.con, &ui_info, false);
+    qemu_dbus_display1_uiinfo_complete_apply(ddc->iface_ui_info, invocation);
+
+    return DBUS_METHOD_INVOCATION_HANDLED;
+}
+
 int dbus_display_console_get_index(DBusDisplayConsole *ddc)
 {
     return qemu_console_get_index(ddc->dcl.con);
@@ -550,6 +627,7 @@ dbus_display_console_new(DBusDisplay *display, QemuConsole *con)
         "org.qemu.Display1.Keyboard",
         "org.qemu.Display1.Mouse",
         "org.qemu.Display1.MultiTouch",
+        "org.qemu.Display1.UIInfo",
         NULL
     };
 
@@ -626,5 +704,13 @@ dbus_display_console_new(DBusDisplay *display, QemuConsole *con)
     qemu_add_mouse_mode_change_notifier(&ddc->mouse_mode_notifier);
     dbus_mouse_update_is_absolute(ddc);
 
+    ddc->iface_ui_info = qemu_dbus_display1_uiinfo_skeleton_new();
+    g_object_connect(ddc->iface_ui_info,
+        "swapped-signal::handle-reload", dbus_ui_info_reload, ddc,
+        "swapped-signal::handle-apply", dbus_ui_info_apply, ddc,
+        NULL);
+    g_dbus_object_skeleton_add_interface(G_DBUS_OBJECT_SKELETON(ddc),
+        G_DBUS_INTERFACE_SKELETON(ddc->iface_ui_info));
+
     return ddc;
 }
ui/dbus-display1.xml +32 -0
index d96bae2ed6..a766fd0862 100644
@@ -1159,4 +1159,36 @@
     -->
     <property name="Encoding" type="s" access="read"/>
   </interface>
+
+  <!--
+      org.qemu.Display1.UIInfo:
+
+        WidthMm: the physical display width in millimeters.
+        HeightMm: the physical display height in millimeters.
+        XOff: horizontal offset, in pixels.
+        YOff: vertical offset, in pixels.
+        Width: console width, in pixels.
+        Height: console height, in pixels.
+        RefreshRate: display refresh rate, in millihertz.
+
+      Reload:
+        Set the staged properties to the state of the display.
+      Apply:
+        Apply the staged properties to the display.
+  -->
+  <interface name="org.qemu.Display1.UIInfo">
+    <property name="WidthMm" type="q" access="readwrite"/>
+    <property name="HeightMm" type="q" access="readwrite"/>
+    <property name="XOff" type="i" access="readwrite"/>
+    <property name="YOff" type="i" access="readwrite"/>
+    <property name="Width" type="u" access="readwrite"/>
+    <property name="Height" type="u" access="readwrite"/>
+    <property name="RefreshRate" type="u" access="readwrite"/>
+
+    <method name="Reload">
+    </method>
+
+    <method name="Apply">
+    </method>
+  </interface>
 </node>
Signature · 1 line
2.55.0
#2 lore raw

Re: [PATCH RFC v2 1/1] ui/dbus: add org.qemu.Display1.UIInfo interface

Hi

Quoted 53 lines · Chengyang Zhu

Currently, the SetUIInfo method cannot set a refresh rate. Simply adding a refresh_rate argument would break the method signature.

This patch adds the UIInfo interface containing
* properties as staged display settings.
* the method Apply applying staged settings.
* the method Reload reloading settings from the console.

---
 ui/dbus-console.c    | 86 ++++++++++++++++++++++++++++++++++++++++++++
 ui/dbus-display1.xml | 32 +++++++++++++++++
 2 files changed, 118 insertions(+)
ui/dbus-console.c +16 -0
index e1ac06814b..dc5c991f80 100644
@@ -55,6 +55,8 @@ struct _DBusDisplayConsole {
     guint last_x;
     guint last_y;
     Notifier mouse_mode_notifier;
+
+    QemuDBusDisplay1UIInfo *iface_ui_info;
 };
 
 G_DEFINE_TYPE(DBusDisplayConsole,
@@ -155,6 +157,7 @@ dbus_display_console_dispose(GObject *object)
     qemu_input_led_notifier_remove(&ddc->led_notifier);
     qemu_console_unregister_listener(&ddc->dcl);
     qemu_remove_mouse_mode_change_notifier(&ddc->mouse_mode_notifier);
+    g_clear_object(&ddc->iface_ui_info);
     g_clear_object(&ddc->iface_touch);
     g_clear_object(&ddc->iface_mouse);
     g_clear_object(&ddc->iface_kbd);
@@ -528,6 +531,80 @@ dbus_mouse_mode_change(Notifier *notify, void *data)
     dbus_mouse_update_is_absolute(ddc);
 }
 
+static gboolean
+dbus_ui_info_reload(DBusDisplayConsole *ddc,
+                    GDBusMethodInvocation *invocation)
+{
+    if (!qemu_console_ui_info_supported(ddc->dcl.con)) {
+        g_dbus_method_invocation_return_error(invocation,
+                                              DBUS_DISPLAY_ERROR,
+                                              DBUS_DISPLAY_ERROR_UNSUPPORTED,
+                                              "UIInfo is not supported");
+        return DBUS_METHOD_INVOCATION_HANDLED;
+    }
+
+    QemuUIInfo ui_info = *qemu_console_get_ui_info(ddc->dcl.con);

ui/dbus-console.c dbus_mouse_mode_change(Notifier *notify, void *data) · line 556

Quoted 10 lines
ui/dbus-console.c +10 -0
+
+    g_object_set(ddc->iface_ui_info,
+                "width-mm", ui_info.width_mm,
+                "height-mm", ui_info.height_mm,
+                "xoff", ui_info.xoff,
+                "yoff", ui_info.yoff,
+                "width", ui_info.width,
+                "height", ui_info.height,
+                "refresh-rate", ui_info.refresh_rate,
+                NULL);

Let's use the qemu_dbus_display1_uiinfo_set.. setters if possible

Quoted 6 lines
ui/dbus-console.c +6 -0
+
+    qemu_dbus_display1_uiinfo_complete_reload(ddc->iface_ui_info, invocation);
+    return DBUS_METHOD_INVOCATION_HANDLED;
+}
+
+static gboolean

ui/dbus-console.c dbus_mouse_mode_change(Notifier *notify, void *data) · line 572

Quoted 10 lines
ui/dbus-console.c +10 -0
+dbus_ui_info_apply(DBusDisplayConsole *ddc,
+                   GDBusMethodInvocation *invocation)
+{
+    if (!qemu_console_ui_info_supported(ddc->dcl.con)) {
+        g_dbus_method_invocation_return_error(invocation,
+                                              DBUS_DISPLAY_ERROR,
+                                              DBUS_DISPLAY_ERROR_UNSUPPORTED,
+                                              "UIInfo is not supported");
+        return DBUS_METHOD_INVOCATION_HANDLED;
+    }

Can we add a read-only bool property "supported" on the interface, so clients can check before?

Quoted 11 lines
ui/dbus-console.c +11 -0
+
+    guint width_mm;
+    guint height_mm;
+    gint xoff;
+    gint yoff;
+    guint width;
+    guint height;
+    guint refresh_rate;
+
+    g_object_get(G_OBJECT(ddc->iface_ui_info),
+                "width-mm", &width_mm,

ui/dbus-console.c dbus_mouse_mode_change(Notifier *notify, void *data) · line 593

Quoted 10 lines
ui/dbus-console.c +10 -0
+                "height-mm", &height_mm,
+                "xoff", &xoff,
+                "yoff", &yoff,
+                "width", &width,
+                "height", &height,
+                "refresh-rate", &refresh_rate,
+                NULL);
+
+    QemuUIInfo ui_info = {
+        .width_mm = (uint16_t)width_mm,

Can we call the accessors directly? qemu_dbus_display1_uiinfo_get_width_mm() etc

That should avoid some extra variables and casting

Quoted 44 lines
ui/dbus-console.c +23 -0
+        .height_mm = (uint16_t)height_mm,
+        .xoff = (int)xoff,
+        .yoff = (int)yoff,
+        .width = (uint32_t)width,
+        .height = (uint32_t)height,
+        .refresh_rate = (uint32_t)refresh_rate
+    };
+
+    qemu_console_set_ui_info(ddc->dcl.con, &ui_info, false);
+    qemu_dbus_display1_uiinfo_complete_apply(ddc->iface_ui_info, invocation);
+
+    return DBUS_METHOD_INVOCATION_HANDLED;
+}
+
 int dbus_display_console_get_index(DBusDisplayConsole *ddc)
 {
     return qemu_console_get_index(ddc->dcl.con);
@@ -550,6 +627,7 @@ dbus_display_console_new(DBusDisplay *display, QemuConsole *con)
         "org.qemu.Display1.Keyboard",
         "org.qemu.Display1.Mouse",
         "org.qemu.Display1.MultiTouch",
+        "org.qemu.Display1.UIInfo",
         NULL
     };
 
@@ -626,5 +704,13 @@ dbus_display_console_new(DBusDisplay *display, QemuConsole *con)
     qemu_add_mouse_mode_change_notifier(&ddc->mouse_mode_notifier);
     dbus_mouse_update_is_absolute(ddc);
 
+    ddc->iface_ui_info = qemu_dbus_display1_uiinfo_skeleton_new();
+    g_object_connect(ddc->iface_ui_info,
+        "swapped-signal::handle-reload", dbus_ui_info_reload, ddc,
+        "swapped-signal::handle-apply", dbus_ui_info_apply, ddc,
+        NULL);
+    g_dbus_object_skeleton_add_interface(G_DBUS_OBJECT_SKELETON(ddc),
+        G_DBUS_INTERFACE_SKELETON(ddc->iface_ui_info));
+
     return ddc;
 }
ui/dbus-display1.xml +0 -0
index d96bae2ed6..a766fd0862 100644

ui/dbus-display1.xml line 1166

Quoted 8 lines
ui/dbus-display1.xml +5 -0
@@ -1159,4 +1159,36 @@
     -->
     <property name="Encoding" type="s" access="read"/>
   </interface>
+
+  <!--
+      org.qemu.Display1.UIInfo:
+
+        WidthMm: the physical display width in millimeters.

Document individually each property/method above its declaration, with @references. Check the doc build results.

Quoted 29 lines
ui/dbus-display1.xml +27 -1
+        HeightMm: the physical display height in millimeters.
+        XOff: horizontal offset, in pixels.
+        YOff: vertical offset, in pixels.
+        Width: console width, in pixels.
+        Height: console height, in pixels.
+        RefreshRate: display refresh rate, in millihertz.
+
+      Reload:
+        Set the staged properties to the state of the display.
+      Apply:
+        Apply the staged properties to the display.
+  -->
+  <interface name="org.qemu.Display1.UIInfo">
+    <property name="WidthMm" type="q" access="readwrite"/>
+    <property name="HeightMm" type="q" access="readwrite"/>
+    <property name="XOff" type="i" access="readwrite"/>
+    <property name="YOff" type="i" access="readwrite"/>
+    <property name="Width" type="u" access="readwrite"/>
+    <property name="Height" type="u" access="readwrite"/>
+    <property name="RefreshRate" type="u" access="readwrite"/>
+
+    <method name="Reload">
+    </method>
+
+    <method name="Apply">
+    </method>
+  </interface>
 </node>
--
Quoted 3 lines

2.55.0

thanks