apply patch from Nikos Mouat to fix this function
2002-11-05 Havoc Pennington <hp@redhat.com> * src/workspace.c (meta_workspace_get_neighbor): apply patch from Nikos Mouat to fix this function
This commit is contained in:
parent
cfd2d87fea
commit
a64b868dbd
@ -1,3 +1,8 @@
|
|||||||
|
2002-11-05 Havoc Pennington <hp@redhat.com>
|
||||||
|
|
||||||
|
* src/workspace.c (meta_workspace_get_neighbor): apply patch from
|
||||||
|
Nikos Mouat to fix this function
|
||||||
|
|
||||||
2002-11-04 Havoc Pennington <hp@pobox.com>
|
2002-11-04 Havoc Pennington <hp@pobox.com>
|
||||||
|
|
||||||
* src/theme.c (scale_and_alpha_pixbuf): fix bug I introduced in
|
* src/theme.c (scale_and_alpha_pixbuf): fix bug I introduced in
|
||||||
|
167
src/workspace.c
167
src/workspace.c
@ -412,6 +412,9 @@ meta_workspace_get_neighbor (MetaWorkspace *workspace,
|
|||||||
{
|
{
|
||||||
int i, num_workspaces, grid_area;
|
int i, num_workspaces, grid_area;
|
||||||
int rows, cols;
|
int rows, cols;
|
||||||
|
int new_workspace_idx;
|
||||||
|
int up_diff, down_diff, left_diff, right_diff;
|
||||||
|
int current_row, current_col;
|
||||||
|
|
||||||
i = meta_workspace_index (workspace);
|
i = meta_workspace_index (workspace);
|
||||||
num_workspaces = meta_screen_get_n_workspaces (workspace->screen);
|
num_workspaces = meta_screen_get_n_workspaces (workspace->screen);
|
||||||
@ -426,89 +429,115 @@ meta_workspace_get_neighbor (MetaWorkspace *workspace,
|
|||||||
rows, cols, workspace->screen->vertical_workspaces,
|
rows, cols, workspace->screen->vertical_workspaces,
|
||||||
i, num_workspaces, direction);
|
i, num_workspaces, direction);
|
||||||
|
|
||||||
|
/* ok, we want to setup the distances in the workspace array to go
|
||||||
/* FIXME someone who's better or more patient at math puzzles
|
* in each direction. Remember, there are many ways that a workspace
|
||||||
* should clean this up. ;-)
|
* array can be setup.
|
||||||
* This'll have to someone with mega patience 'cause you'll
|
* see http://www.freedesktop.org/standards/wm-spec/1.2/html/x109.html
|
||||||
* have to handle screen->starting_corner also.
|
* and look at the _NET_DESKTOP_LAYOUT section for details.
|
||||||
|
* For instance:
|
||||||
*/
|
*/
|
||||||
|
/* starting_corner = META_SCREEN_TOPLEFT
|
||||||
|
* vertical_workspaces = 0 vertical_workspaces=1
|
||||||
|
* 1234 1357
|
||||||
|
* 5678 2468
|
||||||
|
*
|
||||||
|
* starting_corner = META_SCREEN_TOPRIGHT
|
||||||
|
* vertical_workspaces = 0 vertical_workspaces=1
|
||||||
|
* 4321 7531
|
||||||
|
* 8765 8642
|
||||||
|
*
|
||||||
|
* starting_corner = META_SCREEN_BOTTOMLEFT
|
||||||
|
* vertical_workspaces = 0 vertical_workspaces=1
|
||||||
|
* 5678 2468
|
||||||
|
* 1234 1357
|
||||||
|
*
|
||||||
|
* starting_corner = META_SCREEN_BOTTOMRIGHT
|
||||||
|
* vertical_workspaces = 0 vertical_workspaces=1
|
||||||
|
* 8765 8642
|
||||||
|
* 4321 7531
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
if (workspace->screen->vertical_workspaces)
|
if (workspace->screen->vertical_workspaces)
|
||||||
{
|
{
|
||||||
|
up_diff = -1;
|
||||||
|
down_diff = 1;
|
||||||
|
left_diff = -1 * cols;
|
||||||
|
right_diff = cols;
|
||||||
|
current_col = (i / (cols?cols:1)) + 1;
|
||||||
|
current_row = (i % cols) + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
up_diff = -1 * rows;
|
||||||
|
down_diff = rows;
|
||||||
|
left_diff = -1;
|
||||||
|
right_diff = 1;
|
||||||
|
current_col = (i % rows) + 1;
|
||||||
|
current_row = (i / (rows?rows:1)) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (workspace->screen->starting_corner)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case META_SCREEN_TOPLEFT:
|
||||||
|
/* this was the default case setup in the if() above */
|
||||||
|
break;
|
||||||
|
case META_SCREEN_TOPRIGHT:
|
||||||
|
/* ok, we need to inverse the left/right values */
|
||||||
|
left_diff = -1 * left_diff;
|
||||||
|
right_diff = -1 * right_diff;
|
||||||
|
/* also, current column needs to be mirrored */
|
||||||
|
current_col = rows - ((current_col-1)%rows) ;
|
||||||
|
break;
|
||||||
|
case META_SCREEN_BOTTOMLEFT:
|
||||||
|
/* ok, we need to inverse the up/down values */
|
||||||
|
up_diff = -1 * up_diff;
|
||||||
|
down_diff = -1 * up_diff;
|
||||||
|
/* also, current row needs to be mirrored */
|
||||||
|
current_row = cols - ((current_row-1)%cols);
|
||||||
|
break;
|
||||||
|
case META_SCREEN_BOTTOMRIGHT:
|
||||||
|
/* in this case, we need to inverse everything */
|
||||||
|
up_diff = -1 * up_diff;
|
||||||
|
down_diff = -1 * up_diff;
|
||||||
|
left_diff = -1 * left_diff;
|
||||||
|
right_diff = -1 * right_diff;
|
||||||
|
/* also, current column and row need to be reversed */
|
||||||
|
current_col = rows - ((current_col-1)%rows);
|
||||||
|
current_row = cols - ((current_row-1)%cols);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* calculate what we think the next spot should be */
|
||||||
|
new_workspace_idx = i;
|
||||||
|
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
case META_MOTION_LEFT:
|
case META_MOTION_LEFT:
|
||||||
if (i < rows)
|
if ((current_col - 1) > 0)
|
||||||
{
|
new_workspace_idx = i + left_diff;
|
||||||
i = grid_area - (i % rows) - 1;
|
|
||||||
while (i >= num_workspaces)
|
|
||||||
i -= rows;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
i -= rows;
|
|
||||||
break;
|
break;
|
||||||
case META_MOTION_RIGHT:
|
case META_MOTION_RIGHT:
|
||||||
if ((i + rows) >= num_workspaces)
|
if ((current_col + 1) <= rows)
|
||||||
i = (i % rows + 1) % rows;
|
new_workspace_idx = i + right_diff;
|
||||||
else
|
|
||||||
i += rows;
|
|
||||||
break;
|
break;
|
||||||
case META_MOTION_UP:
|
case META_MOTION_UP:
|
||||||
--i;
|
if ((current_row - 1) > 0)
|
||||||
if (i == -1)
|
new_workspace_idx = i + up_diff;
|
||||||
i = num_workspaces - 1;
|
|
||||||
break;
|
break;
|
||||||
case META_MOTION_DOWN:
|
case META_MOTION_DOWN:
|
||||||
++i;
|
if ((current_row + 1) <= cols)
|
||||||
if (i == num_workspaces)
|
new_workspace_idx = i + down_diff;
|
||||||
i = 0;
|
break;
|
||||||
|
default:
|
||||||
|
new_workspace_idx = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
/* and now make sure we don't over/under flow */
|
||||||
{
|
if ((new_workspace_idx >= 0) && (new_workspace_idx < num_workspaces))
|
||||||
switch (direction)
|
i = new_workspace_idx;
|
||||||
{
|
|
||||||
case META_MOTION_LEFT:
|
|
||||||
--i;
|
|
||||||
if (i == -1)
|
|
||||||
i = num_workspaces - 1;
|
|
||||||
break;
|
|
||||||
case META_MOTION_RIGHT:
|
|
||||||
++i;
|
|
||||||
if (i == num_workspaces)
|
|
||||||
i = 0;
|
|
||||||
break;
|
|
||||||
case META_MOTION_UP:
|
|
||||||
if (i < cols)
|
|
||||||
{
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
/* special case: go to bottom right corner == grid_area - 1 */
|
|
||||||
i = grid_area - 1;
|
|
||||||
while (i >= num_workspaces)
|
|
||||||
/* if we are in a non-existant workspace look up in the column for next workspace */
|
|
||||||
i -= cols;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* calculate new workspace based on the bottom left corner == ((rows - 1) * cols) */
|
|
||||||
i = ((rows - 1) * cols) + (i - 1);
|
|
||||||
while (i >= num_workspaces)
|
|
||||||
/* if we are in a non-existant workspace look up in the column for next workspace */
|
|
||||||
i -= cols;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
i -= cols;
|
|
||||||
break;
|
|
||||||
case META_MOTION_DOWN:
|
|
||||||
if ((i + cols) >= num_workspaces)
|
|
||||||
i = (i % cols + 1) % cols;
|
|
||||||
else
|
|
||||||
i += cols;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
meta_verbose ("Neighbor space is %d\n", i);
|
meta_verbose ("Neighbor space is %d\n", i);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user