diff options
author | Jonathon Jongsma <jjongsma@redhat.com> | 2015-07-17 09:57:35 -0500 |
---|---|---|
committer | Jonathon Jongsma <jjongsma@redhat.com> | 2015-09-10 16:02:13 -0500 |
commit | 9c77a78af2ef85f3fcdce21b42d89566a9f7ee17 (patch) | |
tree | 9883bc609bfd263e1f761da9a879130c29e4789f /src/virt-viewer-display.c | |
parent | 344eb9a68595ee26627e27fe733ac7789fdbdbb1 (diff) | |
download | virt-viewer-9c77a78af2ef85f3fcdce21b42d89566a9f7ee17.tar.gz virt-viewer-9c77a78af2ef85f3fcdce21b42d89566a9f7ee17.tar.xz virt-viewer-9c77a78af2ef85f3fcdce21b42d89566a9f7ee17.zip |
Add new functions to enable/disable a display
Previously, there was a single function for controlling the enabled
state of a display: virt_viewer_display_set_enabled(). Unfortunately,
this function is used for two slightly different things:
A. It informs the local display widget that the display has become
disabled or enabled on the server. In other words, it tries to
synchronize the 'enabled' state of the local widget with the actual
state of the remote display.
OR
B. It tries to actively enable a currently-disabled display (or vice
versa) due to some action by the user in the client application.
This causes the client to send a new configuration down to the
server. In other words, it tries to change the state of the remote
display.
There is some conflict between these two scenarios. If the change is due
to a notification from the server, there is no need to send a new
configuration back down to the server, so this results in unnecessary
monitor configuration messages and can in fact cause issues that are a
little bit hard to track down. Because of this, I decided that it was
really necessary to have two separate functions for these two different
scenarios. so the existing _set_enabled() function will be used for
scenario A mentioned above. I added two new
functions (_enable() and _disable()) that are used to send new
configurations down to the server.
Diffstat (limited to 'src/virt-viewer-display.c')
-rw-r--r-- | src/virt-viewer-display.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c index 8431ae4..d8b3312 100644 --- a/src/virt-viewer-display.c +++ b/src/virt-viewer-display.c @@ -682,6 +682,37 @@ void virt_viewer_display_set_show_hint(VirtViewerDisplay *self, guint mask, gboo g_object_notify(G_OBJECT(self), "show-hint"); } +/* This function attempts to enable the display if supported by the backend */ +void virt_viewer_display_enable(VirtViewerDisplay *self) +{ + VirtViewerDisplayClass *klass; + + g_return_if_fail(VIRT_VIEWER_IS_DISPLAY(self)); + + klass = VIRT_VIEWER_DISPLAY_GET_CLASS(self); + if (!klass->enable) + return; + + klass->enable(self); +} + +/* This function attempts to disable the display if supported by the backend */ +void virt_viewer_display_disable(VirtViewerDisplay *self) +{ + VirtViewerDisplayClass *klass; + + g_return_if_fail(VIRT_VIEWER_IS_DISPLAY(self)); + + klass = VIRT_VIEWER_DISPLAY_GET_CLASS(self); + if (!klass->disable) + return; + + klass->disable(self); +} + +/* this function simply informs the display that it is enabled. see + * virt_viewer_display_enable()/disable() if you want to attempt to change the + * state of the display */ void virt_viewer_display_set_enabled(VirtViewerDisplay *self, gboolean enabled) { g_return_if_fail(VIRT_VIEWER_IS_DISPLAY(self)); |