ScreenShield: send a signal to GSD to wake up the screen

Instead of poking through IDLETIME, which confuses the state tracking
and can prevent automatic suspend, send a special signal to GSD
when the screen is to be waken up for a notification.

Someday we'll bring over all the state tracking and avoid this
ping-pong between gnome-shell and gnome-settings-daemon, but
that day's not today.

https://bugzilla.gnome.org/show_bug.cgi?id=712706
This commit is contained in:
Giovanni Campagna 2014-03-10 19:16:03 +01:00
parent fc4bc5277a
commit edd66c40d9
4 changed files with 15 additions and 32 deletions

View File

@ -301,7 +301,7 @@ const NotificationsBox = new Lang.Class({
}); });
this._updateVisibility(); this._updateVisibility();
Shell.util_wake_up_screen(); this.emit('wake-up-screen');
} }
}, },
@ -327,7 +327,7 @@ const NotificationsBox = new Lang.Class({
this._updateVisibility(); this._updateVisibility();
if (obj.sourceBox.visible) if (obj.sourceBox.visible)
Shell.util_wake_up_screen(); this.emit('wake-up-screen');
}, },
_visibleChanged: function(source, obj) { _visibleChanged: function(source, obj) {
@ -342,7 +342,7 @@ const NotificationsBox = new Lang.Class({
this._updateVisibility(); this._updateVisibility();
if (obj.sourceBox.visible) if (obj.sourceBox.visible)
Shell.util_wake_up_screen(); this.emit('wake-up-screen');
}, },
_detailedChanged: function(source, obj) { _detailedChanged: function(source, obj) {
@ -380,6 +380,7 @@ const NotificationsBox = new Lang.Class({
this._sources.delete(source); this._sources.delete(source);
}, },
}); });
Signals.addSignalMethods(NotificationsBox.prototype);
const Arrow = new Lang.Class({ const Arrow = new Lang.Class({
Name: 'Arrow', Name: 'Arrow',
@ -1151,6 +1152,7 @@ const ScreenShield = new Lang.Class({
this._lockScreenContents.add_actor(this._lockScreenContentsBox); this._lockScreenContents.add_actor(this._lockScreenContentsBox);
this._notificationsBox = new NotificationsBox(); this._notificationsBox = new NotificationsBox();
this._wakeUpScreenId = this._notificationsBox.connect('wake-up-screen', Lang.bind(this, this._wakeUpScreen));
this._lockScreenContentsBox.add(this._notificationsBox.actor, { x_fill: true, this._lockScreenContentsBox.add(this._notificationsBox.actor, { x_fill: true,
y_fill: true, y_fill: true,
expand: true }); expand: true });
@ -1158,11 +1160,17 @@ const ScreenShield = new Lang.Class({
this._hasLockScreen = true; this._hasLockScreen = true;
}, },
_wakeUpScreen: function() {
this._onUserBecameActive();
this.emit('wake-up-screen');
},
_clearLockScreen: function() { _clearLockScreen: function() {
this._clock.destroy(); this._clock.destroy();
this._clock = null; this._clock = null;
if (this._notificationsBox) { if (this._notificationsBox) {
this._notificationsBox.disconnect(this._wakeUpScreenId);
this._notificationsBox.destroy(); this._notificationsBox.destroy();
this._notificationsBox = null; this._notificationsBox = null;
} }

View File

@ -69,6 +69,7 @@ const ScreenSaverIface = '<node> \
<signal name="ActiveChanged"> \ <signal name="ActiveChanged"> \
<arg name="new_value" type="b" /> \ <arg name="new_value" type="b" /> \
</signal> \ </signal> \
<signal name="WakeUpScreen" /> \
</interface> \ </interface> \
</node>'; </node>';
@ -407,6 +408,9 @@ const ScreenSaverDBus = new Lang.Class({
screenShield.connect('active-changed', Lang.bind(this, function(shield) { screenShield.connect('active-changed', Lang.bind(this, function(shield) {
this._dbusImpl.emit_signal('ActiveChanged', GLib.Variant.new('(b)', [shield.active])); this._dbusImpl.emit_signal('ActiveChanged', GLib.Variant.new('(b)', [shield.active]));
})); }));
screenShield.connect('wake-up-screen', Lang.bind(this, function(shield) {
this._dbusImpl.emit_signal('WakeUpScreen', null);
}));
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenSaverIface, this); this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ScreenSaverIface, this);
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/ScreenSaver'); this._dbusImpl.export(Gio.DBus.session, '/org/gnome/ScreenSaver');

View File

@ -313,33 +313,6 @@ shell_util_create_pixbuf_from_data (const guchar *data,
(GdkPixbufDestroyNotify) g_free, NULL); (GdkPixbufDestroyNotify) g_free, NULL);
} }
/**
* shell_util_wake_up_screen:
*
* Send a fake key event, resetting the IDLETIME counter and
* causing gnome-settings-daemon to wake up the screen.
*/
/* Shamelessly taken from gnome-settings-daemon/plugins/power/gpm-common.c */
void
shell_util_wake_up_screen (void)
{
static gboolean inited = FALSE;
static KeyCode keycode1, keycode2;
static gboolean first_keycode = FALSE;
if (inited == FALSE) {
keycode1 = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), GDK_KEY_Alt_L);
keycode2 = XKeysymToKeycode (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), GDK_KEY_Alt_R);
}
gdk_error_trap_push ();
/* send a left or right alt key; first press, then release */
XTestFakeKeyEvent (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), first_keycode ? keycode1 : keycode2, True, CurrentTime);
XTestFakeKeyEvent (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), first_keycode ? keycode1 : keycode2, False, CurrentTime);
first_keycode = !first_keycode;
gdk_error_trap_pop_ignored ();
}
void void
shell_util_cursor_tracker_to_clutter (MetaCursorTracker *tracker, shell_util_cursor_tracker_to_clutter (MetaCursorTracker *tracker,
ClutterTexture *texture) ClutterTexture *texture)

View File

@ -41,8 +41,6 @@ GdkPixbuf *shell_util_create_pixbuf_from_data (const guchar *data,
int height, int height,
int rowstride); int rowstride);
void shell_util_wake_up_screen (void);
void shell_util_cursor_tracker_to_clutter (MetaCursorTracker *tracker, void shell_util_cursor_tracker_to_clutter (MetaCursorTracker *tracker,
ClutterTexture *texture); ClutterTexture *texture);