plugin: disable input to stage when screen is locked

This is a slightly modified version of jaapz' branch trying to make the method more general
by applying the lock in update_input_area. begin_modal will now set the the input area
to FULLSCREEN, so set_input_area is no longer required to be called from the windowoverview
or the workspaceview.
This commit is contained in:
Tom Beckmann 2013-08-03 13:15:11 +02:00
commit fec97f1469
5 changed files with 54 additions and 5 deletions

View File

@ -69,6 +69,7 @@ vala_precompile(VALA_C
src/DragDropAction.vala
src/Main.vala
src/Plugin.vala
src/ScreenSaver.vala
src/Settings.vala
src/TextShadowEffect.vala
src/Utils.vala

View File

@ -46,6 +46,8 @@ namespace Gala
Zooming zooming;
WindowOverview window_overview;
ScreenSaver? screensaver;
#if HAS_MUTTER38
// FIXME we need a proper-sized background for every monitor
public BackgroundActor wallpaper { get; private set; }
@ -87,6 +89,17 @@ namespace Gala
DBus.init (this);
// Due to a bug which enables access to the stage when using multiple monitors
// in the screensaver, we have to listen for changes and make sure the input area
// is set to NONE when we are in locked mode
try {
screensaver = Bus.get_proxy_sync (BusType.SESSION, "org.gnome.ScreenSaver",
"/org/gnome/ScreenSaver");
screensaver.active_changed.connect (() => {
update_input_area ();
});
} catch (Error e) { warning (e.message); }
var stage = Compositor.get_stage_for_screen (screen) as Clutter.Stage;
string color = new Settings ("org.gnome.desktop.background").get_string ("primary-color");
@ -250,14 +263,22 @@ namespace Gala
public void update_input_area ()
{
var schema = BehaviorSettings.get_default ().schema;
var screen = get_screen ();
if (schema.get_enum ("hotcorner-topleft") != ActionType.NONE ||
if (screensaver != null && screensaver.get_active ()) {
Utils.set_input_area (screen, InputArea.NONE);
return;
}
if (modal_count > 0)
Utils.set_input_area (screen, InputArea.FULLSCREEN);
else if (schema.get_enum ("hotcorner-topleft") != ActionType.NONE ||
schema.get_enum ("hotcorner-topright") != ActionType.NONE ||
schema.get_enum ("hotcorner-bottomleft") != ActionType.NONE ||
schema.get_enum ("hotcorner-bottomright") != ActionType.NONE)
Utils.set_input_area (get_screen (), InputArea.HOT_CORNER);
Utils.set_input_area (screen, InputArea.HOT_CORNER);
else
Utils.set_input_area (get_screen (), InputArea.NONE);
Utils.set_input_area (screen, InputArea.NONE);
}
public uint32[] get_all_xids ()
@ -318,6 +339,7 @@ namespace Gala
var screen = get_screen ();
var display = screen.get_display ();
update_input_area ();
base.begin_modal (x_get_stage_window (Compositor.get_stage_for_screen (screen)), {}, 0, display.get_current_time ());
}
@ -327,6 +349,7 @@ namespace Gala
if (modal_count > 0)
return;
update_input_area ();
base.end_modal (get_screen ().get_display ().get_current_time ());
}

27
src/ScreenSaver.vala Normal file
View File

@ -0,0 +1,27 @@
//
// Copyright (C) 2012 Jaap Broekhuizen
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
namespace Gala
{
[DBus (name = "org.gnome.ScreenSaver")]
public interface ScreenSaver : GLib.Object
{
public abstract bool get_active () throws GLib.IOError;
public signal void active_changed (bool active);
}
}

View File

@ -581,7 +581,6 @@ namespace Gala
grab_key_focus ();
plugin.begin_modal ();
Utils.set_input_area (screen, InputArea.FULLSCREEN);
visible = true;

View File

@ -388,7 +388,6 @@ namespace Gala
visible = true;
grab_key_focus ();
Utils.set_input_area (screen, InputArea.FULLSCREEN);
plugin.begin_modal ();
var area = screen.get_monitor_geometry (screen.get_primary_monitor ());