mirror of
https://github.com/elementary/gala.git
synced 2024-12-01 03:34:04 +03:00
Some refactoring and clean up
This commit is contained in:
parent
51233c57f2
commit
45441cb78b
@ -1,41 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schemalist>
|
||||
|
||||
<enum id="gala-action-type">
|
||||
<value nick="None" value="0" />
|
||||
<value nick="ShowWorkspaceView" value="1" />
|
||||
<value nick="MaximizeCurrent" value="2" />
|
||||
<value nick="MinimizeCurrent" value="3" />
|
||||
<value nick="OpenLauncher" value="4" />
|
||||
<value nick="CustomCommand" value="5" />
|
||||
<enum id="GalaActionType">
|
||||
<value nick='none' value="0" />
|
||||
<value nick="show-workspace-view" value="1" />
|
||||
<value nick="maximize-current" value="2" />
|
||||
<value nick="minimize-current" value="3" />
|
||||
<value nick="open-launcher" value="4" />
|
||||
<value nick="custom-command" value="5" />
|
||||
</enum>
|
||||
|
||||
<schema path="/org/pantheon/desktop/gala/behavior/" id="org.pantheon.desktop.gala.behavior" gettext-domain="gala">
|
||||
|
||||
<key enum="gala-action-type" name="hotcorner-topleft">
|
||||
<default>"None"</default>
|
||||
<key enum="GalaActionType" name="hotcorner-topleft">
|
||||
<default>'none'</default>
|
||||
<summary>Action for the top left corner</summary>
|
||||
<description></description>
|
||||
</key>
|
||||
<key enum="gala-action-type" name="hotcorner-topright">
|
||||
<default>"None"</default>
|
||||
<key enum="GalaActionType" name="hotcorner-topright">
|
||||
<default>'none'</default>
|
||||
<summary>Action for the top right corner</summary>
|
||||
<description></description>
|
||||
</key>
|
||||
<key enum="gala-action-type" name="hotcorner-bottomleft">
|
||||
<default>"None"</default>
|
||||
<key enum="GalaActionType" name="hotcorner-bottomleft">
|
||||
<default>'none'</default>
|
||||
<summary>Action for the bottom left corner</summary>
|
||||
<description></description>
|
||||
</key>
|
||||
<key enum="gala-action-type" name="hotcorner-bottomright">
|
||||
<default>"None"</default>
|
||||
<key enum="GalaActionType" name="hotcorner-bottomright">
|
||||
<default>'none'</default>
|
||||
<summary>Action for the bottom right corner</summary>
|
||||
<description></description>
|
||||
</key>
|
||||
|
||||
<key type="s" name="hotcorner-custom-command">
|
||||
<default>''</default>
|
||||
<summary>The command that will be executed for the hotcorner action CUSTOM_COMMAND</summary>
|
||||
<summary>The command that will be executed for the hotcorner action 'custom-command'</summary>
|
||||
<description></description>
|
||||
</key>
|
||||
<key type="b" name="edge-tiling">
|
||||
|
@ -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,24 +158,23 @@ 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);
|
||||
else
|
||||
Utils.set_input_area (get_screen (), Utils.InputArea.NONE);
|
||||
}
|
||||
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 (), InputArea.NONE);
|
||||
}
|
||||
|
||||
public void move_window (Window? window, MotionDirection direction)
|
||||
{
|
||||
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user