Take Xinerama screen edges into consideration.

2002-05-25  Anders Carlsson  <andersca@gnu.org>

	* src/place.c: (get_vertical_edges), (get_horizontal_edges):
	Take Xinerama screen edges into consideration.

	* src/screen.c: (meta_rectangle_intersect),
	(meta_screen_get_xinerama_for_window):
	* src/screen.h:
	Add a new function that returns the xinerama monitor that
	a window is on.
This commit is contained in:
Anders Carlsson 2002-05-25 16:30:14 +00:00 committed by Anders Carlsson
parent cc3c995d80
commit d466c615ed
4 changed files with 99 additions and 4 deletions

View File

@ -1,3 +1,14 @@
2002-05-25 Anders Carlsson <andersca@gnu.org>
* src/place.c: (get_vertical_edges), (get_horizontal_edges):
Take Xinerama screen edges into consideration.
* src/screen.c: (meta_rectangle_intersect),
(meta_screen_get_xinerama_for_window):
* src/screen.h:
Add a new function that returns the xinerama monitor that
a window is on.
2002-05-24 Havoc Pennington <hp@pobox.com>
* src/window.c (menu_callback): follow windows to their new

View File

@ -546,7 +546,7 @@ get_vertical_edges (MetaWindow *window,
GSList *tmp;
int n_windows;
int *edges;
int i;
int i, j;
int n_edges;
MetaRectangle rect;
MetaRectangle work_area;
@ -554,7 +554,7 @@ get_vertical_edges (MetaWindow *window,
windows = get_windows_on_same_workspace (window, &n_windows);
i = 0;
n_edges = n_windows * 2 + 4; /* 4 = workspace/screen edges */
n_edges = n_windows * 2 + 4 + window->screen->n_xinerama_infos - 1; /* 4 = workspace/screen edges */
edges = g_new (int, n_edges);
/* workspace/screen edges */
@ -573,6 +573,13 @@ get_vertical_edges (MetaWindow *window,
g_assert (i == 4);
/* Now get the xinerama screen edges */
for (j = 0; j < window->screen->n_xinerama_infos - 1; j++) {
edges[i] = window->screen->xinerama_infos[j].x_origin +
window->screen->xinerama_infos[j].width;
++i;
}
meta_window_get_outer_rect (window, &rect);
/* get window edges */
@ -612,7 +619,7 @@ get_horizontal_edges (MetaWindow *window,
GSList *tmp;
int n_windows;
int *edges;
int i;
int i, j;
int n_edges;
MetaRectangle rect;
MetaRectangle work_area;
@ -620,7 +627,7 @@ get_horizontal_edges (MetaWindow *window,
windows = get_windows_on_same_workspace (window, &n_windows);
i = 0;
n_edges = n_windows * 2 + 4; /* 4 = workspace/screen edges */
n_edges = n_windows * 2 + 4 + window->screen->n_xinerama_infos - 1; /* 4 = workspace/screen edges */
edges = g_new (int, n_edges);
/* workspace/screen edges */
@ -638,6 +645,13 @@ get_horizontal_edges (MetaWindow *window,
++i;
g_assert (i == 4);
/* Now get the xinerama screen edges */
for (j = 0; j < window->screen->n_xinerama_infos - 1; j++) {
edges[i] = window->screen->xinerama_infos[j].y_origin +
window->screen->xinerama_infos[j].height;
++i;
}
meta_window_get_outer_rect (window, &rect);

View File

@ -800,6 +800,74 @@ meta_screen_focus_top_window (MetaScreen *screen,
}
}
static gboolean
meta_rectangle_intersect (MetaRectangle *src1,
MetaRectangle *src2,
MetaRectangle *dest)
{
int dest_x, dest_y;
int dest_w, dest_h;
int return_val;
g_return_val_if_fail (src1 != NULL, FALSE);
g_return_val_if_fail (src2 != NULL, FALSE);
g_return_val_if_fail (dest != NULL, FALSE);
return_val = FALSE;
dest_x = MAX (src1->x, src2->x);
dest_y = MAX (src1->y, src2->y);
dest_w = MIN (src1->x + src1->width, src2->x + src2->width) - dest_x;
dest_h = MIN (src1->y + src1->height, src2->y + src2->height) - dest_y;
if (dest_w > 0 && dest_h > 0)
{
dest->x = dest_x;
dest->y = dest_y;
dest->width = dest_w;
dest->height = dest_h;
return_val = TRUE;
}
else
{
dest->width = 0;
dest->height = 0;
}
return return_val;
}
const MetaXineramaScreenInfo*
meta_screen_get_xinerama_for_window (MetaScreen *screen,
MetaWindow *window)
{
int i;
int best_xinerama, xinerama_score;
best_xinerama = 0;
xinerama_score = 0;
for (i = 0; i < screen->n_xinerama_infos; i++) {
MetaRectangle dest, screen_info;
screen_info.x = screen->xinerama_infos[i].x_origin;
screen_info.y = screen->xinerama_infos[i].y_origin;
screen_info.width = screen->xinerama_infos[i].width;
screen_info.height = screen->xinerama_infos[i].height;
if (meta_rectangle_intersect (&screen_info, &window->rect, &dest))
{
if (dest.width * dest.height > xinerama_score)
{
xinerama_score = dest.width * dest.height;
best_xinerama = i;
}
}
}
return &screen->xinerama_infos[best_xinerama];
}
const MetaXineramaScreenInfo*
meta_screen_get_current_xinerama (MetaScreen *screen)
{

View File

@ -95,6 +95,8 @@ void meta_screen_focus_top_window (MetaScreen *scree
MetaWindow *not_this_one);
const MetaXineramaScreenInfo* meta_screen_get_current_xinerama (MetaScreen *screen);
const MetaXineramaScreenInfo* meta_screen_get_xinerama_for_window (MetaScreen *screen,
MetaWindow *window);
void meta_screen_update_workspace_layout (MetaScreen *screen);