Remove the preceeding functions as they are all obsoleted by the new

2006-05-15  Björn Lindqvist  <bjourne@gmail.com>

	* places.[ch] (intcmp, window_get_edges,
	get_windows_showing_on_same_screen, get_vertical_edges,
	get_horizontal_edges, meta_window_find_next_vertical_edge,
	meta_window_find_next_horizontal_edge,
	meta_window_find_nearest_vertical_edge,
	meta_window_find_nearest_horizontal_edge): Remove the preceeding
	functions as they are all obsoleted by the new edge-resistance
	stuff. Fixes #341561.
This commit is contained in:
Björn Lindqvist 2006-05-15 17:00:14 +00:00 committed by Björn Lindqvist
parent fb3b5c92f8
commit 51ade19ae9
3 changed files with 11 additions and 593 deletions

View File

@ -1,3 +1,14 @@
2006-05-15 Björn Lindqvist <bjourne@gmail.com>
* places.[ch] (intcmp, window_get_edges,
get_windows_showing_on_same_screen, get_vertical_edges,
get_horizontal_edges, meta_window_find_next_vertical_edge,
meta_window_find_next_horizontal_edge,
meta_window_find_nearest_vertical_edge,
meta_window_find_nearest_horizontal_edge): Remove the preceeding
functions as they are all obsoleted by the new edge-resistance
stuff. Fixes #341561.
2006-05-15 Paolo Borelli <pborelli@katamail.com> 2006-05-15 Paolo Borelli <pborelli@katamail.com>
* src/prefs.c (update_binding): plug a small leak. * src/prefs.c (update_binding): plug a small leak.

View File

