diff --git a/data/org.pantheon.desktop.gala.gschema.xml b/data/org.pantheon.desktop.gala.gschema.xml index 80e88930..e820770c 100644 --- a/data/org.pantheon.desktop.gala.gschema.xml +++ b/data/org.pantheon.desktop.gala.gschema.xml @@ -1,41 +1,38 @@ - - - - - - - - + + + + + + + - - - "None" + + 'none' Action for the top left corner - - "None" + + 'none' Action for the top right corner - - "None" + + 'none' Action for the bottom left corner - - "None" + + 'none' Action for the bottom right corner - '' - The command that will be executed for the hotcorner action CUSTOM_COMMAND + The command that will be executed for the hotcorner action 'custom-command' diff --git a/src/Plugin.vala b/src/Plugin.vala index 5fe5b507..1b3cfed7 100644 --- a/src/Plugin.vala +++ b/src/Plugin.vala @@ -19,7 +19,6 @@ using Meta; namespace Gala { - public enum ActionType { NONE = 0, @@ -30,6 +29,12 @@ namespace Gala CUSTOM_COMMAND } + public enum InputArea { + NONE, + FULLSCREEN, + HOT_CORNER + } + public class Plugin : Meta.Plugin { WindowSwitcher winswitcher; @@ -130,17 +135,17 @@ namespace Gala /*hot corner, getting enum values from GraniteServicesSettings did not work, so we use GSettings directly*/ var geometry = screen.get_monitor_geometry (screen.get_primary_monitor ()); - var top_left = create_hotcorner (geometry.x, geometry.y, "hotcorner-topleft"); - var top_right = create_hotcorner (geometry.x + geometry.width - 1, geometry.y, "hotcorner-topright"); - var bottom_left = create_hotcorner (geometry.x, geometry.y + geometry.height - 1, "hotcorner-bottomleft"); - var bottom_right = create_hotcorner (geometry.x + geometry.width - 1, geometry.y + geometry.height - 1, "hotcorner-bottomright"); + add_hotcorner (geometry.x, geometry.y, "hotcorner-topleft"); + add_hotcorner (geometry.x + geometry.width - 1, geometry.y, "hotcorner-topright"); + add_hotcorner (geometry.x, geometry.y + geometry.height - 1, "hotcorner-bottomleft"); + add_hotcorner (geometry.x + geometry.width - 1, geometry.y + geometry.height - 1, "hotcorner-bottomright"); update_input_area (); BehaviorSettings.get_default ().schema.changed.connect ((key) => update_input_area ()); } - Clutter.Actor create_hotcorner (float x, float y, string key) + void add_hotcorner (float x, float y, string key) { var hot_corner = new Clutter.Actor (); hot_corner.x = x; @@ -153,25 +158,24 @@ namespace Gala Compositor.get_stage_for_screen (get_screen ()).add_child (hot_corner); hot_corner.enter_event.connect (() => { - run (this, (ActionType)BehaviorSettings.get_default ().schema.get_enum (key)); + perform_action ((ActionType)BehaviorSettings.get_default ().schema.get_enum (key)); return false; }); - - return hot_corner; } public void update_input_area () { - if (BehaviorSettings.get_default ().schema.get_enum ("hotcorner-topleft") != ActionType.NONE || - BehaviorSettings.get_default ().schema.get_enum ("hotcorner-topright") != ActionType.NONE || - BehaviorSettings.get_default ().schema.get_enum ("hotcorner-bottomleft") != ActionType.NONE || - BehaviorSettings.get_default ().schema.get_enum ("hotcorner-bottomright") != ActionType.NONE) - Utils.set_input_area (get_screen (), Utils.InputArea.HOT_CORNER); + var schema = BehaviorSettings.get_default ().schema; + + 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); else - Utils.set_input_area (get_screen (), Utils.InputArea.NONE); + Utils.set_input_area (get_screen (), InputArea.NONE); } - public void move_window (Window? window, MotionDirection direction) { if (window == null) @@ -237,15 +241,15 @@ namespace Gala win.clear_effects ();*/ } - public static void run (Plugin plugin, ActionType type) + public void perform_action (ActionType type) { - var screen = plugin.get_screen (); + var screen = get_screen (); var display = screen.get_display (); var current = display.get_focus_window (); switch (type) { case ActionType.SHOW_WORKSPACE_VIEW: - plugin.workspace_view.show (); + workspace_view.show (); break; case ActionType.MAXIMIZE_CURRENT: if (current == null) diff --git a/src/Utils.vala b/src/Utils.vala index fb4806bc..5afc636a 100644 --- a/src/Utils.vala +++ b/src/Utils.vala @@ -1,14 +1,9 @@ using Meta; +using Gala; + namespace Gala.Utils { - - public enum InputArea { - NONE, - FULLSCREEN, - HOT_CORNER - } - /* * Reload shadow settings */ @@ -105,7 +100,7 @@ namespace Gala.Utils { var display = screen.get_display (); - X.Xrectangle[] rects; + X.Xrectangle[] rects = {}; int width, height; screen.get_size (out width, out height); var geometry = screen.get_monitor_geometry (screen.get_primary_monitor ()); @@ -115,11 +110,14 @@ namespace Gala.Utils X.Xrectangle rect = {0, 0, (ushort)width, (ushort)height}; rects = {rect}; break; - case InputArea.HOT_CORNER: //if action type is none, make them 0 sized - short tl_size = (BehaviorSettings.get_default ().schema.get_enum ("hotcorner-topleft") != ActionType.NONE)?1:0; - short tr_size = (BehaviorSettings.get_default ().schema.get_enum ("hotcorner-topright") != ActionType.NONE)?1:0; - short bl_size = (BehaviorSettings.get_default ().schema.get_enum ("hotcorner-bottomleft") != ActionType.NONE)?1:0; - short br_size = (BehaviorSettings.get_default ().schema.get_enum ("hotcorner-bottomright") != ActionType.NONE)?1:0; + case InputArea.HOT_CORNER: + var schema = BehaviorSettings.get_default ().schema; + + // if ActionType is NONE make it 0 sized + ushort tl_size = (schema.get_enum ("hotcorner-topleft") != ActionType.NONE ? 1 : 0); + ushort tr_size = (schema.get_enum ("hotcorner-topright") != ActionType.NONE ? 1 : 0); + ushort bl_size = (schema.get_enum ("hotcorner-bottomleft") != ActionType.NONE ? 1 : 0); + ushort br_size = (schema.get_enum ("hotcorner-bottomright") != ActionType.NONE ? 1 : 0); X.Xrectangle topleft = {(short)geometry.x, (short)geometry.y, tl_size, tl_size}; X.Xrectangle topright = {(short)(geometry.x + geometry.width - 1), (short)geometry.y, tr_size, tr_size}; @@ -128,6 +126,7 @@ namespace Gala.Utils rects = {topleft, topright, bottomleft, bottomright}; break; + case InputArea.NONE: default: Util.empty_stage_input_region (screen); return; diff --git a/src/Widgets/WorkspaceView.vala b/src/Widgets/WorkspaceView.vala index ef71ab10..c60fc78b 100644 --- a/src/Widgets/WorkspaceView.vala +++ b/src/Widgets/WorkspaceView.vala @@ -197,7 +197,7 @@ namespace Gala } } - internal void switch_to_next_workspace (MotionDirection direction) + void switch_to_next_workspace (MotionDirection direction) { var screen = plugin.get_screen (); var display = screen.get_display (); @@ -294,7 +294,7 @@ namespace Gala var screen = plugin.get_screen (); - Utils.set_input_area (screen, Utils.InputArea.FULLSCREEN); + Utils.set_input_area (screen, InputArea.FULLSCREEN); plugin.begin_modal (); visible = true;