[gnome-panel/wip/segeiger/fish-add-gdbus-connection: 1/2] free-the-fish.c: Add a gdbus connection and listen to changes of the lockscreen
- From: Sebastian Geiger <segeiger src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/wip/segeiger/fish-add-gdbus-connection: 1/2] free-the-fish.c: Add a gdbus connection and listen to changes of the lockscreen
- Date: Wed, 10 Jun 2015 12:51:04 +0000 (UTC)
commit e9c9b24141f5b934bea7a766f538b343b5a354ef
Author: Sebastian Geiger <sbastig gmx net>
Date: Wed Jun 10 14:45:35 2015 +0200
free-the-fish.c: Add a gdbus connection and listen to changes of the lockscreen
We draw the fish with cairo directly on the screen. When the lock screen
is activated by the screensaver while the fish is active they end up
drawing over each other. The result is that we see a flickering fish
in the area where the fish is drawing over the lock screen.
This patch adds a dbus connection using the GDBus skeletton generated
from the org.gnome.ScreenSaver dbus interface and connects to the 'active-changed'
signal of the screensaver. When the screen saver is activated the fish
hides itself such that it does not draw over the lock screen.
gnome-panel/Makefile.am | 7 ++++++-
gnome-panel/free-the-fish.c | 30 ++++++++++++++++++++++++++++++
gnome-panel/panel-screensaver-dbus.xml | 32 ++++++++++++++++++++++++++++++++
3 files changed, 68 insertions(+), 1 deletions(-)
---
diff --git a/gnome-panel/Makefile.am b/gnome-panel/Makefile.am
index 02d5dba..2039178 100644
--- a/gnome-panel/Makefile.am
+++ b/gnome-panel/Makefile.am
@@ -210,13 +210,18 @@ panel-typebuiltins.h: $(panel_enum_headers)
--eprod "GType @enum_name _get_type (void);\n" \
$(panel_enum_headers) > $@
+%-gdbus.c %-gdbus.h: %-dbus.xml
+ gdbus-codegen --interface-prefix org.gnome. --generate-c-code $*-gdbus --c-namespace PanelGDBus $<
+
gnome_panel_BUILT_SOURCES = \
panel-typebuiltins.c \
panel-typebuiltins.h \
panel-resources.c \
panel-resources.h \
panel-marshal.c \
- panel-marshal.h
+ panel-marshal.h \
+ panel-screensaver-gdbus.c \
+ panel-screensaver-gdbus.h
panel_test_applets_BUILT_SOURCES = \
panel-test-applets-resources.c \
diff --git a/gnome-panel/free-the-fish.c b/gnome-panel/free-the-fish.c
index e4f97da..8de29f8 100644
--- a/gnome-panel/free-the-fish.c
+++ b/gnome-panel/free-the-fish.c
@@ -2,6 +2,7 @@
#include <string.h>
#include "free-the-fish.h"
+#include "panel-screensaver-gdbus.h"
/* free the fish code */
#define FISH_FRAMES 8
@@ -32,6 +33,8 @@ struct _FreeTheFish {
};
static FreeTheFish fish = {NULL};
+static void fish_register_dbus_handler (void);
+
static void
fish_kill (void)
{
@@ -333,6 +336,7 @@ fish_init (void)
gdk_window_show (fish.window);
gdk_event_handler_set ((GdkEventFunc)fish_handle_event, NULL, NULL);
+ fish_register_dbus_handler ();
fish.handler = g_timeout_add (FISH_TIMEOUT, fish_move, NULL);
}
@@ -351,6 +355,32 @@ check_screen_timeout (gpointer data)
return FALSE;
}
+static void
+fish_screen_saver_active_changed_cb (PanelGDBusScreenSaver *proxy, gboolean active)
+{
+ if (active) {
+ gdk_window_hide (fish.window);
+ } else {
+ gdk_window_show (fish.window);
+ }
+}
+
+static void fish_register_dbus_handler (void) {
+ GError *error = NULL;
+ PanelGDBusScreenSaver *proxy = panel_gdbus_screen_saver_proxy_new_for_bus_sync (
+ G_BUS_TYPE_SESSION,
+ G_DBUS_PROXY_FLAGS_NONE,
+ "org.gnome.ScreenSaver",
+ "/org/gnome/ScreenSaver",
+ NULL, &error);
+
+ if (error) {
+ g_warning ("[Free the fish] Error connecting to screen saver dbus: %s", error->message);
+ } else {
+ g_signal_connect (proxy, "active-changed", G_CALLBACK (fish_screen_saver_active_changed_cb),
NULL);
+ }
+}
+
void
free_the_fish (void)
{
diff --git a/gnome-panel/panel-screensaver-dbus.xml b/gnome-panel/panel-screensaver-dbus.xml
new file mode 100644
index 0000000..5721cd3
--- /dev/null
+++ b/gnome-panel/panel-screensaver-dbus.xml
@@ -0,0 +1,32 @@
+<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node>
+ <interface name="org.freedesktop.DBus.Introspectable">
+ <method name="Introspect">
+ <arg name="data" direction="out" type="s"/>
+ </method>
+ </interface>
+ <interface name="org.gnome.ScreenSaver">
+ <method name="Lock">
+ </method>
+ <method name="SimulateUserActivity">
+ </method>
+ <method name="GetActive">
+ <arg name="value" direction="out" type="b"/>
+ </method>
+ <method name="GetActiveTime">
+ <arg name="seconds" direction="out" type="u"/>
+ </method>
+ <method name="SetActive">
+ <arg name="value" direction="in" type="b"/>
+ </method>
+ <method name="ShowMessage">
+ <arg name="summary" direction="in" type="s"/>
+ <arg name="body" direction="in" type="s"/>
+ <arg name="icon" direction="in" type="s"/>
+ </method>
+ <signal name="ActiveChanged">
+ <arg name="new_value" type="b"/>
+ </signal>
+ </interface>
+</node>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]