From 77d2ff94b5d5f4e296565e3d93877f7fe646967e Mon Sep 17 00:00:00 2001 From: Alistair Buxton Date: Fri, 2 May 2014 21:43:19 +0100 Subject: [PATCH] Refactor the multimonitor tasklist code again - alternate version. This version stores the current monitor the tasklist is on. This might still suffer from the problems where it gets confused when the geometry changes. --- plugins/tasklist/tasklist-widget.c | 42 ++++++++++---------------------------- 1 file changed, 11 insertions(+), 31 deletions(-) diff --git a/plugins/tasklist/tasklist-widget.c b/plugins/tasklist/tasklist-widget.c index 1a1755b..056e477 100644 --- a/plugins/tasklist/tasklist-widget.c +++ b/plugins/tasklist/tasklist-widget.c @@ -163,8 +163,7 @@ struct _XfceTasklist * the monitor the tasklist is on */ guint all_monitors : 1; guint n_monitors; - guint my_monitor; - GdkRectangle *all_monitors_geometry; + gint my_monitor; /* whether we show wireframes when hovering a button in * the tasklist */ @@ -558,7 +557,7 @@ xfce_tasklist_init (XfceTasklist *tasklist) tasklist->show_handle = TRUE; tasklist->all_monitors = TRUE; tasklist->n_monitors = 0; - tasklist->all_monitors_geometry = NULL; + tasklist->my_monitor = 0; tasklist->window_scrolling = TRUE; tasklist->all_blinking = TRUE; tasklist->middle_click = XFCE_TASKLIST_MIDDLE_CLICK_DEFAULT; @@ -1903,7 +1902,6 @@ xfce_tasklist_update_monitor_geometry_idle (gpointer data) GdkScreen *screen; gboolean geometry_set = FALSE; GdkWindow *window; - guint tmp; panel_return_val_if_fail (XFCE_IS_TASKLIST (tasklist), FALSE); @@ -1915,20 +1913,10 @@ xfce_tasklist_update_monitor_geometry_idle (gpointer data) window = gtk_widget_get_window (GTK_WIDGET (tasklist)); if (G_LIKELY (screen != NULL - && window != NULL - && (tasklist->n_monitors = gdk_screen_get_n_monitors (screen)) > 1)) + && window != NULL)) { - /* set the monitor geometry */ + tasklist->n_monitors = gdk_screen_get_n_monitors (screen); tasklist->my_monitor = gdk_screen_get_monitor_at_window (screen, window); - - if (tasklist->all_monitors_geometry) - tasklist->all_monitors_geometry = g_renew (GdkRectangle, tasklist->all_monitors_geometry, tasklist->n_monitors); - else - tasklist->all_monitors_geometry = g_new (GdkRectangle, tasklist->n_monitors); - - for(tmp = 0; tmp < tasklist->n_monitors; tmp++) - gdk_screen_get_monitor_geometry (screen, tmp, &tasklist->all_monitors_geometry[tmp]); - geometry_set = TRUE; } } @@ -2248,8 +2236,8 @@ xfce_tasklist_button_visible (XfceTasklistChild *child, WnckWorkspace *active_ws) { XfceTasklist *tasklist = XFCE_TASKLIST (child->tasklist); - GdkRectangle window, intersection; - guint best_size = 0, best_monitor = 0, size, tmp; + gint x, y, w, h; + GdkScreen *screen; panel_return_val_if_fail (active_ws == NULL || WNCK_IS_WORKSPACE (active_ws), FALSE); panel_return_val_if_fail (XFCE_IS_TASKLIST (tasklist), FALSE); @@ -2257,20 +2245,12 @@ xfce_tasklist_button_visible (XfceTasklistChild *child, if (xfce_tasklist_filter_monitors (tasklist)) { - /* center of the window must be on this screen */ - wnck_window_get_geometry (child->window, &window.x, &window.y, &window.width, &window.height); + screen = gtk_widget_get_screen (GTK_WIDGET (tasklist)); + /* center of the window must be on or nearest this monitor */ + wnck_window_get_geometry (child->window, &x, &y, &w, &h); - for (tmp = 0; tmp < tasklist->n_monitors; tmp++) - { - gdk_rectangle_intersect(&tasklist->all_monitors_geometry[tmp], &window, &intersection); - size = intersection.width * intersection.height; - if (size > best_size) - { - best_size = size; - best_monitor = tmp; - } - } - if (best_monitor != tasklist->my_monitor) + if (tasklist->my_monitor != + gdk_screen_get_monitor_at_point(screen, x+(w/2), y+(h/2)) ) return FALSE; } -- 1.9.1