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:
Tomas Frydrych 2008-10-09 17:57:12 +01:00
parent 0225449e12
commit 6b1719de1c
12 changed files with 104 additions and 35 deletions

View File

@ -52,7 +52,8 @@ static void maximize (MetaCompWindow *actor,
static void unmaximize (MetaCompWindow *actor, static void unmaximize (MetaCompWindow *actor,
gint x, gint y, gint width, gint height); 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); static void kill_effect (MetaCompWindow *actor, gulong event);
@ -197,7 +198,8 @@ on_switch_workspace_effect_complete (ClutterActor *group, gpointer data)
} }
static void 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 (); MetaCompositorClutterPlugin *plugin = get_plugin ();
PluginPrivate *ppriv = plugin->plugin_private; PluginPrivate *ppriv = plugin->plugin_private;

View File

@ -52,7 +52,8 @@ static void maximize (MetaCompWindow *actor,
static void unmaximize (MetaCompWindow *actor, static void unmaximize (MetaCompWindow *actor,
gint x, gint y, gint width, gint height); 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); static void kill_effect (MetaCompWindow *actor, gulong event);
@ -197,7 +198,8 @@ on_switch_workspace_effect_complete (ClutterActor *group, gpointer data)
} }
static void 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 (); MetaCompositorClutterPlugin *plugin = get_plugin ();
PluginPrivate *ppriv = plugin->plugin_private; PluginPrivate *ppriv = plugin->plugin_private;

View File

@ -627,7 +627,8 @@ gboolean
meta_compositor_clutter_plugin_manager_switch_workspace (MetaCompositorClutterPluginManager *mgr, meta_compositor_clutter_plugin_manager_switch_workspace (MetaCompositorClutterPluginManager *mgr,
const GList **actors, const GList **actors,
gint from, gint from,
gint to) gint to,
MetaMotionDirection direction)
{ {
GList *l = mgr->plugins; GList *l = mgr->plugins;
gboolean retval = FALSE; gboolean retval = FALSE;
@ -647,7 +648,7 @@ meta_compositor_clutter_plugin_manager_switch_workspace (MetaCompositorClutterPl
meta_compositor_clutter_plugin_manager_kill_effect (mgr, meta_compositor_clutter_plugin_manager_kill_effect (mgr,
META_COMP_WINDOW ((*actors)->data), META_COMP_WINDOW ((*actors)->data),
META_COMPOSITOR_CLUTTER_PLUGIN_SWITCH_WORKSPACE); META_COMPOSITOR_CLUTTER_PLUGIN_SWITCH_WORKSPACE);
plg->switch_workspace (actors, from, to); plg->switch_workspace (actors, from, to, direction);
} }
} }

View File

