Move window_switcher method to WorkspaceSwitcher

This commit is contained in:
Rico Tzschichholz 2012-06-01 14:20:36 +02:00
parent b020dd9152
commit d3db71a6c9
3 changed files with 24 additions and 28 deletions

View File

@ -74,14 +74,8 @@ namespace Gala
} catch (Error e) { warning (e.message); }
});
KeyBinding.set_custom_handler ("switch-windows",
(display, screen, window, ev, binding) => {
window_switcher (display, screen, binding, false);
});
KeyBinding.set_custom_handler ("switch-windows-backward",
(display, screen, window, ev, binding) => {
window_switcher (display, screen, binding, true);
});
KeyBinding.set_custom_handler ("switch-windows", winswitcher.handle_switch_windows);
KeyBinding.set_custom_handler ("switch-windows-backward", winswitcher.handle_switch_windows);
KeyBinding.set_custom_handler ("switch-to-workspace-left", () => {});
KeyBinding.set_custom_handler ("switch-to-workspace-right", () => {});
@ -170,24 +164,6 @@ namespace Gala
base.end_modal (get_screen ().get_display ().get_current_time ());
}
void window_switcher (Display display, Screen screen, KeyBinding binding, bool backward)
{
if (screen.get_display ().get_tab_list (TabList.NORMAL, screen, screen.get_active_workspace ()).length () == 0)
return;
begin_modal ();
int width, height;
screen.get_size (out width, out height);
winswitcher.list_windows (display, screen, binding, backward);
winswitcher.x = width / 2 - winswitcher.width / 2;
winswitcher.y = height / 2 - winswitcher.height / 2;
winswitcher.grab_key_focus ();
winswitcher.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 250, opacity : 255);
}
void workspace_switcher (Screen screen, bool up)
{
int width, height;

View File

@ -156,7 +156,7 @@ namespace Gala
return true;
}
public void list_windows (Meta.Display display, Meta.Screen screen, Meta.KeyBinding binding, bool backward)
void list_windows (Meta.Display display, Meta.Screen screen, Meta.KeyBinding binding, bool backward)
{
get_children ().foreach ((c) => { //clear
if (c != current && c != background && c != title)
@ -233,5 +233,25 @@ namespace Gala
var idx = window_list.index (current_window);
current.x = spacing + idx * (spacing + ICON_SIZE);
}
public void handle_switch_windows (Meta.Display display, Meta.Screen screen, Meta.Window? window,
X.Event event, Meta.KeyBinding binding)
{
if (display.get_tab_list (Meta.TabList.NORMAL, screen, screen.get_active_workspace ()).length () == 0)
return;
plugin.begin_modal ();
int width, height;
screen.get_size (out width, out height);
bool backward = (binding.get_name () == "switch-windows-backward");
list_windows (display, screen, binding, backward);
x = width / 2 - this.width / 2;
y = height / 2 - this.height / 2;
grab_key_focus ();
animate (Clutter.AnimationMode.EASE_OUT_QUAD, 250, opacity : 255);
}
}
}

View File

@ -1106,7 +1106,7 @@ namespace Meta {
OVERRIDE_OTHER
}
[CCode (cheader_filename = "meta/prefs.h", instance_pos = 5.9)]
public delegate void KeyHandlerFunc (Meta.Display display, Meta.Screen screen, Meta.Window? window, void* event, Meta.KeyBinding binding);
public delegate void KeyHandlerFunc (Meta.Display display, Meta.Screen screen, Meta.Window? window, X.Event event, Meta.KeyBinding binding);
[CCode (cheader_filename = "meta/prefs.h", has_target = false)]
public delegate void PrefsChangedFunc (Meta.Preference pref, void* data);
[CCode (cheader_filename = "meta/window.h", has_target = false)]