Lots of changes

This commit is contained in:
Tom Beckmann 2012-05-29 15:38:49 +02:00
parent 783656288f
commit d4d8691327
7 changed files with 1350 additions and 1142 deletions

View File

@ -52,6 +52,8 @@ PACKAGES
libmutter
clutter-gtk-1.0
gdk-x11-3.0
gdesktopenums-3.0
xfixes-4.0
OPTIONS
--vapidir=${CMAKE_CURRENT_SOURCE_DIR}/vapi/
)

View File

@ -16,7 +16,14 @@ public class WindowSwitcher : Clutter.Group {
set { _windows = value; this.width = spacing+_windows*(ICON_SIZE+spacing); }
}
public WindowSwitcher () {
GLib.List<Meta.Window> window_list;
Meta.Window current_window;
Gala.Plugin plugin;
public WindowSwitcher (Gala.Plugin plugin) {
this.plugin = plugin;
this.height = ICON_SIZE+spacing*2;
this.opacity = 0;
@ -58,22 +65,81 @@ public class WindowSwitcher : Clutter.Group {
this.add_child (cur);
bg.add_constraint (new Clutter.BindConstraint (this, Clutter.BindCoordinate.WIDTH, 0));
bg.add_constraint (new Clutter.BindConstraint (this, Clutter.BindCoordinate.HEIGHT, 0));
this.key_release_event.connect_after ( (e) => {
if (((e.modifier_state & Clutter.ModifierType.MOD1_MASK) == 0) ||
e.keyval == Clutter.Key.Alt_L) {
plugin.end_modal ();
current_window.activate (e.time);
this.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200, opacity:0);
}
return true;
});
this.captured_event.connect ( (e) => {
if (!(e.get_type () == Clutter.EventType.KEY_PRESS))
return false;
bool backward = (((Clutter.Event)e).get_state () & X.KeyMask.ShiftMask) == 1;
var action = plugin.get_screen ().get_display ().get_keybinding_action (
((Clutter.Event)e).get_key_code (), ((Clutter.Event)e).get_state ());
switch (action) {
case Meta.KeyBindingAction.SWITCH_GROUP:
case Meta.KeyBindingAction.SWITCH_WINDOWS:
this.current_window = plugin.get_screen ().get_display ().
get_tab_next (Meta.TabList.NORMAL, plugin.get_screen (),
plugin.get_screen ().get_active_workspace (), this.current_window, backward);
break;
case Meta.KeyBindingAction.SWITCH_GROUP_BACKWARD:
case Meta.KeyBindingAction.SWITCH_WINDOWS_BACKWARD:
this.current_window = plugin.get_screen ().get_display ().
get_tab_next (Meta.TabList.NORMAL, plugin.get_screen (),
plugin.get_screen ().get_active_workspace (), this.current_window, true);
break;
default:
break;
}
cur.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 200,
x:0.0f+spacing+this.window_list.index (this.current_window)*(spacing+ICON_SIZE));
return true;
});
}
public void list_windows (List<Object> windows, Meta.Display dpy, bool backwards) {
this.get_children ().foreach ( (c) => {
public void list_windows (Meta.Display display, Meta.Screen screen,
Meta.KeyBinding binding, bool backward) {
this.get_children ().foreach ( (c) => { //clear
if (c != cur && c != bg)
this.remove_child (c);
});
var a = 0;
this.current_window = display.get_tab_next (Meta.TabList.NORMAL, screen,
screen.get_active_workspace (), null, backward);
if (this.current_window == null)
this.current_window = display.get_tab_current (Meta.TabList.NORMAL, screen,
screen.get_active_workspace ());
if (this.current_window == null)
return;
if (binding.get_mask () == 0) {
this.current_window.activate (display.get_current_time ());
return;
}
var i = 0;
windows.foreach ( (w) => {
if ((w as Meta.Window).window_type != Meta.WindowType.NORMAL)
this.window_list = screen.get_display ().get_tab_list (Meta.TabList.NORMAL, screen,
screen.get_active_workspace ());
this.window_list.foreach ( (w) => {
if (w == null)
return;
Gdk.Pixbuf image;
if (((Meta.Window)w).icon == null)
image = Gtk.IconTheme.get_default ().load_icon ("window-new", ICON_SIZE-10, 0);
else
image = ((Meta.Window)w).icon;
var icon = new GtkClutter.Texture ();
try {
icon.set_from_pixbuf (((Meta.Window)w).icon);
icon.set_from_pixbuf (image);
} catch (Error e) { warning (e.message); }
icon.width = ICON_SIZE-10;
icon.height = ICON_SIZE-10;
@ -81,28 +147,12 @@ public class WindowSwitcher : Clutter.Group {
icon.y = spacing+5;
this.add_child (icon);
if (w == dpy.focus_window)
a = i;
i ++;
});
this.windows = i;
cur.x = spacing+a*(spacing+ICON_SIZE);
if (!backwards) {
a ++;
if (a >= i)
a = 0;
} else {
a --;
if (a < 0)
a = i;
}
cur.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 400,
x:0.0f+spacing+a*(spacing+ICON_SIZE)).completed.connect ( () => {
this.animate (Clutter.AnimationMode.EASE_IN_QUAD, 800, opacity:0);
});
(windows.nth_data (a) as Meta.Window).activate (dpy.get_current_time ());
var idx = this.window_list.index (this.current_window);
cur.x = spacing+idx*(spacing+ICON_SIZE);
}
}

View File

@ -13,10 +13,10 @@ namespace Gala {
public override void start () {
this.get_screen ();
this.elements = Meta.get_stage_for_screen (this.get_screen ());
Meta.get_window_group_for_screen (this.get_screen ()).reparent (elements);
Meta.get_overlay_group_for_screen (this.get_screen ()).reparent (elements);
Meta.get_stage_for_screen (this.get_screen ()).add_child (elements);
this.elements = Meta.Compositor.get_stage_for_screen (this.get_screen ());
Meta.Compositor.get_window_group_for_screen (this.get_screen ()).reparent (elements);
Meta.Compositor.get_overlay_group_for_screen (this.get_screen ()).reparent (elements);
Meta.Compositor.get_stage_for_screen (this.get_screen ()).add_child (elements);
this.get_screen ().override_workspace_layout (Meta.ScreenCorner.TOPLEFT, false, -1, 4);
@ -27,32 +27,51 @@ namespace Gala {
this.wswitcher.workspaces = 4;
this.elements.add_child (this.wswitcher);
this.winswitcher = new WindowSwitcher ();
this.winswitcher = new WindowSwitcher (this);
this.elements.add_child (this.winswitcher);
Meta.keybindings_set_custom_handler ("switch-windows",
(display, screen) => {
window_switcher (screen, false);
Meta.KeyBinding.set_custom_handler ("switch-windows",
(display, screen, window, ev, binding) => {
window_switcher (display, screen, binding, false);
});
Meta.keybindings_set_custom_handler ("switch-to-workspace-left", ()=>{});
Meta.keybindings_set_custom_handler ("switch-to-workspace-right", ()=>{});
Meta.keybindings_set_custom_handler ("switch-to-workspace-up", (d,s) =>
Meta.KeyBinding.set_custom_handler ("switch-windows-backward",
(display, screen, window, ev, binding) => {
window_switcher (display, screen, binding, true);
});
Meta.KeyBinding.set_custom_handler ("switch-to-workspace-left", ()=>{});
Meta.KeyBinding.set_custom_handler ("switch-to-workspace-right", ()=>{});
Meta.KeyBinding.set_custom_handler ("switch-to-workspace-up", (d,s) =>
workspace_switcher (s, true) );
Meta.keybindings_set_custom_handler ("switch-to-workspace-down", (d,s) =>
Meta.KeyBinding.set_custom_handler ("switch-to-workspace-down", (d,s) =>
workspace_switcher (s, false) );
Meta.ShadowFactory.get_default ().set_params ("normal", true, {30, -1, 0, 30, 255});
}
public void window_switcher (Meta.Screen screen, bool backwards) {
public new void begin_modal () {
base.begin_modal (x_get_stage_window (Meta.Compositor.get_stage_for_screen (
this.get_screen ())), {}, 0, this.get_screen ().get_display ().get_current_time ());
}
public new void end_modal () {
base.end_modal (this.get_screen ().get_display ().get_current_time ());
}
public void window_switcher (Meta.Display display, Meta.Screen screen,
Meta.KeyBinding binding, bool backward) {
this.begin_modal ();
int w, 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 (screen.get_active_workspace ().list_windows (),
this.get_screen ().get_display (), backwards);
this.winswitcher.x = w/2-winswitcher.width/2;
this.winswitcher.y = h/2-winswitcher.height/2;
this.winswitcher.grab_key_focus ();
this.winswitcher.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 400, opacity:255);
(Meta.get_stage_for_screen (this.get_screen ()) as Clutter.Stage).set_key_focus (null);
}
public void workspace_switcher (Meta.Screen screen, bool up) {
@ -79,7 +98,8 @@ namespace Gala {
this.minimize_completed (actor);
}
public override void maximize (Meta.WindowActor actor, int x, int y, int w, int h) {
//stolen from original mutter plugin
public override void maximize (Meta.WindowActor actor, int ex, int ey, int ew, int eh) {
this.maximize_completed (actor);
}
@ -153,7 +173,7 @@ namespace Gala {
private Clutter.Group out_group;
public override void switch_workspace (int from, int to, Meta.MotionDirection direction) {
unowned List<Clutter.Actor> windows = Meta.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
int w, h;
this.get_screen ().get_size (out w, out h);
@ -179,7 +199,7 @@ namespace Gala {
var in_group = new Clutter.Group ();
var out_group = new Clutter.Group ();
var group = Meta.get_window_group_for_screen (this.get_screen ());
var group = Meta.Compositor.get_window_group_for_screen (this.get_screen ());
group.add_actor (in_group);
group.add_actor (out_group);

View File

@ -6,7 +6,7 @@ public extern X.Window x_get_stage_window (Clutter.Actor stage);
int main (string [] args) {
OptionContext ctx = Meta.get_option_context ();
unowned OptionContext ctx = Meta.get_option_context ();
ctx.add_main_entries (Gala.OPTIONS, null);
try {
ctx.parse (ref args);

105
vapi/gdesktopenums-3.0.vapi Normal file
View File

@ -0,0 +1,105 @@
/* gdesktopenums-3.0.vapi generated by vapigen, do not modify. */
[CCode (cprefix = "GDesktop", gir_namespace = "GDesktopEnums", gir_version = "3.0", lower_case_cprefix = "g_desktop_")]
namespace GDesktop {
[CCode (cheader_filename = "GDesktopEnums-3.0.h", cprefix = "G_DESKTOP_BACKGROUND_SHADING_")]
public enum BackgroundShading {
SOLID,
VERTICAL,
HORIZONTAL
}
[CCode (cheader_filename = "GDesktopEnums-3.0.h", cprefix = "G_DESKTOP_BACKGROUND_STYLE_")]
public enum BackgroundStyle {
NONE,
WALLPAPER,
CENTERED,
SCALED,
STRETCHED,
ZOOM,
SPANNED
}
[CCode (cheader_filename = "GDesktopEnums-3.0.h", cprefix = "G_DESKTOP_CLOCK_FORMAT_")]
public enum ClockFormat {
@24H,
@12H
}
[CCode (cheader_filename = "GDesktopEnums-3.0.h", cprefix = "G_DESKTOP_FOCUS_MODE_")]
public enum FocusMode {
CLICK,
SLOPPY,
MOUSE
}
[CCode (cheader_filename = "GDesktopEnums-3.0.h", cprefix = "G_DESKTOP_FOCUS_NEW_WINDOWS_")]
public enum FocusNewWindows {
SMART,
STRICT
}
[CCode (cheader_filename = "GDesktopEnums-3.0.h", cprefix = "G_DESKTOP_MAGNIFIER_MOUSE_TRACKING_MODE_")]
public enum MagnifierMouseTrackingMode {
NONE,
CENTERED,
PROPORTIONAL,
PUSH
}
[CCode (cheader_filename = "GDesktopEnums-3.0.h", cprefix = "G_DESKTOP_MAGNIFIER_SCREEN_POSITION_")]
public enum MagnifierScreenPosition {
NONE,
FULL_SCREEN,
TOP_HALF,
BOTTOM_HALF,
LEFT_HALF,
RIGHT_HALF
}
[CCode (cheader_filename = "GDesktopEnums-3.0.h", cprefix = "G_DESKTOP_MOUSE_DWELL_DIRECTION_")]
public enum MouseDwellDirection {
LEFT,
RIGHT,
UP,
DOWN
}
[CCode (cheader_filename = "GDesktopEnums-3.0.h", cprefix = "G_DESKTOP_MOUSE_DWELL_MODE_")]
public enum MouseDwellMode {
WINDOW,
GESTURE
}
[CCode (cheader_filename = "GDesktopEnums-3.0.h", cprefix = "G_DESKTOP_PROXY_MODE_")]
public enum ProxyMode {
NONE,
MANUAL,
AUTO
}
[CCode (cheader_filename = "GDesktopEnums-3.0.h", cprefix = "G_DESKTOP_SCREENSAVER_MODE_")]
public enum ScreensaverMode {
BLANK_ONLY,
RANDOM,
SINGLE
}
[CCode (cheader_filename = "GDesktopEnums-3.0.h", cprefix = "G_DESKTOP_TITLEBAR_ACTION_")]
public enum TitlebarAction {
TOGGLE_SHADE,
TOGGLE_MAXIMIZE,
TOGGLE_MAXIMIZE_HORIZONTALLY,
TOGGLE_MAXIMIZE_VERTICALLY,
MINIMIZE,
NONE,
LOWER,
MENU
}
[CCode (cheader_filename = "GDesktopEnums-3.0.h", cprefix = "G_DESKTOP_TOOLBAR_ICON_SIZE_")]
public enum ToolbarIconSize {
SMALL,
LARGE
}
[CCode (cheader_filename = "GDesktopEnums-3.0.h", cprefix = "G_DESKTOP_TOOLBAR_STYLE_")]
public enum ToolbarStyle {
BOTH,
BOTH_HORIZ,
ICONS,
TEXT
}
[CCode (cheader_filename = "GDesktopEnums-3.0.h", cprefix = "G_DESKTOP_VISUAL_BELL_")]
public enum VisualBellType {
FULLSCREEN_FLASH,
FRAME_FLASH
}
}

File diff suppressed because it is too large Load Diff

8
vapi/xfixes-4.0.vapi Normal file
View File

@ -0,0 +1,8 @@
/* xfixes-4.0.vapi generated by vapigen, do not modify. */
[CCode (cprefix = "X", gir_namespace = "xfixes", gir_version = "4.0", lower_case_cprefix = "X_")]
namespace X {
[CCode (cheader_filename = "xfixes-4.0.h", cname = "XserverRegion", has_type_id = false)]
public struct XserverRegion {
}
}