mirror of
https://gitlab.com/marcandre.lureau/qemu-display.git
synced 2025-01-03 11:15:19 +00:00
Add basic SetUIInfo support
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
This commit is contained in:
parent
25537268d1
commit
f468e775d8
@ -12,6 +12,18 @@ pub trait Console {
|
|||||||
/// RegisterListener method
|
/// RegisterListener method
|
||||||
fn register_listener(&self, listener: Fd) -> zbus::Result<()>;
|
fn register_listener(&self, listener: Fd) -> zbus::Result<()>;
|
||||||
|
|
||||||
|
/// SetUIInfo method
|
||||||
|
#[dbus_proxy(name = "SetUIInfo")]
|
||||||
|
fn set_ui_info(
|
||||||
|
&self,
|
||||||
|
width_mm: u16,
|
||||||
|
height_mm: u16,
|
||||||
|
xoff: i32,
|
||||||
|
yoff: i32,
|
||||||
|
width: u32,
|
||||||
|
height: u32,
|
||||||
|
) -> zbus::Result<()>;
|
||||||
|
|
||||||
#[dbus_proxy(property)]
|
#[dbus_proxy(property)]
|
||||||
fn label(&self) -> zbus::Result<String>;
|
fn label(&self) -> zbus::Result<String>;
|
||||||
|
|
||||||
|
@ -114,6 +114,19 @@ mod imp {
|
|||||||
self.area.set_sensitive(true);
|
self.area.set_sensitive(true);
|
||||||
self.area.set_focusable(true);
|
self.area.set_focusable(true);
|
||||||
self.area.set_focus_on_click(true);
|
self.area.set_focus_on_click(true);
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
self.area.connect_notify_unsafe(
|
||||||
|
Some("resize-hack"),
|
||||||
|
clone!(@weak obj => move |_, _| {
|
||||||
|
let priv_ = imp::QemuConsole::from_instance(&obj);
|
||||||
|
let alloc = priv_.area.get_allocation();
|
||||||
|
if let Err(e) = obj.qemu_console().proxy.set_ui_info(0, 0, 0, 0, alloc.width as u32, alloc.height as u32) {
|
||||||
|
eprintln!("Failed to SetUIInfo: {}", e);
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Needed for direct subclasses of GtkWidget;
|
// Needed for direct subclasses of GtkWidget;
|
||||||
@ -126,11 +139,7 @@ mod imp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WidgetImpl for QemuConsole {
|
impl WidgetImpl for QemuConsole {}
|
||||||
fn size_allocate(&self, widget: &Self::Type, width: i32, height: i32, baseline: i32) {
|
|
||||||
self.parent_size_allocate(widget, width, height, baseline);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glib::wrapper! {
|
glib::wrapper! {
|
||||||
|
@ -63,6 +63,29 @@ mod imp {
|
|||||||
fn constructed(&self, obj: &Self::Type) {
|
fn constructed(&self, obj: &Self::Type) {
|
||||||
self.parent_constructed(obj);
|
self.parent_constructed(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn properties() -> &'static [glib::ParamSpec] {
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
|
||||||
|
vec![glib::ParamSpec::boolean(
|
||||||
|
"resize-hack",
|
||||||
|
"resize-hack",
|
||||||
|
"Resize hack to notify parent",
|
||||||
|
false,
|
||||||
|
glib::ParamFlags::READWRITE | glib::ParamFlags::CONSTRUCT,
|
||||||
|
)]
|
||||||
|
});
|
||||||
|
PROPERTIES.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_property(
|
||||||
|
&self,
|
||||||
|
_obj: &Self::Type,
|
||||||
|
_id: usize,
|
||||||
|
_value: &glib::Value,
|
||||||
|
_pspec: &glib::ParamSpec,
|
||||||
|
) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WidgetImpl for QemuConsoleArea {
|
impl WidgetImpl for QemuConsoleArea {
|
||||||
@ -79,6 +102,11 @@ mod imp {
|
|||||||
widget.set_error(Some(&e));
|
widget.set_error(Some(&e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn size_allocate(&self, widget: &Self::Type, width: i32, height: i32, baseline: i32) {
|
||||||
|
self.parent_size_allocate(widget, width, height, baseline);
|
||||||
|
widget.notify("resize-hack");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GLAreaImpl for QemuConsoleArea {
|
impl GLAreaImpl for QemuConsoleArea {
|
||||||
|
Loading…
Reference in New Issue
Block a user