[virt-tools-list] [PATCH virt-viewer 22/25] Simplify display flag handling

Marc-André Lureau marcandre.lureau at gmail.com
Tue Jul 17 19:25:04 UTC 2012


---
 src/virt-viewer-display-spice.c |    9 +--------
 src/virt-viewer-display.c       |   20 ++++++++++----------
 src/virt-viewer-display.h       |    2 +-
 src/virt-viewer-session-vnc.c   |    2 +-
 4 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/src/virt-viewer-display-spice.c b/src/virt-viewer-display-spice.c
index b2f7e6c..8845ee0 100644
--- a/src/virt-viewer-display-spice.c
+++ b/src/virt-viewer-display-spice.c
@@ -141,19 +141,12 @@ display_ready(GObject *display,
               GParamSpec *pspec G_GNUC_UNUSED,
               VirtViewerDisplay *self)
 {
-    guint hint;
     gboolean ready;
 
     g_object_get(display, "ready", &ready, NULL);
     DEBUG_LOG("display %p ready:%d", self, ready);
 
-    hint = virt_viewer_display_get_show_hint(self);
-    if (ready)
-        hint |= VIRT_VIEWER_DISPLAY_SHOW_HINT_READY;
-    else
-        hint &= ~VIRT_VIEWER_DISPLAY_SHOW_HINT_READY;
-
-    virt_viewer_display_set_show_hint(self, hint);
+    virt_viewer_display_set_show_hint(self, VIRT_VIEWER_DISPLAY_SHOW_HINT_READY, ready);
 }
 
 static void
diff --git a/src/virt-viewer-display.c b/src/virt-viewer-display.c
index 8d13733..fe7ce4f 100644
--- a/src/virt-viewer-display.c
+++ b/src/virt-viewer-display.c
@@ -551,12 +551,20 @@ guint virt_viewer_display_get_show_hint(VirtViewerDisplay *self)
     return self->priv->show_hint;
 }
 
-void virt_viewer_display_set_show_hint(VirtViewerDisplay *self, guint hint)
+void virt_viewer_display_set_show_hint(VirtViewerDisplay *self, guint mask, gboolean enable)
 {
     VirtViewerDisplayPrivate *priv;
+    guint hint;
     g_return_if_fail(VIRT_VIEWER_IS_DISPLAY(self));
 
     priv = self->priv;
+    hint = priv->show_hint;
+
+    if (enable)
+        hint |= mask;
+    else
+        hint &= ~mask;
+
     if (priv->show_hint == hint)
         return;
 
@@ -566,17 +574,9 @@ void virt_viewer_display_set_show_hint(VirtViewerDisplay *self, guint hint)
 
 void virt_viewer_display_set_enabled(VirtViewerDisplay *self, gboolean enabled)
 {
-    guint hint;
-
     g_return_if_fail(VIRT_VIEWER_IS_DISPLAY(self));
 
-    hint = virt_viewer_display_get_show_hint(self);
-    if (enabled)
-        hint &= ~VIRT_VIEWER_DISPLAY_SHOW_HINT_DISABLED;
-    else
-        hint |= VIRT_VIEWER_DISPLAY_SHOW_HINT_DISABLED;
-
-    virt_viewer_display_set_show_hint(self, hint);
+    virt_viewer_display_set_show_hint(self, VIRT_VIEWER_DISPLAY_SHOW_HINT_DISABLED, !enabled);
 }
 
 VirtViewerSession* virt_viewer_display_get_session(VirtViewerDisplay *self)
diff --git a/src/virt-viewer-display.h b/src/virt-viewer-display.h
index 4247570..af78709 100644
--- a/src/virt-viewer-display.h
+++ b/src/virt-viewer-display.h
@@ -110,7 +110,7 @@ gboolean virt_viewer_display_get_zoom(VirtViewerDisplay *display);
 void virt_viewer_display_send_keys(VirtViewerDisplay *display,
                                    const guint *keyvals, int nkeyvals);
 GdkPixbuf* virt_viewer_display_get_pixbuf(VirtViewerDisplay *display);
-void virt_viewer_display_set_show_hint(VirtViewerDisplay *display, guint hint);
+void virt_viewer_display_set_show_hint(VirtViewerDisplay *display, guint mask, gboolean enable);
 guint virt_viewer_display_get_show_hint(VirtViewerDisplay *display);
 VirtViewerSession* virt_viewer_display_get_session(VirtViewerDisplay *display);
 void virt_viewer_display_set_auto_resize(VirtViewerDisplay *display, gboolean auto_resize);
diff --git a/src/virt-viewer-session-vnc.c b/src/virt-viewer-session-vnc.c
index 238c865..a24d65d 100644
--- a/src/virt-viewer-session-vnc.c
+++ b/src/virt-viewer-session-vnc.c
@@ -95,7 +95,7 @@ virt_viewer_session_vnc_connected(VncDisplay *vnc G_GNUC_UNUSED,
     GtkWidget *display = virt_viewer_display_vnc_new(session->priv->vnc);
     g_signal_emit_by_name(session, "session-connected");
     virt_viewer_display_set_show_hint(VIRT_VIEWER_DISPLAY(display),
-                                      VIRT_VIEWER_DISPLAY_SHOW_HINT_READY);
+                                      VIRT_VIEWER_DISPLAY_SHOW_HINT_READY, TRUE);
     virt_viewer_session_add_display(VIRT_VIEWER_SESSION(session),
                                     VIRT_VIEWER_DISPLAY(display));
 }
-- 
1.7.10.4




More information about the virt-tools-list mailing list