From f4d8927c5d306c131fe1ca72395d15628cb847c3 Mon Sep 17 00:00:00 2001 From: Dridi Boukelmoune Date: Thu, 31 Oct 2019 17:23:03 +0100 Subject: [PATCH v2 2/2] tabwin: Comply with the primary monitor setting If the user selected a primary monitor, the Alt+Tab window will only appear on that monitor, otherwise on all of them. To quote the GDK documentation for gdk_display_get_primary_monitor: > [...], specialized desktop applications such as panels should place > themselves on the primary monitor. It is however not possible to use gdk_display_get_primary_monitor and also respect the user's setting. Despite what the online documentation says, recent versions of GTK+3 may no longer return a null value and will instead pick one monitor as the primary if there isn't already one defined. The nullable marker [1] for the return value was eventually dropped. Until Wayland support becomes a requirement or until GTK+3's minimum acceptable version increases to the point where the new behavior is guaranteed, this can be conditionally solved for X11 via the RandR extension. Signed-off-by: Dridi Boukelmoune [1] https://gitlab.gnome.org/GNOME/gtk/commit/76d95c312dde --- src/tabwin.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/tabwin.c b/src/tabwin.c index a12105cd..064fa6da 100644 --- a/src/tabwin.c +++ b/src/tabwin.c @@ -900,6 +900,10 @@ tabwinCreate (GList **client_list, GList *selected, gboolean display_workspace) Tabwin *tabwin; TabwinWidget *win; int num_monitors, i; +#ifdef HAVE_RANDR + Display *display; + RROutput primary; +#endif /* HAVE_RANDR */ g_return_val_if_fail (selected, NULL); g_return_val_if_fail (client_list, NULL); @@ -918,11 +922,26 @@ tabwinCreate (GList **client_list, GList *selected, gboolean display_workspace) tabwin->icon_list = NULL; num_monitors = myScreenGetNumMonitors (screen_info); + +#ifdef HAVE_RANDR + display = myScreenGetXDisplay (screen_info); + primary = XRRGetOutputPrimary (display, c->window); +#endif /* HAVE_RANDR */ + for (i = 0; i < num_monitors; i++) { gint monitor_index; monitor_index = myScreenGetMonitorIndex (screen_info, i); + +#ifdef HAVE_RANDR + if (primary != None && + !xfwm_monitor_is_primary (screen_info->gscr, monitor_index)) + { + continue; + } +#endif /* HAVE_RANDR */ + win = tabwinCreateWidget (tabwin, screen_info, monitor_index); tabwin->tabwin_list = g_list_append (tabwin->tabwin_list, win); } -- 2.23.0