diff --git a/panel/panel-app.c b/panel/panel-app.c index ea6bc7c6..9f541245 100644 --- a/panel/panel-app.c +++ b/panel/panel-app.c @@ -301,7 +301,7 @@ create_monitor_list (void) for (j = 0; j < n_monitors; ++j) { - monitor = g_new (XfceMonitor, 1); + monitor = g_new0 (XfceMonitor, 1); monitor->screen = screen; monitor->num = j; @@ -322,7 +322,7 @@ create_monitor_list (void) h = monitor->geometry.height; #if TEST_MULTIPLE_MONITORS - monitor = g_new (XfceMonitor, 1); + monitor = g_new0 (XfceMonitor, 1); monitor->screen = screen; monitor->num = j; @@ -342,6 +342,55 @@ create_monitor_list (void) panel_app.xinerama_and_equal_width = equal_w; panel_app.xinerama_and_equal_height = equal_h; } + + /* check layout */ + /* TODO: can this be optimized? does it need to be? */ + for (i = 0; i < panel_app.monitor_list->len; ++i) + { + XfceMonitor *mon1 = g_ptr_array_index (panel_app.monitor_list, i); + + for (j = 0; j < panel_app.monitor_list->len; ++j) + { + XfceMonitor *mon2; + + if (j == i) + continue; + + mon2 = g_ptr_array_index (panel_app.monitor_list, j); + + if (mon2->geometry.x < mon1->geometry.x + && mon2->geometry.y < mon1->geometry.y + mon1->geometry.height + && mon2->geometry.y + mon2->geometry.height > mon1->geometry.y + ) + { + mon1->has_neighbor_left = TRUE; + } + + if (mon2->geometry.x > mon1->geometry.x + && mon2->geometry.y < mon1->geometry.y + mon1->geometry.height + && mon2->geometry.y + mon2->geometry.height > mon1->geometry.y + ) + { + mon1->has_neighbor_right = TRUE; + } + + if (mon2->geometry.y < mon1->geometry.y + && mon2->geometry.x < mon1->geometry.x + mon1->geometry.width + && mon2->geometry.x + mon2->geometry.width > mon1->geometry.x + ) + { + mon1->has_neighbor_above = TRUE; + } + + if (mon2->geometry.y > mon1->geometry.y + && mon2->geometry.x < mon1->geometry.x + mon1->geometry.width + && mon2->geometry.x + mon2->geometry.width > mon1->geometry.x + ) + { + mon1->has_neighbor_below = TRUE; + } + } + } } /* open dialogs */ diff --git a/panel/panel-app.h b/panel/panel-app.h index 4a887e02..8c80c08a 100644 --- a/panel/panel-app.h +++ b/panel/panel-app.h @@ -34,6 +34,10 @@ struct _XfceMonitor GdkScreen *screen; int num; GdkRectangle geometry; + guint has_neighbor_left:1; + guint has_neighbor_right:1; + guint has_neighbor_above:1; + guint has_neighbor_below:1; }; /* run control */ diff --git a/panel/panel-properties.c b/panel/panel-properties.c index be9159d8..50cbce8b 100644 --- a/panel/panel-properties.c +++ b/panel/panel-properties.c @@ -230,7 +230,7 @@ _set_borders (Panel *panel) } static void -_set_struts (Panel *panel, int x, int y, int w, int h) +_set_struts (Panel *panel, XfceMonitor *xmon, int x, int y, int w, int h) { PanelPrivate *priv; gulong data[12] = { 0, }; @@ -242,31 +242,57 @@ _set_struts (Panel *panel, int x, int y, int w, int h) { if (xfce_screen_position_is_left (priv->screen_position)) { - data[0] = w; /* left */ - - data[4] = y; /* left_start_y */ - data[5] = y + h; /* left_end_y */ + /* no struts possible on Xinerama screens when this is monitor + * has neighbors on the left (see fd.o spec). + */ + if (!xmon->has_neighbor_left) + { + data[0] = xmon->geometry.x + + w; /* left */ + data[4] = y; /* left_start_y */ + data[5] = y + h; /* left_end_y */ + } } else if (xfce_screen_position_is_right (priv->screen_position)) { - data[1] = w; /* right */ - - data[6] = y; /* right_start_y */ - data[7] = y + h; /* right_end_y */ + /* no struts possible on Xinerama screens when this is monitor + * has neighbors on the right (see fd.o spec). + */ + if (!xmon->has_neighbor_right) + { + data[1] = gdk_screen_get_width (xmon->screen) + - xmon->geometry.x - xmon->geometry.width + + w; /* right */ + data[6] = y; /* right_start_y */ + data[7] = y + h; /* right_end_y */ + } } else if (xfce_screen_position_is_top (priv->screen_position)) { - data[2] = h; /* top */ - - data[8] = x; /* top_start_x */ - data[9] = x + w; /* top_end_x */ + /* no struts possible on Xinerama screens when this is monitor + * has neighbors on the top (see fd.o spec). + */ + if (!xmon->has_neighbor_above) + { + data[2] = xmon->geometry.y + + h; /* top */ + data[8] = x; /* top_start_x */ + data[9] = x + w; /* top_end_x */ + } } else { - data[3] = h; /* bottom */ - - data[10] = x; /* bottom_start_x */ - data[11] = x + w; /* bottom_end_x */ + /* no struts possible on Xinerama screens when this is monitor + * has neighbors on the bottom (see fd.o spec). + */ + if (!xmon->has_neighbor_below) + { + data[3] = gdk_screen_get_width (xmon->screen) + - xmon->geometry.x - xmon->geometry.width + + h; /* bottom */ + data[10] = x; /* bottom_start_x */ + data[11] = x + w; /* bottom_end_x */ + } } } @@ -350,7 +376,7 @@ panel_resize_function (XfcePanelWindow *window, Panel *panel, DBG ("\n + Position: %d\n + Offset: (%d, %d)", priv->screen_position, priv->xoffset, priv->yoffset); - _set_struts (panel, *x, *y, new->width, new->height); + _set_struts (panel, xmon, *x, *y, new->width, new->height); } static void @@ -412,7 +438,7 @@ panel_set_position (Panel *panel, XfceScreenPosition position, gtk_window_move (GTK_WINDOW (panel), x, y); - _set_struts (panel, x, y, req.width, req.height); + _set_struts (panel, xmon, x, y, req.width, req.height); } /* screen size */