@ -372,50 +372,6 @@ avoid_being_obscured_as_second_modal_dialog (MetaWindow *window,
} }
} }
static int
intcmp (const void* a, const void* b)
{
const int *ai = a;
const int *bi = b;
if (*ai < *bi)
return -1;
else if (*ai > *bi)
return 1;
else
return 0;
}
static void
window_get_edges (MetaWindow *w,
int *left,
int *right,
int *top,
int *bottom)
{
int left_edge;
int right_edge;
int top_edge;
int bottom_edge;
MetaRectangle rect;
meta_window_get_outer_rect (w, &rect);
left_edge = rect.x;
right_edge = rect.x + rect.width;
top_edge = rect.y;
bottom_edge = rect.y + rect.height;
if (left)
*left = left_edge;
if (right)
*right = right_edge;
if (top)
*top = top_edge;
if (bottom)
*bottom = bottom_edge;
}
static gboolean static gboolean
rectangle_overlaps_some_window (MetaRectangle *rect, rectangle_overlaps_some_window (MetaRectangle *rect,
GList *windows) GList *windows)
@ -826,27 +782,6 @@ meta_window_place (MetaWindow *window,
if (fgeom) if (fgeom)
y += fgeom->top_height; y += fgeom->top_height;
#if 0
/* FIXME: If no one has complained about this within a couple
* months, it means that the constraints.c rewrite fixed this
* correctly and this hack is no longer necessary. Feel free to
* submit a patch removing this #ifdef'd out code. (Comment
* written on 2005-10-28).
*/
MetaRectangle area;
/* clip to xinerama of parent*/
meta_window_get_work_area_current_xinerama (parent, &area);
if (x + window->rect.width > area.x + area.width)
x = area.x + area.width - window->rect.width;
if (y + window->rect.height > area.y + area.height)
y = area.y + area.height - window->rect.height;
if (x < area.x) x = area.x;
if (y < area.y) y = area.y;
#endif
meta_topic (META_DEBUG_PLACEMENT, "Centered window %s over transient parent\n", meta_topic (META_DEBUG_PLACEMENT, "Centered window %s over transient parent\n",
window->desc); window->desc);
@ -1048,512 +983,3 @@ meta_window_place (MetaWindow *window,
*new_x = x; *new_x = x;
*new_y = y; *new_y = y;
} }
/* These are used while moving or resizing to "snap" to useful
* places; the return value is the x/y position of the window to
* be snapped to the given edge.
*
* They only use edges on the current workspace, since things
* would be weird otherwise.
*/
static GSList*
get_windows_showing_on_same_screen (MetaWindow *window,
int *n_windows)
{
GSList *windows;
GSList *all_windows;
GSList *tmp;
int i;
windows = NULL;
i = 0;
all_windows = meta_display_list_windows (window->display);
tmp = all_windows;
while (tmp != NULL)
{
MetaWindow *w = tmp->data;
if (meta_window_should_be_showing (w) &&
w->screen == window->screen &&
w != window)
{
windows = g_slist_prepend (windows, w);
++i;
}
tmp = tmp->next;
}
if (n_windows)
*n_windows = i;
g_slist_free (all_windows);
return windows;
}
static void
get_vertical_edges (MetaWindow *window,
int **edges_p,
int *n_edges_p)
{
GSList *windows;
GSList *tmp;
int n_windows;
GArray *edges;
int edge, i;
MetaRectangle rect;
MetaRectangle work_area;
windows = get_windows_showing_on_same_screen (window, &n_windows);
edges = g_array_sized_new (FALSE, FALSE, sizeof (int),
n_windows * 2 + 4 /* 4 = workspace/screen edges */
+ window->screen->n_xinerama_infos - 1
+ 2 /* active window edges when in wireframe mode */);
/* workspace/screen edges */
meta_window_get_work_area_current_xinerama (window, &work_area);
g_array_append_val (edges, work_area.x);
edge = work_area.x + work_area.width;
g_array_append_val (edges, edge);
edge = 0;
g_array_append_val (edges, edge);
g_array_append_val (edges, window->screen->rect.width);
/* Now get the xinerama screen edges */
for (i = 0; i < window->screen->n_xinerama_infos - 1; i++)
{
edge = window->screen->xinerama_infos[i].rect.x +
window->screen->xinerama_infos[i].rect.width;
g_array_append_val (edges, edge);
}
if (window->display->grab_wireframe_active)
{
int left_edge, right_edge, top_edge, bottom_edge;
meta_window_get_xor_rect (window, &window->display->grab_wireframe_rect,
&rect);
window_get_edges (window, &left_edge, &right_edge,
&top_edge, &bottom_edge);
g_array_append_val (edges, left_edge);
g_array_append_val (edges, right_edge);
}
else
meta_window_get_outer_rect (window, &rect);
/* get window edges */
tmp = windows;
while (tmp != NULL)
{
MetaWindow *w = tmp->data;
MetaRectangle w_rect;
meta_window_get_outer_rect (w, &w_rect);
if (meta_rectangle_vert_overlap (&rect, &w_rect))
{
g_array_append_val (edges, w_rect.x);
edge = w_rect.x + w_rect.width;
g_array_append_val (edges, edge);
}
tmp = tmp->next;
}
g_slist_free (windows);
/* Sort */
qsort (edges->data, edges->len, sizeof (int), intcmp);
*n_edges_p = edges->len;
*edges_p = (int *) g_array_free (edges, FALSE);
}
static void
get_horizontal_edges (MetaWindow *window,
int **edges_p,
int *n_edges_p)
{
GSList *windows;
GSList *tmp;
int n_windows;
GArray *edges;
int edge, i;
MetaRectangle rect;
MetaRectangle work_area;
windows = get_windows_showing_on_same_screen (window, &n_windows);
edges = g_array_sized_new (FALSE, FALSE, sizeof (int),
n_windows * 2 + 4 /* 4 = workspace/screen edges */
+ window->screen->n_xinerama_infos - 1
+ 2 /* active window edges when in wireframe mode */);
/* workspace/screen edges */
meta_window_get_work_area_current_xinerama (window, &work_area);
g_array_append_val (edges, work_area.y);
edge = work_area.y + work_area.height;
g_array_append_val (edges, edge);
edge = 0;
g_array_append_val (edges, edge);
g_array_append_val (edges, window->screen->rect.height);
/* Now get the xinerama screen edges */
for (i = 0; i < window->screen->n_xinerama_infos - 1; i++)
{
edge = window->screen->xinerama_infos[i].rect.y +
window->screen->xinerama_infos[i].rect.height;
g_array_append_val (edges, edge);
}
if (window->display->grab_wireframe_active)
{
int left_edge, right_edge, top_edge, bottom_edge;
meta_window_get_xor_rect (window, &window->display->grab_wireframe_rect,
&rect);
window_get_edges (window, &left_edge, &right_edge,
&top_edge, &bottom_edge);
g_array_append_val (edges, top_edge);
g_array_append_val (edges, bottom_edge);
}
else
meta_window_get_outer_rect (window, &rect);
/* get window edges */
tmp = windows;
while (tmp != NULL)
{
MetaWindow *w = tmp->data;
MetaRectangle w_rect;
meta_window_get_outer_rect (w, &w_rect);
if (meta_rectangle_horiz_overlap (&rect, &w_rect))
{
g_array_append_val (edges, w_rect.y);
edge = w_rect.y + w_rect.height;
g_array_append_val (edges, edge);
}
tmp = tmp->next;
}
g_slist_free (windows);
/* Sort */
qsort (edges->data, edges->len, sizeof (int), intcmp);
*n_edges_p = edges->len;
*edges_p = (int *) g_array_free (edges, FALSE);
}
int
meta_window_find_next_vertical_edge (MetaWindow *window,
MetaWindowEdgePosition source_edge_position,
gboolean right)
{
int left_edge, right_edge, source_edge;
int *edges;
int i;
int n_edges;
int retval;
get_vertical_edges (window, &edges, &n_edges);
/* Find next */
if (window->display->grab_wireframe_active)
{
MetaRectangle rect;
meta_window_get_xor_rect (window, &window->display->grab_wireframe_rect,
&rect);
left_edge = rect.x;
right_edge = left_edge + rect.width;
}
else
window_get_edges (window, &left_edge, &right_edge, NULL, NULL);
switch (source_edge_position)
{
case META_WINDOW_EDGE_LEFT:
source_edge = left_edge;
break;
case META_WINDOW_EDGE_RIGHT:
source_edge = right_edge;
break;
case META_WINDOW_EDGE_TOP:
case META_WINDOW_EDGE_BOTTOM:
default:
g_assert_not_reached ();
}
retval = source_edge;
if (right)
{
i = 0;
while (i < n_edges)
{
if (edges[i] > source_edge)
{
retval = edges[i];
break;
}
++i;
}
}
else
{
i = n_edges;
do
{
--i;
if (edges[i] < source_edge)
{
retval = edges[i];
break;
}
}
while (i > 0);
}
g_free (edges);
return retval;
}
int
meta_window_find_next_horizontal_edge (MetaWindow *window,
MetaWindowEdgePosition source_edge_position,
gboolean down)
{
int top_edge, bottom_edge, source_edge;
int *edges;
int i;
int n_edges;
int retval;
get_horizontal_edges (window, &edges, &n_edges);
/* Find next */
if (window->display->grab_wireframe_active)
{
MetaRectangle rect;
meta_window_get_xor_rect (window, &window->display->grab_wireframe_rect,
&rect);
top_edge = rect.y;
bottom_edge = top_edge + rect.height;
}
else
window_get_edges (window, NULL, NULL, &top_edge, &bottom_edge);
switch (source_edge_position)
{
case META_WINDOW_EDGE_TOP:
source_edge = top_edge;
break;
case META_WINDOW_EDGE_BOTTOM:
source_edge = bottom_edge;
break;
case META_WINDOW_EDGE_LEFT:
case META_WINDOW_EDGE_RIGHT:
default:
g_assert_not_reached ();
}
retval = source_edge;
if (down)
{
i = 0;
while (i < n_edges)
{
if (edges[i] > source_edge)
{
retval = edges[i];
break;
}
++i;
}
}
else
{
i = n_edges;
do
{
--i;
if (edges[i] < source_edge)
{
retval = edges[i];
break;
}
}
while (i > 0);
}
g_free (edges);
return retval;
}
int
meta_window_find_nearest_vertical_edge (MetaWindow *window,
int x_pos)
{
int *edges;
int i;
int n_edges;
int *positions;
int n_positions;
int retval;
get_vertical_edges (window, &edges, &n_edges);
/* Create an array of all snapped positions our window could have */
n_positions = n_edges * 2;
positions = g_new (int, n_positions);
i = 0;
while (i < n_edges)
{
int left_pos, right_pos;
left_pos = edges[i];
if (window->frame)
{
left_pos += window->frame->child_x;
right_pos = edges[i] - window->frame->rect.width;
right_pos += window->frame->child_x;
}
else
{
right_pos = edges[i] - window->rect.width;
}
positions[i * 2] = left_pos;
positions[i * 2 + 1] = right_pos;
++i;
}
g_free (edges);
/* Sort */
qsort (positions, n_positions, sizeof (int), intcmp);
/* Find nearest */
retval = positions[0];
i = 1;
while (i < n_positions)
{
int delta;
int best_delta;
delta = ABS (x_pos - positions[i]);
best_delta = ABS (x_pos - retval);
if (delta < best_delta)
retval = positions[i];
++i;
}
g_free (positions);
return retval;
}
int
meta_window_find_nearest_horizontal_edge (MetaWindow *window,
int y_pos)
{
int *edges;
int i;
int n_edges;
int *positions;
int n_positions;
int retval;
get_horizontal_edges (window, &edges, &n_edges);
/* Create an array of all snapped positions our window could have */
n_positions = n_edges * 2;
positions = g_new (int, n_positions);
i = 0;
while (i < n_edges)
{
int top_pos, bottom_pos;
top_pos = edges[i];
if (window->frame)
{
top_pos += window->frame->child_y;
bottom_pos = edges[i] - window->frame->rect.height;
bottom_pos += window->frame->child_y;
}
else
{
bottom_pos = edges[i] - window->rect.height;
}
positions[i * 2] = top_pos;
positions[i * 2 + 1] = bottom_pos;
++i;
}
g_free (edges);
/* Sort */
qsort (positions, n_positions, sizeof (int), intcmp);
/* Find nearest */
retval = positions[0];
i = 1;
while (i < n_positions)
{
int delta;
int best_delta;
delta = ABS (y_pos - positions[i]);
best_delta = ABS (y_pos - retval);
if (delta < best_delta)
retval = positions[i];
++i;
}
g_free (positions);
return retval;
}

View File

@ -42,23 +42,4 @@ void meta_window_place (MetaWindow *window,
int *new_x, int *new_x,
int *new_y); int *new_y);
/* Returns the position to move the specified window edge to in order
* to snap it to the next edge in the given direction,
* while moving.
*/
int meta_window_find_next_vertical_edge (MetaWindow *window,
MetaWindowEdgePosition source_edge_position,
gboolean down);
int meta_window_find_next_horizontal_edge (MetaWindow *window,
MetaWindowEdgePosition source_edge_position,
gboolean right);
/* Returns the position to move the window to in order
* to snap it to the nearest edge, while moving.
*/
int meta_window_find_nearest_vertical_edge (MetaWindow *window,
int x_pos);
int meta_window_find_nearest_horizontal_edge (MetaWindow *window,
int y_pos);
#endif #endif