Workspace made nicer

This commit is contained in:
Tom Beckmann 2012-05-29 16:34:42 +02:00
parent 54bea7f75b
commit 6f5eebd5fb
3 changed files with 54 additions and 20 deletions

View File

@ -26,6 +26,8 @@ public class WindowSwitcher : Clutter.Group {
this.height = ICON_SIZE+spacing*2; this.height = ICON_SIZE+spacing*2;
this.opacity = 0; this.opacity = 0;
this.scale_x = 0;
this.scale_gravity = Clutter.Gravity.CENTER;
this.bg = new Clutter.CairoTexture (100, 100); this.bg = new Clutter.CairoTexture (100, 100);
this.bg.auto_resize = true; this.bg.auto_resize = true;
@ -72,7 +74,8 @@ public class WindowSwitcher : Clutter.Group {
plugin.end_modal (); plugin.end_modal ();
current_window.activate (e.time); current_window.activate (e.time);
this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200, opacity:0); this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200, opacity:0).
completed.connect ( () => { this.scale_x = 0.0f; });
} }
return true; return true;
}); });

View File

@ -16,17 +16,19 @@ public class WorkspaceSwitcher : Clutter.Group {
get {return _workspace;} get {return _workspace;}
set { set {
_workspace = value; _workspace = value;
cur.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 400, y:_workspace*len+1+spacing) cur.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 400, y:_workspace*len+1+spacing);
.completed.connect ( () => {
this.animate (Clutter.AnimationMode.EASE_IN_QUAD, 800, opacity:0);
});
} }
} }
int spacing = 10; int spacing = 10;
float WIDTH = 200; float WIDTH = 200;
public WorkspaceSwitcher (int w, int h) { Gala.Plugin plugin;
public WorkspaceSwitcher (Gala.Plugin plugin, int w, int h) {
this.plugin = plugin;
this.height = 100+spacing*2; this.height = 100+spacing*2;
this.width = WIDTH+spacing*2; this.width = WIDTH+spacing*2;
this.opacity = 0; this.opacity = 0;
@ -78,5 +80,29 @@ public class WorkspaceSwitcher : Clutter.Group {
this.add_child (cur); this.add_child (cur);
bg.add_constraint (new Clutter.BindConstraint (this, Clutter.BindCoordinate.WIDTH, 0)); bg.add_constraint (new Clutter.BindConstraint (this, Clutter.BindCoordinate.WIDTH, 0));
bg.add_constraint (new Clutter.BindConstraint (this, Clutter.BindCoordinate.HEIGHT, 0)); bg.add_constraint (new Clutter.BindConstraint (this, Clutter.BindCoordinate.HEIGHT, 0));
this.key_release_event.connect ( (e) => {
if (((e.modifier_state & Clutter.ModifierType.MOD1_MASK) == 0) ||
e.keyval == Clutter.Key.Alt_L) {
plugin.end_modal ();
this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200, opacity:0);
return true;
}
return false;
});
this.key_press_event.connect ( (e) => {
switch (e.keyval) {
case Clutter.Key.Up:
this.workspace = plugin.move_workspaces (true);
return false;
case Clutter.Key.Down:
this.workspace = plugin.move_workspaces (false);
return false;
default:
return true;
}
});
} }
} }

View File

@ -23,7 +23,7 @@ namespace Gala {
int w, h; int w, h;
this.get_screen ().get_size (out w, out h); this.get_screen ().get_size (out w, out h);
this.wswitcher = new WorkspaceSwitcher (w, h); this.wswitcher = new WorkspaceSwitcher (this, w, h);
this.wswitcher.workspaces = 4; this.wswitcher.workspaces = 4;
this.elements.add_child (this.wswitcher); this.elements.add_child (this.wswitcher);
@ -63,18 +63,29 @@ namespace Gala {
int w, h; int w, h;
this.get_screen ().get_size (out w, out h); this.get_screen ().get_size (out w, out h);
/*TODO -> bindig.get_modifiers
if ((e.xkey.state & X.KeyMask.ShiftMask) == 1)
backward = !backward;*/
this.winswitcher.list_windows (display, screen, binding, backward); this.winswitcher.list_windows (display, screen, binding, backward);
this.winswitcher.x = w/2-winswitcher.width/2; this.winswitcher.x = w/2-winswitcher.width/2;
this.winswitcher.y = h/2-winswitcher.height/2; this.winswitcher.y = h/2-winswitcher.height/2;
this.winswitcher.grab_key_focus (); this.winswitcher.grab_key_focus ();
this.winswitcher.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 400, opacity:255); this.winswitcher.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 250, opacity:255,
scale_x:1.0F);
} }
public void workspace_switcher (Meta.Screen screen, bool up) { public void workspace_switcher (Meta.Screen screen, bool up) {
int w, h;
this.get_screen ().get_size (out w, out h);
wswitcher.x = w/2-wswitcher.width/2;
wswitcher.y = h/2-wswitcher.height/2;
wswitcher.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 100, opacity:255);
wswitcher.workspace = move_workspaces (up);;
this.begin_modal ();
wswitcher.grab_key_focus ();
}
public int move_workspaces (bool up) {
var i = screen.get_active_workspace_index (); var i = screen.get_active_workspace_index ();
if (up && i-1 >= 0) //move up if (up && i-1 >= 0) //move up
i --; i --;
@ -83,15 +94,8 @@ namespace Gala {
if (i != screen.get_active_workspace_index ()) { if (i != screen.get_active_workspace_index ()) {
screen.get_workspace_by_index (i). screen.get_workspace_by_index (i).
activate (screen.get_display ().get_current_time ()); activate (screen.get_display ().get_current_time ());
int w, h;
this.get_screen ().get_size (out w, out h);
wswitcher.x = w/2-wswitcher.width/2;
wswitcher.y = h/2-wswitcher.height/2;
wswitcher.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 100, opacity:255);
wswitcher.workspace = i;
} }
return i;
} }
public override void minimize (Meta.WindowActor actor) { public override void minimize (Meta.WindowActor actor) {
@ -173,7 +177,8 @@ namespace Gala {
private Clutter.Group out_group; private Clutter.Group out_group;
public override void switch_workspace (int from, int to, Meta.MotionDirection direction) { public override void switch_workspace (int from, int to, Meta.MotionDirection direction) {
unowned List<Clutter.Actor> windows = Meta.Compositor.get_window_actors (this.get_screen ()); unowned List<Clutter.Actor> windows =
Meta.Compositor.get_window_actors (this.get_screen ());
//FIXME js/ui/windowManager.js line 430 //FIXME js/ui/windowManager.js line 430
int w, h; int w, h;
this.get_screen ().get_size (out w, out h); this.get_screen ().get_size (out w, out h);