@ -49,7 +49,8 @@ void meta_compositor_clutter_plugin_manager_update_workspace (MetaCompositorClut
gboolean meta_compositor_clutter_plugin_manager_switch_workspace (MetaCompositorClutterPluginManager *mgr, gboolean meta_compositor_clutter_plugin_manager_switch_workspace (MetaCompositorClutterPluginManager *mgr,
const GList **actors, const GList **actors,
gint from, gint from,
gint to); gint to,
MetaMotionDirection direction);
gboolean meta_compositor_clutter_plugin_manager_xevent_filter (MetaCompositorClutterPluginManager *mgr, gboolean meta_compositor_clutter_plugin_manager_xevent_filter (MetaCompositorClutterPluginManager *mgr,
XEvent *xev); XEvent *xev);

View File

@ -2108,7 +2108,8 @@ static void
clutter_cmp_switch_workspace (MetaCompositor *compositor, clutter_cmp_switch_workspace (MetaCompositor *compositor,
MetaScreen *screen, MetaScreen *screen,
MetaWorkspace *from, MetaWorkspace *from,
MetaWorkspace *to) MetaWorkspace *to,
MetaMotionDirection direction)
{ {
#ifdef HAVE_COMPOSITE_EXTENSIONS #ifdef HAVE_COMPOSITE_EXTENSIONS
MetaCompScreen *info; MetaCompScreen *info;
@ -2119,6 +2120,8 @@ clutter_cmp_switch_workspace (MetaCompositor *compositor,
to_indx = meta_workspace_index (to); to_indx = meta_workspace_index (to);
from_indx = meta_workspace_index (from); from_indx = meta_workspace_index (from);
printf ("Direction of switch %d\n", direction);
l = info->windows; l = info->windows;
while (l) while (l)
{ {
@ -2161,7 +2164,8 @@ clutter_cmp_switch_workspace (MetaCompositor *compositor,
info->plugin_mgr, info->plugin_mgr,
(const GList **)&info->windows, (const GList **)&info->windows,
from_indx, from_indx,
to_indx)) to_indx,
direction))
{ {
info->switch_workspace_in_progress--; info->switch_workspace_in_progress--;
} }

View File

@ -73,10 +73,11 @@ struct _MetaCompositor
void (*update_workspace_geometry) (MetaCompositor *compositor, void (*update_workspace_geometry) (MetaCompositor *compositor,
MetaWorkspace *workspace); MetaWorkspace *workspace);
void (*switch_workspace) (MetaCompositor *compositor, void (*switch_workspace) (MetaCompositor *compositor,
MetaScreen *screen, MetaScreen *screen,
MetaWorkspace *from, MetaWorkspace *from,
MetaWorkspace *to); MetaWorkspace *to,
MetaMotionDirection direction);
}; };
#endif #endif

View File

@ -230,14 +230,15 @@ meta_compositor_update_workspace_geometry (MetaCompositor *compositor,
} }
void void
meta_compositor_switch_workspace (MetaCompositor *compositor, meta_compositor_switch_workspace (MetaCompositor *compositor,
MetaScreen *screen, MetaScreen *screen,
MetaWorkspace *from, MetaWorkspace *from,
MetaWorkspace *to) MetaWorkspace *to,
MetaMotionDirection direction)
{ {
#ifdef HAVE_COMPOSITE_EXTENSIONS #ifdef HAVE_COMPOSITE_EXTENSIONS
if (compositor && compositor->switch_workspace) if (compositor && compositor->switch_workspace)
compositor->switch_workspace (compositor, screen, from, to); compositor->switch_workspace (compositor, screen, from, to, direction);
#endif #endif
} }

View File

@ -36,17 +36,6 @@
#include "workspace.h" #include "workspace.h"
#include "window-private.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 struct _MetaWorkspace
{ {
MetaScreen *screen; MetaScreen *screen;

View File

@ -398,8 +398,49 @@ meta_workspace_activate_with_focus (MetaWorkspace *workspace,
MetaScreen *screen = workspace->screen; MetaScreen *screen = workspace->screen;
MetaDisplay *display = meta_screen_get_display (screen); MetaDisplay *display = meta_screen_get_display (screen);
MetaCompositor *comp = meta_display_get_compositor (display); 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 #endif
} }
@ -769,6 +810,14 @@ meta_motion_direction_to_string (MetaMotionDirection direction)
return "Left"; return "Left";
case META_MOTION_RIGHT: case META_MOTION_RIGHT:
return "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"; return "Unknown";
@ -807,6 +856,7 @@ meta_workspace_get_neighbor (MetaWorkspace *workspace,
case META_MOTION_DOWN: case META_MOTION_DOWN:
layout.current_row += 1; layout.current_row += 1;
break; break;
default:;
} }
if (layout.current_col < 0) if (layout.current_col < 0)

View File

@ -156,7 +156,8 @@ struct MetaCompositorClutterPlugin
*/ */
void (*switch_workspace) (const GList **actors, void (*switch_workspace) (const GList **actors,
gint from, gint from,
gint to); gint to,
MetaMotionDirection direction);
/* /*
* Called if an effect should be killed prematurely; the plugin must * Called if an effect should be killed prematurely; the plugin must

View File

@ -122,10 +122,11 @@ meta_compositor_update_workspace_geometry (MetaCompositor *compositor,
MetaWorkspace *workspace); MetaWorkspace *workspace);
void void
meta_compositor_switch_workspace (MetaCompositor *compositor, meta_compositor_switch_workspace (MetaCompositor *compositor,
MetaScreen *screen, MetaScreen *screen,
MetaWorkspace *from, MetaWorkspace *from,
MetaWorkspace *to); MetaWorkspace *to,
MetaMotionDirection direction);
#endif #endif

View File

@ -37,6 +37,22 @@
#include "boxes.h" #include "boxes.h"
#include "screen.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); int meta_workspace_index (MetaWorkspace *workspace);
MetaScreen *meta_workspace_get_screen (MetaWorkspace *workspace); MetaScreen *meta_workspace_get_screen (MetaWorkspace *workspace);
void meta_workspace_get_work_area_all_xineramas (MetaWorkspace *workspace, void meta_workspace_get_work_area_all_xineramas (MetaWorkspace *workspace,