mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
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:
parent
cc3c995d80
commit
d466c615ed
11
ChangeLog
11
ChangeLog
@ -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>
|
2002-05-24 Havoc Pennington <hp@pobox.com>
|
||||||
|
|
||||||
* src/window.c (menu_callback): follow windows to their new
|
* src/window.c (menu_callback): follow windows to their new
|
||||||
|
22
src/place.c
22
src/place.c
@ -546,7 +546,7 @@ get_vertical_edges (MetaWindow *window,
|
|||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
int n_windows;
|
int n_windows;
|
||||||
int *edges;
|
int *edges;
|
||||||
int i;
|
int i, j;
|
||||||
int n_edges;
|
int n_edges;
|
||||||
MetaRectangle rect;
|
MetaRectangle rect;
|
||||||
MetaRectangle work_area;
|
MetaRectangle work_area;
|
||||||
@ -554,7 +554,7 @@ get_vertical_edges (MetaWindow *window,
|
|||||||
windows = get_windows_on_same_workspace (window, &n_windows);
|
windows = get_windows_on_same_workspace (window, &n_windows);
|
||||||
|
|
||||||
i = 0;
|
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);
|
edges = g_new (int, n_edges);
|
||||||
|
|
||||||
/* workspace/screen edges */
|
/* workspace/screen edges */
|
||||||
@ -573,6 +573,13 @@ get_vertical_edges (MetaWindow *window,
|
|||||||
|
|
||||||
g_assert (i == 4);
|
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);
|
meta_window_get_outer_rect (window, &rect);
|
||||||
|
|
||||||
/* get window edges */
|
/* get window edges */
|
||||||
@ -612,7 +619,7 @@ get_horizontal_edges (MetaWindow *window,
|
|||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
int n_windows;
|
int n_windows;
|
||||||
int *edges;
|
int *edges;
|
||||||
int i;
|
int i, j;
|
||||||
int n_edges;
|
int n_edges;
|
||||||
MetaRectangle rect;
|
MetaRectangle rect;
|
||||||
MetaRectangle work_area;
|
MetaRectangle work_area;
|
||||||
@ -620,7 +627,7 @@ get_horizontal_edges (MetaWindow *window,
|
|||||||
windows = get_windows_on_same_workspace (window, &n_windows);
|
windows = get_windows_on_same_workspace (window, &n_windows);
|
||||||
|
|
||||||
i = 0;
|
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);
|
edges = g_new (int, n_edges);
|
||||||
|
|
||||||
/* workspace/screen edges */
|
/* workspace/screen edges */
|
||||||
@ -639,6 +646,13 @@ get_horizontal_edges (MetaWindow *window,
|
|||||||
|
|
||||||
g_assert (i == 4);
|
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);
|
meta_window_get_outer_rect (window, &rect);
|
||||||
|
|
||||||
/* get window edges */
|
/* get window edges */
|
||||||
|
68
src/screen.c
68
src/screen.c
@ -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*
|
const MetaXineramaScreenInfo*
|
||||||
meta_screen_get_current_xinerama (MetaScreen *screen)
|
meta_screen_get_current_xinerama (MetaScreen *screen)
|
||||||
{
|
{
|
||||||
|
@ -95,6 +95,8 @@ void meta_screen_focus_top_window (MetaScreen *scree
|
|||||||
MetaWindow *not_this_one);
|
MetaWindow *not_this_one);
|
||||||
|
|
||||||
const MetaXineramaScreenInfo* meta_screen_get_current_xinerama (MetaScreen *screen);
|
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);
|
void meta_screen_update_workspace_layout (MetaScreen *screen);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user