diff options
author | Marc-Andre Lureau <marcandre.lureau@redhat.com> | 2012-03-21 22:47:06 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2012-03-22 00:24:47 +0100 |
commit | df1fbf1e8d0b4f56bda6dc4cf40379d5af30d128 (patch) | |
tree | 0af116e3c864c0b381a7ae790eb85425222867a4 | |
parent | c4bfc57e728f281092333e1a3e3e0fb48645ef7c (diff) |
Notify focus state when the foreign menu title is set
The current code only inform of focus state when the listener is ready.
spice-gtk controller code lacks signal when a client connects, but a
client will set the title when connected and send a notify signal.
Use this event to notify of application focus state.
-rw-r--r-- | src/remote-viewer.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/remote-viewer.c b/src/remote-viewer.c index d601ad3..7dda7fe 100644 --- a/src/remote-viewer.c +++ b/src/remote-viewer.c @@ -37,6 +37,10 @@ #include "virt-viewer-app.h" #include "remote-viewer.h" +#ifndef G_VALUE_INIT /* see bug https://bugzilla.gnome.org/show_bug.cgi?id=654793 */ +#define G_VALUE_INIT { 0, { { 0 } } } +#endif + struct _RemoteViewerPrivate { #ifdef HAVE_SPICE_GTK SpiceCtrlController *controller; @@ -62,6 +66,7 @@ static gboolean remote_viewer_start(VirtViewerApp *self); #if HAVE_SPICE_GTK static int remote_viewer_activate(VirtViewerApp *self); static void remote_viewer_window_added(VirtViewerApp *self, VirtViewerWindow *win); +static void spice_foreign_menu_updated(RemoteViewer *self); #endif #if HAVE_SPICE_GTK @@ -185,6 +190,24 @@ remote_viewer_new(const gchar *uri, gboolean verbose) } #if HAVE_SPICE_GTK +static void +foreign_menu_title_changed(SpiceCtrlForeignMenu *menu G_GNUC_UNUSED, + GParamSpec *pspec G_GNUC_UNUSED, + RemoteViewer *self) +{ + gboolean has_focus; + + g_object_get(G_OBJECT(self), "has-focus", &has_focus, NULL); + /* FIXME: use a proper "new client connected" event + ** a foreign menu client set the title when connecting, + ** inform of focus state at that time. + */ + spice_ctrl_foreign_menu_app_activated_msg(self->priv->ctrl_foreign_menu, has_focus); + + /* update menu title */ + spice_foreign_menu_updated(self); +} + RemoteViewer * remote_viewer_new_with_controller(gboolean verbose) { @@ -197,6 +220,9 @@ remote_viewer_new_with_controller(gboolean verbose) "foreign-menu", menu, "verbose", verbose, NULL); + g_signal_connect(menu, "notify::title", + G_CALLBACK(foreign_menu_title_changed), + self); g_object_unref(ctrl); g_object_unref(menu); @@ -408,10 +434,6 @@ remote_viewer_get_spice_session(RemoteViewer *self) return session; } -#ifndef G_VALUE_INIT /* see bug https://bugzilla.gnome.org/show_bug.cgi?id=654793 */ -#define G_VALUE_INIT { 0, { { 0 } } } -#endif - static gchar * ctrl_key_to_gtk_key(const gchar *key) { @@ -650,8 +672,6 @@ spice_ctrl_listen_async_cb(GObject *object, spice_ctrl_controller_listen_finish(SPICE_CTRL_CONTROLLER(object), res, &error); else if (SPICE_CTRL_IS_FOREIGN_MENU(object)) { spice_ctrl_foreign_menu_listen_finish(SPICE_CTRL_FOREIGN_MENU(object), res, &error); - if (!error) - g_object_notify(G_OBJECT(app), "has-focus"); } else g_warn_if_reached(); |