Added direction parameter to plugin switch_workspace()
To facilitate nicer effects; extended direction defined in workspace.h so we can represent up-left, etc.
This commit is contained in:
parent
0225449e12
commit
6b1719de1c
@ -52,7 +52,8 @@ static void maximize (MetaCompWindow *actor,
|
||||
static void unmaximize (MetaCompWindow *actor,
|
||||
gint x, gint y, gint width, gint height);
|
||||
|
||||
static void switch_workspace (const GList **actors, gint from, gint to);
|
||||
static void switch_workspace (const GList **actors, gint from, gint to,
|
||||
MetaMotionDirection direction);
|
||||
|
||||
static void kill_effect (MetaCompWindow *actor, gulong event);
|
||||
|
||||
@ -197,7 +198,8 @@ on_switch_workspace_effect_complete (ClutterActor *group, gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
switch_workspace (const GList **actors, gint from, gint to)
|
||||
switch_workspace (const GList **actors, gint from, gint to,
|
||||
MetaMotionDirection direction)
|
||||
{
|
||||
MetaCompositorClutterPlugin *plugin = get_plugin ();
|
||||
PluginPrivate *ppriv = plugin->plugin_private;
|
||||
|
@ -52,7 +52,8 @@ static void maximize (MetaCompWindow *actor,
|
||||
static void unmaximize (MetaCompWindow *actor,
|
||||
gint x, gint y, gint width, gint height);
|
||||
|
||||
static void switch_workspace (const GList **actors, gint from, gint to);
|
||||
static void switch_workspace (const GList **actors, gint from, gint to,
|
||||
MetaMotionDirection direction);
|
||||
|
||||
static void kill_effect (MetaCompWindow *actor, gulong event);
|
||||
|
||||
@ -197,7 +198,8 @@ on_switch_workspace_effect_complete (ClutterActor *group, gpointer data)
|
||||
}
|
||||
|
||||
static void
|
||||
switch_workspace (const GList **actors, gint from, gint to)
|
||||
switch_workspace (const GList **actors, gint from, gint to,
|
||||
MetaMotionDirection direction)
|
||||
{
|
||||
MetaCompositorClutterPlugin *plugin = get_plugin ();
|
||||
PluginPrivate *ppriv = plugin->plugin_private;
|
||||
|
@ -627,7 +627,8 @@ gboolean
|
||||
meta_compositor_clutter_plugin_manager_switch_workspace (MetaCompositorClutterPluginManager *mgr,
|
||||
const GList **actors,
|
||||
gint from,
|
||||
gint to)
|
||||
gint to,
|
||||
MetaMotionDirection direction)
|
||||
{
|
||||
GList *l = mgr->plugins;
|
||||
gboolean retval = FALSE;
|
||||
@ -647,7 +648,7 @@ meta_compositor_clutter_plugin_manager_switch_workspace (MetaCompositorClutterPl
|
||||
meta_compositor_clutter_plugin_manager_kill_effect (mgr,
|
||||
META_COMP_WINDOW ((*actors)->data),
|
||||
META_COMPOSITOR_CLUTTER_PLUGIN_SWITCH_WORKSPACE);
|
||||
plg->switch_workspace (actors, from, to);
|
||||
plg->switch_workspace (actors, from, to, direction);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,8 @@ void meta_compositor_clutter_plugin_manager_update_workspace (MetaCompositorClut
|
||||
gboolean meta_compositor_clutter_plugin_manager_switch_workspace (MetaCompositorClutterPluginManager *mgr,
|
||||
const GList **actors,
|
||||
gint from,
|
||||
gint to);
|
||||
gint to,
|
||||
MetaMotionDirection direction);
|
||||
|
||||
gboolean meta_compositor_clutter_plugin_manager_xevent_filter (MetaCompositorClutterPluginManager *mgr,
|
||||
XEvent *xev);
|
||||
|
@ -2108,7 +2108,8 @@ static void
|
||||
clutter_cmp_switch_workspace (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
MetaWorkspace *from,
|
||||
MetaWorkspace *to)
|
||||
MetaWorkspace *to,
|
||||
MetaMotionDirection direction)
|
||||
{
|
||||
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
||||
MetaCompScreen *info;
|
||||
@ -2119,6 +2120,8 @@ clutter_cmp_switch_workspace (MetaCompositor *compositor,
|
||||
to_indx = meta_workspace_index (to);
|
||||
from_indx = meta_workspace_index (from);
|
||||
|
||||
printf ("Direction of switch %d\n", direction);
|
||||
|
||||
l = info->windows;
|
||||
while (l)
|
||||
{
|
||||
@ -2161,7 +2164,8 @@ clutter_cmp_switch_workspace (MetaCompositor *compositor,
|
||||
info->plugin_mgr,
|
||||
(const GList **)&info->windows,
|
||||
from_indx,
|
||||
to_indx))
|
||||
to_indx,
|
||||
direction))
|
||||
{
|
||||
info->switch_workspace_in_progress--;
|
||||
}
|
||||
|
@ -73,10 +73,11 @@ struct _MetaCompositor
|
||||
void (*update_workspace_geometry) (MetaCompositor *compositor,
|
||||
MetaWorkspace *workspace);
|
||||
|
||||
void (*switch_workspace) (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
MetaWorkspace *from,
|
||||
MetaWorkspace *to);
|
||||
void (*switch_workspace) (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
MetaWorkspace *from,
|
||||
MetaWorkspace *to,
|
||||
MetaMotionDirection direction);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -230,14 +230,15 @@ meta_compositor_update_workspace_geometry (MetaCompositor *compositor,
|
||||
}
|
||||
|
||||
void
|
||||
meta_compositor_switch_workspace (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
MetaWorkspace *from,
|
||||
MetaWorkspace *to)
|
||||
meta_compositor_switch_workspace (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
MetaWorkspace *from,
|
||||
MetaWorkspace *to,
|
||||
MetaMotionDirection direction)
|
||||
{
|
||||
#ifdef HAVE_COMPOSITE_EXTENSIONS
|
||||
if (compositor && compositor->switch_workspace)
|
||||
compositor->switch_workspace (compositor, screen, from, to);
|
||||
compositor->switch_workspace (compositor, screen, from, to, direction);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -36,17 +36,6 @@
|
||||
#include "workspace.h"
|
||||
#include "window-private.h"
|
||||
|
||||
/* Negative to avoid conflicting with real workspace
|
||||
* numbers
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
META_MOTION_UP = -1,
|
||||
META_MOTION_DOWN = -2,
|
||||
META_MOTION_LEFT = -3,
|
||||
META_MOTION_RIGHT = -4
|
||||
} MetaMotionDirection;
|
||||
|
||||
struct _MetaWorkspace
|
||||
{
|
||||
MetaScreen *screen;
|
||||
|
@ -398,8 +398,49 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace,
|
||||
MetaScreen *screen = workspace->screen;
|
||||
MetaDisplay *display = meta_screen_get_display (screen);
|
||||
MetaCompositor *comp = meta_display_get_compositor (display);
|
||||
MetaWorkspaceLayout layout1, layout2;
|
||||
gint num_workspaces, current_space, new_space;
|
||||
MetaMotionDirection direction = 0;
|
||||
|
||||
meta_compositor_switch_workspace (comp, screen, old, workspace);
|
||||
current_space = meta_workspace_index (old);
|
||||
new_space = meta_workspace_index (workspace);
|
||||
|
||||
num_workspaces = meta_screen_get_n_workspaces (workspace->screen);
|
||||
meta_screen_calc_workspace_layout (workspace->screen, num_workspaces,
|
||||
current_space, &layout1);
|
||||
|
||||
meta_screen_calc_workspace_layout (workspace->screen, num_workspaces,
|
||||
new_space, &layout2);
|
||||
|
||||
if (layout1.current_col < layout2.current_col)
|
||||
direction = META_MOTION_RIGHT;
|
||||
if (layout1.current_col > layout2.current_col)
|
||||
direction = META_MOTION_LEFT;
|
||||
|
||||
if (layout1.current_row < layout2.current_row)
|
||||
{
|
||||
if (!direction)
|
||||
direction = META_MOTION_DOWN;
|
||||
else if (direction == META_MOTION_RIGHT)
|
||||
direction = META_MOTION_DOWN_RIGHT;
|
||||
else
|
||||
direction = META_MOTION_DOWN_LEFT;
|
||||
}
|
||||
|
||||
if (layout1.current_row > layout2.current_row)
|
||||
{
|
||||
if (!direction)
|
||||
direction = META_MOTION_UP;
|
||||
else if (direction == META_MOTION_RIGHT)
|
||||
direction = META_MOTION_UP_RIGHT;
|
||||
else
|
||||
direction = META_MOTION_UP_LEFT;
|
||||
}
|
||||
|
||||
meta_screen_free_workspace_layout (&layout1);
|
||||
meta_screen_free_workspace_layout (&layout2);
|
||||
|
||||
meta_compositor_switch_workspace (comp, screen, old, workspace, direction);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -769,6 +810,14 @@ meta_motion_direction_to_string (MetaMotionDirection direction)
|
||||
return "Left";
|
||||
case META_MOTION_RIGHT:
|
||||
return "Right";
|
||||
case META_MOTION_UP_RIGHT:
|
||||
return "Up-Right";
|
||||
case META_MOTION_DOWN_RIGHT:
|
||||
return "Down-Right";
|
||||
case META_MOTION_UP_LEFT:
|
||||
return "Up-Left";
|
||||
case META_MOTION_DOWN_LEFT:
|
||||
return "Down-Left";
|
||||
}
|
||||
|
||||
return "Unknown";
|
||||
@ -807,6 +856,7 @@ meta_workspace_get_neighbor (MetaWorkspace *workspace,
|
||||
case META_MOTION_DOWN:
|
||||
layout.current_row += 1;
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
|
||||
if (layout.current_col < 0)
|
||||
|
@ -156,7 +156,8 @@ struct MetaCompositorClutterPlugin
|
||||
*/
|
||||
void (*switch_workspace) (const GList **actors,
|
||||
gint from,
|
||||
gint to);
|
||||
gint to,
|
||||
MetaMotionDirection direction);
|
||||
|
||||
/*
|
||||
* Called if an effect should be killed prematurely; the plugin must
|
||||
|
@ -122,10 +122,11 @@ meta_compositor_update_workspace_geometry (MetaCompositor *compositor,
|
||||
MetaWorkspace *workspace);
|
||||
|
||||
void
|
||||
meta_compositor_switch_workspace (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
MetaWorkspace *from,
|
||||
MetaWorkspace *to);
|
||||
meta_compositor_switch_workspace (MetaCompositor *compositor,
|
||||
MetaScreen *screen,
|
||||
MetaWorkspace *from,
|
||||
MetaWorkspace *to,
|
||||
MetaMotionDirection direction);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -37,6 +37,22 @@
|
||||
#include "boxes.h"
|
||||
#include "screen.h"
|
||||
|
||||
/* Negative to avoid conflicting with real workspace
|
||||
* numbers
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
META_MOTION_UP = -1,
|
||||
META_MOTION_DOWN = -2,
|
||||
META_MOTION_LEFT = -3,
|
||||
META_MOTION_RIGHT = -4,
|
||||
/* These are only used for effects */
|
||||
META_MOTION_UP_LEFT = -5,
|
||||
META_MOTION_UP_RIGHT = -6,
|
||||
META_MOTION_DOWN_LEFT = -7,
|
||||
META_MOTION_DOWN_RIGHT = -8
|
||||
} MetaMotionDirection;
|
||||
|
||||
int meta_workspace_index (MetaWorkspace *workspace);
|
||||
MetaScreen *meta_workspace_get_screen (MetaWorkspace *workspace);
|
||||
void meta_workspace_get_work_area_all_xineramas (MetaWorkspace *workspace,
|
||||
|
Loading…
Reference in New Issue
Block a user